/* Nebula Ops — shares the Nebula PC Attendance Hub theme (tokens, fonts, components) */
:root {
  --purple: #9b5cff; --blue: #4fa9ff; --pink: #ff5cc8; --cyan: #5cf0ff; --ink: #050510;
  --bg: #07071a; --panel: #10102a; --panel-2: #16163a; --line: #26264d; --line-2: #34346a;
  --text: #ecebff; --muted: #a3a1c9; --faint: #6f6d96;
  --field: #0b0b22; --bar: rgba(7, 7, 26, .86); --tint: rgba(255,255,255,.02); --toast: #1d1d45;
  --backdrop: rgba(2,2,12,.7); --skeleton: #1f1f48; --glow-a: rgba(155, 92, 255, .18); --glow-b: rgba(79, 169, 255, .12);
  --shadow: rgba(0,0,0,.5); --net: var(--cyan);
  --ok: #3ee39b; --warn: #ffc65c; --bad: #ff6b81;
  --radius: clamp(12px, 3.5vw, 16px); --radius-sm: clamp(8px, 2.4vw, 10px);
  /* Fluid sizing: scales smoothly between a 320px phone and a desktop */
  --gutter: clamp(12px, 4vw, 24px);          /* page side padding */
  --pad: clamp(14px, 4vw, 20px);             /* card padding */
  --gap: clamp(8px, 2.5vw, 14px);            /* space between items */
  --fs-xs: clamp(.7rem, .66rem + .2vw, .78rem);
  --fs-sm: clamp(.8rem, .76rem + .2vw, .88rem);
  --fs-body: clamp(.94rem, .9rem + .2vw, 1rem);
  --fs-h: clamp(1rem, .94rem + .35vw, 1.15rem);
  --fs-time: clamp(2rem, 1.3rem + 3.6vw, 2.8rem);
  --fs-elapsed: clamp(1.5rem, 1.05rem + 2.3vw, 2rem);
  --fs-stat: clamp(.95rem, .78rem + .9vw, 1.3rem);
  --fs-kpi: clamp(1.4rem, 1.1rem + 1.4vw, 1.9rem);
  --control-h: clamp(44px, 11.5vw, 48px);    /* inputs & buttons; 44px+ for touch */
  --clock-h: clamp(84px, 24vw, 104px);
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
/* Light theme — same layout, light surfaces, darker accents so text stays readable */
:root[data-theme="light"] {
  --purple: #7c3aed; --blue: #2563eb; --pink: #c026d3; --cyan: #0891b2;
  --bg: #f4f3fa; --panel: #ffffff; --panel-2: #fcfbff; --line: #e5e2f0; --line-2: #d4d0e6;
  --text: #17152b; --muted: #57546f; --faint: #85829f;
  --ok: #0f8a57; --warn: #a15c00; --bad: #d02c4a;
  --field: #ffffff; --bar: rgba(255, 255, 255, .88); --tint: rgba(23, 21, 43, .025); --toast: #ffffff;
  --backdrop: rgba(23, 21, 43, .45); --skeleton: #ebe8f6; --glow-a: rgba(124, 58, 237, .10); --glow-b: rgba(37, 99, 235, .08);
  --shadow: rgba(23, 21, 43, .18); --net: #0e7490;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg); font-size: var(--fs-body); line-height: 1.45;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  background-image: radial-gradient(1200px 600px at 85% -10%, var(--glow-a), transparent 60%),
                    radial-gradient(900px 500px at -10% 10%, var(--glow-b), transparent 60%);
  background-attachment: fixed; min-height: 100vh; -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono, .time { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--gap); padding: clamp(8px, 2.4vw, 12px) var(--gutter);
  padding-top: max(clamp(8px, 2.4vw, 12px), env(safe-area-inset-top));
  background: var(--bar); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: clamp(6px, 2vw, 10px); font-weight: 700; font-size: var(--fs-h); letter-spacing: .01em; text-decoration: none; color: var(--text); min-width: 0; white-space: nowrap; }
.brand .mark { flex: none; width: clamp(26px, 7vw, 30px); height: clamp(26px, 7vw, 30px); border-radius: 8px; background: linear-gradient(135deg, var(--purple), var(--blue)); display: grid; place-items: center; font-size: 14px; color: #fff; box-shadow: 0 0 18px rgba(155,92,255,.5); }
.brand small { font-weight: 500; font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.brand b span { color: var(--purple); }
.topbar .spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: clamp(6px, 1.6vw, 10px); flex: none; }
.topbar .btn.sm { padding-inline: clamp(9px, 2.6vw, 12px); }
.wrap { max-width: 1440px; margin: 0 auto; padding: var(--gutter); }
.narrow { max-width: 560px; margin: 0 auto; }

.card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); min-width: 0; }
.card + .card, .stack > * + * { margin-top: var(--gap); }
:is(.admin-grid, .grid2, .grid3) > .card { margin-top: 0; }
.card h2, .card h3 { margin: 0 0 10px; font-size: var(--fs-h); letter-spacing: .01em; }
.row > h2, .row > h3 { margin: 0; }
.card > .row.between:first-child:has(> h2, > h3) { margin-bottom: 12px; }
/* No trailing margin at the bottom of cards, pop-ups and alerts */
.card p:last-child, .d-body p:last-child, .card > :last-child, .d-body > :last-child { margin-bottom: 0; }
/* Empty message slots take no space */
[id$=Msg]:empty, .cmsg:empty { display: none; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-sm); }
.row { display: flex; gap: clamp(6px, 2vw, 10px); align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(6px, 2vw, 10px); }
.grid2 > *, .grid3 > *, .filters > * { min-width: 0; }
:is(.grid2, .grid3) > label.f { margin-bottom: 0; }
:is(.grid2, .grid3):has(> label.f) { row-gap: 12px; margin-bottom: 12px; }
input, select, textarea { min-width: 0; max-width: 100%; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--panel-2);
  color: var(--text); padding: 10px clamp(12px, 3.5vw, 16px); border-radius: var(--radius-sm); font-weight: 600; font-size: var(--fs-body); cursor: pointer; text-decoration: none; min-height: var(--control-h); white-space: nowrap; }
.btn:hover { border-color: var(--purple); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--purple), #7b5cff 50%, var(--blue)); border: 0; color: #fff; }
.btn.danger { border-color: rgba(255,107,129,.5); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: clamp(36px, 9.5vw, 38px); padding: 6px clamp(10px, 3vw, 12px); font-size: var(--fs-sm); }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font-weight: 600; }

.clock-btn { width: 100%; min-height: var(--clock-h); border-radius: clamp(16px, 5vw, 22px); border: 0; font-size: clamp(1.25rem, 1rem + 1.3vw, 1.55rem); font-weight: 700; letter-spacing: .02em; cursor: pointer; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: transform .08s ease, filter .2s; }
.clock-btn small { font-size: var(--fs-sm); font-weight: 500; opacity: .85; }
.clock-btn:active:not(:disabled) { transform: scale(.985); }
.clock-btn.start { background: linear-gradient(135deg, #18b47a, #1fcf9a 60%, #29d7c8); box-shadow: 0 10px 40px rgba(62,227,155,.25); }
.clock-btn.end { background: linear-gradient(135deg, #ff5c7a, var(--pink)); box-shadow: 0 10px 40px rgba(255,92,200,.25); }
.clock-btn:disabled { filter: saturate(.4) brightness(.8); cursor: progress; }

/* Status */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px clamp(8px, 2.4vw, 10px); border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; border: 1px solid var(--line-2); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.in { color: var(--ok); border-color: rgba(62,227,155,.4); background: rgba(62,227,155,.08); }
.pill.in .dot { box-shadow: 0 0 10px var(--ok); animation: pulse 1.6s infinite; }
.pill.out { color: var(--muted); }
.pill.warn { color: var(--warn); border-color: rgba(255,198,92,.4); background: rgba(255,198,92,.08); }
.pill.bad { color: var(--bad); border-color: rgba(255,107,129,.4); background: rgba(255,107,129,.08); }
.pill.ok { color: var(--ok); border-color: rgba(62,227,155,.4); }
.pill.ok.solid { background: rgba(62,227,155,.14); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
:root[data-theme="light"] .pill.ok.solid { background: rgba(15,138,87,.12); }
.pill.demo { color: var(--pink); border-color: rgba(255,92,200,.5); background: rgba(255,92,200,.08); }
@keyframes pulse { 50% { opacity: .35; } }

.big-time { font-family: var(--mono); font-size: var(--fs-time); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.big-time .ampm { font-size: .5em; margin-left: .3em; letter-spacing: 0; opacity: .8; }
.elapsed { font-family: var(--mono); font-size: var(--fs-elapsed); font-weight: 600; color: var(--ok); }
.stat { background: var(--tint); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: clamp(8px, 2.4vw, 12px); min-width: 0; }
.stat .k { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-family: var(--mono); font-size: var(--fs-stat); font-weight: 600; margin-top: 2px; white-space: nowrap; }
.stat.net .v { color: var(--net); }

/* Alerts & toasts */
.alert { border-radius: var(--radius-sm); padding: clamp(10px, 3vw, 14px); font-size: var(--fs-body); border: 1px solid var(--line-2); background: var(--panel-2); }
.alert.error { border-color: rgba(255,107,129,.5); background: rgba(255,107,129,.08); }
.alert.warn { border-color: rgba(255,198,92,.5); background: rgba(255,198,92,.07); }
.alert.ok { border-color: rgba(62,227,155,.5); background: rgba(62,227,155,.07); }
.alert.info { border-color: rgba(79,169,255,.45); background: rgba(79,169,255,.07); }
.alert b { display: block; margin-bottom: 2px; }
.toast-host { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 440px); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--toast); color: var(--text); border: 1px solid var(--line-2); box-shadow: 0 10px 30px var(--shadow); animation: rise .2s ease; }
.toast.ok { border-color: rgba(62,227,155,.6); }
.toast.error { border-color: rgba(255,107,129,.6); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* Lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 4px; }
.list > li:last-child { padding-bottom: 0; }
.shift-line { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: clamp(.86rem, .82rem + .25vw, .95rem); }
.day { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: clamp(10px, 3vw, 14px); background: var(--tint); }
.day + .day { margin-top: 10px; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 8px; font-family: var(--mono); font-size: var(--fs-sm); }
.day-totals span { color: var(--muted); font-family: var(--font); font-size: var(--fs-xs); display: block; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: clamp(.84rem, .8rem + .25vw, .92rem); }
th, td { padding: clamp(8px, 2.4vw, 10px) clamp(8px, 2.6vw, 12px); text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; background: var(--tint); white-space: nowrap; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.sub td { background: var(--tint); font-size: .88rem; }

/* Forms */
label.f { display: block; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 12px; min-width: 0; }
label.f > span { display: block; margin-bottom: 5px; }
input:not([type]), input[type=text], input[type=email], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  display: block; width: 100%; min-width: 0; background: var(--field); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 0 12px; height: var(--control-h); line-height: normal; color: var(--text);
  font-size: 16px; /* 16px stops iOS zooming in when a field is tapped */ }
textarea { height: auto; padding: 11px 12px; }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; background: transparent; }
/* iOS Safari draws date/time fields with their own size and centred text; make them behave like the other fields */
input[type=date], input[type=datetime-local] { -webkit-appearance: none; appearance: none; text-align: left;
  /* Safari top-aligns date text inside a fixed height, so size the box from padding instead:
     text line (1.25em) + equal top/bottom padding + 2px border = exactly --control-h, text centred */
  height: var(--control-h); min-height: 0; line-height: 1.25; padding-block: calc((var(--control-h) - 1.25em - 2px) / 2); }
input[type=date]::-webkit-date-and-time-value, input[type=datetime-local]::-webkit-date-and-time-value {
  text-align: left; margin: 0; padding: 0; line-height: 1.25; min-height: 1.25em; height: 1.25em; }
input[type=date]::-webkit-datetime-edit, input[type=datetime-local]::-webkit-datetime-edit { padding: 0; }
select { -webkit-appearance: none; appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a3a1c9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .clock-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
textarea { min-height: 84px; resize: vertical; }
.code-input { font-family: var(--mono); font-size: clamp(1.4rem, 1rem + 2.4vw, 1.8rem) !important; letter-spacing: .4em; text-align: center; height: calc(var(--control-h) + 10px) !important;
  padding-left: calc(12px + .4em) !important; /* balances the trailing letter-space so digits sit centred */ }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: var(--fs-body); cursor: pointer; }
.check input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--purple); }

/* Tabs */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, minmax(0, 186px)); justify-content: center;
  background: var(--bar); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { background: none; border: 0; color: var(--muted); padding: clamp(10px, 3vw, 13px) 4px clamp(12px, 3.4vw, 15px); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; }
.tabbar button[aria-selected=true] { color: var(--text); box-shadow: inset 0 2px 0 var(--purple); }
.has-tabbar { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
/* Admin section tabs: one swipeable row on phones, with a fade hinting there's more to the right */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; scroll-snap-align: start; background: transparent; border: 1px solid transparent; color: var(--muted); padding: 8px clamp(10px, 3vw, 14px); border-radius: 999px; font-weight: 600; font-size: var(--fs-body); cursor: pointer; white-space: nowrap; min-height: clamp(36px, 9.5vw, 40px); }
.tabs button[aria-selected=true] { color: var(--text); background: var(--panel-2); border-color: var(--line-2); }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--pink); color: #fff; font-size: var(--fs-xs); text-align: center; margin-left: 4px; }

/* Modal */
dialog { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 32px); }
dialog[open] { display: flex; flex-direction: column; }
dialog:focus { outline: none; }
.d-body form > label.f:last-of-type { margin-bottom: 0; }
.d-body [id$=Msg]:not(:empty) { margin-top: 12px; }
.sheet-ok p { margin: 8px 0 0; }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
dialog .d-head { padding: var(--pad); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .d-head h3 { margin: 0; }
dialog .d-body { padding: var(--pad); overflow-y: auto; min-height: 0; }
dialog .d-foot { padding: 12px var(--pad) max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* States */
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--skeleton), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 18px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-top-color: transparent; opacity: .85; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Success sheet */
.sheet-ok { text-align: center; }
.sheet-ok .tick { width: 64px; height: 64px; border-radius: 50%; margin: 6px auto 10px; display: grid; place-items: center; font-size: 30px; background: rgba(62,227,155,.12); color: var(--ok); border: 1px solid rgba(62,227,155,.5); }

/* Login */
.login { min-height: calc(100dvh - 70px); display: grid; justify-items: center; align-items: start; padding: clamp(24px, 9vh, 96px) var(--gutter) 24px; }
.login .card { width: 100%; max-width: 420px; padding: clamp(20px, 6vw, 28px); }
.login h1 { font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.65rem); margin: 0 0 4px; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.kpi { padding: var(--pad); display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.kpi .v { font-family: var(--mono); font-size: var(--fs-kpi); font-weight: 600; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: var(--gap); align-items: end; }
.filters label.f { margin: 0; }
/* Quick-range buttons always get their own full-width row, side by side */
.filters .quick { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: clamp(6px, 2vw, 10px); }
.toolbar { gap: clamp(6px, 2vw, 10px); }
#map { isolation: isolate; overflow: hidden; clip-path: inset(0 round var(--radius-sm)); height: clamp(260px, 55vw, 400px); border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--field); }
.leaflet-container { font-family: var(--font); }
pre.json { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .78rem; background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 6px 0 0; max-height: 220px; overflow: auto; }
.diff { font-family: var(--mono); font-size: .82rem; }
.diff del { color: var(--bad); text-decoration: line-through; }
.diff ins { color: var(--ok); text-decoration: none; }

@media (max-width: 860px) {
  .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Card toolbars: buttons share the row evenly instead of wrapping raggedly */
  .filters .quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { width: 100%; }
  .toolbar > .btn, dialog .d-foot > .btn { flex: 1 1 auto; }
  .tabs { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; max-height: 92dvh; }
}
/* Admin tables become stacked cards on phones (labels come from data-label) */
.show-sm { display: none !important; }
@media (max-width: 640px) {
  .show-sm { display: inline-flex !important; }
  .table-wrap:has(.rtable) { border: 0; overflow: visible; }
  .rtable thead { display: none; }
  .rtable, .rtable tbody { display: block; }
  .rtable tr { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 10px; align-items: center;
    padding: clamp(10px, 3vw, 14px); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--tint); }
  .rtable tr + tr { margin-top: 10px; }
  .rtable td { display: block; grid-column: 1 / -1; padding: 0; border: 0; text-align: left; white-space: normal !important; min-width: 0; }
  .rtable td:empty { display: none; }
  .rtable td.c3 { grid-column: span 2; }
  .rtable td.half { grid-column: span 3; }
  .rtable td.rest { grid-column: span 4; }
  .rtable td.half, .rtable td.rest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .rtable td.end { text-align: right; justify-content: flex-end; }
  .rtable td.lead { order: -2; font-weight: 600; padding-right: 40px; }
  .rtable td.sub { order: -1; margin-top: -6px; color: var(--muted); }
  .rtable td.cb { position: absolute; top: clamp(10px, 3vw, 14px); right: clamp(10px, 3vw, 14px); }
  .rtable td.cb input { width: 22px; height: 22px; accent-color: var(--purple); }
  .rtable td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-family: var(--font); font-size: var(--fs-xs);
    font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
  .rtable tr.total { background: transparent; border-style: dashed; }
}
@media (max-width: 400px) {
  .brand small { display: none; }
}
@media (max-width: 340px) {
  .filters { grid-template-columns: 1fr; }
  .day-totals { grid-template-columns: 1fr 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Timesheets grouped by day */
.day-group + .day-group { margin-top: clamp(16px, 4vw, 22px); }
.day-group-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; margin-bottom: 8px; }
.day-group-head h4 { margin: 0; font-size: var(--fs-h); display: inline-flex; align-items: center; gap: 8px; }
.day-group-head input, .rtable td.cb input, .sel { width: 18px; height: 18px; accent-color: var(--purple); flex: none; }
.day-sum { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); }
.day-sum b { color: var(--text); font-weight: 600; }
.period-total { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px;
  margin-top: clamp(16px, 4vw, 22px); padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); }

@media (min-width: 641px) {
  .day-group table { table-layout: fixed; }
  .day-group th:nth-child(1) { width: 44px; }
  .day-group th:nth-child(2) { width: 20%; }
  .day-group th:nth-child(4), .day-group th:nth-child(5), .day-group th:nth-child(6) { width: 92px; }
  .day-group th:nth-child(7) { width: 150px; }
  .day-group th:nth-child(8) { width: 214px; }
}

td.end .btn + .btn { margin-left: 6px; }
@media (max-width: 640px) {
  .day-group .rtable td.half:not(.end) { grid-column: span 2; }
  .day-group .rtable td.half.end { grid-column: span 4; }
  td.end .btn + .btn { margin-left: 0; }
}

/* Break options in the shift pop-up */
.break-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px 12px; margin: 0 0 12px; min-width: 0; }
.break-box legend { padding: 0 6px; font-size: var(--fs-sm); color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg label { cursor: pointer; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px;
  font-weight: 600; font-size: var(--fs-sm); background: var(--field); }
.seg label input:checked + span { border-color: var(--purple); background: color-mix(in srgb, var(--purple) 16%, transparent); color: var(--text); }
.seg label input:focus-visible + span { outline: 2px solid var(--purple); outline-offset: 2px; }
.seg-custom { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
.seg-custom input { width: 84px !important; height: 38px !important; }

/* Light/dark toggle */
.theme-btn { width: clamp(36px, 9.5vw, 38px); padding: 0 !important; }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .i-sun { display: none; }
:root[data-theme="light"] .theme-btn .i-sun { display: block; }
:root[data-theme="light"] .theme-btn .i-moon { display: none; }
:root[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(23, 21, 43, .04), 0 4px 16px rgba(23, 21, 43, .04); }
:root[data-theme="light"] .brand .mark { box-shadow: 0 0 12px rgba(124, 58, 237, .3); }
:root[data-theme="light"] .clock-btn.start { box-shadow: 0 10px 30px rgba(15, 138, 87, .22); }
:root[data-theme="light"] .clock-btn.end { box-shadow: 0 10px 30px rgba(208, 44, 74, .2); }
:root[data-theme="light"] .pill.in .dot { box-shadow: none; }
/* Very small phones (≈320px): tighten the header so brand, toggle and buttons all fit */
@media (max-width: 360px) {
  .topbar { gap: 6px; }
  .top-actions { gap: 4px; }
  .topbar .btn.sm { font-size: .78rem; padding-inline: 8px; min-height: 34px; }
  .theme-btn { width: 32px; }
  .brand { gap: 6px; font-size: .95rem; flex: none; }
  .brand .mark { width: 24px; height: 24px; font-size: 12px; }
}

/* Reminders */
input[type=time] { display: block; width: 100%; min-width: 0; background: var(--field); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 0 12px; height: var(--control-h); color: var(--text); font-size: 16px; -webkit-appearance: none; appearance: none; text-align: left; }
.rem-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--gap); }
.rem-kpis > .card { margin-top: 0; }
.kpi .v.sm { font-size: var(--fs-stat); line-height: 1.25; }
.kpi .v.word { font-family: var(--font); letter-spacing: -.01em; }
.rem-health { margin-top: var(--gap); }
.rem-list > .card, #remHistory { margin-top: 14px; }
.rem-list-head { margin-top: clamp(16px, 4vw, 22px); }
.rem-list-head h3 { margin: 0; }
.rem-list > .card:first-child { margin-top: 10px; }
.rem-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--gap); }
.rem-title { min-width: 0; }
.rem-title h3 { margin: 0 0 4px; }
.rem-actions { margin-top: 14px; flex-wrap: wrap; }
.rem-edit { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.rem-edit > summary, .excl > summary, .runs > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); padding: 4px 0; }
.rem-edit[open] > summary { margin-bottom: 12px; }
.rem-edit textarea { font-family: var(--font); line-height: 1.5; resize: vertical; min-height: 180px; }
fieldset.plain { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
fieldset.plain legend { padding: 0; margin-bottom: 6px; font-size: var(--fs-sm); color: var(--muted); }
fieldset.plain .seg label span { min-width: 50px; justify-content: center; }
.excl { margin: -2px 0 12px; }
.excl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 8px 14px; padding: 10px 0 2px; max-height: 220px; overflow: auto; }
.ph { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 8px; }
.chip { font-family: var(--mono); font-size: var(--fs-xs); background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); border-radius: 999px; padding: 5px 10px; cursor: pointer; min-height: 30px; }
.chip:hover { border-color: var(--purple); }
.switch { flex: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: var(--fs-sm); min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 48px; height: 28px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .18s; flex: none; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px var(--shadow); transition: transform .18s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track .thumb { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--purple); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .6; }
.switch-label { min-width: 2.2em; color: var(--muted); }
.switch input:checked ~ .switch-label { color: var(--ok); }
.rem-counts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.rem-counts > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--tint); }
.rem-counts b { font-size: var(--fs-stat); }
.runs { margin-top: 12px; }
.runs .list { margin-top: 6px; }
.mail-meta { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--tint); word-break: break-word; }
.mail-meta .muted { display: inline-block; min-width: 4.2em; }
.mail-frame { width: 100%; height: min(60dvh, 560px); border: 1px solid var(--line); border-radius: var(--radius-sm); background: #0b0b18; display: block; }
.mail-text { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .82rem; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin: 0; max-height: min(60dvh, 560px); overflow: auto; }
@media (max-width: 1000px) { .rem-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .rem-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rem-kpis > .card:last-child { grid-column: 1 / -1; }
  .rem-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rem-actions > .btn { flex: 1 1 auto; }
}

/* Brand: Nebula logo + "Attendance Hub" */
.brand .logo { display: block; flex: none; height: clamp(18px, 4.6vw, 22px); width: auto; }
.brand .logo.mark-only { display: none; height: clamp(24px, 6.4vw, 28px); }
.brand .on-light { display: none; }
:root[data-theme="light"] .brand .on-light { display: block; }
:root[data-theme="light"] .brand .on-dark { display: none; }
.brand .app-name { font-weight: 700; padding-left: clamp(8px, 2.4vw, 12px); border-left: 1px solid var(--line-2); line-height: 1.2; }
@media (max-width: 520px) {
  .brand .logo.full { display: none !important; }
  .brand .logo.mark-only { display: block; }
  .brand .app-name { padding-left: 0; border-left: 0; }
}
@media (max-width: 430px) { .brand .app-name { font-size: .92rem; } .brand { gap: 6px; } }
@media (max-width: 380px) { .brand .app-name { display: none; } }
@media (max-width: 400px) { .brand:has(small) .app-name { display: none; } }

/* ═════════════════════════ Nebula Ops additions ═════════════════════════ */
:root { --side-w: 236px; --top-h: 60px; --info: var(--blue); }
:root[data-theme="light"] { --info: #2563eb; }

/* Brand: logo + Operations Hub */
.brand .app-name.ops { font-size: var(--fs-h); }
.brand .app-name.ops small { display: block; font-size: .62rem; letter-spacing: .04em; color: var(--muted); font-weight: 500; text-transform: none; }

/* Shell */
.topbar { height: var(--top-h); }
.menu-btn { display: none; width: 40px; padding: 0 !important; }
.menu-btn svg { width: 20px; height: 20px; }
.search-trigger { flex: 1 1 auto; max-width: 560px; margin-inline: clamp(8px, 3vw, 40px); display: flex; align-items: center; gap: 10px; height: 40px;
  border: 1px solid var(--line-2); background: var(--field); border-radius: var(--radius-sm); color: var(--faint); padding: 0 10px 0 12px; cursor: text; font-size: var(--fs-sm); min-width: 0; }
.search-trigger:hover { border-color: var(--purple); }
.search-trigger svg { width: 16px; height: 16px; flex: none; }
.search-trigger span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd { font-family: var(--mono); font-size: .7rem; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--muted); background: var(--panel-2); white-space: nowrap; }
.top-actions .btn svg { width: 18px; height: 18px; flex: none; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.user-chip b { color: var(--text); font-weight: 600; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .78rem; color: #fff; background: linear-gradient(135deg, var(--purple), var(--blue)); flex: none; }

.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.side { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; border-right: 1px solid var(--line); padding: 14px 10px 20px; background: color-mix(in srgb, var(--bg) 60%, transparent); }
.nav { display: grid; gap: 2px; }
.nav .label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; border: 1px solid transparent; }
.nav a:hover { background: var(--tint); color: var(--text); }
.nav a[aria-current="page"] { background: var(--panel-2); color: var(--text); border-color: var(--line-2); box-shadow: inset 3px 0 0 var(--purple); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a .badge { margin-left: auto; }
.side-foot { margin-top: 18px; padding: 12px; font-size: var(--fs-xs); color: var(--faint); border-top: 1px solid var(--line); }
.view { min-width: 0; padding: var(--gutter) var(--gutter) 48px; max-width: 1440px; width: 100%; }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: clamp(1.3rem, 1.1rem + .8vw, 1.6rem); letter-spacing: -.01em; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-sm); max-width: 760px; }
.page-head > div:first-child { flex: 1 1 420px; min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; font-size: var(--fs-h); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--gap); }
.grid-2 > .card, .grid-2 > div > .card:first-child { margin-top: 0; }
.grid-cal { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.grid-halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-halves > .card { margin-top: 0; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: var(--gap); }
.kpis > .card { margin: 0; }
.kpi { position: relative; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--line-2); }
.kpi .k { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.kpi .v { font-family: var(--mono); font-size: var(--fs-kpi); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: .5em; color: var(--muted); font-weight: 500; margin-left: 4px; }
.kpi .s { font-size: var(--fs-xs); color: var(--muted); }
.kpi.ok .v { color: var(--ok); } .kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--bad); }

/* Capacity */
.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .3s ease; }
.lvl-warn .bar > i { background: var(--warn); }
.lvl-full .bar > i, .lvl-over .bar > i, .lvl-closed .bar > i { background: var(--bad); }
.cap-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--gap); }
.cap-day { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--tint);
  text-decoration: none; color: inherit; cursor: pointer; min-width: 0; font: inherit; text-align: left; }
.cap-day:hover { border-color: var(--line-2); }
.cap-day .d { display: flex; justify-content: space-between; gap: 6px; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.cap-day .d b { color: var(--text); font-weight: 600; }
.cap-day .n { font-family: var(--mono); font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cap-day .n small { font-size: .62em; color: var(--muted); font-weight: 500; }
.cap-day .r { font-size: var(--fs-xs); color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.cap-day.today { border-color: color-mix(in srgb, var(--purple) 55%, var(--line)); }
.lvl-text { font-weight: 600; }
.lvl-ok .lvl-text { color: var(--ok); } .lvl-warn .lvl-text { color: var(--warn); } .lvl-full .lvl-text, .lvl-over .lvl-text, .lvl-closed .lvl-text { color: var(--bad); }
.lvl-nonworking { opacity: .55; }

/* Month calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cal-head h2 { margin: 0; font-size: var(--fs-h); min-width: 9em; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--faint); padding: 0 4px 2px; }
.cal-cell { min-height: 98px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--tint); padding: 8px 9px; display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; text-align: left; font: inherit; color: inherit; min-width: 0; }
.cal-cell:hover { border-color: var(--line-2); }
.cal-cell.other { opacity: .35; }
.cal-cell.past { opacity: .6; }
.cal-cell.is-sel { border-color: var(--purple); box-shadow: 0 0 0 1px var(--purple) inset; }
.cal-cell .top { display: flex; justify-content: space-between; align-items: center; gap: 4px; font-size: var(--fs-sm); }
.cal-cell .top b { font-weight: 600; }
.cal-cell .top .today-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 8px var(--purple); }
.cal-cell .n { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-cell .n small { color: var(--muted); font-weight: 500; font-size: .75em; }
.cal-cell .note { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-cell.lvl-nonworking { cursor: default; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-xs); color: var(--muted); margin-top: 10px; }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; }
.legend-row i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Status tones */
.pill.tone-neutral { color: var(--muted); }
.pill.tone-info { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); background: color-mix(in srgb, var(--info) 9%, transparent); }
.pill.tone-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 9%, transparent); }
.pill.tone-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 9%, transparent); }
.pill.tone-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 9%, transparent); }
.pill.tag { color: var(--pink); border-color: color-mix(in srgb, var(--pink) 45%, transparent); }
.pill.sev-high { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.sev-medium { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.sev-low { color: var(--muted); }

/* Data tables */
.data td { white-space: nowrap; }
.data td.wrap { white-space: normal; min-width: 120px; max-width: 420px; }
.data tbody tr:hover td { background: var(--tint); }
.data tbody tr.click { cursor: pointer; }
.data tr.muted-row td { opacity: .55; }
.order-no { font-family: var(--mono); font-weight: 600; letter-spacing: .01em; }
a.order-no { color: var(--text); text-decoration: none; }
a.order-no:hover { color: var(--blue); text-decoration: underline; }
.cell-sub { display: block; font-size: var(--fs-xs); color: var(--muted); }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; justify-content: space-between; margin-bottom: 12px; }
.toolbar-row .filters { flex: 1 1 520px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: var(--fs-sm); color: var(--muted); }
.seg-tabs { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--field); }
.seg-tabs button { border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); padding: 6px 12px; border-radius: 7px; cursor: pointer; min-height: 32px; }
.seg-tabs button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }

/* Alerts, activity */
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.attn li:first-child { border-top: 0; padding-top: 2px; }
.attn .ico { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; margin-top: 1px; }
.attn .ico.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.attn .ico.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.attn a { color: var(--text); text-decoration: none; }
.attn a:hover { text-decoration: underline; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.feed li:first-child { border-top: 0; padding-top: 2px; }
.feed time { font-family: var(--mono); color: var(--faint); font-size: var(--fs-xs); padding-top: 2px; }
.feed a { color: var(--text); text-decoration: none; }
.feed a:hover { color: var(--blue); }
.feed .act { color: var(--faint); font-size: var(--fs-xs); }

/* Builder progress */
.prog { display: grid; grid-template-columns: minmax(80px, 140px) minmax(0, 1fr) 72px; gap: 10px; align-items: center; padding: 7px 0; font-size: var(--fs-sm); }
.prog .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.prog .num { font-family: var(--mono); text-align: right; color: var(--muted); }
.prog .num b { color: var(--text); }
.prog .bar { height: 10px; position: relative; overflow: visible; }
.prog .bar > i { background: var(--blue); }
.prog.met .bar > i { background: var(--ok); }

/* Charts */
.chart-box { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .ax text { fill: var(--faint); font: 11px var(--mono); }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--line-2); }
.chart .tgt { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }
.chart .hit { fill: transparent; cursor: default; }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--toast); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 10px; font-size: var(--fs-xs); box-shadow: 0 8px 24px var(--shadow); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.chart-tip b { font-family: var(--mono); font-size: .9rem; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--muted); margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-legend i.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 5px, transparent 5px 8px) !important; }

/* Search palette */
dialog.palette { width: min(680px, calc(100vw - 24px)); margin: 10vh auto auto; max-height: 76vh; }
.palette .pal-in { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.palette .pal-in svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.palette .pal-in input { border: 0 !important; background: transparent !important; height: 40px !important; padding: 0 !important; font-size: 1.05rem !important; outline: none !important; }
.palette .pal-res { overflow-y: auto; padding: 6px; min-height: 60px; }
.pal-group { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 10px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.pal-item[aria-selected="true"], .pal-item:hover { background: var(--panel-2); }
.pal-item .sub { color: var(--muted); font-size: var(--fs-xs); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.pal-item .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pal-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--faint); }

/* Order view */
.order-hero { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.order-hero .order-no { font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); }
.cctv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--gap); }
.cctv { grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); }
.cctv .stat .v { font-size: 1.05rem; white-space: normal; font-family: var(--font); overflow-wrap: anywhere; }
.cctv .stat.net .v { font-family: var(--mono); font-size: 1.25rem; }
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; font-size: var(--fs-sm); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 18px; font-size: var(--fs-sm); }
.timeline li::before { content: ''; position: absolute; left: 3px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--purple); }
.timeline li::after { content: ''; position: absolute; left: 6px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; font-family: var(--mono); color: var(--faint); font-size: var(--fs-xs); }

/* Misc */
.demo-banner { background: color-mix(in srgb, var(--pink) 12%, var(--bg)); color: var(--pink); border-bottom: 1px solid color-mix(in srgb, var(--pink) 40%, transparent); padding: 6px var(--gutter); font-size: var(--fs-sm); text-align: center; }
.empty .big { font-size: 1.6rem; margin-bottom: 6px; }
.err-card { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0 var(--gap); }
.cap-hint { margin: -6px 0 12px; font-size: var(--fs-sm); }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label.f { margin: 0; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line-2); vertical-align: -2px; }
.grid-preview { font-size: .78rem; }
.grid-preview td { padding: 4px 8px; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); }
.state-new { color: var(--ok); } .state-warning { color: var(--warn); } .state-invalid, .state-conflict, .state-unmatched { color: var(--bad); } .state-duplicate, .state-skipped { color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.subnav { display: grid; gap: 2px; position: sticky; top: calc(var(--top-h) + 16px); }
.subnav a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); }
.subnav a:hover { color: var(--text); background: var(--tint); }
.subnav a[aria-current="page"] { color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); }
.toast-host { left: auto; right: 20px; transform: none; bottom: 20px; }
.click-row { cursor: pointer; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt0 { margin-top: 0 !important; }
.mt { margin-top: var(--gap) !important; }
details.more > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }
.checklist { display: grid; gap: 10px; }

@media (max-width: 1180px) {
  .cap-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2, .grid-cal { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1060px) {
  :root { --side-w: 68px; }
  .nav a { justify-content: center; padding: 10px; }
  .nav a span, .nav .label, .nav a .badge, .side-foot { display: none; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .subnav { position: static; display: flex; overflow-x: auto; }
  .subnav a { white-space: nowrap; }
}
@media (max-width: 760px) {
  :root { --side-w: 0px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .side { position: fixed; z-index: 40; left: 0; top: var(--top-h); bottom: 0; width: 264px; height: auto; transform: translateX(-102%); transition: transform .2s ease;
    background: var(--bg); box-shadow: 0 0 40px var(--shadow); }
  body.nav-open .side { transform: none; }
  .nav a { justify-content: flex-start; padding: 10px 12px; }
  .nav a span, .nav .label, .nav a .badge { display: revert; }
  .search-trigger { margin-inline: 4px; }
  .search-trigger kbd, .user-chip b, .user-chip .role { display: none; }
  .cap-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-halves { grid-template-columns: minmax(0, 1fr); }
  .cal { gap: 3px; }
  .cal-cell { min-height: 64px; padding: 5px; }
  .cal-cell .note, .cal-cell .bar { display: none; }
  .cal-cell .n { font-size: .85rem; }
  .toast-host { left: 50%; right: auto; transform: translateX(-50%); }
  .feed li { grid-template-columns: 1fr; gap: 2px; }
}
.data td.note-col { min-width: 240px; }
