/* Zenix AI console — mau lay tu logo (xanh duong -> cham, diem teal). */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --text: #0f1b2d;
  --muted: #5b6b82;
  --faint: #8a98ad;
  --line: #e3e9f2;
  --brand: #2f6fd0;
  --brand-2: #3aa3d8;
  --brand-3: #3bb6c4;
  --brand-ink: #ffffff;
  --brand-soft: #eaf2fd;
  --grad: linear-gradient(135deg, #3aa8d8 0%, #2f6fd0 55%, #3252a1 100%);
  --ok: #10a36f; --ok-soft: #e3f6ee;
  --warn: #d98a06; --warn-soft: #fdf3dd;
  --err: #d6334a; --err-soft: #fde8eb;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 4px 16px rgba(15, 27, 45, .05);
  --shadow-lg: 0 20px 50px rgba(15, 27, 45, .18);
  --side-w: 248px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --surface: #121b2c; --surface-2: #0f1727; --text: #e7eef8; --muted: #9aabc3; --faint: #6f819b;
    --line: #22304a; --brand: #5b97f0; --brand-soft: #172846;
    --ok: #34c58f; --ok-soft: #12302a; --warn: #f0b03c; --warn-soft: #33290f; --err: #f06a7d; --err-soft: #3a1820;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.55 "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 26px; line-height: 1.25; margin: 0; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: var(--text);
         font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--faint); letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
         color: var(--muted); font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line);
      border-radius: 14px; background: var(--surface-2); }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { font-size: 12px; color: var(--faint); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
            border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.content { flex: 1; margin-left: var(--side-w); min-width: 0; }
main { max-width: 1120px; margin: 0 auto; padding: 36px 32px 72px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 4px 10px; border-radius: 7px;
              font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15, 27, 45, .12); }

.avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; flex: none;
          background: var(--grad); color: #fff; font-weight: 700; font-size: 15px; }
.avatar.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.avatar svg.i { width: 20px; height: 20px; }
.avatar.muted { background: var(--surface-2); color: var(--faint); border: 1px solid var(--line); }

/* ---------- page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.crumb:hover { color: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 26px; }
.stat { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat b { display: block; font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat svg.i { position: absolute; right: 18px; top: 18px; width: 22px; height: 22px; color: var(--brand); opacity: .9; }
.stat.hero { background: var(--grad); border: 0; color: #fff; }
.stat.hero span, .stat.hero svg.i { color: rgba(255, 255, 255, .85); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-title h2 { margin: 0; }
.card-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.stack > * + * { margin-top: 18px; }

.item { display: flex; flex-direction: column; transition: border-color .15s, transform .15s, box-shadow .15s; }
.item:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); box-shadow: 0 8px 28px rgba(15, 27, 45, .08); }
.item-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.item-head .t { flex: 1; min-width: 0; }
.item-head .t b { display: block; font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-head .t small { color: var(--faint); font-size: 12.5px; font-family: ui-monospace, Menlo, monospace; }
.item .grow { flex: 1; }
.item-foot { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--line); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
        font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.live { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.live::before { animation: pulse 1.2s ease-in-out infinite; }
.pill.plain::before { display: none; }
@keyframes pulse { 50% { opacity: .3; } }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: 13px; margin-bottom: 16px; }
.kv span:nth-child(odd) { color: var(--faint); }
.kv span:nth-child(even) { word-break: break-all; font-weight: 500; }
.clamp { color: var(--muted); margin: 0 0 16px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.muted { color: var(--muted); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
       border-radius: 11px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
       background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(47, 111, 208, .28); transition: transform .1s, box-shadow .15s, background .15s; }
.btn:hover { box-shadow: 0 8px 22px rgba(47, 111, 208, .36); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--surface); color: var(--err); border-color: var(--line); box-shadow: none; }
.btn.danger:hover { background: var(--err-soft); border-color: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

label.f { display: block; margin-bottom: 18px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
label.f > small { display: block; color: var(--faint); margin-top: 6px; font-size: 12.5px; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface-2); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--brand) 25%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
textarea { min-height: 170px; resize: vertical; line-height: 1.6; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.chips span { font-size: 12.5px; color: var(--faint); margin-right: 2px; }
.chips button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 99px;
                padding: 4px 12px; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; }
.chips button:hover { border-color: var(--brand); color: var(--brand); }

.empty { text-align: center; padding: 56px 20px; }
.empty .avatar { width: 56px; height: 56px; border-radius: 18px; margin-bottom: 14px; }
.empty .avatar svg.i { width: 26px; height: 26px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 0 18px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
td .who { display: flex; align-items: center; gap: 10px; font-weight: 500; }

.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 5px; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble time { display: block; font-size: 11px; opacity: .7; margin-top: 4px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
          background: var(--warn-soft); color: var(--text); }
.notice svg.i { color: var(--warn); margin-top: 1px; }
.notice.err svg.i { color: var(--err); }
.notice.err { background: var(--err-soft); }

/* ---------- modal & toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(8, 15, 28, .55); backdrop-filter: blur(4px);
            display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 20px; padding: 26px; width: 100%; max-width: 460px;
         box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.modal h2 { font-size: 19px; margin-bottom: 6px; }
.modal > p { color: var(--muted); margin: 0 0 20px; }
.modal .row-actions { justify-content: flex-end; margin-top: 8px; }
.code-input { font: 700 30px/1 ui-monospace, Menlo, monospace; letter-spacing: 14px; text-align: center; padding: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }

#toast { position: fixed; bottom: 24px; right: 24px; z-index: 50; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
#toast div { display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--text);
             border: 1px solid var(--line); padding: 12px 16px; border-radius: 12px; font-weight: 500;
             box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
#toast div::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
#toast div.err::before { background: var(--err); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { position: relative; overflow: hidden; background: var(--grad); color: #fff; padding: 48px;
            display: flex; flex-direction: column; justify-content: space-between; }
.auth-art::before, .auth-art::after { content: ""; position: absolute; border-radius: 50%; filter: blur(2px); }
.auth-art::before { width: 520px; height: 520px; right: -180px; top: -160px; background: rgba(255, 255, 255, .10); }
.auth-art::after { width: 380px; height: 380px; left: -120px; bottom: -140px; background: rgba(59, 182, 196, .35); }
.auth-art > * { position: relative; z-index: 1; }
.auth-art .logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; }
.auth-art .logo img { width: 44px; height: 44px; background: #fff; border-radius: 14px; padding: 6px; }
.auth-art h2 { font-size: 36px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 14px; font-weight: 700; max-width: 440px; }
.auth-art p { margin: 0; opacity: .85; max-width: 420px; font-size: 15.5px; }
.auth-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-art li { display: flex; gap: 10px; align-items: center; opacity: .95; }
.auth-art li svg.i { background: rgba(255, 255, 255, .18); border-radius: 8px; padding: 5px; width: 28px; height: 28px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 24px; }
.auth-form form { width: 100%; max-width: 380px; }
.auth-form h1 { margin-bottom: 8px; }
.auth-form p { color: var(--muted); margin: 0 0 28px; }
.auth-form .btn { width: 100%; padding: 12px; margin-top: 4px; }
.auth-form .seg { margin-top: 26px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .side { position: sticky; top: 0; inset: auto; width: auto; height: auto; flex-direction: row; flex-wrap: wrap;
          align-items: center; gap: 8px 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .layout { flex-direction: column; }
  .brand { padding: 0; font-size: 16px; }
  .brand img { width: 28px; height: 28px; }
  .brand small { display: none; }
  .nav { order: 3; flex-basis: 100%; flex-direction: row; overflow-x: auto; margin: 0 -4px; }
  .nav a { padding: 8px 12px; gap: 8px; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 8px; }
  .me { padding: 4px 4px 4px 4px; border: 0; background: none; }
  .me .who { display: none; }
  .content { margin-left: 0; }
  main { padding: 24px 16px 60px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 24px; }
  .auth-art h2 { font-size: 26px; }
  .auth-art ul { display: none; }
}
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat b { font-size: 24px; }
  .stat svg.i { display: none; }
  .two { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  #toast { left: 16px; right: 16px; align-items: stretch; }
}
.side-foot .seg { display: flex; }
.side-foot .seg button { flex: 1; padding: 6px; }
@media (max-width: 900px) { .side-foot .seg button { padding: 4px 10px; } }
@media (max-width: 640px) { .nav a svg.i { display: none; } .nav a { padding: 7px 11px; } }

/* ---------- model picker ---------- */
.modal.wide { max-width: 760px; padding: 0; display: flex; flex-direction: column; max-height: min(86vh, 820px); }
.picker-head { padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.picker-head h2 { margin-bottom: 12px; }
.picker-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.picker-tools .chips { margin: 0; }
.chips button.on { background: var(--brand-soft); border-color: transparent; color: var(--brand); font-weight: 600; }
.picker-tools select { width: auto; padding: 6px 10px; font-size: 13px; margin-left: auto; }
.picker-list { overflow-y: auto; padding: 8px 12px 12px; flex: 1; }
.picker-foot { padding: 12px 24px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; color: var(--faint); font-size: 12.5px; }
.mrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; width: 100%; text-align: left;
        border: 1px solid transparent; background: none; color: var(--text); font: inherit; padding: 10px 12px;
        border-radius: 12px; cursor: pointer; }
.mrow:hover { background: var(--surface-2); border-color: var(--line); }
.mrow.on { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.mrow .nm { min-width: 0; }
.mrow .nm b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .nm small { color: var(--faint); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.mrow .pr { text-align: right; font-size: 12.5px; white-space: nowrap; }
.mrow .pr b { font-weight: 600; }
.mrow .pr span { color: var(--faint); }
.mrow .tags { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 99px;
       background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tag.green { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.blue { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.model-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 13px;
             border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); color: var(--text);
             font: inherit; cursor: pointer; }
.model-btn:hover { border-color: var(--brand); }
.model-btn .nm { flex: 1; min-width: 0; }
.model-btn .nm b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn .nm small { color: var(--faint); font-size: 12.5px; }
.model-btn:disabled { opacity: .55; cursor: default; }

/* ---------- api keys ---------- */
.key-card .item-head { margin-bottom: 12px; }
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; }
.switch input { width: 42px; height: 24px; appearance: none; border-radius: 99px; background: var(--line); position: relative;
                padding: 0; border: 0; cursor: pointer; transition: background .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
                       background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }
.auth-switch { margin-top: 18px; color: var(--muted); font-size: 13.5px; }
.auth-switch a { font-weight: 600; cursor: pointer; }
.key-card .item-head .t small { font-family: inherit; }
.table-wrap { overflow-x: auto; }
.table-wrap select, .table-wrap input[type=date] { padding: 6px 9px; font-size: 13px; min-width: 120px; }
.plan-card.none { border-style: dashed; }
.plan-card.none .card-title { margin: 0; }
.picker-foot .muted { font-size: 12px; margin: 0 12px; }
@media (max-width: 640px) { .picker-foot .muted { display: none; } }
