:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e3e6ee;
  --border-strong: #cfd4e0;
  --text: #171b26;
  --muted: #68708a;
  --faint: #9aa1b6;
  --accent: #3b5bdb;
  --accent-hover: #3250c4;
  --accent-soft: #e8edff;
  --ok: #2f9e44;      --ok-soft: #e6f6ea;
  --abs: #6c7489;     --abs-soft: #eef0f4;
  --hlf: #e8590c;     --hlf-soft: #fff0e6;
  --mis: #e03131;     --mis-soft: #ffe8e8;
  --warn: #7048e8;    --warn-soft: #f0ebff;
  --night: #1971c2;   --night-soft: #e7f1fd;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 16px rgba(20, 24, 40, .05);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1d2130;
  --border: #272b3a;
  --border-strong: #353a4d;
  --text: #e8eaf1;
  --muted: #9ba3bb;
  --faint: #6b7390;
  --accent: #6d8cff;
  --accent-hover: #809bff;
  --accent-soft: #1f2846;
  --ok: #51cf66;    --ok-soft: #15301d;
  --abs: #9aa3b8;   --abs-soft: #232838;
  --hlf: #ff922b;   --hlf-soft: #3a2614;
  --mis: #ff6b6b;   --mis-soft: #3d1b1b;
  --warn: #b197fc;  --warn-soft: #2a2244;
  --night: #74c0fc; --night-soft: #15283d;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: 11px var(--mono); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--muted); background: var(--surface-2); }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand div { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.brand span { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.hint { font-size: 12.5px; color: var(--muted); }
.hint b { color: var(--text); font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.badge.ok::before { background: var(--ok); }
.badge.bad::before { background: var(--mis); }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100% - 56px); }
.sidebar {
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto;
  padding: 16px 14px; border-right: 1px solid var(--border); background: var(--surface);
}
.sidebar-head { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 6px 8px; }
.sidebar-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
.count { font-size: 12px; color: var(--faint); }
.report-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.report-item {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
  border-radius: 10px; padding: 9px 10px; display: flex; flex-direction: column; gap: 5px;
}
.report-item:hover { background: var(--surface-2); }
.report-item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.report-item .d { display: flex; justify-content: space-between; align-items: baseline; }
.report-item .d b { font-size: 13.5px; font-weight: 600; }
.report-item .d span { font-size: 11px; color: var(--muted); }
.report-item .mini { display: flex; gap: 5px; flex-wrap: wrap; }
.mini i { font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.mini i.hlf { color: var(--hlf); background: var(--hlf-soft); border-color: transparent; }
.mini i.mis { color: var(--mis); background: var(--mis-soft); border-color: transparent; }
.mini i.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.empty-note { color: var(--muted); font-size: 13px; margin: 14px 6px; }

.main { padding: 28px 32px 60px; max-width: 1320px; width: 100%; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 550; font-size: 13.5px; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.block { width: 100%; }
.btn.block + .btn.block { margin-top: 8px; }
.btn.ghost-danger { color: var(--mis); }
.btn.ghost-danger:hover { background: var(--mis-soft); border-color: transparent; }
.btn.confirm { background: var(--mis); border-color: var(--mis); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.split { position: relative; display: inline-flex; }
.split .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .caret { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 10px; border-left-color: rgba(255,255,255,.35); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 290px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column;
}
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu-check { display: flex; gap: 10px; align-items: center; padding: 8px 10px; font-size: 13px; cursor: pointer; border-radius: 8px; }
.menu-check:hover { background: var(--surface-2); }
.menu-check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.menu-item { text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; font-size: 13px; }
.menu-item:hover { background: var(--surface-2); }
.theme-pick { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; font-size: 13px; }
div.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
div.seg button { border: 0; background: none; padding: 4px 9px; border-radius: 6px; font-size: 12px; color: var(--muted); }
div.seg button:hover { color: var(--text); }
div.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }

/* ---- drop view ---- */
.drop-view { display: flex; flex-direction: column; align-items: center; gap: 28px; padding-top: 6vh; }
.dropzone {
  width: 100%; max-width: 680px; padding: 52px 32px 40px; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: 20px; background: var(--surface);
  transition: border-color .15s, background .15s, transform .15s; outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.dropzone.busy { pointer-events: none; opacity: .8; }
.drop-icon { color: var(--accent); margin-bottom: 14px; }
.dropzone h1 { font-size: 22px; margin-bottom: 8px; }
.dropzone p { color: var(--muted); margin: 0 auto 20px; max-width: 420px; }
.drop-progress { margin-top: 18px; display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; width: 100%; max-width: 820px; }
.features > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; }
.features b { font-size: 13.5px; }
.features span:last-child { grid-column: 2; font-size: 12.5px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.hlf { background: var(--hlf); } .dot.mis { background: var(--mis); } .dot.warn { background: var(--warn); } .dot.ok { background: var(--ok); }

/* ---- report head ---- */
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.report-title h1 { font-size: 26px; }
.meta { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.meta a { color: var(--accent); text-decoration: none; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notice { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.notice.warn { background: var(--hlf-soft); color: var(--hlf); border-color: color-mix(in srgb, var(--hlf) 25%, transparent); }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 2px; position: relative; transition: border-color .12s, box-shadow .12s;
}
.stat:hover { border-color: var(--border-strong); }
.stat.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .pct { position: absolute; right: 12px; top: 12px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.stat.ok .v { color: var(--ok); } .stat.abs .v { color: var(--abs); } .stat.hlf .v { color: var(--hlf); }
.stat.mis .v { color: var(--mis); } .stat.warn .v { color: var(--warn); } .stat.night .v { color: var(--night); }

/* ---- attention ---- */
.attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 22px; }
.att-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.att-card header { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.att-card header h3 { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.att-card header .pill { font-size: 12px; font-weight: 650; padding: 2px 9px; border-radius: 999px; }
.att-card.hlf header .pill { color: var(--hlf); background: var(--hlf-soft); }
.att-card.mis header .pill { color: var(--mis); background: var(--mis-soft); }
.att-card.warn header .pill { color: var(--warn); background: var(--warn-soft); }
.att-card header button { background: none; border: 0; color: var(--accent); font-size: 12.5px; padding: 2px 4px; }
.att-list { list-style: none; margin: 0; padding: 4px 0; max-height: 300px; overflow: auto; }
.att-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 14px; cursor: pointer; }
.att-list li:hover { background: var(--surface-2); }
.att-list .n { font-weight: 600; font-size: 13px; }
.att-list .m { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.att-list .t { font-family: var(--mono); font-size: 12px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.att-list .t em { font-style: normal; color: var(--mis); }
.att-empty { padding: 20px 14px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---- toolbar ---- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); min-width: 260px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; color: var(--text); min-width: 0; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
select { height: 36px; padding: 0 30px 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2368708a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; appearance: none; max-width: 260px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.chip:hover { border-color: var(--text); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .k { font-size: 11px; opacity: .8; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin-left: auto; cursor: pointer; white-space: nowrap; }
.switch input { accent-color: var(--accent); margin: 0; }

/* ---- table ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid .c { text-align: center; }
.grid .num { width: 44px; color: var(--faint); font-variant-numeric: tabular-nums; }
.grid td.mono, .grid td.time { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.grid td.time { text-align: center; }
.grid td.time.missing { color: var(--mis); font-weight: 600; }
.grid td.hrs { font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.grid td.name { font-weight: 550; }
.grid td.name small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.grid td.remarks { color: var(--muted); font-size: 12.5px; max-width: 360px; }
.grid tbody tr.emp:hover td { background: var(--surface-2); }
.grid tr.dept td { background: var(--surface-2); padding: 7px 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.grid tr.dept td span { margin-left: 10px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--faint); }
.grid tr.dept td span i { font-style: normal; margin-right: 8px; }
.grid tr.dept td span i.hlf { color: var(--hlf); } .grid tr.dept td span i.mis { color: var(--mis); }
.grid tr.emp td:first-child { box-shadow: inset 3px 0 0 transparent; }
.grid tr.emp.is-mis td { background: color-mix(in srgb, var(--mis-soft) 55%, var(--surface)); }
.grid tr.emp.is-mis td:first-child { box-shadow: inset 3px 0 0 var(--mis); }
.grid tr.emp.is-hlf td { background: color-mix(in srgb, var(--hlf-soft) 55%, var(--surface)); }
.grid tr.emp.is-hlf td:first-child { box-shadow: inset 3px 0 0 var(--hlf); }
.grid tr.emp.is-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.grid tr.emp.is-abs td { color: var(--muted); }
.grid tr.emp.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; }
.status.P { color: var(--ok); background: var(--ok-soft); }
.status.A { color: var(--abs); background: var(--abs-soft); }
.status.HLF { color: var(--hlf); background: var(--hlf-soft); }
.status.MIS { color: var(--mis); background: var(--mis-soft); }
.status.other { color: var(--night); background: var(--night-soft); }
.tag { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 5px; margin-right: 4px; font-weight: 600; }
.tag.night { color: var(--night); background: var(--night-soft); }
.tag.warn { color: var(--warn); background: var(--warn-soft); }
.tag.manual { color: var(--muted); background: var(--abs-soft); }
.table-foot { color: var(--faint); font-size: 12px; margin-top: 10px; }

/* ---- overlay / modal / toasts ---- */
.drag-overlay { position: fixed; inset: 0; z-index: 100; background: color-mix(in srgb, var(--accent) 12%, var(--bg) 80%); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drag-overlay > div { border: 2px dashed var(--accent); color: var(--accent); border-radius: 20px; padding: 40px 60px; text-align: center; background: var(--surface); font-weight: 600; font-size: 16px; }
.drag-overlay p { margin: 10px 0 0; }
.modal { position: fixed; inset: 0; z-index: 110; background: rgba(10, 12, 20, .45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--surface); border-radius: 16px; padding: 22px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.modal-card h3 { font-size: 16px; margin-bottom: 6px; }
.modal-card p { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.modal-card input[type=date] { width: 100%; height: 38px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 0 10px; background: var(--surface); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); max-width: 380px; animation: rise .18s ease-out; }
.toast.err { background: var(--mis); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---- responsive ---- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .report-list { flex-direction: row; overflow-x: auto; }
  .report-item { min-width: 190px; }
  .main { padding: 18px 16px 40px; }
  .hint { display: none; }
  .switch { margin-left: 0; }
}

/* ---- print ---- */
@media print {
  .topbar, .sidebar, .actions, .toolbar, .attention, .drag-overlay, .toasts { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; max-width: none; }
  .table-wrap { border: 0; overflow: visible; }
  .grid th { position: static; }
  body { background: #fff; color: #000; font-size: 11px; }
  .stat { break-inside: avoid; }
}

/* =================== v2: auth, nav, admin pages, corrections =================== */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.brand.big { margin-bottom: 8px; }
.brand.big strong { font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.field > span { color: var(--muted); font-weight: 550; font-size: 12px; }
.field input:not([type=checkbox]), .field select, .field textarea { height: 38px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 0 11px; background: var(--surface); color: var(--text); width: 100%; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.field.check input { accent-color: var(--accent); margin: 0; }
.form-error { background: var(--mis-soft); color: var(--mis); padding: 9px 12px; border-radius: 9px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.modal-card.wide { max-width: 560px; }
.modal-card form { display: contents; }

.tabs { display: flex; gap: 4px; margin-left: 26px; }
.tab { height: 34px; padding: 0 14px; border: 0; background: transparent; border-radius: 8px; font-weight: 550; color: var(--muted); }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.usermenu { position: relative; }
.userbtn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.userbtn:hover { background: var(--surface-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.uname { font-weight: 600; font-size: 13px; }
.role-badge { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: var(--abs-soft); color: var(--muted); }
.role-badge.admin { background: var(--accent-soft); color: var(--accent); }
.role-badge.hod { background: var(--ok-soft); color: var(--ok); }
.role-badge.hr { background: var(--warn-soft); color: var(--warn); }
.menu-head { padding: 8px 10px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.menu-head b { color: var(--text); }

.page { padding: 28px 32px 60px; max-width: 1320px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); margin: 6px 0 0; max-width: 760px; font-size: 13.5px; }
.nonadmin-empty { text-align: center; max-width: 480px; }
.nonadmin-empty h1 { font-size: 22px; margin-bottom: 8px; }
.nonadmin-empty p { color: var(--muted); }

.act-col { width: 1%; white-space: nowrap; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.fix { background: var(--mis); border-color: var(--mis); color: #fff; }
.btn.fix:hover { filter: brightness(1.08); }
.btn.undo { color: var(--muted); }
.grid td.time .was { display: block; font-size: 10.5px; color: var(--faint); text-decoration: line-through; font-family: var(--font); }
.grid tr.emp.is-fixed td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.grid tr.emp.is-fixed td { background: color-mix(in srgb, var(--ok-soft) 45%, var(--surface)); }
.tag.fixed { color: var(--ok); background: var(--ok-soft); }
.tag.seg { color: var(--muted); background: var(--abs-soft); font-weight: 600; }
.stat.pend .v { color: var(--mis); } .stat.fixed .v { color: var(--ok); }
.att-card.pend header .pill { color: var(--mis); background: var(--mis-soft); }
.att-list li .state { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; justify-self: end; }
.att-list li .state.open { color: var(--mis); background: var(--mis-soft); }
.att-list li .state.done { color: var(--ok); background: var(--ok-soft); }
.att-list li.grid3 { grid-template-columns: 1fr auto auto; }

.fix-emp { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; }
.fix-emp b { font-size: 14px; }
.fix-emp .t { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.fix-emp .t em { font-style: normal; color: var(--mis); font-weight: 700; }
.fix-emp .m { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.fix-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.opt input[type=radio] { margin: 3px 0 0; accent-color: var(--accent); }
.opt > div { display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.opt > div > span { color: var(--muted); font-size: 12px; }
.opt .inline { display: flex; gap: 8px; margin-top: 8px; }
.opt .inline select, .opt .inline input { height: 34px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 8px; background: var(--surface); color: var(--text); }
.opt .inline select { padding-right: 28px; }

.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 10px; max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; }
.dept-grid label { display: flex; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; cursor: pointer; }
.dept-grid input { accent-color: var(--accent); margin: 0; }
.dept-grid label small { color: var(--faint); }
.pill-list { display: flex; flex-wrap: wrap; gap: 4px; }
.pill-list i { font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.inactive td { opacity: .55; }
.shift-input { height: 30px; width: 86px; border: 1px solid var(--border-strong); border-radius: 7px; padding: 0 8px; background: var(--surface); color: var(--text); font-family: var(--mono); text-align: center; }
.shift-input.name { width: 170px; font-family: var(--font); text-align: left; }
.grid td .arrow { color: var(--faint); margin: 0 4px; }
.grid td.before { color: var(--muted); }
@media (max-width: 960px) { .tabs { margin-left: 8px; } .form-grid { grid-template-columns: 1fr; } .uname { display: none; } }
@media print { .tabs, .usermenu, .set-nav { display: none !important; } .settings { display: block; } }
#uDeptsField, #uOfficesField { margin-top: 12px; }
#uDeptsField > span, #uOfficesField > span { display: block; margin-bottom: 6px; }


/* =================== v3: audit trail =================== */
.notice.info { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.notice.info button { background: none; border: 0; color: inherit; font-weight: 600; text-decoration: underline; }
.audit-stats { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.stat.integrity.ok .v { color: var(--ok); font-size: 18px; margin-top: 4px; }
.stat.integrity.bad .v { color: var(--mis); font-size: 18px; margin-top: 4px; }
.stat.integrity.unknown .v { color: var(--muted); font-size: 18px; margin-top: 4px; }
.stat.static { cursor: default; }
.stat.static:hover { border-color: var(--border); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.panel > header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.panel > header h3 { font-size: 13.5px; }
.table-wrap.flat { border: 0; border-radius: 0; }
.audit-toolbar select { max-width: 200px; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-day { position: sticky; top: 56px; z-index: 3; background: var(--bg); padding: 14px 0 8px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.tl-day::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.tl-day span { color: var(--faint); font-weight: 500; letter-spacing: 0; text-transform: none; }
.ev { display: grid; grid-template-columns: 36px 1fr auto; gap: 0 12px; padding: 10px 14px 10px 10px; background: var(--surface); border: 1px solid var(--border); border-top: 0; cursor: pointer; }
.ev:first-of-type, .tl-day + .ev { border-top: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.ev.last { border-radius: 0 0 var(--radius) var(--radius); }
.ev.single { border-radius: var(--radius); }
.ev:hover { background: var(--surface-2); }
.ev.open { background: var(--surface-2); }
.ev-ico { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; align-self: start; margin-top: 1px; }
.ev-ico svg { width: 17px; height: 17px; }
.ev-ico.auth { background: var(--accent-soft); color: var(--accent); }
.ev-ico.user { background: var(--warn-soft); color: var(--warn); }
.ev-ico.report { background: var(--night-soft); color: var(--night); }
.ev-ico.correction { background: var(--ok-soft); color: var(--ok); }
.ev-ico.export { background: var(--hlf-soft); color: var(--hlf); }
.ev-ico.shift { background: var(--abs-soft); color: var(--abs); }
.ev-ico.access { background: var(--mis-soft); color: var(--mis); }
.ev-ico.audit, .ev-ico.system { background: var(--abs-soft); color: var(--muted); }
.ev-main { min-width: 0; }
.ev-sum { font-size: 13.5px; line-height: 1.4; }
.ev-sum b { font-weight: 650; }
.ev-meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.ev-meta .mono { font-family: var(--mono); font-size: 11.5px; }
.ev-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; white-space: nowrap; }
.ev-time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ev-badges { display: flex; gap: 6px; align-items: center; min-height: 16px; }
.sev { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; display: inline-block; }
.sev-info { background: var(--faint); } .sev-notice { background: var(--night); } .sev-warning { background: var(--hlf); } .sev-critical { background: var(--mis); }
.outcome { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 5px; letter-spacing: .04em; }
.outcome.success { color: var(--ok); background: var(--ok-soft); }
.outcome.failure { color: var(--mis); background: var(--mis-soft); }
.outcome.denied { color: var(--mis); background: var(--mis-soft); }
.ev-detail { grid-column: 1 / -1; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 14px; cursor: default; }
.ev-detail h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.ev-detail .full { grid-column: 1 / -1; }
.difftable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.difftable td, .difftable th { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.difftable th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.difftable td.from { color: var(--mis); text-decoration: line-through; }
.difftable td.to { color: var(--ok); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }
.hashline { font-family: var(--mono); font-size: 11px; color: var(--faint); word-break: break-all; }
.timeline-foot { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.tl-empty { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.btn.icon { width: 30px; height: 28px; padding: 0; color: var(--muted); border-color: transparent; background: transparent; }
.btn.icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.ev-link { color: var(--accent); background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 105; background: rgba(10, 12, 20, .35); display: flex; justify-content: flex-end; }
.drawer-card { width: min(560px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-card > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.drawer-card h3 { font-size: 18px; }
.drawer-body { overflow: auto; padding: 16px 20px 30px; display: flex; flex-direction: column; gap: 18px; }
.drawer-body h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.punch-now { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.punch-now div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.punch-now b { display: block; font-size: 16px; font-family: var(--mono); }
.punch-now span { font-size: 11px; color: var(--muted); }
.punch-now small { display: block; color: var(--faint); text-decoration: line-through; font-family: var(--mono); font-size: 11px; }
.story { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); margin-left: 8px; }
.story li { position: relative; padding: 0 0 14px 18px; font-size: 13px; }
.story li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.story li.fix::before { border-color: var(--ok); } .story li.revert::before { border-color: var(--hlf); } .story li.fail::before { border-color: var(--mis); }
.story .when { font-family: var(--mono); font-size: 11.5px; color: var(--muted); display: block; }
.story .what b { font-weight: 650; }
.story .remark { color: var(--muted); font-style: italic; }
.days { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.days td, .days th { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.days th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.days td.mono { font-family: var(--mono); }
.days tr.cur td { background: var(--accent-soft); }
@media (max-width: 960px) { .ev-detail { grid-template-columns: 1fr; } .punch-now { grid-template-columns: repeat(2, 1fr); } }
@media print { .drawer { display: none !important; } }


/* =================== v4: integrations =================== */
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.section-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
.section-head.small { margin: 10px 0 6px; } .section-head.small h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card .top b { font-size: 14.5px; }
.card .sub2 { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.card .status { font-size: 12px; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.card .status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: 0 0 8px; }
.card .status.ok::before { background: var(--ok); } .card .status.bad::before { background: var(--mis); }
.card .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.dialect { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; background: var(--night-soft); color: var(--night); white-space: nowrap; }
.dir { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; padding: 2px 7px; border-radius: 6px; }
.dir.pull { background: var(--ok-soft); color: var(--ok); } .dir.push { background: var(--hlf-soft); color: var(--hlf); }
.run-status { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.run-status.success { background: var(--ok-soft); color: var(--ok); } .run-status.failed { background: var(--mis-soft); color: var(--mis); }
.run-status.partial { background: var(--hlf-soft); color: var(--hlf); } .run-status.running { background: var(--accent-soft); color: var(--accent); }
.modal-card.xwide { max-width: 980px; max-height: 94vh; overflow: auto; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.field textarea { height: auto; padding: 8px 11px; font-family: var(--mono); font-size: 12.5px; line-height: 1.45; resize: vertical; }
.field code { font-family: var(--mono); background: var(--surface-2); padding: 0 4px; border-radius: 4px; }
.field small { color: var(--faint); font-weight: 400; }
.adv { margin: 10px 0; font-size: 13px; } .adv summary { cursor: pointer; color: var(--muted); } .adv .field { margin-top: 8px; }
.hint-box { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin: 10px 0; }
.hint-box:empty { display: none; }
.test-result { font-size: 13px; padding: 9px 12px; border-radius: 9px; margin-top: 10px; }
.test-result.ok { background: var(--ok-soft); color: var(--ok); } .test-result.bad { background: var(--mis-soft); color: var(--mis); }
.modal-card.console { padding: 0; display: flex; flex-direction: column; height: 90vh; }
.console-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.console-head h3 { font-size: 15px; } .console-head select { height: 32px; max-width: 220px; }
.console-body { display: flex; flex: 1; min-height: 0; }
.schema-pane { width: 260px; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.schema-pane input { margin: 10px; height: 32px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; background: var(--surface); color: var(--text); }
.schema-list { list-style: none; margin: 0; padding: 0 6px 10px; overflow: auto; flex: 1; font-size: 12.5px; }
.schema-list li { padding: 5px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; }
.schema-list li:hover { background: var(--surface-2); } .schema-list li.active { background: var(--accent-soft); color: var(--accent); }
.schema-list li small { color: var(--faint); }
.schema-cols { font-size: 12px; color: var(--muted); padding: 4px 8px 8px 18px; }
.schema-cols div { display: flex; justify-content: space-between; gap: 8px; } .schema-cols b { color: var(--text); font-weight: 500; font-family: var(--mono); }
.console-main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 12px 16px 16px; gap: 8px; }
.console-main textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 9px; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: var(--surface); color: var(--text); resize: vertical; }
.console-bar { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.console-bar input { height: 30px; border: 1px solid var(--border-strong); border-radius: 7px; padding: 0 8px; background: var(--surface); color: var(--text); }
.result-wrap { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: 10px; min-height: 120px; background: var(--surface); }
.result-wrap table { border-collapse: collapse; font-size: 12px; font-family: var(--mono); min-width: 100%; }
.result-wrap th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); font-weight: 600; white-space: nowrap; font-family: var(--font); color: var(--muted); font-size: 11.5px; }
.result-wrap th small { display: block; color: var(--accent); font-weight: 600; }
.result-wrap td { padding: 4px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.result-wrap td.null { color: var(--faint); font-style: italic; }
.result-wrap .err { padding: 14px; color: var(--mis); font-size: 13px; }
.preview-bar { display: flex; gap: 12px; align-items: center; margin: 12px 0 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.preview-bar input { height: 32px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 8px; background: var(--surface); color: var(--text); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 6px 14px; margin-top: 10px; }
.map-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; font-size: 12.5px; padding: 4px 0; }
.map-row .lbl b { font-weight: 600; } .map-row .lbl small { display: block; color: var(--faint); font-size: 11px; }
.map-row .req b::after { content: " *"; color: var(--mis); }
.map-row select { height: 30px; font-size: 12.5px; padding: 0 26px 0 8px; max-width: 100%; }
.map-row select.mapped { border-color: var(--ok); }
.map-group { grid-column: 1 / -1; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-top: 8px; }
.pv-summary { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.pv-summary span { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-size: 12.5px; }
.pv-summary span b { font-weight: 650; }
.pv-summary span.bad { background: var(--mis-soft); color: var(--mis); border-color: transparent; }
.pv-table { border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 220px; }
.pv-table table { font-size: 12px; border-collapse: collapse; min-width: 100%; }
.pv-table th { text-align: left; padding: 5px 8px; background: var(--surface-2); color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
.pv-table td { padding: 4px 8px; border-top: 1px solid var(--border); white-space: nowrap; font-family: var(--mono); }
.colmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; }
.colmap label { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; }
.colmap label span { font-family: var(--mono); color: var(--muted); } .colmap input[type=text] { height: 28px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 8px; font-family: var(--mono); font-size: 12px; background: var(--surface); color: var(--text); min-width: 0; }
.colmap input[type=checkbox] { accent-color: var(--accent); margin: 0; }
.sched { margin-top: 14px; align-items: end; }
.run-log { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin-top: 10px; white-space: pre-wrap; max-height: 220px; overflow: auto; }
.btn.sm.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 960px) { .form-grid.three { grid-template-columns: 1fr; } .schema-pane { display: none; } }

/* ============================ offices, machines, employees (0.4) ============================ */
.role-badge.office_admin { background: var(--night-soft); color: var(--night); }
.role-badge.office_viewer, .role-badge.viewer { background: var(--warn-soft); color: var(--warn); }
.faint { color: var(--faint); }
.sub-line { display: block; color: var(--faint); font-size: 11.5px; margin-top: 2px; }

.office-pick { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.office-pick select { width: 100%; height: 36px; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 13.5px; }
.report-item .office-tag { font-size: 11px; color: var(--muted); margin: 1px 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.office { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.office > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.office h2 { font-size: 16px; margin: 0 0 3px; }
.office header p { margin: 0; font-size: 12.5px; color: var(--muted); }
.office header p.faint { color: var(--faint); margin-top: 2px; }
.office .table-wrap.flat { border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
.office .empty-note { margin: 4px 0 0; text-align: left; padding: 0; }
.dotline { display: inline-flex; align-items: baseline; gap: 7px; font-size: 12.5px; color: var(--muted); }
.dotline::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: 0 0 8px; transform: translateY(-1px); }
.dotline.ok::before { background: var(--ok); }
.dotline.bad::before { background: var(--mis); }
.dotline.bad { color: var(--mis); }

/* native dialogs */
dialog.dlg { border: 0; border-radius: 16px; padding: 22px; width: calc(100% - 32px); max-width: 420px; max-height: calc(100dvh - 32px); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog.dlg.wide { max-width: 620px; }
dialog.dlg:modal { overscroll-behavior: contain; }
dialog.dlg::backdrop { background: rgba(10, 12, 20, .45); overflow: hidden; overscroll-behavior: contain; }
dialog.dlg h1 { font-size: 16px; margin: 0 0 6px; }
dialog.dlg p { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
dialog.dlg form { display: flex; flex-direction: column; gap: 12px; }
dialog.dlg form > p, dialog.dlg form > h1 { margin-bottom: 0; }
dialog.dlg .field input[type=file] { height: auto; padding: 7px 8px; font-size: 12.5px; }
dialog.dlg .field > small { color: var(--faint); font-size: 11.5px; }
dialog.dlg .modal-actions { margin-top: 4px; }
.mach-list { display: flex; flex-direction: column; gap: 6px; }
.mach-list:empty { display: none; }
.mach { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; cursor: pointer; }
.mach input { accent-color: var(--accent); margin: 3px 0 0; }
.mach small { color: var(--faint); font-family: var(--mono); font-size: 11.5px; }
.mach small.st { display: block; font-family: var(--font); color: var(--muted); margin-top: 1px; }
.mach.ok small.st { color: var(--ok); }
.mach.bad { cursor: default; }
.mach.bad small.st { color: var(--mis); }
#machineInfo:empty { display: none; }
.import-errors { margin: 0; padding: 8px 12px 8px 26px; max-height: 150px; overflow: auto; font-size: 12.5px; background: var(--mis-soft); color: var(--mis); border-radius: 9px; }
.import-errors b { font-weight: 650; margin-right: 4px; }
#iResult:empty { display: none; }
#iResult .faint { font-size: 12px; margin: 6px 0; }
@media (max-width: 960px) { .office > header { flex-direction: column; } dialog.dlg .form-grid { grid-template-columns: 1fr; } }
@media print { dialog.dlg, .office-pick { display: none !important; } }

/* ---------- 0.5: days worked out from punches, the month, punches, the schedule ---------- */
.notice.note { background: var(--surface-2); color: var(--text); border-color: var(--border); display: grid; gap: 4px; }
.notice.note p { margin: 0; color: inherit; }
#empUnlisted { grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.bad { color: var(--mis); }
.status.live { color: var(--night); background: var(--night-soft); }
.status.off { color: var(--abs); background: var(--abs-soft); }
.mini i.live { color: var(--night); background: var(--night-soft); border-color: transparent; }
.toolbar input[type=date], .toolbar input[type=month], .inline-form input { height: 36px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 0 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.toolbar input:focus-visible, .inline-form input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.opt .inline { align-items: center; }
fieldset.days { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
fieldset.days legend { color: var(--muted); font-weight: 550; font-size: 12px; padding: 0; margin-bottom: 5px; }
fieldset.days label { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; }
fieldset.days input { accent-color: var(--accent); margin: 0; }
.field.check small { display: inline; color: var(--faint); font-weight: 400; }
.section-head { justify-content: space-between; flex-wrap: wrap; }
.section-head > p { margin: 0; max-width: 760px; font-size: 13px; }
.section-head .toolbar { margin: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); }
.kv b { font-size: 15px; color: var(--text); }
.kv .bad, .kv .bad b { color: var(--mis); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.byhand { color: var(--hlf); text-decoration: underline dotted; }
td.small { font-size: 11.5px; }
.cell-input { height: 30px; width: 100%; min-width: 120px; border: 1px solid var(--border-strong); border-radius: 7px; padding: 0 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.card-days { max-height: 46vh; }
.table-wrap.narrow { max-width: 760px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form input[name=name] { flex: 1 1 240px; max-width: 420px; }
dialog.dlg.wide:has(.card-days) { max-width: 860px; }
.legend { color: var(--muted); font-size: 12px; margin: 10px 2px 0; line-height: 1.6; }
.dotc { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); margin-left: 2px; vertical-align: super; }

/* A wide grid: the header row and the name column stay in view while the rest scrolls. */
.matrix-wrap { overflow: auto; max-inline-size: 100%; max-block-size: max(320px, calc(100dvh - 330px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.matrix-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.matrix caption { caption-side: top; text-align: start; padding: 8px 12px; color: var(--muted); font-size: 12px; position: sticky; inset-inline-start: 0; }
table.matrix thead { position: sticky; inset-block-start: 0; z-index: 2; }
table.matrix thead th { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 5px 3px; font-weight: 600; text-align: center; white-space: nowrap; }
table.matrix th.who { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); text-align: start; padding: 5px 12px; min-width: 210px; max-width: 280px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.matrix thead th.who { background: var(--surface-2); font-weight: 600; }
table.matrix th.who small { display: block; color: var(--faint); font-weight: 400; font-size: 11px; }
table.matrix th.who .n { color: var(--faint); font-weight: 400; margin-left: 4px; }
table.matrix th.who button, table.matrix th.day button { all: unset; cursor: pointer; }
table.matrix th.who button { color: var(--text); font-weight: 550; }
table.matrix th.who button:hover { color: var(--accent); text-decoration: underline; }
table.matrix button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
table.matrix th.day { min-width: 34px; }
table.matrix th.day b { display: block; }
table.matrix th.day i { font-style: normal; font-size: 10px; color: var(--faint); font-weight: 400; }
table.matrix th.day.off, table.matrix th.day.hol { background: var(--abs-soft); }
table.matrix th.day.today { border-bottom: 2px solid var(--accent); }
table.matrix td { border-bottom: 1px solid var(--border); text-align: center; height: 36px; min-width: 34px; padding: 0 2px; white-space: nowrap; }
table.matrix td.c { font-weight: 600; font-size: 11.5px; }
table.matrix td.p { color: var(--ok); }
table.matrix td.a { color: var(--abs); background: var(--abs-soft); }
table.matrix td.h { color: var(--hlf); background: var(--hlf-soft); }
table.matrix td.m { color: var(--mis); background: var(--mis-soft); }
table.matrix td.o { color: var(--faint); font-weight: 400; }
table.matrix td.l { color: var(--night); background: var(--night-soft); }
table.matrix td.live { color: var(--night); font-weight: 400; }
table.matrix td.pend { outline: 1px dashed var(--mis); outline-offset: -3px; }
table.matrix td.tot { font-family: var(--mono); font-size: 12px; padding: 0 8px; color: var(--text); }
table.matrix th.tot { padding: 5px 8px; }
table.matrix .tot.present { border-left: 1px solid var(--border); }
table.matrix td.tot.payable { font-weight: 700; }
table.matrix td.tot.open { color: var(--mis); }
table.matrix tfoot th, table.matrix tfoot td { background: var(--surface-2); font-weight: 650; border-bottom: 0; }
table.matrix.roster td { padding: 0; }
table.matrix.roster td button { all: unset; display: block; width: 100%; line-height: 36px; cursor: pointer; }
table.matrix.roster td button:hover { background: var(--accent-soft); }
table.matrix.roster td.usual { color: var(--faint); font-weight: 400; }
table.matrix.roster td.set { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
table.matrix.roster td.o { background: var(--abs-soft); }

/* Tabs inside a page. The selected one is told apart by more than colour: it carries the underline. */
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.subtabs button { position: relative; background: none; border: 0; padding: 10px 14px; font: inherit; font-size: 13.5px; font-weight: 550; color: var(--muted); cursor: pointer; white-space: nowrap; }
.subtabs button:hover { color: var(--text); }
.subtabs button[aria-selected="true"] { color: var(--accent); }
.subtabs button[aria-selected="true"]::after { content: ""; position: absolute; inset: auto 0 0; border-block-end: 3px solid var(--accent); }
.subtabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
@media (max-width: 960px) { .matrix-wrap { max-block-size: none; } table.matrix th.who { min-width: 150px; max-width: 170px; } }
@media print { .subtabs, .legend { display: none !important; } .matrix-wrap { max-block-size: none; overflow: visible; border: 0; } table.matrix thead, table.matrix th.who { position: static; } }
#attendancePage, #schedulePage, #punchesPage { max-width: 1680px; }

/* ---------- 0.6: connectors ---------- */
#connectorsPage { max-width: 1320px; }
.grid td.name small.via { color: var(--night); }
.conn h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.conn h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; margin: 18px 0 8px; }
.conn .conn-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 18px 0 8px; }
.conn .conn-head h3 { margin: 0; }
.conn .conn-head .faint { font-size: 12px; }
.conn .conn-head .btn { margin-inline-start: auto; }
.conn .switch.sm { margin: 0 8px 0 0; font-size: 12px; vertical-align: middle; }
.conn-busy { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; padding: 9px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.conn-busy .spinner { flex: none; border-color: color-mix(in srgb, var(--accent) 35%, transparent); border-top-color: var(--accent); }
.badge.bad { color: var(--mis); border-color: color-mix(in srgb, var(--mis) 30%, transparent); background: var(--mis-soft); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: var(--ok-soft); }
.empty-state { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 36px 28px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty-state h2 { font-size: 17px; }
.empty-state p { margin: 0; color: var(--muted); max-width: 560px; font-size: 13.5px; }

/* dialogs of the connectors page */
fieldset.machs, fieldset.kinds { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
fieldset.machs legend, fieldset.kinds legend { color: var(--muted); font-weight: 550; font-size: 12px; padding: 0; margin-bottom: 5px; }
fieldset.machs > small { color: var(--faint); font-size: 11.5px; }
.opt .inline input[type=number] { width: 84px; }
.opt .inline.times { flex-wrap: wrap; }
.time-row { display: inline-flex; gap: 4px; align-items: center; }
.time-row .btn { width: 28px; padding: 0; color: var(--muted); }
.days-pick { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; align-items: center; font-size: 13px; }
.days-pick label { display: inline-flex; gap: 5px; align-items: center; }
.days-pick input { accent-color: var(--accent); margin: 0; }
.days-pick small { font-size: 11.5px; }
span.inline { display: inline-flex; align-items: center; gap: 8px; }
.pair-steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 14px; font-size: 13.5px; }
.pair-steps .mono, .pair-code { font-family: var(--mono); }
.pair-steps small { display: block; margin-top: 6px; font-size: 12px; line-height: 1.5; }
.copyable { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.copyable output { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 7px 12px; font-size: 13.5px; overflow-wrap: anywhere; user-select: all; }
.copyable output.pair-code { font-size: 26px; font-weight: 650; letter-spacing: .14em; padding: 8px 16px; color: var(--text); }
.copy { position: relative; display: inline-flex; align-items: center; gap: 8px; }
.copy-button { min-inline-size: 24px; min-block-size: 24px; }
.copy-button[data-copied] { border-color: var(--ok); color: var(--ok); }
.copy-button[data-failed] { border-color: var(--mis); color: var(--mis); }
.copy .tip { font-size: 12px; color: var(--muted); opacity: 0; transition: opacity .15s; }      /* shown and hidden by opacity, so it stays readable to a screen reader */
.copy .tip:not(:empty) { opacity: 1; }
.pair-wait { display: flex; align-items: center; gap: 10px; margin: 2px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.pair-wait.done { background: var(--ok-soft); color: var(--ok); font-weight: 550; }
.pair-wait.late { background: var(--mis-soft); color: var(--mis); }
dialog.dlg p.pair-wait { margin: 0; }
dialog.dlg p.pair-wait.done { color: var(--ok); } dialog.dlg p.pair-wait.late { color: var(--mis); }
dialog.dlg:has(.pair-steps) { max-width: 520px; }
@media (prefers-reduced-motion: reduce) { .copy .tip { transition: none; } }
@media (max-width: 960px) { .conn .conn-head .btn { margin-inline-start: 0; } }
fieldset.machs, fieldset.kinds { font-size: 13px; }
fieldset.kinds .opt > div { flex: 1; min-width: 0; }
fieldset.kinds .opt .inline { flex-wrap: wrap; align-items: center; }

/* ---------- 0.7: settings ---------- */
/* One tab, set apart from the daily ones, leads to everything that is set up once. */
.tab-settings { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: 14px; position: relative; }
.tab-settings::before { content: ""; position: absolute; inset-block: 7px; inset-inline-start: -8px; border-inline-start: 1px solid var(--border-strong); }

.settings { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100% - 56px); }
.set-nav { position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow: auto; padding: 24px 12px; border-right: 1px solid var(--border); background: var(--surface); }
.set-nav > h2 { font-size: 17px; margin: 0 10px 14px; }
.set-nav .office-pick { margin: 0 10px 10px; }
.set-nav h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; margin: 20px 10px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-nav h3:first-child { margin-top: 6px; }
.set-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.set-nav button { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: start; border: 0; background: none; border-radius: 8px; padding: 7px 10px; font-size: 13.5px; font-weight: 500; color: var(--text); }
.set-nav button:hover { background: var(--surface-2); }
/* the section in view is told apart by more than colour: it is bolder and carries a bar */
.set-nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
.set-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.set-nav .mark { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--hlf); flex: none; }
.set-nav button.unsaved .mark { display: block; }
.set-main { min-width: 0; }
.set-main > .page { max-width: 1120px; }
.set-main span.mono, .set-main small.mono { font-family: var(--mono); font-size: .95em; }

.set-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 14px; max-width: 780px; min-width: 0; }
.set-card h2 { font-size: 14.5px; }
.set-card p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.set-form { display: grid; gap: 14px; }
.set-form .field > small { color: var(--faint); font-size: 11.5px; }
.set-form .field input:disabled { background: var(--surface-2); color: var(--muted); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.set-row + .set-row { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.set-row > div:first-child { flex: 1 1 280px; min-width: 0; }
.set-foot { color: var(--muted); font-size: 12.5px; margin: 10px 2px 0; max-width: 780px; }
.save-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.save-bar .end { margin-inline-start: auto; }
.save-bar.sticky { position: sticky; bottom: 0; z-index: 4; max-width: 780px; padding: 12px 0; background: var(--bg); border-top: 1px solid var(--border); }
form.changed .save-bar [data-state] { color: var(--hlf); font-weight: 550; }
.empty-state .row-actions { justify-content: center; }
.year-pick { display: inline-flex; align-items: center; gap: 6px; margin-inline-end: 6px; }
.year-pick b { min-width: 44px; text-align: center; font-size: 15px; font-variant-numeric: tabular-nums; }
.toolbar .inline-form { margin: 0; flex: 1 1 420px; }

/* overview: one card per part of the office's set-up; the dot says how it stands, the words say why */
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ov-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ov-card h2 { font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.ov-card h2::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; }
.ov-card.ok h2::before { background: var(--ok); }
.ov-card.bad h2::before { background: var(--mis); }
.ov-card.todo h2::before { background: var(--hlf); }
.ov-card p { margin: 0; color: var(--muted); font-size: 13px; }
.ov-card p b { color: var(--text); font-weight: 600; }
.ov-card .btn { margin-top: auto; }
.ov-card > p:last-of-type { margin-bottom: 8px; }

/* attendance rules: a card per subject; in it, a rule a row, said on the left and set on the right */
form.rules { max-width: 780px; }
fieldset.set-card { padding: 0; }
fieldset.set-card > legend { float: inline-start; inline-size: 100%; padding: 16px 20px 12px; font-size: 14.5px; font-weight: 650; }
fieldset.set-card > legend + * { clear: both; }
.card-intro { margin: -8px 0 0 !important; padding: 0 20px 14px; }
.rule { display: flex; align-items: center; justify-content: space-between; gap: 10px 28px; flex-wrap: wrap; padding: 13px 20px; border-top: 1px solid var(--border); }
label.rule { cursor: pointer; }
.rule-text { flex: 1 1 300px; min-width: 0; display: grid; gap: 2px; }
.rule-text b { font-size: 13.5px; font-weight: 600; }
.rule-text span { color: var(--muted); font-size: 12.5px; }
.rule-input { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.rule-input input[type=number], .rule-input input[type=time] { height: 36px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 0 8px; background: var(--surface); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; }
.rule-input input[type=number] { width: 66px; text-align: end; }
.rule-input input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rule-input input:user-invalid { border-color: var(--mis); box-shadow: 0 0 0 3px var(--mis-soft); }
.rule-input input:disabled { background: var(--surface-2); color: var(--muted); }
.rule .unit { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.rule .usual { color: var(--faint); font-size: 11.5px; }
.rule .days-pick { margin: 0; }
/* a switch: a checkbox drawn as one, so it still works as a checkbox does */
input.toggle { appearance: none; inline-size: 38px; block-size: 22px; margin: 0; flex: none; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; }
input.toggle::before { content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px; inline-size: 18px; block-size: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: translate .15s; }
input.toggle:checked { background: var(--accent); }
input.toggle:checked::before { translate: 16px 0; }
input.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input.toggle:disabled { opacity: .55; cursor: default; }
@media (prefers-reduced-motion: reduce) { input.toggle, input.toggle::before { transition: none; } }

/* server: what it was installed with, read-only */
.set-list { margin: 12px 0 0; }
.set-list > div { display: flex; justify-content: space-between; gap: 6px 24px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.set-list > div:last-child { padding-bottom: 0; }
.set-list dt { flex: 1 1 280px; display: grid; gap: 2px; font-size: 13.5px; }
.set-list dt small { color: var(--muted); font-size: 12.5px; }
.set-list dd { margin: 0; display: grid; gap: 2px; justify-items: end; text-align: end; font-size: 13.5px; }
.set-list dd small { color: var(--faint); font-size: 11px; }

@media (max-width: 960px) {
  .settings { grid-template-columns: 1fr; }
  .set-nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 12px 8px; }
  .set-nav > h2 { display: none; }
  .set-nav nav { display: flex; align-items: center; gap: 2px; overflow-x: auto; }
  .set-nav h3, .set-nav h3:first-child { margin: 0 4px 0 12px; flex: none; }
  .set-nav ul { display: flex; gap: 2px; }
  .set-nav button { white-space: nowrap; }
  .set-nav button[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
  .rule-input { align-items: flex-start; }
  .set-list dd { justify-items: start; text-align: start; }
  .tab-settings { margin-inline-start: 8px; }
  /* a narrow window: the tabs scroll sideways, so that Settings and the menu of who is signed in stay within reach */
  .topbar { gap: 8px; }
  .tabs { flex: 1; min-width: 0; overflow-x: auto; }
  .tab { flex: none; white-space: nowrap; }
}

/* ---- 0.8: waiting, work in the background, long tables ---- */
/* A line across the top of the page while an answer is waited for. */
.activity { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 400; overflow: hidden; background: color-mix(in srgb, var(--accent) 18%, transparent); pointer-events: none; }
.activity::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 34%; border-radius: 3px; background: var(--accent); animation: sweep 1.15s ease-in-out infinite; }
@keyframes sweep { from { transform: translateX(-110%); } to { transform: translateX(310%); } }
/* What is being waited for, in words. Over an open dialog too. */
.activity-note { position: fixed; top: 62px; left: 50%; translate: -50% 0; z-index: 400; display: inline-flex; align-items: center; gap: 9px; padding: 8px 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 999px; box-shadow: var(--shadow); font-size: 13px; font-weight: 550; pointer-events: none; animation: rise .18s ease-out; }
.activity[hidden], .activity-note[hidden], .tasks[hidden] { display: none; }
/* The part of the page a slow answer will fill: what is there stays, dimmed, and cannot be clicked meanwhile. */
.pending { min-height: 120px; }
.pending > * { opacity: .45; pointer-events: none; transition: opacity .15s; }
/* A button doing what was asked of it. */
.btn.working { position: relative; color: transparent !important; }
.btn.working::after { content: ""; position: absolute; inset: 0; margin: auto; width: 15px; height: 15px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.btn.primary.working::after { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }
.btn.working:disabled { opacity: .8; }
.toast.busy { display: flex; align-items: center; gap: 10px; }
.toast.busy .spinner { flex: none; border-color: color-mix(in srgb, var(--bg) 35%, transparent); border-top-color: var(--bg); }
/* The row that stands for the rows of a long table not drawn yet. */
tr.more-rows td { text-align: left; padding: 14px 16px; color: var(--muted); font-size: 12.5px; background: var(--surface-2); height: 46px; }
tr.more-rows .spinner { display: inline-block; vertical-align: -3px; margin-right: 8px; width: 13px; height: 13px; }
/* Work the server does on its own time, in the corner where it is out of the way. */
.tasks { position: fixed; left: 18px; bottom: 18px; z-index: 119; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.task { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(20, 24, 40, .16); padding: 12px 14px; display: grid; gap: 8px; animation: rise .18s ease-out; }
.task.still { animation: none; }
.task-head { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; line-height: 1.35; }
.task-head b { flex: 1; font-weight: 600; }
.task-head .spinner { flex: none; margin-top: 1px; }
.task-head .btn.icon { flex: none; margin: -6px -8px -6px 0; }
.task-mark { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--ok); }
.task.failed .task-mark { background: var(--mis); }
.task.failed { border-color: var(--mis); }
.task small { color: var(--muted); font-size: 12px; }
.task progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 6px; overflow: hidden; background: var(--border); accent-color: var(--accent); }
.task progress::-webkit-progress-bar { background: var(--border); border-radius: 6px; }
.task progress::-webkit-progress-value { background: var(--accent); border-radius: 6px; transition: width .4s; }
.task progress::-moz-progress-bar { background: var(--accent); border-radius: 6px; }
@media (max-width: 640px) { .tasks { left: 10px; right: 10px; bottom: 10px; width: auto; } .toasts { bottom: 96px; } }
@media (prefers-reduced-motion: reduce) {
  .activity::before { animation: none; width: 100%; opacity: .7; }
  .btn.working::after, .spinner { animation-duration: 2.4s; }
  .pending > *, .task progress::-webkit-progress-value { transition: none; }
}
@media print { .activity, .activity-note, .tasks, tr.more-rows { display: none !important; } .pending > * { opacity: 1; } }
