/* PavOS admin - plain CSS, desktop + tablet. Simplicity over looks. */
:root {
  --bg: #f5f7fa;
  --fg: #16202a;
  --muted: #5b6875;
  --card: #ffffff;
  --border: #d5dce4;
  --accent: #0b3d6b;
  --accent-fg: #ffffff;
  --accent-soft: #e3edf7;
  --error: #b42318;
  --ok: #1a7f37;
  --ok-bg: #dcf5e3;
  --warn: #8a5a00;
  --warn-bg: #fff1c7;
  --bad: #b42318;
  --bad-bg: #fde2df;
  --info: #0b5cad;
  --info-bg: #e1eefc;
  --weekend: #eef1f5;
  --holiday: #fbe9d7;
  --today: #fff7c2;
  --sidebar: 12.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151b;
    --fg: #e6ebf0;
    --muted: #9aa7b4;
    --card: #182028;
    --border: #2b3742;
    --accent: #1d6fb0;
    --accent-soft: #1b3044;
    --error: #ff8a80;
    --ok: #6fdc8c;
    --ok-bg: #173524;
    --warn: #f5c451;
    --warn-bg: #3a2f10;
    --bad: #ff8a80;
    --bad-bg: #3d1a17;
    --info: #8cc4ff;
    --info-bg: #15304c;
    --weekend: #1d2630;
    --holiday: #3a2a1a;
    --today: #3b3712;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--info); }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
h4 { font-size: 0.95rem; margin: 0.75rem 0 0.4rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); }
.warn { color: var(--warn); }
.pre { white-space: pre-line; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------------------------------------- frame */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  padding-top: max(0.6rem, env(safe-area-inset-top));
  background: var(--accent);
  color: var(--accent-fg);
}
.topbar h1 { font-size: 1.2rem; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 0.9rem; opacity: 0.9; }
.mode-badge { background: #f5c451; color: #3a2f10; border-radius: 0.3rem; padding: 0.1rem 0.5rem; font-size: 0.8rem; font-weight: 700; }

.screen { flex: 1; padding: 2rem 1rem; display: flex; justify-content: center; align-items: flex-start; }
.card.narrow { max-width: 30rem; width: 100%; }

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: calc(100vh - 3rem);
}
#nav { display: flex; flex-direction: column; padding: 0.5rem; gap: 0.15rem; overflow-y: auto; }
#nav a {
  padding: 0.55rem 0.75rem;
  border-radius: 0.4rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
}
#nav a:hover { background: var(--accent-soft); }
#nav a.active { background: var(--accent); color: var(--accent-fg); }
.sidebar-foot { margin-top: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }

main#view { flex: 1; min-width: 0; padding: 1rem 1.25rem 2rem; outline: none; }

footer { padding: 0.75rem; text-align: center; font-size: 0.8rem; color: var(--muted); }

/* Tablet portrait: menu on top as a scrolling strip. */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--border); }
  #nav { flex-direction: row; overflow-x: auto; flex: 1; }
  #nav a { white-space: nowrap; }
  .sidebar-foot { margin: 0; flex-direction: row; align-items: center; }
  main#view { padding: 0.75rem; }
}

/* ---------------------------------------------------------------- building blocks */

.card {
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  margin-bottom: 1rem;
}
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; }
.two-col > .card { margin-bottom: 0; }
.two-col + * { margin-top: 1rem; }
.empty { padding: 0.5rem 0; }
.notice { background: var(--warn-bg); color: var(--warn); padding: 0.5rem 0.75rem; border-radius: 0.4rem; margin-bottom: 0.75rem; }
.badge { display: inline-block; min-width: 1.4rem; padding: 0 0.35rem; border-radius: 0.7rem; background: var(--accent-soft); font-size: 0.8rem; text-align: center; }
.badge:empty { display: none; }

button {
  min-height: 2.4rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 0.4rem;
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--fg); border-color: var(--border); }
button.secondary:hover { border-color: var(--accent); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.secondary.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.small { min-height: 2rem; padding: 0.2rem 0.7rem; font-size: 0.88rem; }
button:disabled { opacity: 0.55; cursor: progress; }
button.loading::after { content: ' …'; }

input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.4rem 0.55rem;
  min-height: 2.4rem;
  max-width: 100%;
}
textarea { min-height: auto; width: 100%; resize: vertical; }
input[type='checkbox'] { min-height: auto; width: 1.1rem; height: 1.1rem; vertical-align: middle; }
input.search { min-width: 12rem; }
input.filled, select.filled { background: var(--info-bg); }

.chip {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-muted { background: var(--weekend); color: var(--muted); }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a { padding: 0.5rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--fg); border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; background: var(--card); }
table.data th, table.data td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { font-size: 0.82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.data th.num { text-align: right; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--accent-soft); }
table.data tr.selected td { background: var(--accent-soft); box-shadow: inset 0 0 0 0 var(--accent); }
table.data tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.count { margin: 0 0 0.4rem; font-size: 0.85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 0.75rem; }
.actions.inline { margin: 0; justify-content: flex-start; flex-wrap: nowrap; }
td.row-actions { white-space: nowrap; }
.secondary-actions { justify-content: flex-start; border-top: 1px solid var(--border); padding-top: 0.75rem; }

/* ---------------------------------------------------------------- list + sticky detail */

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(22rem, 34rem); gap: 1rem; align-items: start; }
.list-pane { min-width: 0; }
.detail-pane { position: sticky; top: 0.75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.sub { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 0.25rem; }
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .detail-pane { position: static; max-height: none; }
}

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.6rem 0.8rem; }
.field { display: flex; flex-direction: column; gap: 0.2rem; }
.field label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.field.wide { grid-column: 1 / -1; }
.field-check label { color: var(--fg); font-weight: 500; display: flex; align-items: center; gap: 0.4rem; }
.field small { font-size: 0.78rem; }
.readonly { padding: 0.4rem 0; }
.checkboxes { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
.check { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--fg); font-weight: 500; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0.5rem 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.doc-rows { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.5rem; }
.doc-row { display: grid; grid-template-columns: 11rem 1fr 10rem auto; gap: 0.4rem; }
fieldset.card { min-width: 0; }
fieldset.card legend { font-weight: 700; padding: 0 0.3rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 0.5rem 0; }

/* ---------------------------------------------------------------- dialogs, toasts */

dialog.dialog {
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0;
  width: min(34rem, calc(100vw - 2rem));
  background: var(--card);
  color: var(--fg);
}
dialog.dialog.wide { width: min(52rem, calc(100vw - 2rem)); }
dialog.dialog.import-dialog { width: min(84rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); }
.import-sheet { margin: 1rem 0; }
.import-sheet h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.import-skipped { margin: 0.8rem 0; }
.warn-list { margin: 0; padding-left: 1.1rem; color: var(--warn); }
tr.needs-choice { background: var(--warn-bg); }
.strong { font-weight: 600; }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
.dialog-form { padding: 1.1rem 1.2rem; }

#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 1000; max-width: 26rem; }
.toast { padding: 0.65rem 0.9rem; border-radius: 0.5rem; background: var(--card); border: 1px solid var(--border); box-shadow: 0 4px 16px rgb(0 0 0 / 0.15); }
.toast-ok { border-left: 5px solid var(--ok); }
.toast-error { border-left: 5px solid var(--bad); }
.toast-warn { border-left: 5px solid var(--warn); }
.toast-info { border-left: 5px solid var(--info); }

/* ---------------------------------------------------------------- attendance grid */

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; font-size: 0.85rem; margin-bottom: 0.6rem; }
.legend-item { padding: 0.05rem 0.45rem; border-radius: 0.3rem; }
.grid-wrap { overflow: auto; max-height: calc(100vh - 14rem); border: 1px solid var(--border); border-radius: 0.5rem; background: var(--card); }
table.att-grid { border-collapse: separate; border-spacing: 0; font-size: 0.82rem; }
table.att-grid th, table.att-grid td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0; text-align: center; }
table.att-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--card); padding: 0.25rem 0; min-width: 2.35rem; }
table.att-grid .day-num { display: block; font-weight: 700; }
table.att-grid .day-wd { display: block; font-size: 0.72rem; color: var(--muted); font-weight: 400; }
table.att-grid .name-col {
  position: sticky; left: 0; z-index: 1;
  background: var(--card);
  text-align: left; padding: 0.25rem 0.5rem;
  min-width: 11rem; max-width: 14rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
table.att-grid thead .name-col { z-index: 3; }
table.att-grid .total-col { font-weight: 700; min-width: 2.6rem; padding: 0 0.3rem; }
table.att-grid tr.grp-company th { text-align: left; background: var(--accent); color: var(--accent-fg); padding: 0.3rem 0.5rem; position: sticky; left: 0; }
td.cell { cursor: pointer; height: 2.3rem; line-height: 1.05; }
td.cell:hover, td.cell:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
td.cell .code { display: block; font-weight: 700; font-size: 0.95rem; }
td.cell .job { display: block; font-size: 0.66rem; color: var(--muted); }
.weekend { background: var(--weekend); }
.holiday { background: var(--holiday); }
.att-grid .today { box-shadow: inset 0 0 0 2px var(--warn); }
.att-grid thead th.today { background: var(--today); }
.st-worked .code, b.st-worked, .legend-item.st-worked b { color: var(--ok); }
.st-vacation .code, b.st-vacation, .legend-item.st-vacation b { color: var(--info); }
.st-sick .code, b.st-sick, .legend-item.st-sick b { color: var(--warn); }
.st-holiday .code, b.st-holiday, .legend-item.st-holiday b { color: var(--muted); }
.st-absent .code, b.st-absent, .legend-item.st-absent b { color: var(--muted); }
.st-auto_absent .code, b.st-auto_absent, .legend-item.st-auto_absent b { color: var(--bad); }
td.st-auto_absent { background: var(--bad-bg); }
td.src-admin { box-shadow: inset 0 -3px 0 var(--info); }
.legend-item.src-admin { box-shadow: inset 0 -3px 0 var(--info); }
td.dim { opacity: 0.35; }

/* ---------------------------------------------------------------- today */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.75rem 1rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-warn .stat-value { color: var(--warn); }
.stat-ok .stat-value { color: var(--ok); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.75rem; }
.job-card { margin: 0; }
.job-card h3 { margin-top: 0; }
.job-card p { margin: 0.1rem 0; }
ul.people { list-style: none; padding: 0; margin: 0.4rem 0; }
ul.people li { padding: 0.2rem 0; border-bottom: 1px dashed var(--border); }
.closing { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.closing p { margin: 0.2rem 0; }

/* ---------------------------------------------------------------- runs, files */

.runs details.run { padding: 0.5rem 0.9rem; margin-bottom: 0.5rem; }
.runs summary { cursor: pointer; }
.summary-line { margin-left: 1.2rem; }
pre.log { white-space: pre-wrap; font-size: 0.8rem; background: var(--bg); padding: 0.6rem; border-radius: 0.4rem; max-height: 24rem; overflow: auto; }
ul.files { margin: 0; padding-left: 1.1rem; }

.big-pin { font-size: 2.2rem; font-weight: 700; letter-spacing: 0.3rem; text-align: center; margin: 0.8rem 0; font-variant-numeric: tabular-nums; }
