/* GrallingsNet Workbench — styled after the UISP console: dark navigation rail, white header, light canvas, blue primary. */
:root {
  --font: "Lato", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --nav-bg: #1c2127;
  --nav-bg-2: #232a31;
  --nav-text: #a9b4c0;
  --nav-text-strong: #ffffff;
  --nav-active: rgba(0, 111, 255, 0.16);
  --primary: #006fff;
  --primary-hover: #005ad1;
  --primary-soft: #e6f0ff;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e1e5ea;
  --border-strong: #cfd5dc;
  --text: #1f2a37;
  --text-2: #4b5664;
  --muted: #7b8794;
  --ok: #1d9f61;
  --ok-soft: #e3f6ec;
  --warn: #c77700;
  --warn-soft: #fff3dc;
  --bad: #d83a3a;
  --bad-soft: #fde8e8;
  --info: #006fff;
  --info-soft: #e6f0ff;
  --neutral-soft: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.22);
  --radius: 6px;
  --nav-w: 232px;
  --header-h: 56px;
  color-scheme: light;
}

[data-theme="dark"] {
  --nav-bg: #14181c;
  --nav-bg-2: #1a1f24;
  --bg: #1b2026;
  --surface: #232a31;
  --surface-2: #283039;
  --border: #333d47;
  --border-strong: #42505d;
  --text: #e7ecf1;
  --text-2: #c2cbd4;
  --muted: #8b97a3;
  --primary-soft: rgba(0, 111, 255, 0.18);
  --ok-soft: rgba(29, 159, 97, 0.18);
  --warn-soft: rgba(199, 119, 0, 0.2);
  --bad-soft: rgba(216, 58, 58, 0.2);
  --info-soft: rgba(0, 111, 255, 0.18);
  --neutral-soft: #2d3640;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--text); }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
small, .muted { color: var(--muted); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav { background: var(--nav-bg); color: var(--nav-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.nav-brand { display: flex; align-items: center; gap: 10px; height: var(--header-h); padding: 0 18px; color: var(--nav-text-strong); font-weight: 800; letter-spacing: .01em; border-bottom: 1px solid rgba(255,255,255,.06); }
.nav-brand img { height: 28px; max-width: 150px; object-fit: contain; }
.nav-brand .logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; color: #fff; font-size: 15px; }
.nav-brand small { display: block; color: var(--nav-text); font-weight: 600; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.nav-section { padding: 14px 18px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #6c7783; }
.nav a.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 18px; color: var(--nav-text); font-weight: 600; border-left: 3px solid transparent; text-decoration: none; }
.nav a.nav-item:hover { color: var(--nav-text-strong); background: var(--nav-bg-2); }
.nav a.nav-item.active { color: var(--nav-text-strong); background: var(--nav-active); border-left-color: var(--primary); }
.nav a.nav-item .count { margin-left: auto; background: var(--primary); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.nav-foot { margin-top: auto; padding: 14px 18px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.06); }

.main { min-width: 0; display: flex; flex-direction: column; }
.header { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 20; }
.header .title { display: flex; flex-direction: column; min-width: 0; }
.header .crumbs { font-size: 12px; color: var(--muted); }
.header .crumbs a { color: var(--muted); }
.header h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 22px; max-width: 1480px; width: 100%; }

.timer-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-chip.running { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.timer-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.timer-chip.running .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.user-menu { position: relative; }
.user-menu > button { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; color: var(--text); font: inherit; padding: 4px; border-radius: 6px; }
.user-menu > button:hover { background: var(--surface-2); }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 4px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row .spacer { flex: 1; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

.stat { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.stat .value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.accent { border-top: 3px solid var(--primary); }
.stat.ok { border-top: 3px solid var(--ok); }
.stat.warn { border-top: 3px solid var(--warn); }
.stat.bad { border-top: 3px solid var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 13px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg.i { width: 16px; height: 16px; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text-2); padding: 0 12px; height: 32px; font: 600 13px var(--font); cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary-soft); color: var(--primary); }

/* ---------- forms ---------- */
label.field { display: grid; gap: 5px; font-size: 12px; font-weight: 700; color: var(--text-2); }
label.field .req { color: var(--bad); }
label.field .help { font-weight: 400; color: var(--muted); }
.input, input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], input[type=search], select, textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); color: var(--text); font: 14px var(--font);
}
textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.invalid input, .invalid select, .invalid textarea { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: 12px; font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.search-input { position: relative; }
.search-input svg { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.search-input input { padding-left: 34px; min-width: 240px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 800; border-top: 2px solid var(--border-strong); background: var(--surface-2); }
.table td.sub { padding-left: 28px; }
.table input, .table select { height: 32px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty svg.i { width: 36px; height: 36px; margin-bottom: 8px; stroke-width: 1.4; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--neutral-soft); color: var(--text-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.plain::before { display: none; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; }
.kv dt { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.kv dd { margin: 0; word-break: break-word; }
.pre { white-space: pre-wrap; }
.notice { padding: 10px 14px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 10px; align-items: flex-start; }
.notice.bad { border-color: var(--bad); background: var(--bad-soft); }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice.info { border-color: var(--primary); background: var(--info-soft); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-2); font-weight: 700; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }

.timeline { display: grid; gap: 12px; }
.timeline .item { display: grid; grid-template-columns: 24px 1fr; gap: 10px; }
.timeline .meta { font-size: 12px; color: var(--muted); }

/* ---------- kanban ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; align-items: start; }
.lane { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-height: 200px; display: flex; flex-direction: column; }
.lane-head { padding: 10px 12px; font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.lane-body { padding: 10px; display: grid; gap: 8px; min-height: 120px; align-content: start; flex: 1; }
.lane.drag-over { border-color: var(--primary); background: var(--primary-soft); }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 10px; cursor: grab; box-shadow: var(--shadow); display: grid; gap: 6px; }
.task-card:hover { border-color: var(--primary); }
.task-card.dragging { opacity: .5; }
.task-card .t { font-weight: 700; }
.task-card .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.prio-urgent { border-left: 3px solid var(--bad); }
.prio-high { border-left: 3px solid var(--warn); }

.progress { height: 6px; background: var(--neutral-soft); border-radius: 3px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }

/* ---------- photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo { position: relative; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.photo img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; cursor: zoom-in; }
.photo .cap { padding: 6px 8px; font-size: 12px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.photo .cap span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 3px; border: 1px solid var(--border); display: block; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: grid; place-items: center; z-index: 200; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 90vh; }
.lightbox .cap { color: #fff; text-align: center; margin-top: 10px; }

.fiber { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); vertical-align: -2px; margin-right: 5px; }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 25, .55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-head h2 { flex: 1; font-size: 16px; }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 8px 8px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 300; }
.toast { background: #1f2a37; color: #fff; padding: 11px 16px; border-radius: 6px; box-shadow: var(--shadow-lg); max-width: 380px; border-left: 4px solid var(--primary); animation: slide .2s ease-out; }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--nav-bg); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; background-image: radial-gradient(circle at 20% 0%, rgba(0,111,255,.35), transparent 50%); }
.auth-side h1 { color: #fff; font-size: 34px; line-height: 1.15; margin-top: 18px; }
.auth-side p { color: var(--nav-text); margin-top: 12px; max-width: 420px; line-height: 1.6; }
.auth-side ul { color: var(--nav-text); padding-left: 18px; line-height: 1.9; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form .box { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.auth-form h2 { font-size: 22px; }

/* ---------- form builder ---------- */
.fb-field { border: 1px solid var(--border); border-radius: 4px; background: var(--surface); padding: 12px; display: grid; gap: 10px; }
.fb-field.sel { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.fb-field .fb-head { display: flex; align-items: center; gap: 8px; }
.fb-field .fb-head strong { flex: 1; }
.fb-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fb-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }

/* ---------- print (invoices, reports) ---------- */
.doc { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 40px; border: 1px solid var(--border); }
.doc table { width: 100%; border-collapse: collapse; }
.doc th { text-align: left; border-bottom: 2px solid #111; padding: 8px 6px; font-size: 12px; text-transform: uppercase; }
.doc td { border-bottom: 1px solid #ddd; padding: 8px 6px; }
.doc .num { text-align: right; }
.doc .totals td { border: 0; }
.doc h1 { color: #111; font-size: 28px; }

@media print {
  .nav, .header, .no-print, #toasts { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .doc { border: 0; padding: 0; }
  .card { box-shadow: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; left: 0; top: 0; bottom: 0; width: var(--nav-w); transform: translateX(-100%); transition: transform .2s; }
  .nav.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px; }
  .header { padding: 0 12px; }
  .grid.cols-2, .grid.cols-3, .form-grid, .fb-grid { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .hide-sm { display: none !important; }
  .search-input input { min-width: 0; }
  .board { grid-template-columns: repeat(4, 82vw); }
}
@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 19px; }
}

/* ---------- v2: alerts bell, register ---------- */
.bell-count { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }
.bell-count[hidden], .nav .count[hidden] { display: none; }
.big-money { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.eod-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.eod-line.total { border-bottom: 0; border-top: 2px solid var(--border-strong); font-weight: 800; font-size: 16px; }

[hidden] { display: none !important; }

/* ---------- POS receipts (80 mm / 58 mm thermal or full page) ---------- */
.pos-doc { max-width: none; width: fit-content; padding: 18px; }
.pos { width: 72mm; font: 12px/1.35 "Menlo", "Consolas", "Courier New", monospace; color: #000; }
.pos-center { text-align: center; }
.pos-company { font-size: 15px; }
.pos-logo { max-height: 48px; max-width: 70%; margin-bottom: 4px; }
.pos-row { display: flex; justify-content: space-between; gap: 8px; }
.pos-row span:last-child { text-align: right; white-space: nowrap; }
.pos-strong { font-weight: 800; font-size: 13px; }
.pos-rule { border-top: 1px dashed #000; margin: 6px 0; }
@media print {
  .pos-doc { padding: 0; margin: 0; }
}

/* ---------------- network (NOC) ---------------- */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; vertical-align: middle; }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.down { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: pulse-down 1.6s infinite; }
.dot.unknown { background: var(--border-strong); }
@keyframes pulse-down { 50% { box-shadow: 0 0 0 6px var(--bad-soft); } }
.stat .value small { font-size: 0.55em; color: var(--muted); font-weight: 600; }
.site-card { border-top: 3px solid var(--ok); transition: box-shadow .15s; }
.site-card.warn { border-top-color: var(--warn); }
.site-card.bad { border-top-color: var(--bad); }
.site-card:hover { box-shadow: var(--shadow-lg); }
.site-code { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 4px; background: var(--primary); color: #fff; font-size: 12px; margin-right: 8px; padding: 0 4px; }
.mini-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
.map-wrap { position: relative; display: grid; grid-template-columns: 1fr 300px; gap: 12px; height: calc(100vh - 190px); min-height: 480px; }
.net-map { border-radius: 6px; border: 1px solid var(--border); min-height: 420px; z-index: 0; }
.map-panel { overflow: auto; margin: 0; }
.map-panel .check { font-size: 13px; }
.legend { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend.round { width: 10px; height: 10px; border-radius: 50%; }
.site-pin span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; font: 800 13px var(--font); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.map-pop { font: 13px var(--font); min-width: 160px; }
.map-pop div { margin-top: 3px; }
.map-incident { display: block; font-size: 13px; padding: 3px 0; color: var(--text); }
@media (max-width: 900px) { .map-wrap { grid-template-columns: 1fr; height: auto; } .net-map { height: 65vh; } }
.chat-layout { display: grid; grid-template-columns: 260px 1fr; gap: 12px; height: calc(100vh - 200px); min-height: 460px; }
.chat-list { overflow: auto; margin: 0; }
.chat-item { display: flex; flex-direction: column; padding: 9px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.chat-item:hover { background: var(--surface-2); text-decoration: none; }
.chat-item.on { background: var(--primary-soft); }
.chat-item span { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { display: flex; flex-direction: column; margin: 0; overflow: hidden; }
.chat-scroll { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-input textarea { flex: 1; resize: vertical; min-height: 44px; }
.chat-empty { margin: auto; max-width: 520px; text-align: center; }
.chat-empty > .i { width: 34px; height: 34px; color: var(--primary); }
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.user { align-self: flex-end; }
.msg.user .msg-body { background: var(--primary); color: #fff; border-radius: 12px 12px 2px 12px; }
.msg.assistant .msg-body, .msg.action .msg-body { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px 12px 12px 2px; }
.msg.action .msg-body { border-color: var(--warn); background: var(--warn-soft); }
.msg-body { padding: 10px 14px; line-height: 1.5; overflow-wrap: anywhere; }
.msg-body p { margin: 0 0 6px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { margin: 4px 0 8px 18px; padding: 0; }
.msg-body code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 3px; font-size: .92em; }
.msg-tools { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 4px; align-items: center; }
.msg-tools .i { width: 13px; height: 13px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
@media (max-width: 800px) { .chat-layout { grid-template-columns: 1fr; height: auto; } .chat-list { max-height: 160px; } .chat-main { height: 70vh; } }
[data-theme=dark] .leaflet-container { background: #1c2127; }

/* ---------------- topology ---------------- */
.topo-view { position: relative; height: calc(100vh - 230px); min-height: 460px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px;
  background-color: var(--surface-2); background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 22px 22px; cursor: grab; touch-action: none; user-select: none; }
.topo-view:active { cursor: grabbing; }
.topo-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.topo-edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.topo-edges path { fill: none; stroke: var(--border-strong); stroke-width: 1.6; }
.topo-edges path.down { stroke: var(--bad); stroke-dasharray: 5 4; }
.topo-edges path.degraded { stroke: var(--warn); }
.topo-node { position: absolute; box-sizing: border-box; width: 228px; display: flex; align-items: center; gap: 8px; padding: 6px 30px 6px 8px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow); cursor: pointer; }
.topo-node:hover { border-color: var(--primary); }
.topo-node.up { border-left-color: var(--ok); }
.topo-node.down { border-left-color: var(--bad); background: var(--bad-soft); }
.topo-node.degraded { border-left-color: var(--warn); }
.topo-node.match { outline: 3px solid var(--primary); outline-offset: 2px; }
.topo-node.internet, .topo-node.group { background: var(--surface-2); }
.topo-node.site { border-width: 1px 1px 1px 5px; }
.topo-node > .dot { position: absolute; right: 9px; top: 9px; }
.topo-ic { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.topo-ic .i { width: 16px; height: 16px; }
.topo-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.topo-text strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-text small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-text .site-code { min-width: 18px; height: 18px; font-size: 11px; margin-right: 5px; }
.topo-bar { display: block; height: 4px; margin-top: 4px; border-radius: 2px; background: var(--bad-soft); overflow: hidden; }
.topo-bar span { display: block; height: 100%; background: var(--ok); }
.topo-wans { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 3px; font-size: 11px; color: var(--text-2); }
.topo-wans .dot { width: 7px; height: 7px; margin-right: 3px; box-shadow: none; }
.topo-link { color: var(--primary) !important; }
.topo-fold { position: absolute; right: -12px; top: 50%; transform: translateY(-50%); min-width: 24px; height: 22px; padding: 0 5px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 700 11px var(--font); cursor: pointer; z-index: 1; }
.topo-fold:hover { border-color: var(--primary); color: var(--primary); }
