:root {
  --bg: #f5f7f9; --surface: #ffffff; --surface-2: #f3f5f7; --border: #e4e8ec; --border-2: #d6dce2;
  --text: #16202a; --muted: #66727f; --accent: #1b5e3f; --accent-2: #154b32; --accent-soft: #e7f3ec; --accent-row: #eef7f1;
  --amber: #b45309; --amber-soft: #fff4e0; --red: #b42318; --red-soft: #fdecea; --green: #15803d; --green-soft: #e5f6ea;
  --blue: #1d4ed8; --blue-soft: #e8eefc; --purple: #6d28d9; --purple-soft: #efe9fd; --pink: #be185d; --pink-soft: #fce7f3;
  --teal: #0f766e; --teal-soft: #e0f2f0; --orange: #c2410c; --orange-soft: #ffedd5; --gray-soft: #eceff2;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 10px rgba(16,24,40,.05); --radius: 14px; font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'Be Vietnam Pro', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.small { font-size: 13px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 18px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; letter-spacing: .5px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 12px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a.active, .nav a:hover { background: var(--accent-soft); color: var(--accent-2); }
.auth { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--red); border-color: #f3b7b1; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.icon { padding: 6px 10px; font-size: 18px; line-height: 1; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-2); border-radius: 9px; padding: 9px 12px; }
select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2366727f' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
textarea { width: 100%; min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.search { position: relative; flex: 1; min-width: 240px; }
.search input { width: 100%; padding-left: 38px; }
.search::before { content: ''; position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366727f' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat center / contain; }

/* Cards / layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card h3 { margin: 0 0 12px; font-size: 17px; }
.card h4 { margin: 14px 0 6px; font-size: 14.5px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 14px; }
.page-head h1 { margin: 0; font-size: 24px; }
.count-pill { background: var(--gray-soft); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; }
.page-head .right { margin-left: auto; display: flex; gap: 8px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.toolbar .spacer { flex: 1; }
.toprow { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.adv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; padding: 14px; margin-bottom: 12px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0 18px; }
.stat { padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; color: var(--accent-2); }
.stat .l { color: var(--muted); font-size: 13px; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.row-link { cursor: pointer; }
tbody tr.row-link:hover { background: var(--surface-2); }
tbody tr.top15 { background: var(--accent-row); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
.proj { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--surface-2); border: 1px solid var(--border); }
.proj .t { min-width: 0; }
.proj .t strong { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.proj .t small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.4; max-height: 2.8em; overflow: hidden; }
.score-big { font-weight: 700; font-size: 15px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge.status-ai { background: var(--amber-soft); color: var(--amber); }
.badge.status-done { background: var(--green-soft); color: var(--green); }
.badge.status-none { background: var(--gray-soft); color: var(--muted); }
.badge.rec-yes { background: var(--green-soft); color: var(--green); }
.badge.rec-maybe { background: var(--amber-soft); color: var(--amber); }
.badge.rec-no { background: var(--red-soft); color: var(--red); }
.badge.code { background: var(--gray-soft); color: var(--muted); font-weight: 600; }
.badge.f-nn { background: var(--green-soft); color: var(--green); }
.badge.f-tp { background: var(--orange-soft); color: var(--orange); }
.badge.f-cn { background: var(--blue-soft); color: var(--blue); }
.badge.f-gd { background: var(--purple-soft); color: var(--purple); }
.badge.f-dl { background: var(--pink-soft); color: var(--pink); }
.badge.f-mt { background: var(--teal-soft); color: var(--teal); }
.badge.f-yt { background: var(--red-soft); color: var(--red); }
.badge.f-tm { background: var(--amber-soft); color: var(--amber); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pager { display: flex; align-items: center; gap: 6px; margin: 14px 0; flex-wrap: wrap; }
.pager .info { color: var(--muted); font-size: 13.5px; margin-right: auto; }
.pager button { min-width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface); font: inherit; cursor: pointer; }
.pager button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager button:disabled { opacity: .4; cursor: default; }
.menu { position: relative; }
.menu .dd { position: absolute; right: 0; top: 36px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 30px rgba(16,24,40,.14); min-width: 180px; z-index: 10; padding: 6px; }
.menu .dd a { display: block; padding: 8px 10px; border-radius: 7px; color: var(--text); font-size: 14px; }
.menu .dd a:hover { background: var(--surface-2); }

/* Detail header */
.dhead { display: flex; gap: 20px; align-items: flex-start; margin-top: 20px; }
.dhead .cover { width: 150px; height: 150px; border-radius: 14px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface-2); }
.dhead .info { flex: 1; min-width: 0; }
.dhead .titlerow { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.dhead h1 { margin: 0; font-size: 23px; line-height: 1.3; }
.dhead .status-wrap { margin-left: auto; }
.dhead .desc { margin: 8px 0 10px; color: var(--muted); }
.dhead .meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.dhead .meta span { display: inline-flex; align-items: center; gap: 6px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 18px 0 18px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 10px 16px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs button.active { color: var(--accent-2); border-bottom-color: var(--accent); }
.layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 18px; }
.boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 700px) { .boxes { grid-template-columns: 1fr; } }
.box { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; }
.box h4 { margin: 0 0 8px; font-size: 14.5px; }
.box ul { margin: 0; padding-left: 18px; font-size: 14px; }
.box li + li { margin-top: 4px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; font-size: 14px; align-items: center; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.sections details { border-top: 1px solid var(--border); padding: 10px 0; }
.sections summary { cursor: pointer; font-weight: 600; font-size: 14.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
.sections summary::before { content: '▸'; color: var(--muted); font-size: 12px; transition: transform .15s; }
.sections details[open] summary::before { transform: rotate(90deg); }
.sections p { margin: 8px 0 0; white-space: pre-line; font-size: 14.5px; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
.figure { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.figure .v { font-weight: 700; font-size: 14.5px; }
.figure .l { font-size: 12px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.name-cell { display: flex; align-items: center; gap: 10px; }
.author-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.author-card { display: flex; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.author-card .n { font-weight: 700; }
.author-card .r { color: var(--accent-2); font-size: 13px; font-weight: 600; }
.author-card .d { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.doc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.doc-tile { border: 1px solid var(--border); border-radius: 12px; padding: 18px 12px 14px; text-align: center; cursor: pointer; background: var(--surface); }
.doc-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
.doc-tile .ic { font-size: 30px; }
.doc-tile .n { font-weight: 600; font-size: 13.5px; margin-top: 6px; }
.doc-tile .c { color: var(--muted); font-size: 12.5px; }

/* Files */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface); font-size: 13px; cursor: pointer; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.file-row .icon { width: 42px; height: 42px; border-radius: 9px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.icon.pdf { background: #d33a2c; } .icon.docx { background: #2b579a; } .icon.jpg, .icon.jpeg, .icon.png { background: #7c3aed; } .icon.mp4 { background: #0f766e; } .icon.zip, .icon.rar { background: #6b7280; }
.file-row .name { flex: 1; min-width: 0; }
.file-row .name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.file-row .name small { color: var(--muted); font-size: 12.5px; }
.file-row .actions { display: flex; gap: 6px; flex-shrink: 0; }
.folder-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 12px 14px; background: var(--accent-soft); border-radius: 12px; color: var(--accent-2); font-size: 14px; }
.viewer { width: 100%; height: 75vh; border: 1px solid var(--border); border-radius: 10px; background: #111; }
.viewer-img { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 10px; }

/* Evaluation sheet */
.sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--shadow); }
.sheet-head { text-align: center; margin-bottom: 14px; }
.sheet-head .org { font-size: 12.5px; color: var(--muted); }
.sheet-head h2 { margin: 6px 0 2px; font-size: 18px; }
.sheet-info { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; font-size: 14px; margin: 12px 0; }
@media (max-width: 700px) { .sheet-info { grid-template-columns: 1fr; } }
.sheet table td { vertical-align: top; }
.sheet table th:first-child, .sheet table td:first-child { width: 44px; text-align: center; }
.sheet .crit-name { font-weight: 600; }
.sheet .crit-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sheet .crit-comment { margin-top: 6px; font-size: 14px; white-space: pre-line; }
.sheet td.score { text-align: center; font-weight: 700; font-size: 16px; width: 90px; }
.sheet input.score-input { width: 74px; text-align: center; font-weight: 700; }
.sheet tfoot td { font-weight: 700; background: var(--surface-2); }
.sheet .block { margin-top: 16px; }
.sheet .block h4 { margin: 0 0 6px; font-size: 13.5px; text-transform: uppercase; color: var(--accent-2); letter-spacing: .3px; }
.sheet ul { margin: 0; padding-left: 20px; }
.sheet .signature { display: flex; justify-content: flex-end; margin-top: 22px; text-align: center; font-size: 13px; }
.sheet .signature div { min-width: 240px; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.sheet-actions .spacer { flex: 1; }
.version-note { font-size: 13px; color: var(--muted); }
.orig-compare { font-size: 12px; color: var(--muted); font-weight: 400; }
.delta-up { color: var(--green); } .delta-down { color: var(--red); }
.alert { padding: 10px 14px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); font-size: 13.5px; margin-bottom: 12px; }
.alert.info { background: var(--blue-soft); color: var(--blue); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.tl-item { display: grid; grid-template-columns: 14px 1fr; gap: 12px; }
.tl-item .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); margin-top: 5px; }
.tl-item .dot.old { background: var(--border-2); }
.tl-item details summary { cursor: pointer; font-weight: 600; }
.mini-scores { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.mini-scores span { display: inline-block; min-width: 26px; text-align: center; padding: 1px 3px; border-radius: 4px; background: var(--surface-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 8px 0 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

/* Modal, toast */
.modal { position: fixed; inset: 0; background: rgba(8,12,16,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal .box-m { background: var(--surface); border-radius: 14px; padding: 22px; width: min(100%, 440px); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 12px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.modal form { display: flex; flex-direction: column; gap: 10px; }
.error { color: var(--red); font-size: 13px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #16202a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.footer { display: flex; flex-direction: column; gap: 4px; padding: 30px 16px; font-size: 12.5px; color: var(--muted); }
.criteria-table td:nth-child(2) { white-space: normal; }

@media print {
  .topbar, .footer, .tabs, .sheet-actions, .toolbar, .nav, .pager { display: none !important; }
  body { background: #fff; }
  .sheet { border: none; box-shadow: none; padding: 0; }
  .wrap { max-width: 100%; }
}
@media (max-width: 640px) {
  .dhead { flex-direction: column; }
  .dhead .cover { width: 100%; height: 180px; }
  .file-row .actions { flex-direction: column; }
  .proj .t strong { white-space: normal; }
}
