/* Centrala admin – neutral, dense, hairline borders, small radii. */

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #fbfbfb;
  --sidebar: #f4f4f5;
  --hover: #efeff1;
  --fg: #0a0a0b;
  --fg-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --primary: #18181b;
  --primary-fg: #fafafa;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, .08);
  --ring: rgba(37, 99, 235, .28);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, .09);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, .1);
  --danger: #b91c1c;
  --danger-soft: rgba(220, 38, 38, .08);
  --r: 4px;
  --r-lg: 6px;
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, .04), 0 12px 32px -8px rgba(0, 0, 0, .18);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --surface: #111113;
    --surface-2: #0e0e10;
    --sidebar: #0c0c0e;
    --hover: #1c1c1f;
    --fg: #fafafa;
    --fg-2: #d4d4d8;
    --muted: #a1a1aa;
    --faint: #71717a;
    --line: #26262a;
    --line-strong: #34343a;
    --primary: #fafafa;
    --primary-fg: #09090b;
    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, .1);
    --ring: rgba(96, 165, 250, .35);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, .1);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .1);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .1);
    --shadow-pop: 0 0 0 1px rgba(255, 255, 255, .06), 0 16px 40px -8px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 13.5px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -.015em; margin: 0; line-height: 1.3; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-size: 12px; font-weight: 600; margin: 0 0 8px; color: var(--fg-2); }
p { margin: 0 0 8px; }
code, .mono, pre { font-family: var(--mono); font-size: 12px; }
code { padding: 1px 5px; background: var(--hover); border: 1px solid var(--line); border-radius: 3px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error, .warn-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.loading { padding: 48px; color: var(--muted); text-align: center; }
.empty { padding: 32px 16px; color: var(--muted); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface-2); }
.empty strong { display: block; color: var(--fg); font-weight: 600; margin-bottom: 4px; }
[hidden] { display: none !important; }

.icon { display: inline-flex; width: 16px; height: 16px; flex: none; }
.icon svg { width: 100%; height: 100%; }

/* ---- shell ---------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--line);
}
.sidebar-head { height: 52px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 600; font-size: 14px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 24px; height: 24px; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-fg);
  border-radius: var(--r); font-size: 13px; font-weight: 700;
}
.nav { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.nav-group { margin: 18px 10px 6px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 10px; margin: 1px 0;
  border-radius: var(--r); color: var(--fg-2); font-weight: 450;
  white-space: nowrap; overflow: hidden;
}
.nav-link > span:not(.icon):not(.nav-count) { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav-link .icon { color: var(--muted); }
.nav-link .icon.trailing { width: 12px; height: 12px; color: var(--faint); }
.nav-link:hover { background: var(--hover); color: var(--fg); text-decoration: none; }
.nav-link.active { background: var(--surface); color: var(--fg); font-weight: 550; box-shadow: inset 0 0 0 1px var(--line); }
.nav-link.active .icon { color: var(--fg); }
.nav-count {
  min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px;
  display: inline-grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 600;
}
.sidebar-foot { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 8px; border-top: 1px solid var(--line); }
.me {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--r); color: var(--fg);
}
.me:hover { background: var(--hover); text-decoration: none; }
.me.active { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.avatar {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center;
  border-radius: var(--r); background: var(--hover); border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--fg-2);
}
.me-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.me-name { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .topbar-brand, .topbar .menu-btn { display: none; }
.crumbs { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs b { color: var(--fg); font-weight: 550; }
.spacer { flex: 1; }
.main { padding: 28px; max-width: 1240px; width: 100%; outline: none; }
.scrim { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: 264px;
    transform: translateX(-100%); transition: transform .18s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .35); }
  .topbar { padding: 0 16px; }
  .topbar .topbar-brand, .topbar .menu-btn { display: inline-flex; }
  .crumbs { display: none; }
  .main { padding: 20px 16px; }
  .customer-link { display: none; }
}

/* ---- page structure ---------------------------------------------------------- */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--line);
}
.page-title { min-width: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 76ch; }
.page-head + .tabbed > .tabs { margin-top: -20px; }
.back { display: inline-flex; margin-bottom: 6px; font-size: 12.5px; color: var(--muted); }
.back:hover { color: var(--fg); text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta .icon { width: 14px; height: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; margin-bottom: 16px; min-width: 0;
}
.card > h2:first-child, .card > .row:first-child h2 { margin-bottom: 4px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; max-width: 70ch; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 20px 0; }
.card.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.card.warn ul { margin: 0; padding-left: 18px; }
.card.error { color: var(--danger); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r-lg); margin-bottom: 16px; font-size: 13px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg-2); }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }
.notice.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--fg-2); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.row.between { justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.side .card { padding: 16px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1080px) { .split, .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.toolbar select { width: auto; min-width: 160px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; max-width: 360px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 12.5px; }

/* segmented filter (Svi / Novo / Moji …) */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg button { height: 32px; padding: 0 12px; border: 0; background: none; color: var(--fg-2); font: inherit; font-size: 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--primary); color: var(--primary-fg); }

/* KPI tiles: one bordered panel with hairline dividers */
.tiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  overflow: hidden; margin-bottom: 24px;
}
.tile { display: block; padding: 16px 18px; background: var(--surface); color: var(--fg); box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
a.tile:hover { background: var(--surface-2); text-decoration: none; }
.tile-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { margin-top: 6px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }
.tile-sub.warn { color: var(--warn); }

/* ---- tabs ------------------------------------------------------------------------ */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); }
.tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--fg); border-radius: 2px 2px 0 0; }
.tab-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--hover); color: var(--fg-2); font-size: 11px; font-weight: 600; }

/* ---- controls -------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
  font: inherit; font-weight: 500; font-size: 13px; line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .03);
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn .icon { width: 14px; height: 14px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 86%, var(--bg)); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; border-color: transparent; color: var(--danger); box-shadow: none; }
.btn.danger.ghost:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; height: 36px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; flex: none;
  border: 0; border-radius: var(--r); background: none; color: var(--muted); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--hover); color: var(--fg); }

input, select, textarea {
  width: 100%; min-height: 34px; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--fg); font: inherit; font-size: 13px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  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='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
textarea { resize: vertical; line-height: 1.55; }
textarea.mono { font-family: var(--mono); font-size: 12px; }
input[readonly], textarea[readonly], select:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
input[type=checkbox], input[type=radio] { width: 15px; height: 15px; min-height: 0; padding: 0; margin: 0; accent-color: var(--primary); flex: none; }
input[type=color] { height: 34px; padding: 3px; cursor: pointer; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-section {
  grid-column: 1 / -1; margin: 12px 0 -4px; padding-top: 20px; border-top: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--fg);
}
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form > p { grid-column: 1 / -1; margin: -6px 0 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: 12.5px; font-weight: 500; color: var(--fg-2); }
.field.bool { justify-content: flex-end; padding-bottom: 7px; }
.help { font-size: 12px; color: var(--muted); line-height: 1.45; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 450; color: var(--fg); cursor: pointer; }
.checks {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0;
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.checks .check { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.checks .check:hover { background: var(--surface-2); }
@media (max-width: 680px) { .form { grid-template-columns: minmax(0, 1fr); } }

/* sticky save bar at the bottom of long editors */
.savebar {
  position: sticky; bottom: 0; z-index: 10; margin: 8px -28px -28px; padding: 12px 28px;
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
}
.savebar .muted { margin-right: auto; font-size: 12.5px; }
@media (max-width: 860px) { .savebar { margin: 8px -16px -20px; padding: 12px 16px; } }

.kv-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.kv-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 6px; }
.kv-k { font-family: var(--mono); font-size: 12px; }
@media (max-width: 680px) { .kv-row { grid-template-columns: minmax(0, 1fr) auto; } .kv-row .kv-v { grid-column: 1; } }

.fields-editor { border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 12px; overflow: hidden; }
.fields-editor:empty { display: none; }
.fe-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding: 12px; background: var(--surface); }
.fe-row + .fe-row { border-top: 1px solid var(--line); }
.fe-main { display: grid; grid-template-columns: 2fr 1.4fr 1fr auto; gap: 8px; align-items: center; }
.fe-extra { grid-column: 1; display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.fe-options { display: flex; align-items: center; gap: 8px; }
.fe-options label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.fe-actions { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 760px) { .fe-main, .fe-extra { grid-template-columns: minmax(0, 1fr); } }

/* ---- tables ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card .table-wrap { border-radius: var(--r); }
.card.flush .table-wrap { border: 0; border-top: 1px solid var(--line); border-radius: 0; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0 14px; height: 40px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td { padding-top: 8px; padding-bottom: 8px; color: var(--fg); overflow-wrap: break-word; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; overflow-wrap: normal; }
th {
  height: 34px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: var(--surface-2); white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sub { display: block; font-size: 12px; color: var(--muted); }
@media (max-width: 680px) {
  .table-wrap thead { display: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table-wrap td { border: 0; height: auto; padding: 2px 14px; text-align: left; }
  .table-wrap td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
}

/* compact key → number list (diagnostics) */
.kv-table { width: 100%; font-size: 12px; }
.kv-table td { height: auto; padding: 5px 0; border-bottom: 1px solid var(--line); }
.kv-table td:first-child { font-family: var(--mono); color: var(--fg-2); padding-right: 12px; overflow-wrap: anywhere; }
.kv-table td:last-child { text-align: right; white-space: nowrap; overflow-wrap: normal; font-variant-numeric: tabular-nums; }

/* status label: small square-cornered tag with a dot */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 3px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 12px; font-weight: 500; color: var(--fg-2); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.s-novo, .badge.s-active { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.badge.s-preuzeto { color: var(--fg-2); }
.badge.s-rijeseno, .badge.s-closed, .badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.s-nepotpuno, .badge.s-hitno, .badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.s-failed, .badge.s-odbaceno, .badge.bad { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

/* on/off state */
.state { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; white-space: nowrap; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.state.on { color: var(--fg); }
.state.on::before { background: var(--ok); }
.state.off { color: var(--muted); }
.state.off::before { background: var(--line-strong); }
.state.bad::before { background: var(--danger); }

.dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { padding: 10px 0; border-top: 1px solid var(--line); }
.log-list li:first-child { border-top: 0; padding-top: 0; }
.pre {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 440px; overflow: auto;
  margin: 0 0 14px; line-height: 1.55;
}
details.tool { border-top: 1px solid var(--line); padding: 8px 0; }
details.tool summary { cursor: pointer; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
details summary { cursor: pointer; }
details.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 16px; }
details.section > summary { padding: 14px 20px; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before { content: "›"; color: var(--muted); font-size: 16px; transition: transform .12s ease; }
details.section[open] > summary::before { transform: rotate(90deg); }
details.section > summary .muted { font-weight: 400; font-size: 12.5px; }
details.section > .section-body { padding: 0 20px 20px; }

/* ---- call timeline: transcript with what the system did in between ---------------- */

.timeline { display: flex; flex-direction: column; }
.turn {
  display: grid; grid-template-columns: 44px 84px minmax(0, 1fr); gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--line); line-height: 1.55;
}
.turn:first-child { border-top: 0; padding-top: 0; }
.turn .t { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 2px; }
.turn .who { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: 2px; }
.turn.caller .who { color: var(--accent); }
.turn .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.event { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.event .t { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 3px; }
.event .body {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  padding: 6px 10px; border-radius: var(--r); font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--fg-2);
}
.event.ok .body { background: var(--ok-soft); border-color: transparent; color: var(--fg); }
.event.warn .body { background: var(--warn-soft); border-color: transparent; color: var(--fg); }
.event .body b { font-weight: 600; }
.event .body .muted { font-size: 12px; }
@media (max-width: 560px) {
  .turn { grid-template-columns: 38px minmax(0, 1fr); }
  .turn .who { grid-column: 2; }
  .turn .text { grid-column: 2; }
  .event { grid-template-columns: 38px minmax(0, 1fr); }
}

.player { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.player audio { flex: 1; min-width: 240px; height: 36px; }

/* ---- roles: permission matrix ------------------------------------------------------ */

.perm-table td, .perm-table th { height: 38px; }
.perm-table td:not(:first-child), .perm-table th:not(:first-child) { text-align: center; width: 110px; }
.perm-table input { vertical-align: middle; }
.perm-table td:first-child { font-weight: 500; }
.perm-table .sub { font-weight: 400; }

/* ---- overlays ------------------------------------------------------------------ */

.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(9, 9, 11, .45); backdrop-filter: blur(2px);
}
.modal {
  width: min(540px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
}
.modal.wide { width: min(860px, 100%); }
.modal-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 20px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 40px); }
.toast {
  min-width: 240px; padding: 10px 14px; border-radius: var(--r-lg);
  background: var(--primary); color: var(--primary-fg); font-size: 13px; box-shadow: var(--shadow-pop);
}
.toast.err { background: var(--danger); color: #fff; }

/* ---- login ------------------------------------------------------------------------ */

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px;
  padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.login-card h1 { font-size: 18px; margin-top: 8px; }
.login-card p { margin: 4px 0 0; }
.login-card .error:empty { display: none; }

/* ---- telephony: weekly hours editor -------------------------------------------- */

.hours-grid { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); margin-top: 6px; }
.hours-row { display: grid; grid-template-columns: 160px 120px 12px 120px; justify-content: start; gap: 10px; align-items: center; padding: 6px 12px; }
.hours-row + .hours-row { border-top: 1px solid var(--line); }
.hours-row input[type=time] { min-height: 30px; padding: 4px 8px; }
@media (max-width: 560px) { .hours-row { grid-template-columns: 1fr 1fr auto 1fr; } }

/* ---- customer-facing appearance editor ----------------------------------------- */

.appearance { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.preview-col { position: sticky; top: 68px; }
.preview-frame { width: 100%; height: 760px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg); display: block; }
@media (max-width: 1180px) {
  .appearance { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; }
  .preview-frame { height: 680px; }
}
