/* Teos console. Tokens first; components below use only tokens. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e3e7eb;
  --border-strong: #cfd6dc;
  --text: #17202a;
  --text-2: #4c5a67;
  --text-3: #7b8894;
  --accent: #0f766e;
  --accent-hover: #0d6560;
  --accent-soft: #e0f2f0;
  --accent-text: #0b5c56;
  --danger: #c2362b;
  --danger-soft: #fdecea;
  --warn: #b26a00;
  --warn-soft: #fff4de;
  --ok: #1f8a4c;
  --ok-soft: #e4f5ea;
  --info-soft: #e8f0fb;
  --info: #2c5fa8;
  --side-bg: #0f1a22;
  --side-text: #b8c4cc;
  --side-active: #1c2d38;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 16px rgba(16, 24, 32, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 32, .22);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1418; --surface: #141e24; --surface-2: #18242b; --border: #24333c; --border-strong: #31434e;
    --text: #e4ebef; --text-2: #a9b7c0; --text-3: #7c8d98;
    --accent: #2bb3a5; --accent-hover: #3cc5b6; --accent-soft: #11302d; --accent-text: #7ee0d4;
    --danger: #f0675b; --danger-soft: #3a1b18; --warn: #f2b14c; --warn-soft: #3a2c12;
    --ok: #4fc483; --ok-soft: #12301f; --info: #7aa7e8; --info-soft: #172a44;
    --side-bg: #0a1014; --side-active: #16232b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1418; --surface: #141e24; --surface-2: #18242b; --border: #24333c; --border-strong: #31434e;
  --text: #e4ebef; --text-2: #a9b7c0; --text-3: #7c8d98;
  --accent: #2bb3a5; --accent-hover: #3cc5b6; --accent-soft: #11302d; --accent-text: #7ee0d4;
  --danger: #f0675b; --danger-soft: #3a1b18; --warn: #f2b14c; --warn-soft: #3a2c12;
  --ok: #4fc483; --ok-soft: #12301f; --info: #7aa7e8; --info-soft: #172a44;
  --side-bg: #0a1014; --side-active: #16232b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--text-3); }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 17px; }
.brand img { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-text); letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 14px 18px; font-size: 12px; color: #6f8290; border-top: 1px solid #1b2a33; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); font-weight: 500; }
.crumbs a { color: var(--text-2); }
.crumbs .sep { color: var(--text-3); }
.crumbs span:last-child { color: var(--text); }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head .sub { color: var(--text-3); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn.menu-btn { display: none; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 18px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid > .card { margin-top: 0; }
.stack > * + * { margin-top: 16px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.grid > * { min-width: 0; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--text-3); font-size: 12.5px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, .input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 32px; padding: 0; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Forms */
.form { display: grid; gap: 14px; }
.form.two { grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field > label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.field .hint { color: var(--text-3); font-size: 12.5px; }
.input, select, textarea { width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; }
textarea { height: auto; min-height: 90px; padding: 9px 11px; font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.input.mono { font-family: var(--mono); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 20px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > .input, .inline > select { flex: 1; }
.rows { display: grid; gap: 8px; }
.row-edit { display: grid; gap: 8px; align-items: center; }
.search { position: relative; }
.search .input { padding-left: 32px; }
.search svg { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; color: var(--text-3); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.selected td { background: var(--accent-soft); }
.table .cell-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.table .cell-name svg { width: 18px; height: 18px; flex: none; color: var(--text-3); }
.table .cell-name .folder { color: var(--accent); }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table td.actions .btn-row { flex-wrap: nowrap; justify-content: flex-end; }
.table .check input { margin: 0; }
.clickable { cursor: pointer; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.danger { background: var(--danger); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* Toolbar & breadcrumbs inside the object browser */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 550; }
.path a { padding: 2px 6px; border-radius: 4px; color: var(--text-2); }
.path a:hover { background: var(--surface-2); text-decoration: none; }
.path .sep { color: var(--text-3); }
.dropzone { position: relative; }
.dropzone.dragging::after { content: "Drop files to upload"; position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent); border: 2px dashed var(--accent); border-radius: var(--radius);
  color: var(--accent-text); font-weight: 650; font-size: 16px; z-index: 3; }
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); }
.empty svg { width: 40px; height: 40px; margin-bottom: 8px; opacity: .6; }
.empty h3 { color: var(--text-2); margin-bottom: 4px; }
.load-more { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--border); }

/* Progress / uploads */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }
.progress.error > div { background: var(--danger); }
.uploads { position: fixed; right: 20px; bottom: 20px; width: 380px; max-height: 50vh; display: flex; flex-direction: column; z-index: 40; }
.uploads .card-body { overflow-y: auto; display: grid; gap: 10px; }
.upload-item .name { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.meter { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; display: flex; }
.meter > span { height: 100%; }

/* Modal, drawer, menus */
.overlay { position: fixed; inset: 0; background: rgba(8, 14, 18, .5); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .12s ease-out; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(860px, 100%); }
.modal.full { width: min(1100px, 100%); height: calc(100vh - 40px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.drawer-overlay { position: fixed; inset: 0; background: rgba(8, 14, 18, .35); z-index: 45; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); box-shadow: var(--shadow-lg); z-index: 46;
  display: flex; flex-direction: column; animation: slide .16s ease-out; }
.drawer .modal-body { flex: 1; }
.menu { position: fixed; z-index: 60; min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.menu svg { width: 16px; height: 16px; color: var(--text-3); }
.preview { display: grid; place-items: center; min-height: 300px; height: 100%; }
.preview img, .preview video { max-width: 100%; max-height: 75vh; border-radius: 6px; }
.preview iframe { width: 100%; height: 75vh; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
pre.code { margin: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: auto; font-family: var(--mono); font-size: 12.5px; max-height: 320px; }
.secret { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.secret span { flex: 1; }
.callout { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--info); }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.danger { background: var(--danger-soft); color: var(--danger); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.rule { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: grid; gap: 12px; background: var(--surface-2); }
.rule-head { display: flex; gap: 10px; align-items: center; }
.section-title { font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }

/* Toasts */
#toasts { position: fixed; top: 68px; right: 16px; display: grid; gap: 8px; z-index: 80; }
.toast { min-width: 260px; max-width: 420px; padding: 11px 14px; border-radius: 8px; background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); animation: fade .15s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% 0%, var(--accent-soft), transparent), var(--bg); }
.login .card { width: min(420px, 100%); }
.login .brand { color: var(--text); padding: 24px 24px 0; }
.login .brand small { color: var(--text-3); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; transform: translateX(-100%); transition: transform .2s; z-index: 70; }
  .layout.nav-open .sidebar { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .form.two { grid-template-columns: 1fr; }
  .grid.c2 { grid-template-columns: minmax(0, 1fr); }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { margin-left: 0; }
  .toolbar .search { width: 100% !important; }
  .uploads { left: 16px; right: 16px; width: auto; }
  .hide-sm { display: none; }
}
