/* CadLink portal - one stylesheet, no inline styles (the hub's CSP forbids them).
   Plain product style: neutral light surfaces, hairline borders, sentence-case labels.
   Lime (#8DC63F) is only for primary buttons and the current-page marker; status is a dot + text. */
:root {
    color-scheme: light;
    --bg: #F6F7F9;
    --surface: #FFFFFF;
    --surface-2: #F3F4F6;
    --surface-3: #E9EBEF;
    --border: #E4E6EA;
    --border-2: #D2D6DC;
    --text: #15171C;
    --text-2: #3F4451;
    --muted: #6B7280;
    --accent: #8DC63F;          /* fills */
    --accent-hover: #9ED350;
    --accent-ink: #4D7C0F;      /* text/lines on light */
    --accent-wash: #EEF6E0;
    --accent-text: #15171C;     /* text on a lime fill */
    --focus: #4D7C0F;
    --good: #15803D;   --good-bg: #ECFDF3;
    --warn: #B45309;   --warn-bg: #FFF7E6;
    --bad: #B91C1C;    --bad-bg: #FEF2F2;
    --info: #1D4ED8;   --info-bg: #EFF4FF;
    --neutral-bg: #F1F2F4;
    --red: #DC2626; --blue: #1D4ED8; --purple: #6D28D9; --amber: #D97706;
    --preview: #5B21B6; --preview-bg: #F3EEFF;
    --sim: #92400E;     --sim-bg: #FEF3C7;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-pop: 0 8px 24px rgba(16, 24, 40, .12);
    --radius: 8px;
    --radius-sm: 6px;
    --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
    --top-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 600; margin: 1.4rem 0 .6rem; }
h3 { font-size: .93rem; font-weight: 600; margin: 1rem 0 .4rem; }
p { margin: .35rem 0; }
code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--neutral-bg); padding: .05rem .35rem; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-wash); }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; }
.boot { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: .75rem; }
.spacer { height: .75rem; }
.icon { flex: 0 0 auto; }

/* -- Brand -- */
.brand { display: flex; align-items: center; gap: .5rem; }
.brand .logo { color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.brand-name b { color: var(--text); font-weight: 700; }
.brand-tag { display: none; }
.brand-link { text-decoration: none; flex: 0 0 auto; }
.brand-link:hover { text-decoration: none; }

/* -- Mode banner (preview / simulation only) -- */
.mode-banner { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .75rem; padding: .45rem 1rem; font-weight: 600; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mode-preview { background: var(--preview-bg); color: var(--preview); }
.mode-simulate { background: var(--sim-bg); color: var(--sim); }
.mode-banner .mode-label { font-size: .85rem; }
.mode-banner .mode-detail { font-weight: 400; }
.mode-banner .btn { margin-left: auto; }

/* -- Top bar -- */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 1.25rem; padding: 0 1rem;
          background: var(--surface); border-bottom: 1px solid var(--border); }
.topnav { display: flex; align-items: stretch; gap: .1rem; height: 100%; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.top-link { display: flex; align-items: center; gap: .45rem; padding: 0 .75rem; color: var(--text-2); text-decoration: none; font-weight: 500; white-space: nowrap; position: relative; }
.top-link:hover { color: var(--text); text-decoration: none; }
.top-link[aria-current="page"] { color: var(--text); font-weight: 600; }
.top-link[aria-current="page"]::after { content: ""; position: absolute; left: .6rem; right: .6rem; bottom: 0; height: 2px; background: var(--accent); }
.top-right { display: flex; align-items: center; gap: .6rem; flex: 0 0 auto; }
.env-pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 500; padding: .15rem .5rem; border-radius: 4px; border: 1px solid var(--border-2); color: var(--warn); }
.env-pill.live { color: var(--good); }
.dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; display: inline-block; flex: 0 0 auto; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; color: var(--text-2); background: transparent; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.bell .count { position: absolute; top: 2px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
.menu-btn { display: none; }
.user-wrap { position: relative; }
.user-chip { display: flex; align-items: center; gap: .55rem; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: .25rem .45rem; color: var(--text); cursor: pointer; font: inherit; }
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .78rem; color: var(--text-2); background: var(--surface-3); flex: 0 0 auto; }
.user-text { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-text .name { font-weight: 600; }
.user-text .sub { font-size: .78rem; color: var(--muted); }
.user-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-pop); padding: .3rem; z-index: 50; }
.um-head { padding: .5rem .6rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.um-head .name { font-weight: 600; }
.um-item { display: flex; align-items: center; gap: .55rem; padding: .45rem .6rem; border-radius: 6px; color: var(--text-2); text-decoration: none; }
.um-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* -- Shell + sidebar -- */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: calc(100vh - var(--top-h)); }
.sidebar { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; display: flex; flex-direction: column;
           background: var(--surface); border-right: 1px solid var(--border); padding: .9rem .6rem; }
.sidenav { flex: 1 1 auto; }
.side-section { display: none; }
.side-section.current { display: block; }
.side-section-title { display: none; }
.nav-group { margin: 0 0 1rem; }
.nav-title { padding: .2rem .65rem .35rem; font-size: .8rem; color: var(--muted); font-weight: 500; }
.nav-link { display: flex; align-items: center; gap: .6rem; padding: .45rem .65rem; margin: 1px 0; border-radius: 6px; color: var(--text-2); text-decoration: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { color: var(--text); font-weight: 600; background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.nav-link[aria-current="page"] .icon { color: var(--accent-ink); }
.side-collapse { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; padding: .45rem .65rem; border-radius: 6px; border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.side-collapse:hover { color: var(--text); background: var(--surface-2); }
.shell.collapsed { grid-template-columns: 60px minmax(0, 1fr); }
.shell.collapsed .nav-link span, .shell.collapsed .nav-title, .shell.collapsed .side-collapse span { display: none; }
.shell.collapsed .nav-link, .shell.collapsed .side-collapse { justify-content: center; padding: .55rem; }
.shell.collapsed .side-collapse .icon { transform: rotate(180deg); }
.main { padding: 1.5rem 1.75rem 3rem; width: 100%; max-width: 1480px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head .intro { color: var(--text-2); max-width: 75ch; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

@media (max-width: 1600px) {
    .top-link span { display: none; }
    .top-link { padding: 0 .65rem; }
    .top-link[aria-current="page"] span { display: inline; }
}
@media (max-width: 860px) {
    .topbar { gap: .6rem; padding: 0 .6rem 0 .4rem; }
    .menu-btn { display: inline-grid; }
    .topnav { display: none; }
    .top-right { margin-left: auto; gap: .3rem; }
    .env-pill { display: none; }
    .shell, .shell.collapsed { grid-template-columns: 1fr; }
    .sidebar { display: none; position: fixed; z-index: 45; top: var(--top-h); left: 0; right: 0; bottom: 0; height: auto; border-right: 0; }
    .sidebar.open { display: flex; }
    .side-section { display: block; }
    .side-section-title { display: block; padding: .4rem .65rem; color: var(--text); font-weight: 600; }
    .side-collapse { display: none; }
    .shell.collapsed .nav-link span, .shell.collapsed .nav-title { display: initial; }
    .main { padding: 1rem 16px 3rem; }
}

/* -- Cards, tiles -- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.card + .card { margin-top: .85rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; }
a.tile { color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--border-2); text-decoration: none; }
.tile .value { font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }
.tile .label { color: var(--muted); font-size: .85rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* -- Badges / tones (text always carries the meaning; color is extra) -- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .45rem; border-radius: 4px; font-size: .78rem; font-weight: 500; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; border: 1px solid transparent; }
.tone-good { background: var(--good-bg); color: var(--good); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-info, .tone-pending { background: var(--info-bg); color: var(--info); }
.tone-neutral { background: var(--neutral-bg); color: var(--text-2); }
i.dot.tone-good, i.dot.tone-warn, i.dot.tone-bad, i.dot.tone-info { background: currentColor; }
.callout { border-radius: var(--radius-sm); padding: .65rem .9rem; margin: .5rem 0; border: 1px solid var(--border); background: var(--surface); }
.callout.tone-good { border-color: #BBE5C8; }
.callout.tone-warn { border-color: #F5D9A8; }
.callout.tone-bad { border-color: #F5C2C2; }
.callout.tone-info { border-color: #C7D7FB; }

/* -- Tables -- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; font-weight: 500; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FAFAFB; }
tr.attention td { background: var(--bad-bg); }
tr.attention td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* -- Forms, buttons -- */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); border-radius: 6px; padding: .4rem .85rem; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn.danger { color: var(--bad); border-color: #F0B4B4; background: var(--surface); }
.btn.danger:hover:not(:disabled) { background: var(--bad-bg); color: var(--bad); }
.btn.small { padding: .2rem .55rem; font-size: .82rem; border-radius: 5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.field > label, .field > .label { font-weight: 500; font-size: .86rem; color: var(--text-2); }
.field .help { color: var(--muted); font-size: .8rem; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=date], input[type=time], input:not([type]), select, textarea {
    font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-2); border-radius: 6px; padding: .45rem .65rem; min-width: 0; max-width: 100%;
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 3px rgba(141, 198, 63, .25); }
textarea { min-height: 5rem; width: 100%; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent-ink); }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin: .5rem 0 .9rem; }
.inline-form .field { margin-bottom: 0; }
.check { display: flex; gap: .5rem; align-items: flex-start; margin: .35rem 0; }
.check input { margin-top: .25rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .5rem 0 .9rem; }
.tabs { display: flex; gap: .25rem; margin: .25rem 0 1.1rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs a { padding: .45rem .75rem; text-decoration: none; color: var(--text-2); font-weight: 500; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
details > summary { cursor: pointer; color: var(--text-2); }

/* -- Secret shown once -- */
.secret { font-family: var(--mono); font-size: 1rem; padding: .6rem .8rem; background: var(--surface-2); border: 1px dashed var(--border-2); border-radius: 6px; word-break: break-all; user-select: all; }

/* -- Timeline, key/value, logs -- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 9.5rem 6.5rem 1fr; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
@media (max-width: 640px) { .timeline li { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.log { font-family: var(--mono); font-size: .8rem; max-height: 420px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .6rem; }
.log div { padding: .14rem 0; border-bottom: 1px dotted var(--border); }
.steps { margin: .25rem 0 0; padding-left: 1.2rem; }

/* -- Dialog, toasts -- */
dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); padding: 0; width: min(580px, calc(100vw - 32px)); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(15, 17, 22, .4); }
dialog .dlg-head { padding: .9rem 1.15rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 1rem; }
dialog .dlg-body { padding: 1rem 1.15rem; max-height: 70vh; overflow: auto; }
dialog .dlg-foot { padding: .8rem 1.15rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: .5rem; z-index: 60; max-width: calc(100vw - 32px); }
.toast { padding: .65rem .95rem; border-radius: 8px; box-shadow: var(--shadow-pop); background: var(--text); color: #fff; max-width: 420px; }

/* -- Sign-in -- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--bg); }
.auth-card { width: min(400px, 100%); padding: 1.6rem 1.6rem 1.4rem; }
.auth-card .brand { margin-bottom: .6rem; }
.auth-tag { color: var(--text-2); margin: 0 0 1.2rem; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: .55rem; }

/* -- Dashboard -- */
.dash { display: grid; gap: 1rem; }
.dash > .page-head { margin-bottom: 0; }
.status-line { display: flex; align-items: center; gap: .45rem; margin: .2rem 0 0; flex-wrap: wrap; }
.status-line .dot { color: var(--good); }
.status-line.warn .dot { color: var(--amber); }
.status-line.bad .dot { color: var(--red); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.kpi { display: block; padding: .9rem 1rem; border-radius: var(--radius); text-decoration: none; color: var(--text); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
a.kpi:hover { border-color: var(--border-2); color: var(--text); text-decoration: none; }
.kpi .lbl { color: var(--muted); font-size: .85rem; }
.kpi .num { font-size: 1.6rem; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; margin-top: .15rem; }
.kpi .sub { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.kpi .sub.up { color: var(--bad); }

.dash-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) 300px; gap: .75rem; align-items: stretch; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; min-width: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.panel-head h2 { margin: 0; font-size: .95rem; }
.panel-head .more { margin-left: auto; font-size: .85rem; display: inline-flex; align-items: center; gap: .25rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

.netmap { position: relative; flex: 1 1 auto; min-height: 340px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); background: #FAFAFB; }
.netmap > svg { display: block; width: 100%; height: 100%; position: absolute; inset: 0; }
.netmap .grid-line { stroke: rgba(15, 23, 42, .035); }
.netmap .ring { fill: none; stroke: rgba(15, 23, 42, .09); stroke-dasharray: 2 6; }
.netmap .edge { stroke: #C9CED6; stroke-width: 1.5; fill: none; }
.netmap .edge.busy { stroke: var(--accent-ink); stroke-width: 2; stroke-dasharray: 6 8; animation: flow 1.6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -28; } }
.netmap .node-halo { opacity: .18; }
.netmap .node-label { fill: var(--text); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: #FAFAFB; stroke-width: 4px; }
.netmap .node-sub { fill: var(--muted); font-size: 10px; paint-order: stroke; stroke: #FAFAFB; stroke-width: 3px; }
.netmap .node-text { fill: #fff; font-size: 11px; font-weight: 700; }
.netmap a { cursor: pointer; }
.netmap a:hover .node-core { stroke: var(--text); stroke-width: 2; }
.netmap-bar { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .6rem; border-radius: 6px; font: inherit; font-size: .82rem; font-weight: 500; cursor: pointer;
        background: var(--surface); color: var(--text-2); border: 1px solid var(--border-2); }
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: #fff; border-color: var(--text); }
.chip .sw { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.sw.fire { background: #C2410C; } .sw.ems { background: #1D4ED8; } .sw.law { background: #4338CA; } .sw.other { background: #57534E; }
.netmap-online { margin-left: auto; display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .6rem; border-radius: 6px; background: var(--surface); border: 1px solid var(--border-2); font-size: .82rem; font-weight: 500; }
.netmap-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 2rem; }
.netmap .off { display: none; }

.feed { list-style: none; margin: 0; padding: 0; overflow: auto; max-height: 420px; }
.feed li { display: grid; grid-template-columns: 44px 22px minmax(0, 1fr); gap: .55rem; padding: .45rem 0; align-items: start; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--muted); font-size: .8rem; padding-top: .1rem; font-variant-numeric: tabular-nums; }
.feed .ico { width: 22px; height: 22px; display: grid; place-items: center; color: var(--muted); }
.feed .ico.problem { color: var(--bad); }
.feed .ttl { font-weight: 600; }
.feed .ttl a { color: var(--text); }
.feed .d { color: var(--text-2); font-size: .85rem; }
.feed .x { color: var(--muted); font-size: .8rem; }
.feed-empty { color: var(--muted); padding: 1rem 0; }

.agencies { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: .1rem; flex: 1 1 auto; overflow: auto; max-height: 380px; }
.agencies li a { display: flex; align-items: center; gap: .65rem; padding: .45rem .35rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.agencies li a:hover { background: var(--surface-2); text-decoration: none; }
.ag-badge { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; font-weight: 600; font-size: .72rem; color: var(--text-2); background: var(--surface-3); flex: 0 0 auto; }
.ag-text { min-width: 0; flex: 1 1 auto; }
.ag-text b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-text span { font-size: .8rem; color: var(--muted); }
.ag-state { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; white-space: nowrap; color: var(--text-2); }
.ag-state.online .dot { color: var(--good); } .ag-state.quiet .dot { color: var(--amber); } .ag-state.offline .dot, .ag-state.never .dot { color: var(--red); }
.panel .add { margin-top: .7rem; justify-content: center; width: 100%; }

.attention-list { display: grid; gap: .5rem; }
.attention-item { display: flex; align-items: center; gap: .8rem; padding: .65rem .85rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }
.attention-item.bad { box-shadow: inset 3px 0 0 var(--red); }
.attention-item.warn { box-shadow: inset 3px 0 0 var(--amber); }
.attention-item.info { box-shadow: inset 3px 0 0 var(--blue); }
.attention-item .txt { flex: 1 1 auto; min-width: 0; }
.attention-item .txt b { display: block; font-weight: 600; }
.attention-item .txt span { color: var(--text-2); font-size: .85rem; }

@media (max-width: 1380px) { .dash-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .dash-main .netpanel { grid-column: 1 / -1; } }
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .kpis, .dash-main { grid-template-columns: 1fr; } .netmap { min-height: 280px; } }
@media (prefers-reduced-motion: reduce) { .netmap .edge.busy { animation: none; } }

/* -- Web CAD simulator: dispatch board -- */
.wc-header { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; margin-bottom: .25rem; }
.wc-title { display: flex; align-items: baseline; gap: .6rem; }
.wc-agency { font-size: 1.35rem; font-weight: 700; }
.wc-switch { display: flex; gap: .3rem; flex-wrap: wrap; }
.wc-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.wc-live { font-size: .82rem; color: var(--good); font-weight: 500; }
.wc-live.wc-live-bad { color: var(--bad); }
.wc-section-title { display: flex; align-items: center; gap: .45rem; font-weight: 600; font-size: .88rem; color: var(--text-2); margin: 1rem 0 .4rem; }
.wc-dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; }
.wc-dot-pending { background: var(--amber); }
.wc-dot-active { background: var(--good); }
.wc-incoming { background: var(--warn-bg); border: 1px solid #F5D9A8; border-radius: var(--radius); padding: .25rem .75rem .75rem; margin: .5rem 0; }
.wc-incoming .wc-section-title { color: var(--warn); margin-top: .5rem; }
.wc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .6rem; }
.wc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .75rem; display: grid; gap: .3rem; box-shadow: var(--shadow); }
.wc-card-top { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.wc-board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 470px); gap: 1rem; align-items: start; }
.wc-col { min-width: 0; }
.wc-queue { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 .75rem .75rem; position: sticky; top: .5rem; max-height: calc(100vh - 1rem); overflow: auto; }
.wc-table td { vertical-align: top; }
.wc-table tr.wc-selected td { background: var(--info-bg); }
.wc-empty { padding: .6rem .75rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-2); border-radius: var(--radius); font-size: .88rem; }
.wc-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.wc-chip, .wc-pill { display: inline-block; padding: .02rem .4rem; border-radius: 4px; font-size: .78rem; font-weight: 500; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; }
.wc-closed { margin-top: 1rem; }
.wc-closed summary { cursor: pointer; color: var(--text-2); font-weight: 500; }
.wc-hint { margin: .25rem 0 .5rem; }
.wc-assigning { background: var(--info-bg); color: var(--info); font-weight: 500; border-radius: 6px; padding: .35rem .55rem; margin: .25rem 0 .5rem; font-size: .85rem; }
.wc-group-title { font-size: .82rem; font-weight: 500; color: var(--muted); margin: .75rem 0 .3rem; }
.wc-unit { border: 1px solid var(--border); border-radius: 6px; padding: .4rem .5rem; margin-bottom: .35rem; display: grid; gap: .3rem; background: var(--surface); }
.wc-unit.wc-selected { border-color: var(--info); box-shadow: inset 3px 0 0 var(--info); }
.wc-unit-main { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.wc-unit-name { font-weight: 700; font-family: var(--mono); }
.wc-unit-controls { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.wc-status-select { max-width: 11rem; }
.wc-tag { font-size: .72rem; font-weight: 500; color: var(--info); border: 1px solid #C7D7FB; border-radius: 4px; padding: 0 .3rem; }
.wc-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-pop);
             transform: translateX(105%); transition: transform .18s ease; z-index: 50; overflow: auto; padding: 0 1rem 1rem; }
.wc-drawer.open { transform: none; }
.wc-drawer-head { position: sticky; top: 0; background: var(--surface); display: flex; justify-content: space-between; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--border); z-index: 1; }
.wc-manage { margin-top: 1.5rem; }
.wc-chip.tone-good, .wc-pill.tone-good { background: var(--good-bg); color: var(--good); }
.wc-chip.tone-info, .wc-pill.tone-info { background: var(--info-bg); color: var(--info); }
.wc-chip.tone-warn, .wc-pill.tone-warn { background: var(--warn-bg); color: var(--warn); }
.wc-chip.tone-bad, .wc-pill.tone-bad { background: var(--bad-bg); color: var(--bad); }
.wc-open-cell { text-align: right; width: 1%; }
@media (max-width: 960px) { .wc-board { grid-template-columns: 1fr; } .wc-queue { position: static; max-height: none; } }
@media (prefers-reduced-motion: reduce) { .wc-drawer { transition: none; } }

/* -- Web CAD tester: acting-as bar, answer strip, command line, incident cards, unit board -- */
.wc-actbar { --wc-hue: var(--accent-ink); display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding: .7rem 1rem; margin-bottom: .5rem;
             border: 1px solid var(--border); border-left: 3px solid var(--wc-hue); border-radius: var(--radius); background: var(--surface); }
.wc-swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--wc-hue); flex: 0 0 auto; }
.wc-acting { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.wc-acting-label { font-size: .82rem; color: var(--muted); }
.wc-actbar .wc-agency { color: var(--text); font-size: 1.35rem; }
.wc-switchto { display: flex; align-items: center; gap: .4rem; }
.wc-agency-pick { max-width: 18rem; }
.wc-answer { border: 1px solid #F5D9A8; background: var(--warn-bg); border-radius: var(--radius); padding: .2rem .9rem .8rem; margin: .5rem 0 .75rem; }
.wc-answer .wc-section-title { color: var(--warn); }
.wc-asks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .6rem; }
.wc-ask { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .6rem .8rem; display: grid; gap: .3rem; box-shadow: inset 3px 0 0 var(--amber); }
.wc-ask-request { box-shadow: inset 3px 0 0 var(--blue); }
.wc-ask-offer { box-shadow: inset 3px 0 0 var(--purple); }
.wc-ask-kind { font-size: .8rem; color: var(--muted); }
.wc-ask-main { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.wc-ask-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .2rem; }
.wc-waiting { margin-top: .6rem; color: var(--text-2); }
.wc-cmd { display: flex; align-items: center; gap: .5rem; margin: .5rem 0 .25rem; padding: .3rem .5rem .3rem .75rem; border: 1px solid var(--border-2); border-radius: 6px; background: var(--surface); }
.wc-cmd:focus-within { border-color: var(--accent-ink); box-shadow: 0 0 0 3px rgba(141, 198, 63, .25); }
.wc-prompt { color: var(--accent-ink); font-family: var(--mono); font-weight: 700; }
.wc-cmd input { flex: 1 1 auto; border: 0; background: transparent; font-family: var(--mono); padding: .3rem .2rem; box-shadow: none !important; }
.wc-incs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem; }
.wc-inc { position: relative; display: grid; gap: .3rem; padding: .6rem .8rem .55rem 1rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; overflow: hidden; }
.wc-inc::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--blue); }
.wc-inc.pri-bad::before { background: var(--red); } .wc-inc.pri-warn::before { background: var(--amber); }
.wc-inc:hover { border-color: var(--border-2); }
.wc-inc.wc-selected { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.wc-inc-pending { background: #FFFDF7; }
.wc-inc-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.wc-inc-num { font-family: var(--mono); }
.wc-pri { font-size: .75rem; font-weight: 600; padding: .02rem .4rem; border-radius: 4px; }
.wc-inc-age { margin-left: auto; }
.wc-timer { font-family: var(--mono); font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.wc-inc-nature { font-weight: 600; display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.wc-inc-addr { font-size: .85rem; }
.wc-inc-actions { display: flex; justify-content: flex-end; }
.wc-status-btns { gap: .25rem; }
.wc-status-btns .btn.small { min-width: 2.35rem; justify-content: center; font-family: var(--mono); padding: .18rem .35rem; font-size: .76rem; }
.wc-unit.wc-running { border-color: #C5E09B; }
.wc-runnext { color: var(--accent-ink); display: inline-flex; gap: .25rem; align-items: center; }
.wc-countdown { color: var(--accent-ink); font-family: var(--mono); }
@media (max-width: 960px) { .wc-incs, .wc-asks { grid-template-columns: 1fr; } }

/* -- Partner-unit checklist (portal + Web CAD) -- */
.checklist ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.checklist li { display: flex; align-items: baseline; gap: .4rem; font-size: .86rem; }
.ck-mark { width: 1.1rem; font-weight: 700; text-align: center; }
.ck-good .ck-mark { color: var(--good); } .ck-bad { color: var(--text); } .ck-bad .ck-mark { color: var(--bad); } .ck-neutral { color: var(--muted); }
.ck-todo { margin-top: .4rem; padding: .4rem .55rem; border-radius: 6px; background: var(--bad-bg); border: 1px solid #F5C2C2; display: grid; gap: .15rem; }

/* -- Plain mapping pages -- */
.map-summary { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .8rem; }
details.adv { margin-top: 1rem; }
details.adv > summary { font-weight: 600; color: var(--text-2); }

/* -- "Acting as" badge -- */
.acting-badge { --ag: var(--accent-ink); display: inline-flex; align-items: center; gap: .45rem; padding: .25rem .6rem; border-radius: 6px; border: 1px solid var(--border-2); background: var(--surface); box-shadow: inset 3px 0 0 var(--ag); white-space: nowrap; }
.acting-badge .ab-kind { font-size: .78rem; color: var(--muted); }
.acting-badge .ab-code { font-weight: 700; color: var(--text); }
.acting-badge .ab-name { font-size: .8rem; color: var(--text-2); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.wc-note { margin: -.2rem 0 .6rem .3rem; }
@media (max-width: 1720px) { .acting-badge .ab-name { display: none; } }
@media (max-width: 1500px) { .user-text { display: none; } }
@media (max-width: 860px) { .acting-badge .ab-kind { display: none; } }
