:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e3e6ea;
  --line-strong: #cfd4da;
  --text: #1d2228;
  --muted: #69727d;
  --accent: #F7921C;
  --accent-dark: #d97a0c;
  --blue: #1f6feb;
  --blue-bg: #e8f0fe;
  --green: #1a7f37;
  --green-bg: #e6f4ea;
  --red: #c62828;
  --red-bg: #fdecea;
  --grey-bg: #eef0f2;
  --sidebar-w: 220px;
  --radius: 6px;
  font-family: "Segoe UI", -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }

/* ---------- Khung chính ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
.topbar { grid-column: 1 / 3; display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo-mark { width: 28px; height: 28px; display: block; flex: none; }
.project-pick { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px; background: var(--panel); max-width: 380px; }
.project-pick .code { font-family: Consolas, monospace; font-size: 12px; background: var(--grey-bg); padding: 1px 6px; border-radius: 4px; margin-right: 6px; }
.topbar .spacer { flex: 1; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; padding: 4px 8px; border-radius: var(--radius); }
.user-btn:hover { background: var(--grey-bg); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--blue-bg); color: var(--blue); display: grid; place-items: center; font-size: 12px; font-weight: 600; }

.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 10px 0; overflow-y: auto; }
.nav-group { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; padding: 14px 18px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 18px; color: var(--text); cursor: pointer; }
.nav-item:hover { background: var(--grey-bg); }
.nav-item.active { background: #fff4e6; color: var(--accent-dark); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item .soon { margin-left: auto; font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; }
.nav-item.disabled { color: var(--muted); cursor: default; }
.nav-item.disabled:hover { background: none; }

.main { overflow: auto; padding: 22px 28px; min-width: 0; }
.main.full { padding: 14px 18px; display: flex; flex-direction: column; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb a:hover { color: var(--blue); text-decoration: underline; }
.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 650; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Nút, ô nhập ---------- */
.btn { border: 1px solid var(--line-strong); background: var(--panel); border-radius: var(--radius); padding: 6px 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--grey-bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.blue:hover { filter: brightness(.93); }
.btn.danger { color: var(--red); border-color: #f1b8b4; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn.icon { padding: 4px 7px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 15px; height: 15px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; }
.input, select.input, textarea.input { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 7px 10px; background: var(--panel); width: 100%; }
.input:focus { outline: 2px solid #fcd9a8; border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 64px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ---------- Bảng ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.card-head { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.click { cursor: pointer; }
table.grid tr.click:hover td { background: #fafbfc; }
table.grid td.num, table.grid th.num { text-align: right; }
table.grid td.acts { text-align: right; white-space: nowrap; }
table.grid td.acts .btn + .btn { margin-left: 6px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 4px; background: var(--grey-bg); color: #444; white-space: nowrap; }
.badge.WIP { background: #f1f1f1; color: #555; }
.badge.Shared { background: var(--blue-bg); color: var(--blue); }
.badge.Published { background: var(--green-bg); color: var(--green); }
.badge.Archived { background: #2f3640; color: #fff; }
.disc { font-family: Consolas, monospace; font-size: 12px; font-weight: 600; background: #fff4e6; color: var(--accent-dark); padding: 1px 6px; border-radius: 4px; }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #aab; }
.status.ready::before { background: var(--green); }
.status.processing::before, .status.uploading::before { background: var(--accent); animation: pulse 1.2s infinite; }
.status.failed::before { background: var(--red); }
.status.stored::before { background: #8a96a3; }
@keyframes pulse { 50% { opacity: .3; } }
select.state-pick { border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; font-size: 12px; background: var(--panel); }

.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.project-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; cursor: pointer; }
.project-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.project-card .code { font-family: Consolas, monospace; font-size: 12px; color: var(--muted); }
.project-card .name { font-weight: 600; font-size: 15px; margin: 4px 0 10px; }
.project-card .meta { font-size: 12px; color: var(--muted); }

/* ---------- Viewer ---------- */
.viewer-wrap { flex: 1; display: grid; grid-template-columns: 280px 1fr; gap: 12px; min-height: 0; }
.viewer-wrap.collapsed { grid-template-columns: 0 1fr; }
.viewer-wrap.collapsed .side-panel { display: none; }
.side-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.side-panel .head { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.side-panel .head .btn { margin-left: auto; }
.side-panel .body { overflow-y: auto; padding: 8px 0; flex: 1; }
.side-panel .search { margin: 0 10px 8px; }
.tree-group { font-size: 13px; font-weight: 600; padding: 8px 12px 4px; color: var(--muted); cursor: pointer; user-select: none; }
.tree-item { padding: 6px 12px 6px 28px; font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.tree-item:hover { background: var(--grey-bg); }
.tree-item.active { background: var(--blue-bg); color: var(--blue); }
.tree-item svg { width: 14px; height: 14px; flex: none; opacity: .7; }
.viewer-box { position: relative; background: #e9ecef; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; min-height: 300px; }
.viewer-box .msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.viewer-box .floating-btn { position: absolute; top: 10px; left: 10px; z-index: 5; }
.combo-model { border-bottom: 1px solid var(--line); padding: 10px 12px; }
.combo-model .title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.combo-model .title input { margin: 0; }
.combo-model .sub { font-size: 12px; color: var(--muted); margin: 2px 0 8px 24px; }
.combo-model .line { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 6px; margin: 4px 0 4px 24px; font-size: 12px; }
.combo-model select { font-size: 12px; padding: 3px 6px; }

/* ---------- Upload ---------- */
.dropzone { border: 2px dashed var(--line-strong); border-radius: 8px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: 14px; }
.dropzone.over { border-color: var(--accent); background: #fff8ef; color: var(--accent-dark); }
.dropzone b { color: var(--text); }
.file-list { margin: -6px 0 14px; font-size: 13px; }
.file-list div { padding: 4px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; }
.file-list div span:last-child { margin-left: auto; color: var(--muted); }
.uploads { position: fixed; right: 18px; bottom: 18px; width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.12); z-index: 50; }
.uploads .head { padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; }
.uploads .head button { margin-left: auto; border: 0; background: none; cursor: pointer; font-size: 16px; color: var(--muted); }
.up-item { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.up-item:last-child { border-bottom: 0; }
.up-item .name { display: flex; gap: 8px; }
.up-item .name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.bar { height: 5px; background: var(--grey-bg); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.up-item.done .bar > div { background: var(--green); }
.up-item.err .bar > div { background: var(--red); }
.up-item .info { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Hộp thoại ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20,24,30,.35); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: 10px; width: 100%; max-width: 520px; box-shadow: 0 10px 40px rgba(0,0,0,.2); max-height: 92vh; display: flex; flex-direction: column; }
.modal .head { padding: 14px 18px; font-weight: 650; font-size: 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal .head .x { margin-left: auto; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal .content { padding: 18px; overflow-y: auto; }
.modal .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.err-text { color: var(--red); font-size: 13px; margin-top: 8px; }

.menu { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.12); z-index: 120; min-width: 170px; padding: 4px 0; }
.menu div { padding: 7px 14px; cursor: pointer; font-size: 13px; }
.menu div:hover { background: var(--grey-bg); }
.menu div.danger { color: var(--red); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #262b31; color: #fff; padding: 9px 18px; border-radius: 6px; z-index: 200; font-size: 13px; }

/* ---------- Đăng nhập ---------- */
/* ---- Màn đăng nhập + chọn dự án: cột trái + nền giới thiệu */
.entry { min-height: 100vh; display: grid; grid-template-columns: 400px 1fr; position: relative; }
.entry-side { background: #f1f2f4; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 32px 48px; z-index: 2; }
.entry-mid { margin: auto 0; }
.entry-logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 30px; letter-spacing: .5px; color: #3a4048; margin-bottom: 26px; }
.entry-logo .logo-mark { width: 52px; height: 52px; }
.entry-logo b { color: var(--accent); font-weight: 700; }
.entry-h { text-align: center; font-size: 24px; font-weight: 600; margin: 0 0 18px; }
.entry-note { text-align: center; font-size: 13px; color: var(--muted); margin: -8px 0 16px; }
.entry-form { display: flex; flex-direction: column; gap: 10px; }
.entry-form .input { padding: 10px 12px; background: #fff; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 40px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; display: flex; }
.pw-eye svg { width: 18px; height: 18px; }
.entry-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin: 2px 0 6px; }
.entry-row a { color: var(--blue); text-decoration: underline; }
.chk { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }
.entry-btn { justify-content: center; padding: 11px; font-size: 15px; }
.entry-foot { text-align: center; font-size: 12px; color: var(--muted); }
.who { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.avatar.lg { width: 42px; height: 42px; font-size: 15px; flex: none; }
.who-n { font-weight: 600; }
.who-e { font-size: 12px; color: var(--muted); word-break: break-all; }
.who-r { font-size: 11px; color: var(--accent-dark); font-weight: 600; margin-top: 2px; }
.who-links { margin-top: 12px; text-align: center; font-size: 13px; }
.who-links a { display: inline-flex; align-items: center; gap: 6px; color: var(--blue); }
.who-links svg { width: 15px; height: 15px; }

.stage { background: #c9ccd1; position: relative; overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto 1fr; gap: 22px; padding: 56px 7%; align-content: center; }
.stage-title { grid-column: 1 / -1; font-size: 34px; font-weight: 700; color: #2f353c; line-height: 1.2; }
.feat { background: #e6e8eb; border-radius: 22px; padding: 22px 24px; color: #2f353c; box-shadow: 0 1px 0 rgba(255,255,255,.5) inset; }
.feat-k { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #59616b; }
.feat-k svg { width: 18px; height: 18px; }
.feat-h { font-size: 22px; font-weight: 700; margin: 8px 0 14px; line-height: 1.25; }
.feat-t { font-size: 14px; color: #4b525b; }
.mini-ver { background: #fff; border-radius: 10px; padding: 8px 12px; display: grid; gap: 6px; font-size: 13px; }
.mini-ver div { display: flex; align-items: center; gap: 10px; }
.mini-pick { background: #fff; border-radius: 10px; padding: 6px; font-size: 13px; display: grid; gap: 2px; max-width: 220px; }
.mini-pick div { padding: 5px 10px; border-radius: 6px; }
.mini-pick .on { background: #fde9cf; color: #8a5300; font-weight: 600; }
.feat-d { background: #303740; color: #fff; font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; text-align: center; }

.pj-back { position: absolute; inset: 0 0 0 400px; display: grid; place-items: center; padding: 40px; background: rgba(60,66,74,.28); z-index: 3; }
.pj { background: #fff; width: 100%; max-width: 900px; height: min(800px, 100%); border-radius: 4px; box-shadow: 0 12px 40px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.pj-head { display: flex; align-items: center; padding: 20px 20px 8px; }
.pj-head h2 { margin: 0; font-size: 24px; font-weight: 600; }
.pj-x { margin-left: auto; border: 0; background: none; font-size: 30px; line-height: 1; cursor: pointer; color: #444; padding: 0 4px; }
.pj-bar { display: flex; align-items: center; gap: 6px; padding: 8px 16px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pj-act { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; cursor: pointer; padding: 6px 10px; border-radius: 4px; font-size: 14px; color: #333; }
.pj-act:hover { background: var(--grey-bg); }
.pj-act svg { width: 17px; height: 17px; }
.pj-search { margin-left: auto; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 10px; width: 260px; max-width: 100%; }
.pj-search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.pj-search input { border: 0; outline: 0; padding: 7px 0; width: 100%; background: none; }
.pj-search:focus-within { border-color: var(--accent); }
.pj-body { flex: 1; overflow-y: auto; background: #eceef0; padding: 10px 16px; }
.pj-row { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; margin-bottom: 8px; }
.pj-row:hover { border-color: var(--accent); }
.pj-row > svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.pj-code { font-family: Consolas, monospace; font-size: 12px; background: var(--grey-bg); border-radius: 4px; padding: 2px 8px; color: #444; flex: none; }
.pj-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-meta { font-size: 12px; color: var(--muted); flex: none; }
.pj-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #555; font-size: 17px; min-height: 260px; }
.pj-empty svg { width: 72px; height: 72px; color: #9aa1a9; stroke-width: 1.2; }

@media (max-width: 1100px) { .stage { grid-template-columns: 1fr; } .feat-b, .feat-d { display: none; } }
@media (max-width: 800px) {
  .entry { grid-template-columns: 1fr; }
  .stage { display: none; }
  .entry-side { padding: 28px 22px; }
  .pj-back { inset: 0; padding: 0; background: none; }
  .pj { height: 100%; max-width: none; border-radius: 0; }
  .pj-search { margin-left: 0; width: 100%; }
}
.notice { background: #fff8ef; border: 1px solid #fde0b8; color: #8a5300; border-radius: 6px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px; }
  .viewer-wrap { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
  table.grid .hide-sm { display: none; }
}
