/* ============================================================
   ip.skol.tech — design system
   Aesthetic ported from innomap.ru: editorial corporate on warm
   paper. Lora display, IBM Plex Sans body, IBM Plex Mono accents.
   Navy / teal / carmine / gold. Sharp 3px radius.
   ============================================================ */

:root {
  /* colour */
  --bg: #f5f2eb;
  --bg-2: #efebe0;
  --bg-3: #e9e4d4;
  --bg-elev: #ffffff;
  --ink: #0e1316;
  --ink-2: #3c4148;
  --ink-3: #6b6f76;
  --line: #e0dcd0;
  --line-2: #cdc7b6;
  --navy: #0b1f3a;
  --navy-2: #122e55;
  --navy-3: #1f4072;
  --teal: #0b6157;
  --teal-2: #14b8a6;
  --carmine: #8b2a2a;
  --carmine-2: #b13838;
  --gold: #b08c34;
  --shadow-1: 0 6px 24px rgba(11, 31, 58, 0.08);
  --shadow-2: 0 18px 50px rgba(11, 31, 58, 0.12);

  /* type */
  --font-display: 'Lora', 'Times New Roman', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Menlo', 'Monaco', monospace;

  /* layout */
  --radius: 3px;
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --gutter: clamp(1.25rem, 3vw, 2.5rem);

  /* status semantics */
  --ok: #0b6157;
  --warn: #b08c34;
  --crit: #b13838;
  --info: #1f4072;
}

*, *::before, *::after { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--navy);
  letter-spacing: -0.015em;
  font-weight: 500;
  margin: 0;
}

a { color: var(--navy-3); text-decoration: none; }
a:hover { color: var(--teal); }

::selection { background: var(--teal-2); color: #fff; }

/* scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* ===== shared bits ============================================ */

.eyebrow {
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: inline-flex;
  align-items: baseline;
  gap: .55rem;
  margin: 0 0 1rem;
}
.eyebrow-mark { color: var(--teal); }

.mono { font-family: var(--font-mono); }
.dim { color: var(--ink-3); }
.serif { font-family: var(--font-display); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--font-mono); font-size: .74rem; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  padding: .62rem 1rem; border-radius: var(--radius);
  cursor: pointer; border: 1px solid transparent;
  transition: background .18s, color .18s, border-color .18s, transform .18s;
  white-space: nowrap; background: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: var(--bg); border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-2); color: #fff; }
.btn-secondary { color: var(--navy); border-color: var(--navy); }
.btn-secondary:hover { background: var(--navy); color: var(--bg); }
.btn-ghost { color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { padding: .42rem .7rem; font-size: .68rem; }
.btn-arrow { transition: transform .18s; }
.btn:hover .btn-arrow { transform: translateX(.25em); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* pills / badges */
.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--font-mono); font-size: .66rem; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 2px; border: 1px solid var(--line-2);
  color: var(--ink-2); background: var(--bg-2); white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, var(--bg-elev)); }
.pill-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 38%, var(--line)); background: color-mix(in srgb, var(--warn) 10%, var(--bg-elev)); }
.pill-crit { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 38%, var(--line)); background: color-mix(in srgb, var(--crit) 9%, var(--bg-elev)); }
.pill-info { color: var(--info); border-color: color-mix(in srgb, var(--info) 32%, var(--line)); background: color-mix(in srgb, var(--info) 8%, var(--bg-elev)); }
.pill-neutral { color: var(--ink-3); }

/* cards */
.card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.5rem 1.5rem 1.4rem;
  position: relative; transition: border-color .18s, box-shadow .18s, transform .18s;
}
.card-hover:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.card-num { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; color: var(--carmine); margin: 0 0 1rem; }

/* ===== app shell ============================================== */

#app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--navy);
  color: rgba(245, 242, 235, .82);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid #08172b;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.15rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .brand-mark { width: 26px; height: 26px; flex: none; }
.sidebar-brand .brand-name {
  font-family: var(--font-display); font-weight: 600; font-size: 1.18rem;
  color: var(--bg); letter-spacing: -.01em;
}
.sidebar-brand .brand-name b { color: var(--teal-2); font-weight: 600; }
.sidebar-brand .brand-sub { font-family: var(--font-mono); font-size: .58rem; letter-spacing: .16em; color: rgba(245,242,235,.45); text-transform: uppercase; display: block; }

.nav { padding: .75rem .65rem 1rem; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-family: var(--font-mono); font-size: .58rem; letter-spacing: .18em; text-transform: uppercase;
  color: rgba(245,242,235,.4); padding: 1rem .6rem .4rem;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .52rem .6rem; border-radius: var(--radius);
  color: rgba(245,242,235,.78); font-size: .86rem; cursor: pointer;
  transition: background .15s, color .15s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--navy-3); color: #fff; }
.nav-item.active::before {
  content: ''; position: absolute; left: -.65rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--teal-2); border-radius: 2px;
}
.nav-item .ico { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item .count {
  margin-left: auto; font-family: var(--font-mono); font-size: .62rem;
  background: rgba(255,255,255,.1); color: var(--bg); padding: .05rem .38rem; border-radius: 10px;
}
.nav-item .count.alert { background: var(--carmine-2); color: #fff; }

.sidebar-user {
  display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--teal); color: #fff; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: .72rem; font-weight: 600;
}
.sidebar-user .u-name { font-size: .82rem; color: var(--bg); line-height: 1.2; }
.sidebar-user .u-role { font-family: var(--font-mono); font-size: .6rem; letter-spacing: .08em; color: rgba(245,242,235,.5); text-transform: uppercase; }

/* main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 var(--gutter);
  background: rgba(245, 242, 235, .85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar .crumb { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.topbar .crumb b { color: var(--navy); }
.topbar .search {
  margin-left: auto; position: relative; display: flex; align-items: center; gap: .5rem;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .4rem .65rem; width: min(320px, 32vw); color: var(--ink-3);
}
.topbar .search input { border: none; background: transparent; outline: none; font: inherit; font-size: .85rem; color: var(--ink); width: 100%; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(20, 30, 60, .16); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.search-results[hidden] { display: none; }
.search-row { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-row:last-child { border-bottom: none; }
.search-row:hover { background: var(--bg); }
.search-ic { display: grid; place-items: center; color: var(--ink-3); flex: none; }
.search-tx { display: flex; flex-direction: column; min-width: 0; }
.search-lb { font-size: .85rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-sb { font-size: .72rem; color: var(--ink-3); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: .8rem .7rem; font-size: .82rem; color: var(--ink-3); text-align: center; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-elev); border-radius: var(--radius);
  color: var(--ink-2); position: relative; transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--navy); color: var(--navy); }
.icon-btn .badge-dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--carmine-2); border: 1.5px solid var(--bg); }

.content { padding: var(--gutter); max-width: 1340px; width: 100%; margin: 0 auto; }

/* page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1.05; }
.page-head .sub { color: var(--ink-3); margin-top: .35rem; max-width: 60ch; }
.page-actions { display: flex; gap: .55rem; flex-wrap: wrap; }

/* ===== KPI cards ============================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.kpi { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent, var(--teal)); }
.kpi .k-label { font-family: var(--font-mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.kpi .k-val { font-family: var(--font-display); font-size: 2.1rem; line-height: 1; color: var(--navy); margin: .5rem 0 .25rem; }
.kpi .k-val small { font-size: .9rem; color: var(--ink-3); font-family: var(--font-body); }
.kpi .k-delta { font-family: var(--font-mono); font-size: .68rem; }
.k-delta.up { color: var(--teal); } .k-delta.down { color: var(--carmine-2); }
.kpi-link { cursor: pointer; transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.kpi-link:hover { border-color: var(--accent, var(--teal)); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.06); }
.kpi-link:focus-visible { outline: 2px solid var(--accent, var(--teal)); outline-offset: 2px; }

/* ===== layout helpers ========================================= */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; }
.grid-12 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.1rem; }
.stack > * + * { margin-top: 1.1rem; }
.row { display: flex; align-items: center; gap: .6rem; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wrap { flex-wrap: wrap; }
@media (max-width: 1100px){ .grid-12, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 .9rem; }
.section-title h3 { font-size: 1.15rem; }
.section-title .link { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }

/* ===== tables ================================================= */
.table-wrap { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data thead th {
  text-align: left; font-family: var(--font-mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: var(--bg-2);
  white-space: nowrap;
}
table.data tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr.row-link { cursor: pointer; }
table.data tbody tr.row-link:hover { background: var(--bg-2); }
.th-sort { cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: .15rem; }
.th-sort:hover { color: var(--navy); }
.th-sort.active { color: var(--navy); font-weight: 600; }
/* generic table sort + filter (tableEnhance.js) */
th.th-sortable { cursor: pointer; user-select: none; }
th.th-sortable:hover { color: var(--navy); }
th.th-sortable .srt-arrow { color: var(--navy); font-weight: 600; }
.tbl-toolbar { display: flex; justify-content: flex-end; margin-bottom: .6rem; }
.tbl-toolbar .tbl-q { width: 230px; max-width: 100%; }
.tbl-nomatch td { padding: 0; }
/* pagination */
.pager { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; margin-top: .8rem; }
.pg-btn {
  min-width: 30px; height: 30px; padding: 0 .5rem; border: 1px solid var(--line); background: var(--bg-elev);
  border-radius: var(--radius); font-family: var(--font-mono); font-size: .76rem; color: var(--ink-2); cursor: pointer;
  transition: background .12s, border-color .12s;
}
.pg-btn:hover:not(:disabled):not(.active) { background: var(--bg-2); border-color: var(--ink-3); }
.pg-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; cursor: default; }
.pg-btn:disabled { opacity: .4; cursor: default; }
.pg-gap { padding: 0 .15rem; color: var(--ink-3); }
.pg-info { margin-left: auto; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); }
table.data .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.case-no { font-family: var(--font-mono); font-size: .8rem; color: var(--navy-3); }
.t-title { font-weight: 500; color: var(--ink); }
.t-sub { font-size: .76rem; color: var(--ink-3); }

/* toolbar (filters) */
.toolbar { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); }
.toolbar .seg button { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; padding: .42rem .7rem; border: none; background: transparent; cursor: pointer; color: var(--ink-3); border-right: 1px solid var(--line); }
.toolbar .seg button:last-child { border-right: none; }
.toolbar .seg button.active { background: var(--navy); color: var(--bg); }
.input, select.input { font: inherit; font-size: .85rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); color: var(--ink); }
.input:focus, select.input:focus { outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 3px rgba(31,64,114,.12); }

/* ===== timeline ============================================== */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line-2); }
.tl-item { position: relative; padding: 0 0 1.1rem; }
.tl-item::before { content: ''; position: absolute; left: -1.5rem; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--teal); }
.tl-item.done::before { background: var(--teal); }
.tl-item.crit::before { border-color: var(--carmine-2); }
.tl-date { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .06em; color: var(--ink-3); }
.tl-title { font-weight: 500; }
.tl-docs { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.tl-docs:empty { margin-top: 0; }
.tl-doc-link { display: inline-flex; align-items: center; gap: .25rem; max-width: 18rem; padding: .12rem .45rem; border: 1px solid var(--line); border-radius: 5px; font-size: .74rem; color: var(--ink); text-decoration: none; background: var(--bg-elev); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-doc-link:hover { border-color: var(--teal); color: var(--teal); }
.tl-attach { margin-top: .3rem; padding: 0; border: 0; background: none; font: inherit; font-size: .72rem; color: var(--ink-3); cursor: pointer; opacity: 0; transition: opacity .12s, color .12s; }
.tl-item:hover .tl-attach, .tl-attach:focus-visible { opacity: 1; }
.tl-attach:hover { color: var(--teal); }

/* ===== calendar ============================================== */
.cal { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head div { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: .6rem; text-align: center; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 96px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .4rem .45rem; position: relative; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.dim { background: var(--bg-2); }
.cal-cell.today .d { color: #fff; background: var(--navy); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; }
.cal-cell .d { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); }
.cal-cell { display: flex; flex-direction: column; }
.cal-ev { font-size: .68rem; padding: .12rem .35rem; border-radius: 2px; margin-top: .25rem; border-left: 2px solid; background: var(--bg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; transition: background .12s, transform .12s; }
.cal-ev:hover { background: var(--bg-elev); transform: translateX(1px); filter: brightness(1.05); }
.cal-ev.crit { border-color: var(--crit); color: var(--crit); }
.cal-ev.warn { border-color: var(--warn); color: var(--warn); }
.cal-ev.ok   { border-color: var(--ok);   color: var(--ok); }
.cal-more { font-size: .64rem; font-family: var(--font-mono); color: var(--ink-3); margin-top: .25rem; padding: .05rem .35rem; cursor: pointer; }
.cal-more:hover { color: var(--navy); text-decoration: underline; }

/* ===== wizard ================================================ */
.wizard-steps { display: flex; gap: 0; margin-bottom: 1.6rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); }
.wz-step { flex: 1; padding: .85rem 1rem; display: flex; align-items: center; gap: .6rem; border-right: 1px solid var(--line); color: var(--ink-3); }
.wz-step:last-child { border-right: none; }
.wz-step .n { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-family: var(--font-mono); font-size: .72rem; flex: none; }
.wz-step.active { background: var(--bg-2); color: var(--navy); }
.wz-step.active .n { background: var(--navy); color: var(--bg); border-color: var(--navy); }
.wz-step.done .n { background: var(--teal); color: #fff; border-color: var(--teal); }
.wz-label { font-size: .8rem; line-height: 1.15; }
.wz-label small { display: block; font-family: var(--font-mono); font-size: .58rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* forms */
.field { margin-bottom: 1.1rem; }
.field > label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: .35rem; }
.field > label .req { color: var(--carmine-2); }
.field .hint { font-size: .74rem; color: var(--ink-3); margin-top: .3rem; }
.field input[type=text], .field input[type=date], .field input[type=number], .field textarea, .field select {
  width: 100%; font: inherit; font-size: .9rem; padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); color: var(--ink);
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 3px rgba(31,64,114,.12); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
@media (max-width: 760px){ .form-grid { grid-template-columns: 1fr; } }

/* misc */
.bar { height: 8px; border-radius: 4px; background: var(--bg-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--teal); }
.divide { height: 1px; background: var(--line); margin: 1.2rem 0; }
.tag-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.empty { text-align: center; color: var(--ink-3); padding: 3rem; font-family: var(--font-mono); font-size: .8rem; letter-spacing: .05em; }

.share-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.share-bar > span { display: block; }

/* fade-in */
.view { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* toast */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100; background: var(--navy); color: var(--bg); padding: .8rem 1.1rem; border-radius: var(--radius); box-shadow: var(--shadow-2); font-size: .85rem; display: flex; gap: .6rem; align-items: center; animation: fade .25s ease; }
.toast .ico { color: var(--teal-2); }

/* responsive: collapse sidebar */
@media (max-width: 880px){
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 256px; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-2); }
  .topbar .menu-toggle { display: grid; }
}
.menu-toggle { display: none; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(11,31,58,.4); z-index: 55; }
.scrim.show { display: block; }
@media (max-width: 620px){
  :root { --gutter: 1rem; }
  .topbar .search { display: none; }
  .topbar .crumb { margin-right: auto; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; justify-content: center; }
  table.data { font-size: .8rem; }
  table.data tbody td, table.data thead th { padding: .6rem .7rem; }
  .pg-info { width: 100%; margin: .3rem 0 0; text-align: right; }
}

/* sidebar logout */
.sidebar-user .u-meta { min-width: 0; flex: 1; }
.sidebar-user .u-meta .u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { flex: none; width: 30px; height: 30px; border-radius: var(--radius); display: grid; place-items: center; color: rgba(245,242,235,.55); background: transparent; border: 1px solid transparent; cursor: pointer; transition: color .15s, background .15s; }
.logout-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

/* login screen */
#login-layer {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(20,184,166,.12), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, rgba(31,64,114,.18), transparent 55%),
    var(--navy);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: calc(var(--radius) * 2);
  box-shadow: 0 30px 80px rgba(11,31,58,.45); padding: 2.4rem 2.2rem;
  animation: fade .4s ease both;
}
.login-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.8rem; }
.login-brand .brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.14rem; color: var(--navy); display: block; }
.login-brand .brand-sub { font-family: var(--font-mono); font-size: .56rem; letter-spacing: .16em; color: var(--ink-3); text-transform: uppercase; display: block; }
.login-brand .brand-mark { width: 34px; height: 34px; }
.login-title { font-family: var(--font-display); font-size: 1.55rem; color: var(--navy); margin: 0 0 .25rem; }
.login-sub { font-size: .82rem; color: var(--ink-3); margin: 0 0 1.6rem; }
.login-form .field { display: block; margin-bottom: 1rem; }
.login-form .field > span { display: block; font-size: .78rem; font-weight: 500; margin-bottom: .35rem; color: var(--ink-2); }
.login-form .field input {
  width: 100%; font: inherit; font-size: .9rem; padding: .6rem .7rem;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg); color: var(--ink);
}
.login-form .field input:focus { outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 3px rgba(31,64,114,.12); background: var(--bg-elev); }
.login-err { min-height: 1.1rem; font-size: .78rem; color: var(--crit); margin-bottom: .4rem; }
.login-submit { width: 100%; justify-content: center; padding: .65rem; font-size: .82rem; margin-top: .3rem; }
.login-guest { width: 100%; justify-content: center; padding: .6rem; font-size: .82rem; margin-top: .9rem; }
.login-guest-note { font-size: .72rem; color: var(--ink-3); text-align: center; margin: .55rem 0 0; line-height: 1.4; }
@media (max-width: 480px){ .login-card { padding: 1.8rem 1.4rem; } }

/* Guest (read-only) mode: hide create/export affordances the API would reject anyway. */
body.guest [data-go$="/new"],
body.guest [data-action="export"],
body.guest [data-action="new-asset"] { display: none !important; }

/* deal comments / chat */
.chat-threads { display: flex; flex-direction: column; gap: .5rem; }
.chat-thread { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); }
.chat-thread > summary { cursor: pointer; list-style: none; padding: .6rem .8rem; display: flex; align-items: center; gap: .6rem; font-weight: 500; color: var(--navy); }
.chat-thread > summary::-webkit-details-marker { display: none; }
.chat-thread > summary::before { content: '▸'; color: var(--ink-3); transition: transform .15s; }
.chat-thread[open] > summary::before { transform: rotate(90deg); }
.chat-thread-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread .count { font-family: var(--font-mono); font-size: .62rem; color: var(--ink-3); background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .5rem; }
.chat-body { padding: .2rem .8rem .6rem; display: flex; flex-direction: column; gap: .5rem; }
.chat-msg { border-left: 2px solid var(--line-2); padding: .25rem 0 .25rem .7rem; }
.chat-msg.mine { border-left-color: var(--teal); }
.chat-meta { display: flex; gap: .5rem; align-items: baseline; font-size: .76rem; margin-bottom: .15rem; }
.chat-meta .dim { font-family: var(--font-mono); font-size: .66rem; }
.chat-text { font-size: .86rem; color: var(--ink-2); line-height: 1.45; }
.chat-compose { display: flex; gap: .5rem; padding: .2rem .8rem .8rem; }
.chat-compose .input { flex: 1; }
@media (max-width: 600px){ .chat-compose { flex-direction: column; } .chat-compose .btn { width: 100%; justify-content: center; } }

/* inline small select (e.g. role picker in users table) */
.inp-sm {
  font: inherit; font-size: .78rem; line-height: 1.2;
  padding: .35rem 1.6rem .35rem .55rem;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--bg-elev) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b6f76' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right .55rem center;
  color: var(--ink); cursor: pointer; max-width: 100%;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  text-overflow: ellipsis; white-space: nowrap;
}
.inp-sm:focus { outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 3px rgba(31,64,114,.12); }
