/* digitweb — "control room" design system.
   Dark instrument-panel sidebar, cool paper content area, one hot signal colour
   (the Digit red) used only for what matters, IBM Plex for a technical voice. */

:root {
  --ink: #0b1220;          /* sidebar */
  --ink-2: #131c2c;
  --ink-3: #1d2941;
  --ink-line: rgba(255,255,255,.08);
  --ink-text: #c6cfdd;
  --ink-muted: #7d8aa1;

  --signal: #e5322d;       /* Digit red */
  --signal-soft: #fdecec;
  --amber: #d97706;
  --amber-soft: #fff4e0;
  --green: #15803d;
  --green-soft: #e6f7ec;
  --blue: #2457c5;
  --blue-soft: #e8efff;
  --violet: #6d4fd6;
  --violet-soft: #efeaff;

  --paper: #f3f5f8;
  --paper-2: #e9edf2;
  --card: #ffffff;
  --text: #16202e;
  --text-2: #4a5568;
  --muted: #7b8794;
  --line: #e3e8ee;
  --line-2: #cfd6df;
  --line-strong: var(--line-2);
  --danger: var(--signal);
  --topbar-bg: rgba(243,245,248,.85);
  --input-bg: #ffffff;
  --row-hover: #f7f9fc;
  --primary-bg: #16202e;
  --primary-fg: #ffffff;
  --primary-hover: #000000;
  --flash-err-fg: #9f1d1a;   --flash-err-line: #f7c1c0;
  --flash-ok-line: #bde5c9;  --flash-info-line: #c3d4ff;
  --flash-warn-fg: #92400e;  --flash-warn-line: #f5d9a7;
  --btn-danger-line: #f0b7b5;
  color-scheme: light;

  --sidebar-w: 236px;
  --r: 10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(11,18,32,.05), 0 4px 16px -8px rgba(11,18,32,.12);
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* dark theme (data-theme="dark" on <html>; see the theme script in layout.html) */
:root[data-theme="dark"] {
  --ink: #080d18; --ink-2: #111a2a; --ink-3: #1a2540;
  --signal: #f0514c; --signal-soft: #3a1618;
  --amber: #f5a524; --amber-soft: #3a2a0c;
  --green: #3ccf77; --green-soft: #10301f;
  --blue: #7aa5ff; --blue-soft: #172a52;
  --violet: #ae97ff; --violet-soft: #271f4a;
  --paper: #0d1420; --paper-2: #182234; --card: #131c2c;
  --text: #e6ebf2; --text-2: #b4bfcd; --muted: #8b98ad;
  --line: #243047; --line-2: #34435e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px -8px rgba(0,0,0,.6);
  --topbar-bg: rgba(13,20,32,.85);
  --input-bg: #0f1726;
  --row-hover: #18233a;
  --primary-bg: #e6ebf2; --primary-fg: #0d1420; --primary-hover: #ffffff;
  --flash-err-fg: #ff9d99;  --flash-err-line: #5c2226;
  --flash-ok-line: #1d4a31; --flash-info-line: #26407a;
  --flash-warn-fg: #fbbf6b; --flash-warn-line: #5a4115;
  --btn-danger-line: #5c2226;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); color: var(--text); background: var(--paper); line-height: 1.45; font-feature-settings: "tnum" 1; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
h2 { font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1.2rem 0 .6rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin: .8rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.ico { width: 18px; height: 18px; flex: none; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
body.has-sidebar .shell { margin-left: var(--sidebar-w); }
.page { flex: 1; padding: 26px 32px 48px; max-width: 1600px; width: 100%; }
.footer { padding: 18px 32px; color: var(--muted); font-size: .78rem; font-family: var(--mono); }

/* ---------- sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--ink); color: var(--ink-text); display: flex; flex-direction: column; z-index: 60;
  background-image: radial-gradient(1200px 300px at -20% -10%, rgba(229,50,45,.18), transparent 60%), linear-gradient(var(--ink), var(--ink)); }
.sidebar-brand { padding: 22px 20px 18px; border-bottom: 1px solid var(--ink-line); }
.brand-mark { display: flex; flex-direction: column; color: #fff; text-decoration: none; }
.brand-word { font-weight: 700; font-size: 1.45rem; letter-spacing: -.03em; line-height: 1; }
.brand-word::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 5px; background: var(--signal); border-radius: 50%; box-shadow: 0 0 0 4px rgba(229,50,45,.18); vertical-align: 2px; }
.brand-sub { font-family: var(--mono); font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-muted); margin-top: 6px; }
.sidenav { flex: 1; overflow-y: auto; padding: 12px 12px; }
.navgroup + .navgroup { margin-top: 14px; }
.navgroup-label { font-family: var(--mono); font-size: .64rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-muted); padding: 6px 10px 6px; }
.navlink { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-text); font-weight: 500; font-size: .92rem; text-decoration: none; transition: background .15s, color .15s; }
.navlink .ico { color: var(--ink-muted); transition: color .15s; }
.navlink:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.navlink:hover .ico { color: #fff; }
.navlink.active { background: var(--ink-3); color: #fff; box-shadow: inset 3px 0 0 var(--signal); }
.navlink.active .ico { color: var(--signal); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--ink-line); }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--signal), #ff7a45); color: #fff; font-weight: 700; display: grid; place-items: center; flex: none; }
.who-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who-text b { color: #fff; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text .muted { color: var(--ink-muted); font-size: .72rem; font-family: var(--mono); }
.navlink.logout { color: var(--ink-muted); }
.nav-toggle, .scrim, .menu-btn { display: none; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 32px; background: var(--topbar-bg); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--line); }
.crumb { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.crumb .sep { margin: 0 8px; opacity: .5; }
.crumb-title { color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.clock { font-family: var(--mono); font-size: .8rem; color: var(--text-2); padding: 4px 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--card); }

/* ---------- page header ---------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pagehead h1 .muted, .pagehead h1 .count { font-family: var(--mono); font-weight: 400; font-size: 1rem; color: var(--muted); margin-left: 8px; }
.pagehead .sub { margin: 4px 0 0; color: var(--muted); }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; animation: rise .35s ease both; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid > .card:nth-child(2) { animation-delay: .05s } .grid > .card:nth-child(3) { animation-delay: .1s } .grid > .card:nth-child(4) { animation-delay: .15s }
@keyframes rise { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) { .card { animation: none } }

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 12px; position: relative; overflow: hidden; animation: rise .35s ease both; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.stat.ok::before { background: var(--green); } .stat.warn::before { background: var(--amber); } .stat.bad::before { background: var(--signal); } .stat.info::before { background: var(--blue); }
.stat .label { font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat .value { font-family: var(--mono); font-size: 1.7rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
.stat .value small { font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: 4px; }
.stat .hint { font-size: .78rem; color: var(--muted); margin-top: 2px; }
a.stat { color: inherit; text-decoration: none; transition: transform .15s, box-shadow .15s; }
a.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

/* ---------- pills / badges / dots ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; line-height: 1.6; background: var(--paper-2); color: var(--text-2); white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--signal-soft); color: var(--signal); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-grey { background: var(--paper-2); color: var(--text-2); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--line-2); }
.dot-green { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.dot-red { background: var(--signal); } .dot-amber { background: #f59e0b; } .dot-grey { background: #9ca3af; } .dot-blue { background: #3b82f6; } .dot-violet { background: #8b5cf6; }
.dot-live { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.18) } 50% { box-shadow: 0 0 0 6px rgba(34,197,94,.05) } }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--card); color: var(--text-2); font-size: .82rem; font-weight: 500; text-decoration: none; }
.pill:hover { border-color: var(--text-2); color: var(--text); text-decoration: none; }
.pill b { font-family: var(--mono); color: var(--signal); }
.pill.zero b { color: var(--green); }

/* ---------- flash ---------- */
.flash { padding: 11px 14px; border-radius: var(--r-sm); border: 1px solid; margin-bottom: 16px; font-size: .92rem; }
.flash-error { background: var(--signal-soft); border-color: var(--flash-err-line); color: var(--flash-err-fg); }
.flash-success { background: var(--green-soft); border-color: var(--flash-ok-line); color: var(--green); }
.flash-info { background: var(--blue-soft); border-color: var(--flash-info-line); color: var(--blue); }
.flash-warn { background: var(--amber-soft); border-color: var(--flash-warn-line); color: var(--flash-warn-fg); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--card); color: var(--text); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; transition: background .12s, border-color .12s, transform .08s; }
.btn:hover { background: var(--paper-2); border-color: var(--text-2); text-decoration: none; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-fg); }
.btn-accent { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn-accent:hover { background: #c4251f; border-color: #c4251f; color: #fff; }
.btn-danger { background: var(--card); border-color: var(--btn-danger-line); color: var(--signal); }
.btn-danger:hover { background: var(--signal-soft); border-color: var(--signal); color: var(--signal); }
.btn-sm { padding: 4px 9px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--paper-2); }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; font-size: .86rem; color: var(--text-2); margin-bottom: 12px; }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: 5px; font-weight: 400; color: var(--text); }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], input[type=datetime-local], input[type=search], input[type=file], select, textarea {
  font: inherit; font-size: .92rem; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--input-bg); color: var(--text); max-width: 100%; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,87,197,.15); }
input[type=checkbox], input[type=radio] { accent-color: var(--text); width: 15px; height: 15px; vertical-align: -2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 18px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-form { display: inline; }
.topbar .switched { display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 10px; background: var(--signal-soft); border: 1px solid var(--signal); border-radius: 6px; font-size: .85rem; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar input[type=text] { min-width: 260px; }
.toolbar .spacer { flex: 1; }
.toolbar select { padding: 6px 30px 6px 10px; }
.toolbar form.inline-form { display: inline-flex; align-items: center; gap: 8px; }
.toolbar form.inline-form label { margin: 0; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 18px; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table thead th { background: var(--paper); color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; position: sticky; top: 0; z-index: 1; white-space: nowrap; border-bottom: 1px solid var(--line-2); }
.table thead th[data-sort] { cursor: pointer; user-select: none; }
.table thead th[data-sort]:hover { color: var(--text); }
.table thead th[data-sort]:after { content: "↕"; margin-left: 5px; color: var(--line-2); }
.table thead th.sort-asc:after { content: "↑"; color: var(--text); }
.table thead th.sort-desc:after { content: "↓"; color: var(--text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--row-hover); }
.table tr.row-link { cursor: pointer; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .btn { visibility: hidden; }
.table tr:hover td.actions .btn, .table tr:focus-within td.actions .btn { visibility: visible; }
@media (hover: none) { .table td.actions .btn { visibility: visible; } }
.table .num { text-align: right; font-family: var(--mono); font-size: .84rem; }
.table .imei { font-family: var(--mono); font-size: .84rem; letter-spacing: .02em; }
.table-compact th, .table-compact td { padding: 6px 10px; font-size: .84rem; }
.kv { width: auto; }
.kv th { width: 200px; background: transparent; color: var(--muted); font-weight: 500; font-size: .84rem; text-transform: none; letter-spacing: 0; position: static; }
.kv td { font-weight: 500; }
tr.section > td { background: var(--paper); font-weight: 600; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); padding-top: 12px; }
tr.section.archived > td { color: var(--green); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

/* status rows: a coloured edge and a dot instead of pink backgrounds */
.table tr.level1 td:first-child, .table tr.level2 td:first-child, .table tr.level3 td:first-child, .table tr.level8 td:first-child, .table tr.level0 td:first-child { box-shadow: inset 3px 0 0 var(--edge, transparent); }
.table tr.level1 { --edge: var(--signal); }
.table tr.level2 { --edge: #f97316; }
.table tr.level3 { --edge: #f59e0b; }
.table tr.level8 { --edge: #8b5cf6; }
.table tr.level0 { --edge: #eab308; }
.table tr.level1 td { color: var(--text-2); }

/* ---------- details / overview ---------- */
details.overview { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 18px; }
details.overview > summary { list-style: none; cursor: pointer; padding: 12px 20px; font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 10px; }
details.overview > summary::-webkit-details-marker { display: none; }
details.overview > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.overview[open] > summary::before { transform: rotate(90deg); }
details.overview > .body { padding: 4px 20px 20px; border-top: 1px solid var(--line); }

/* ---------- login ---------- */
body.no-sidebar { background: var(--ink); background-image: radial-gradient(900px 500px at 80% -10%, rgba(229,50,45,.25), transparent 60%), radial-gradient(700px 400px at -10% 110%, rgba(36,87,197,.25), transparent 60%); }
body.no-sidebar .footer { color: var(--ink-muted); }
.login-wrap { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); padding: 34px 34px 28px; animation: rise .5s ease both; }
.login-brand { display: flex; flex-direction: column; margin-bottom: 22px; }
.login-brand .brand-word { color: var(--text); font-size: 2rem; }
.login-brand .brand-sub { color: var(--muted); }
.login-card h1 { font-size: 1.1rem; margin-bottom: 14px; }
.login-card .btn { margin-top: 6px; padding: 10px; }

/* ---------- error / misc ---------- */
.error-card { max-width: 520px; margin: 60px auto; text-align: center; }
.error-card h1 { font-family: var(--mono); font-size: 3.4rem; color: var(--line-2); }
.map { width: 100%; height: 520px; border: 1px solid var(--line-2); border-radius: var(--r); }
.leaflet-control-zoom a, .leaflet-control-attribution a { color: #333 !important; }
.pager { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.pager .current { font-weight: 700; padding: 3px 8px; background: var(--primary-bg); color: var(--primary-fg); border-radius: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); align-items: center; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 9px 14px; color: var(--text-2); font-weight: 500; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-color: var(--signal); }
.bulkbar { display: none; align-items: center; gap: 8px; padding: 10px 14px; background: var(--ink); color: #fff; border-radius: var(--r); margin-bottom: 12px; position: sticky; top: 58px; z-index: 5; }
.bulkbar.show { display: flex; }
.bulkbar .count { font-family: var(--mono); margin-right: 8px; }
.bulkbar .btn { background: transparent; border-color: rgba(255,255,255,.3); color: #fff; }
.bulkbar .btn:hover { background: rgba(255,255,255,.12); }
.bulkbar .btn-danger { border-color: var(--signal); color: #ff8b87; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  body.has-sidebar .shell { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; background: rgba(11,18,32,.5); z-index: 50; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); cursor: pointer; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  html { font-size: 14px; }
}
@media print {
  .sidebar, .topbar, .footer, .toolbar, .btn, .bulkbar { display: none !important; }
  body.has-sidebar .shell { margin-left: 0; }
  .card, .table-wrap { box-shadow: none; border: 0; }
  .table-wrap { overflow: visible; }
  .hscroll { display: none !important; }
  body { background: #fff; }
}

/* e-mail body popup (alert history) */
.mail-dialog { width: min(720px, calc(100vw - 32px)); max-height: 80vh; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); box-shadow: 0 20px 50px rgba(11,18,32,.25); }
.mail-dialog::backdrop { background: rgba(11,18,32,.45); }
.mail-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.mail-dialog .md-body { margin: 0; padding: 14px 16px; max-height: calc(80vh - 70px); overflow: auto; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: .9rem; }
button.badge-btn { border: 0; cursor: pointer; font-family: inherit; font-size: .74rem; }
button.badge-btn:hover { filter: brightness(.93); outline: 1px solid currentColor; }
.table.th-2line thead th { vertical-align: bottom; line-height: 1.35; }
/* portal usage bars: new portal (green) then old site (grey), scaled to the busiest day */
.usage-bar { display: flex; height: 10px; border-radius: 3px; background: var(--paper); overflow: hidden; }
.usage-bar span { display: block; height: 100%; }
.usage-go { background: var(--green); }
.usage-php { background: var(--line-2); }
.usage-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
/* portal feedback (top bar thumbs, comment + "do you like it?" dialogs) */
.fb-widget { display: inline-flex; align-items: center; gap: 6px; }
.fb-widget form { display: inline-flex; gap: 2px; }
.fb-thumb { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 2px 7px; font-size: 1rem; line-height: 1.4; cursor: pointer; filter: grayscale(1); opacity: .7; }
.fb-thumb:hover { filter: none; opacity: 1; }
.fb-thumb.fb-on-up { filter: none; opacity: 1; background: var(--green-soft); border-color: var(--green); }
.fb-thumb.fb-on-down { filter: none; opacity: 1; background: var(--signal-soft); border-color: var(--signal); }
.fb-dialog { width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; background: var(--card); color: var(--text); box-shadow: 0 20px 50px rgba(11,18,32,.25); }
.fb-dialog::backdrop { background: rgba(11,18,32,.45); }
.fb-dialog h2 { margin-top: 0; }
.fb-dialog textarea { width: 100%; box-sizing: border-box; }
.fb-choice { display: flex; gap: 10px; margin: 12px 0; }
.fb-choice label { flex: 1; margin: 0; }
.fb-choice input { position: absolute; opacity: 0; }
.fb-choice span { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; border: 2px solid var(--line); border-radius: 10px; font-size: 1.8rem; cursor: pointer; }
.fb-choice span b { font-size: .85rem; }
.fb-choice input:checked + span { border-color: var(--text); background: var(--paper); }
.fb-choice input:focus-visible + span { outline: 2px solid var(--blue); }
@media (max-width: 720px) { .fb-ask { display: none; } }
.pw-peek { display: inline-flex; align-items: center; gap: 8px; }
.pw-peek .pw-value { font-size: .95rem; padding: 1px 6px; background: var(--amber-soft); border-radius: 4px; }

/* theme toggle (top bar) */
.theme-toggle { border: 1px solid var(--line); background: var(--card); color: var(--text-2); border-radius: 6px; width: 32px; height: 28px; display: inline-grid; place-items: center; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.theme-toggle:hover { color: var(--text); border-color: var(--line-2); }
.theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }

/* Sideways scrollbar for wide tables that stays at the bottom of the screen (app.js adds it):
   the table's own horizontal scrollbar is hidden and this one drives it. */
.table-wrap.has-hscroll { scrollbar-width: none; }
.table-wrap.has-hscroll::-webkit-scrollbar { height: 0; }
.hscroll { position: sticky; bottom: 0; z-index: 20; overflow-x: auto; overflow-y: hidden; height: 16px; margin: -18px 0 18px; background: var(--paper); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r) var(--r); }
.hscroll > div { height: 1px; }
