/* Tokens: paper surface + one accent. 4px grid, 10px cards / 8px controls, shadow only on overlays.
   Same family as the AI Chatbot console so the tools feel like one product line. */
:root {
  --bg: #F7F6F3; --surface: #FFFFFF; --side: #EFEDE8; --line: #E1DED7; --ink: #18181B; --muted: #6C6B72;
  --accent: #4B3FBF; --on-accent: #FFFFFF; --gold: #A8741A;
  --ok: #2F855A; --warn: #B7791F; --err: #C53030;
  --hover: color-mix(in srgb, var(--ink) 6%, transparent);
  --soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --surface-2: color-mix(in srgb, var(--ink) 3%, var(--surface));
  --r-card: 10px; --r-ctl: 8px;
  --shadow-pop: 0 12px 32px -8px rgb(24 24 27 / .24), 0 2px 6px rgb(24 24 27 / .06);
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --code-bg: #18181B; --code-ink: #EDEDF0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121216; --surface: #1A1A20; --side: #16161B; --line: #2B2B33; --ink: #EDEDF0; --muted: #9B9AA5;
    --accent: #8F83F0; --on-accent: #14141A; --gold: #D9A441;
    --ok: #4CB27D; --warn: #D9A441; --err: #EF6B6B;
    --shadow-pop: 0 12px 32px -8px rgb(0 0 0 / .6), 0 2px 6px rgb(0 0 0 / .3);
    --code-bg: #0E0E12; color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { font: 14px/1.5 var(--sans); background: var(--bg); color: var(--ink); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd, pre { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.i { width: 18px; height: 18px; flex-shrink: 0; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--mono); }
.danger { color: var(--err) !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--err) 86%, #000); }
.btn-ghost { background: none; border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: var(--r-ctl); background: none; color: var(--muted); cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--soft); }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea.input { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
textarea.mono { font: 12.5px/1.5 var(--mono); min-height: 200px; }
select.input { cursor: pointer; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; background: var(--hover); color: var(--muted); font: 500 11px/1 var(--mono); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.err { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.acc { background: var(--soft); color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.card-p { padding: 20px; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; } }
kbd { padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 11px; line-height: 1.2; }
pre { padding: 12px; border-radius: var(--r-ctl); background: var(--code-bg); color: var(--code-ink); font-size: 12px; overflow: auto; max-height: 56vh; white-space: pre-wrap; word-break: break-word; }

/* Shell: sidebar 264px | main */
#app { display: grid; grid-template-columns: 264px minmax(0, 1fr); height: 100vh; height: 100dvh; }
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side { display: flex; flex-direction: column; min-height: 0; padding: 12px 10px 8px; border-right: 1px solid var(--line); background: var(--side); }
.brand { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 6px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: var(--accent); }
.brand-mark .i { width: 16px; height: 16px; }
.brand small { margin-left: auto; padding: 2px 6px; border-radius: 5px; background: var(--hover); color: var(--muted); font: 500 10.5px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.nav { flex: 1; min-height: 0; margin-top: 8px; overflow-y: auto; }
.nav-label { padding: 16px 10px 4px; color: var(--muted); font: 500 11px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--r-ctl); color: inherit; font-size: 13.5px; text-decoration: none; }
.nav-item .i { color: var(--muted); }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }
.nav-item.active .i { color: var(--accent); }
.side-foot { padding-top: 8px; border-top: 1px solid var(--line); }
.user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 0; border-radius: var(--r-ctl); background: none; text-align: left; cursor: pointer; }
.user:hover { background: var(--hover); }
.avatar { position: relative; display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px; overflow: hidden; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 600; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.user-text { flex: 1; min-width: 0; }
.user-name, .user-email { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-name { font-size: 13px; font-weight: 500; }
.user-email { color: var(--muted); font-size: 12px; }
.head { display: flex; flex-shrink: 0; align-items: center; gap: 10px; height: 56px; padding: 0 16px 0 24px; border-bottom: 1px solid var(--line); background: var(--bg); }
.head-title { flex: 1; min-width: 0; overflow: hidden; font-size: 15px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.head-title small { margin-left: 8px; color: var(--muted); font-weight: 400; font-size: 13px; }
.menu-btn { display: none; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; }
.page { max-width: 1120px; margin: 0 auto; padding: 24px 32px 64px; }
.scrim { position: fixed; inset: 0; z-index: 70; background: rgb(24 24 27 / .4); }
@media (max-width: 860px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 75; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .18s ease; }
  #app.nav-open .side { transform: none; box-shadow: var(--shadow-pop); }
  .menu-btn { display: inline-flex; }
  .head { padding-left: 8px; }
  .page { padding: 16px 16px 56px; }
}

/* Boot / login */
.screen { position: fixed; inset: 0; z-index: 80; overflow-y: auto; background: var(--bg); }
.center { display: grid; place-items: center; min-height: 100%; padding: 24px; }
.login-card { width: min(400px, 100%); padding: 32px 28px; text-align: center; }
.login-card .brand-mark { width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 12px; }
.login-card .brand-mark .i { width: 24px; height: 24px; }
.login-card h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.login-card p { margin: 6px 0 24px; color: var(--muted); }
.login-card .btn { width: 100%; height: 40px; }
.login-err { margin-top: 12px; color: var(--err); font-size: 13px; }
.glogo { width: 18px; height: 18px; }

/* Page header row + toolbar + table */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h2 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { flex-basis: 100%; margin-top: -6px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.search { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.search .i { position: absolute; top: 9px; left: 10px; width: 16px; height: 16px; color: var(--muted); }
.search .input { padding-left: 32px; }
.toolbar select.input { width: auto; min-width: 180px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font: 500 11px/1 var(--mono); letter-spacing: .05em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover { background: var(--surface-2); }
td.num { text-align: right; font-family: var(--mono); }
td .thumb { display: block; width: 36px; height: 48px; border-radius: 4px; background: var(--hover); object-fit: cover; }
td .thumb.none { display: grid; place-items: center; color: var(--muted); }
td .sub { color: var(--muted); font-size: 12px; }
.cell-title { font-weight: 500; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 56px 20px; color: var(--muted); text-align: center; }
.empty .i { width: 32px; height: 32px; }
.empty b { color: var(--ink); font-size: 15px; }
.more { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--line); }
.loading-center { display: flex; justify-content: center; padding: 56px; }

/* Slide-over editor */
.panel { position: fixed; z-index: 72; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column; width: min(640px, 100vw); border-left: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-pop); animation: slide .16s ease-out; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 0 20px; }
.panel-head h3 { flex: 1; font-size: 16px; font-weight: 600; }
.langs { display: flex; gap: 2px; padding: 8px 20px 0; border-bottom: 1px solid var(--line); }
.lang { margin-bottom: -1px; padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: 500 12.5px/1 var(--mono); text-transform: uppercase; cursor: pointer; }
.lang:hover { color: var(--ink); }
.lang.active { border-bottom-color: var(--accent); color: var(--ink); }
.lang i { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--line); }
.lang i.on { background: var(--ok); }
.panel-body { flex: 1; min-height: 0; padding: 8px 20px 24px; overflow-y: auto; }
.panel-head + .panel-body { padding-top: 16px; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.panel-foot .grow { flex: 1; }
.field { margin-bottom: 18px; }
.field > label, .label { display: flex; align-items: baseline; gap: 6px; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
.req { color: var(--err); }
.help { margin-top: 5px; color: var(--muted); font-size: 12px; }
.ferr { margin-top: 5px; color: var(--err); font-size: 12.5px; }
.input.bad { border-color: var(--err); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sec-title { margin: 6px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font: 500 11px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; max-height: 200px; padding: 8px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-ctl); }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.check:hover { background: var(--hover); }
.imgfield { display: flex; gap: 12px; align-items: flex-start; }
.imgfield .prev { display: grid; place-items: center; flex-shrink: 0; width: 72px; height: 96px; overflow: hidden; border: 1px dashed var(--line); border-radius: var(--r-ctl); background: var(--surface-2); color: var(--muted); }
.imgfield .prev img { width: 100%; height: 100%; object-fit: cover; }
.imgfield .ctl { flex: 1; display: grid; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* Modal + toast */
.modal { position: fixed; z-index: 91; top: 16vh; left: 50%; width: min(440px, calc(100vw - 32px)); padding: 20px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-pop); animation: rise .12s ease-out; }
.modal h3 { margin-bottom: 8px; font-size: 16px; font-weight: 600; }
.modal p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.scrim.top { z-index: 90; }
.toasts { position: fixed; z-index: 95; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 380px; padding: 10px 14px; border-left: 3px solid var(--ok); border-radius: var(--r-ctl); background: var(--ink); color: var(--bg); font-size: 13px; box-shadow: var(--shadow-pop); animation: rise .12s ease-out; }
.toast.error { border-left-color: var(--err); }

/* Account + console */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.card h3 { margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.console { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .console { grid-template-columns: 1fr; } }
.eplist { padding: 6px; max-height: 70vh; overflow-y: auto; }
.eplist .grp { padding: 10px 8px 4px; color: var(--muted); font: 500 11px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.ep { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: none; font: 12.5px/1.3 var(--mono); text-align: left; cursor: pointer; }
.ep:hover { background: var(--hover); }
.ep.active { background: var(--soft); }
.ep .m { flex-shrink: 0; width: 46px; color: var(--muted); font-weight: 600; font-size: 11px; }
.ep .m.GET { color: var(--ok); } .ep .m.POST { color: var(--accent); } .ep .m.PUT { color: var(--warn); } .ep .m.DELETE { color: var(--err); }
.reqbar { display: flex; gap: 8px; margin-bottom: 10px; }
.reqbar .input:first-child { width: 90px; flex-shrink: 0; font-family: var(--mono); }
.reqbar .input { font-family: var(--mono); font-size: 13px; }
.resbar { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
