:root {
  /* COS AI brand: red #d10216, black, light grey */
  --paper: #f5f5f6;
  --surface: #ffffff;
  --ink: #141416;
  --ink-soft: #5c5c66;
  --line: #e4e4e8;
  --stamp: #d10216;        /* brand red: buttons, links, the one bold colour */
  --stamp-tint: #fde8ea;
  --on-stamp: #ffffff;
  --data: #26262b;         /* neutral fill for progress bars, so red keeps meaning "brand"/"problem" */
  /* Sidebar */
  --nav-bg: #0b0b0c; --nav-ink: #c4c4ca; --nav-hover: #1b1b1e; --nav-active: #2b0c10; --nav-active-ink: #ffffff;
  /* Today hero */
  --hero-a: #141416; --hero-b: #a3021a; --on-hero: #ffffff; --on-hero-soft: #e6d3d6; --hero-ink: #a3021a;
  /* Status text (chips, numbers) - all >= 4.5:1 on their tint */
  --present: #137148;
  --present-tint: #e0f3ea;
  --late: #955400;
  --late-tint: #fcefd6;
  --absent: #b0172a;
  --absent-tint: #fde7e9;
  --leave: #5443c4;
  --leave-tint: #ece9fb;
  /* Chart fills (validated as a set: on time, late, leave, absent) */
  --fill-present: #1baf7a; --fill-late: #eda100; --fill-leave: #6250d6; --fill-absent: #e34948; --fill-empty: #e4e4e8;
  --radius-s: 6px;
  --radius-m: 12px;
  --shadow: 0 1px 2px rgb(16 16 20 / 0.05);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d0d0f; --surface: #18181b; --ink: #ededf0; --ink-soft: #a1a1aa; --line: #2c2c31;
    --stamp: #ff5a67; --stamp-tint: #3a1418; --on-stamp: #1a0004; --data: #d4d4d8;
    --nav-bg: #000000; --nav-ink: #a8a8b0; --nav-hover: #161618; --nav-active: #2e0d12; --nav-active-ink: #ffffff;
    --hero-a: #141416; --hero-b: #7d0214; --on-hero: #ffffff; --on-hero-soft: #dcc5c8; --hero-ink: #a3021a;
    --present: #4fd1a0; --present-tint: #12352b; --late: #f0b048; --late-tint: #3a2e17;
    --absent: #ff8a8f; --absent-tint: #3d1a1d; --leave: #b3a8ff; --leave-tint: #29244a;
    --fill-present: #199e70; --fill-late: #c98500; --fill-leave: #9085e9; --fill-absent: #e66767; --fill-empty: #2c2c31;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0d0d0f; --surface: #18181b; --ink: #ededf0; --ink-soft: #a1a1aa; --line: #2c2c31;
  --stamp: #ff5a67; --stamp-tint: #3a1418; --on-stamp: #1a0004; --data: #d4d4d8;
  --nav-bg: #000000; --nav-ink: #a8a8b0; --nav-hover: #161618; --nav-active: #2e0d12; --nav-active-ink: #ffffff;
  --hero-a: #141416; --hero-b: #7d0214; --on-hero: #ffffff; --on-hero-soft: #dcc5c8; --hero-ink: #a3021a;
  --present: #4fd1a0; --present-tint: #12352b; --late: #f0b048; --late-tint: #3a2e17;
  --absent: #ff8a8f; --absent-tint: #3d1a1d; --leave: #b3a8ff; --leave-tint: #29244a;
  --fill-present: #199e70; --fill-late: #c98500; --fill-leave: #9085e9; --fill-absent: #e66767; --fill-empty: #2c2c31;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--stamp); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--nav-bg) 220px, transparent 220px); }
.side {
  padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; background: var(--nav-bg); color: var(--nav-ink);
}
.brand { padding: 0 2px 18px; }
.brand .logo { display: block; background: #ffffff; border-radius: var(--radius-s); padding: 8px 10px; }
.brand .logo img { display: block; width: 100%; height: auto; }
.brand .app-name { display: block; margin: 10px 8px 0; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--nav-ink); }
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: var(--radius-s); color: var(--nav-ink); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--nav-hover); color: var(--nav-active-ink); }
.nav-link.active { background: var(--nav-active); color: var(--nav-active-ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--stamp); }
.nav-count { font-size: 0.75rem; background: var(--stamp); color: var(--on-stamp); border-radius: 99px; padding: 0 7px; font-weight: 700; }
.side .nav-count { background: #d10216; color: #ffffff; }
.side-foot { margin-top: auto; padding: 10px; border-top: 1px solid rgb(255 255 255 / 0.1); }
.side-foot .who { font-weight: 600; color: var(--nav-active-ink); }
.side-foot .muted { color: var(--nav-ink); }
.side-foot .btn { background: transparent; color: var(--nav-ink); border-color: rgb(255 255 255 / 0.22); }
.side-foot .btn:hover { color: var(--nav-active-ink); border-color: rgb(255 255 255 / 0.5); }
main { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1840px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin-top: 4px; }

.topbar, .nav-ic, .nav-more { display: none; }
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  /* Top bar with the logo (the bell sits on its right); bottom bar with four pages and More */
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 15; height: 56px; padding: 0 64px 0 16px;
    background: var(--surface); border-bottom: 1px solid var(--line); }
  .topbar img { height: 28px; width: auto; background: #ffffff; border-radius: 6px; padding: 3px 6px; }
  .topbar span { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
  .side {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 15;
    flex-direction: row; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .brand, .side-foot, .side .nav-link:not(.nav-primary):not(.nav-more) { display: none; }
  .nav-link { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px; font-size: 0.7rem; padding: 6px 2px;
    text-align: center; white-space: nowrap; position: relative; border: 0; background: none; font-family: inherit; cursor: pointer; }
  .nav-link.active { box-shadow: none; background: var(--nav-active); }
  .nav-ic { display: block; line-height: 0; }
  .nav-ic svg { width: 22px; height: 22px; }
  .nav-text { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav-more { display: flex; color: var(--nav-ink); }
  .side .nav-link .nav-count { position: absolute; top: 2px; left: calc(50% + 6px); font-size: 0.65rem; padding: 0 5px; }
  main { padding: 18px 16px 96px; }
  .page-head { margin-bottom: 16px; }
  h1 { font-size: 1.45rem; }
}

/* ---------- Building blocks ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2 > .panel { margin-top: 0; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius-s); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--ink-soft); }
.btn.primary { background: var(--stamp); border-color: var(--stamp); color: var(--on-stamp); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--absent); }
.btn.small { padding: 4px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn { font: inherit; border: 0; background: none; color: var(--ink-soft); cursor: pointer; padding: 4px 8px; font-size: 1rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

label.field { display: grid; gap: 4px; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 8px 10px; width: 100%;
}
textarea { min-height: 120px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters label.field { min-width: 150px; }

.tabs { display: inline-flex; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-s); overflow-x: auto; background: var(--surface); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; white-space: nowrap; font: inherit; border: 0; background: none; padding: 7px 14px; cursor: pointer; color: var(--ink-soft); font-weight: 500; }
.tabs button + button { border-left: 1px solid var(--line); }
.tabs button.on { background: var(--stamp-tint); color: var(--stamp); font-weight: 700; }

/* Status chips: the dot carries the colour, the word carries the meaning */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.present, .chip.done { background: var(--present-tint); color: var(--present); }
.chip.late, .chip.in_progress, .chip.medium { background: var(--late-tint); color: var(--late); }
.chip.absent, .chip.high, .chip.overdue { background: var(--absent-tint); color: var(--absent); }
.chip.half_day, .chip.todo, .chip.low { background: var(--paper); color: var(--ink-soft); }
.chip.leave { background: var(--leave-tint); color: var(--leave); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-weight: 600; color: var(--ink-soft); font-size: 0.8rem; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
td.r, th.r { text-align: right; }

.empty { padding: 28px 8px; text-align: center; color: var(--ink-soft); }
.empty .btn { margin-top: 10px; }

/* ---------- Today: the register clock and stamp ---------- */
.clock-panel {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: 28px;
  background: linear-gradient(120deg, var(--hero-a), var(--hero-b)); border: 0; color: var(--on-hero);
}
.clock-panel .muted, .clock-panel .clock .sec, .clock-panel .clock-date { color: var(--on-hero-soft); }
.clock-panel .btn.primary { background: #ffffff; border-color: #ffffff; color: var(--hero-ink); }
.clock-panel .btn:not(.primary) { background: rgb(255 255 255 / 0.12); border-color: rgb(255 255 255 / 0.5); color: var(--on-hero); }
.clock-panel .stamp { background: #ffffff; border-color: #ffffff; color: var(--hero-ink); box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); }
.clock-panel .stamp.late { color: #955400; }
@media (max-width: 640px) { .clock-panel { grid-template-columns: 1fr; padding: 20px; gap: 16px; } .clock { font-size: 3.2rem; } .punch { width: 100%; } .clock-actions { width: 100%; } }
.clock { font-size: clamp(3rem, 8vw, 5rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.clock .sec { color: var(--ink-soft); font-weight: 500; font-size: 0.45em; letter-spacing: 0; margin-left: 4px; }
.clock-date { margin-top: 8px; color: var(--ink-soft); }
.clock-actions { display: grid; gap: 10px; justify-items: end; }
@media (max-width: 640px) { .clock-actions { justify-items: start; } }
.punch { font-size: 1.05rem; padding: 14px 26px; border-radius: var(--radius-m); }

.stamps { display: flex; gap: 14px; flex-wrap: wrap; }
.stamp {
  border: 2.5px solid var(--stamp); color: var(--stamp); border-radius: 8px; padding: 6px 14px 4px;
  transform: rotate(-4deg); text-align: center; font-weight: 800; line-height: 1.1; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums; background: var(--surface);
}
.stamp b { display: block; font-size: 1.6rem; letter-spacing: -0.01em; }
.stamp span { font-size: 0.7rem; }
.stamp.out { transform: rotate(3deg); }
.stamp.late { border-color: var(--late); color: var(--late); }
.stamp.fresh { animation: thump 0.38s cubic-bezier(.2,1.6,.4,1); }
@keyframes thump { from { transform: scale(1.6) rotate(-12deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .stamp.fresh { animation: none; } }

/* ---------- Today: tiles, attendance bar, team progress ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin: 16px 0; }

.tile {
  --c: var(--stamp); --t: var(--stamp-tint);
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px;
  color: inherit; text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
a.tile:hover { border-color: var(--c); transform: translateY(-1px); }
.tile-icon { grid-row: span 2; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--t); color: var(--c); }
.tile-icon svg { width: 22px; height: 22px; }
.tile-value { font-size: 1.75rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.tile-label { font-size: 0.85rem; color: var(--ink-soft); }
.tile.green { --c: var(--present); --t: var(--present-tint); }
.tile.amber { --c: var(--late); --t: var(--late-tint); }
.tile.red { --c: var(--absent); --t: var(--absent-tint); }
.tile.violet { --c: var(--leave); --t: var(--leave-tint); }
.tile.alert .tile-value { color: var(--c); }
.tile.quiet .tile-icon { background: var(--paper); color: var(--ink-soft); }

.team-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 960px) { .team-grid { grid-template-columns: minmax(0, 1fr); } }
.headline { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.headline strong { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.headline span { color: var(--ink-soft); }
.att-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--fill-empty); }
.att-bar > span { min-width: 4px; }
.att-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px 16px; margin: 14px 0 0; padding: 0; list-style: none; }
.att-legend li { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: center; }
.att-legend i { width: 10px; height: 10px; border-radius: 3px; grid-row: span 2; }
.att-legend b { font-size: 1.15rem; font-weight: 700; }
.att-legend span { font-size: 0.8rem; color: var(--ink-soft); grid-column: 2; }
.sw-present { background: var(--fill-present); } .sw-late { background: var(--fill-late); }
.sw-leave { background: var(--fill-leave); } .sw-absent { background: var(--fill-absent); }
.sw-empty { background: var(--fill-empty); outline: 1px solid var(--line); }
.mini-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-fig { border-radius: var(--radius-s); background: var(--paper); padding: 12px; text-decoration: none; color: inherit; }
.mini-fig strong { display: block; font-size: 1.45rem; font-weight: 800; }
.mini-fig span { font-size: 0.8rem; color: var(--ink-soft); }
.mini-fig.warn { background: var(--absent-tint); } .mini-fig.warn strong { color: var(--absent); }
a.mini-fig:hover span { color: var(--stamp); }
.people { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.people li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; font-size: 0.9rem; }
.people .progress { max-width: none; grid-column: 1 / -1; }
.section-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 10px; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.figure { background: var(--surface); padding: 14px 16px; }
.figure strong { display: block; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.figure.warn strong { color: var(--absent); }
.figure span { font-size: 0.85rem; color: var(--ink-soft); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.task { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: start; }
.task-title { font-weight: 600; }
.task.done .task-title { text-decoration: line-through; color: var(--ink-soft); }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 0.85rem; color: var(--ink-soft); }
.task-side { display: flex; gap: 6px; align-items: center; }
.task-side select { width: auto; padding: 5px 8px; font-size: 0.85rem; }
.progress { display: inline-block; flex: 1; min-width: 80px; max-width: 220px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; vertical-align: middle; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--data); }
.task.done .progress > span { background: var(--present); }
.progress-cell { display: flex; align-items: center; gap: 8px; }
.timeline > li { padding: 8px 0; }
@media (max-width: 560px) { .task { grid-template-columns: 1fr; } }
input[type="range"] { padding: 0; accent-color: var(--stamp); }

.circular { cursor: pointer; padding: 14px 0 14px 16px; position: relative; }
.circular.unread::before { content: ""; position: absolute; left: 0; top: 21px; width: 8px; height: 8px; border-radius: 50%; background: var(--stamp); }
.circular.unread .c-title { font-weight: 700; }
.c-title { font-weight: 500; }
.c-body { margin-top: 10px; white-space: pre-wrap; max-width: 72ch; }
.c-foot { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login h1 { margin-bottom: 4px; }
.login form { display: grid; gap: 14px; margin-top: 24px; }
.login .stamp { display: inline-block; margin-bottom: 22px; }
.login { border-top: 4px solid var(--stamp); }
.login-logo { display: block; width: 200px; max-width: 100%; height: auto; margin-bottom: 20px; border-radius: var(--radius-s); background: #ffffff; padding: 6px 8px; }
.err { color: var(--absent); font-size: 0.88rem; min-height: 1.3em; }

/* ---------- Modal & toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius-m); padding: 8px 22px 22px; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); max-height: calc(100vh - 48px);
}
dialog::backdrop { background: rgb(15 20 30 / 0.45); }
.modal-close-row { display: flex; justify-content: flex-end; margin: 0 -14px 0 0; }
#modal-body h2 { margin-bottom: 16px; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--radius-s);
  font-weight: 600; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--absent); color: #fff; }
@media (max-width: 820px) { #toast { bottom: 84px; } }

/* ---------- v2: leave, payroll, devices ---------- */
.link-figure { text-decoration: none; color: inherit; }
.link-figure:hover span { color: var(--stamp); }
.tabs .nav-count { margin-left: 4px; }
.edited { font-size: 0.72rem; font-weight: 700; color: var(--stamp); background: var(--stamp-tint); border-radius: 4px; padding: 1px 5px; }
.punch-tag { display: inline-flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 4px 10px; margin: 0 6px 6px 0; font-weight: 700; color: var(--ink); }
.punch-tag span { font-weight: 400; font-size: 0.75rem; color: var(--ink-soft); }
.neg { color: var(--absent); font-weight: 700; }
.notice { background: var(--late-tint); color: var(--ink); border-left: 3px solid var(--late); padding: 10px 14px; border-radius: var(--radius-s); margin-bottom: 14px; }
.notice.ok { background: var(--present-tint); border-left-color: var(--present); margin: 0; }

.balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.balance { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; }
.balance-top strong { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.balance-name { font-weight: 700; margin-top: 8px; }
.meter { display: flex; height: 6px; border-radius: 99px; background: var(--paper); overflow: hidden; margin-top: 8px; }
.meter .used { background: var(--data); }
.meter .pend { background: repeating-linear-gradient(45deg, var(--data) 0 3px, transparent 3px 6px); opacity: 0.5; }

.pay-table td, .pay-table th { padding-left: 8px; padding-right: 8px; }
.sal-total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sal-total strong { font-size: 1.3rem; }
fieldset.checks { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; }
fieldset.checks legend { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); padding: 0 4px; }
fieldset.checks label { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; }
fieldset.checks input { width: auto; }
@media (max-width: 560px) { fieldset.checks { grid-template-columns: 1fr; } }

.howto h3 { margin: 16px 0 4px; }
.howto h3:first-child { margin-top: 0; }
.howto p { margin-bottom: 6px; max-width: 70ch; }
.setting { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; background: var(--paper); border-radius: var(--radius-s); padding: 10px 14px; margin: 8px 0; }
.setting dt { color: var(--ink-soft); }
.setting dd { margin: 0; font-weight: 700; }
code, pre.key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }
pre.key { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px; white-space: pre-wrap; word-break: break-all; margin: 8px 0 12px; }

/* Payslip */
dialog:has(.payslip) { width: min(760px, calc(100vw - 32px)); }
.payslip { color: var(--ink); }
.ps-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 14px; }
.ps-company { font-size: 1.25rem; font-weight: 800; }
.ps-title { text-align: right; font-weight: 800; font-size: 1.1rem; }
.ps-title span { font-weight: 500; color: var(--ink-soft); font-size: 0.95rem; }
.ps-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; margin-bottom: 14px; font-size: 0.9rem; }
.ps-grid div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--line); padding: 3px 0; }
.ps-days { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: 14px; }
.ps-days div { padding: 8px 10px; }
.ps-days div + div { border-left: 1px solid var(--line); }
.ps-days strong { display: block; font-size: 1.1rem; }
.ps-days span { font-size: 0.75rem; color: var(--ink-soft); }
.ps-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.ps-cols table { font-size: 0.9rem; }
.ps-cols tfoot td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 0; }
.ps-net { display: flex; justify-content: space-between; align-items: baseline; border: 2px solid var(--ink); border-radius: var(--radius-s); padding: 10px 14px; margin: 16px 0 6px; }
.ps-net span { font-weight: 700; }
.ps-net strong { font-size: 1.5rem; font-weight: 800; }
@media (max-width: 640px) {
  .ps-grid, .ps-cols { grid-template-columns: 1fr; }
  .ps-days { grid-template-columns: repeat(3, 1fr); }
  .ps-days div:nth-child(4) { border-left: 0; }
}
@media print {
  #app, #toast, .modal-close-row, .no-print { display: none !important; }
  body { background: #fff; }
  dialog { position: static; border: 0; padding: 0; width: 100% !important; max-height: none; color: #000; background: #fff; }
  dialog::backdrop { display: none; }
  .payslip, .payslip * { color: #000 !important; border-color: #999 !important; }
}
.clock-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--paper); border-radius: var(--radius-s); padding: 8px 12px; }
[hidden] { display: none !important; }

/* ---------- Live status ---------- */
.presence { display: inline-flex; align-items: center; gap: 7px; font-size: 0.88rem; color: var(--ink-soft); }
.presence::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: transparent; border: 2px solid var(--ink-soft); box-sizing: border-box; flex: none; }
.presence.on { color: var(--present); font-weight: 600; }
.presence.on::before { background: var(--fill-present); border-color: var(--fill-present); box-shadow: 0 0 0 3px var(--present-tint); }
table.live tr.needs td { background: var(--absent-tint); }
table.live tr.needs td:first-child { box-shadow: inset 3px 0 0 var(--absent); }
.live-strip { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 10px 12px; margin: -4px 0 16px; border-radius: var(--radius-s);
  background: var(--paper); color: inherit; text-decoration: none; font-size: 0.9rem; }
.live-strip.warn { background: var(--absent-tint); }
.live-strip.warn b { color: var(--absent); }
.live-strip:hover .muted:last-child { color: var(--stamp); }
@media (max-width: 640px) {
  table.live thead { display: none; }
  table.live tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.live tr:last-child { border-bottom: 0; }
  table.live td { padding: 0; border: 0; text-align: left; }
  table.live td:first-child { grid-column: 1 / -1; }
  table.live td[data-label]::before { content: attr(data-label); display: block; font-size: 0.72rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
  table.live tr.needs { margin: 0 -20px; padding: 12px 20px; background: var(--absent-tint); box-shadow: inset 3px 0 0 var(--absent); }
  table.live tr.needs td, table.live tr.needs td:first-child { background: none; box-shadow: none; }
  .live-tabs { display: flex; width: 100%; overflow-x: auto; }
  .live-tabs button { flex: 1; white-space: nowrap; }
}

/* ---------- Messages ---------- */
main.main-chat { max-width: none; padding: 16px clamp(12px, 2vw, 24px); }
.chat {
  display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - 32px); height: calc(100dvh - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; box-shadow: var(--shadow);
}
.chat-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: var(--surface); }
.chat-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 14px 10px; }
.chat-list-head h1 { font-size: 1.3rem; }
.chat-list-body { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.chat-list-body .section-label { margin: 6px 10px 6px; }
.chat-list-foot { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.conv { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius-s); color: inherit; text-decoration: none; }
.conv:hover { background: var(--paper); }
.conv.on { background: var(--stamp-tint); }
.conv-text { display: grid; min-width: 0; }
.conv-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-prev { font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-name { font-weight: 800; }
.conv.unread .conv-prev { color: var(--ink); }
.conv-side { display: grid; justify-items: end; gap: 3px; }
.conv-time { font-size: 0.72rem; color: var(--ink-soft); white-space: nowrap; }
.chan-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--paper); color: var(--ink-soft); font-weight: 800; font-size: 1.05rem; }

.avatar { position: relative; flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; background: var(--stamp-tint); color: var(--stamp); }
.avatar.sm { width: 32px; height: 32px; font-size: 0.78rem; }
.avatar[data-hue="1"] { background: var(--present-tint); color: var(--present); }
.avatar[data-hue="2"] { background: var(--late-tint); color: var(--late); }
.avatar[data-hue="3"] { background: var(--leave-tint); color: var(--leave); }
.avatar[data-hue="4"] { background: var(--paper); color: var(--ink); }
.avatar[data-hue="5"] { background: var(--line); color: var(--ink); }
.dot-online { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--fill-present); border: 2px solid var(--surface); }

.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat-head h2 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-back { display: none; text-decoration: none; font-size: 1.3rem; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 8px 18px 12px; }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; font-size: 0.78rem; font-weight: 700; color: var(--ink-soft); }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 0 12px; padding: 6px 8px; margin: 0 -8px; border-radius: var(--radius-s); }
.msg:not(.grouped) { margin-top: 8px; }
.msg.grouped { padding-top: 2px; padding-bottom: 2px; }
.msg:hover { background: var(--paper); }
.msg-gutter { font-size: 0.68rem; color: var(--ink-soft); text-align: center; padding-top: 3px; visibility: hidden; }
.msg:hover .msg-gutter { visibility: visible; }
.msg-head { display: flex; gap: 8px; align-items: baseline; }
.msg-body { overflow-wrap: anywhere; line-height: 1.45; }
.msg-body a { word-break: break-all; }
.msg.deleted .msg-body { color: var(--ink-soft); }
.msg-actions { position: absolute; top: -10px; right: 8px; display: none; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 1px; box-shadow: var(--shadow); }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.icon-btn.small { font-size: 0.8rem; padding: 3px 8px; }
.msg-edit textarea { min-height: 60px; margin: 4px 0 6px; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.chat-compose textarea { min-height: 42px; max-height: 160px; resize: none; line-height: 1.4; }
.chat-compose.join { justify-content: space-between; align-items: center; }
.chat-older:empty { display: none; }

.picker-search { margin: 6px 0 8px; }
.picker { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-s); }
.picker.static { max-height: 260px; }
.picker li + li { border-top: 1px solid var(--line); }
.pick { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.pick:hover, label.pick:hover { background: var(--paper); }
.picker.static .pick { cursor: default; }
.pick input[type="checkbox"] { width: auto; }
.check-row { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 500; color: var(--ink); }
.check-row input { width: auto; margin-top: 4px; }

@media (max-width: 820px) {
  main.main-chat { padding: 0 0 72px; }
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 72px); border: 0; border-radius: 0; }
  .chat .chat-main { display: none; }
  .chat.has-active .chat-list { display: none; }
  .chat.has-active .chat-main { display: flex; }
  .chat-back { display: inline-block; }
  .chat-head { padding: 10px 12px; }
  .chat-msgs { padding: 6px 12px 10px; }
  .chat-compose { padding: 10px 12px; }
  .msg:hover .msg-actions { display: none; }
  .msg:focus .msg-actions, .msg:focus-within .msg-actions { display: flex; position: static; grid-column: 2; justify-self: start; box-shadow: none; border: 0; background: none; padding: 0; margin-top: 2px; }
  .msg:focus { outline: none; background: var(--paper); }
}

/* Overtime / short time */
.ot { color: var(--present); font-weight: 700; }
.short { color: var(--late); font-weight: 700; }

/* ---------- Messages: typing, emoji, reactions ---------- */
.typing-line { min-height: 22px; padding: 0 18px; font-size: 0.8rem; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.typing-inline { color: var(--present); font-style: normal; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-soft); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: .6; } }
.emoji-btn { font-size: 1.25rem; padding: 6px; align-self: center; }
.big-emoji { font-size: 2.2rem; line-height: 1.2; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { font: inherit; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.react:hover { border-color: var(--ink-soft); }
.react.on { background: var(--stamp-tint); border-color: var(--stamp); color: var(--stamp); }
.react.add { color: var(--ink-soft); }
.msg-actions .icon-btn.small { font-size: 0.85rem; padding: 3px 6px; }
.emoji-pop { position: fixed; z-index: 60; width: 300px; max-height: 320px; overflow-y: auto; padding: 8px 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); }
.emoji-pop .section-label { margin: 8px 2px 2px; }
.emoji-quick { display: flex; justify-content: space-between; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); }
.emoji-pop button { font-size: 1.3rem; line-height: 1; padding: 5px 0; border: 0; background: none; border-radius: 6px; cursor: pointer; }
.emoji-pop button:hover, .emoji-pop button:focus-visible { background: var(--paper); }

/* ---------- Calls ---------- */
.call-btns { display: flex; gap: 4px; }
.call-btn { color: var(--ink-soft); padding: 6px 8px; border-radius: var(--radius-s); }
.call-btn:hover { background: var(--paper); color: var(--stamp); }
.avatar.lg { width: 88px; height: 88px; font-size: 1.8rem; }
.call-ui { position: fixed; z-index: 70; right: 20px; bottom: 20px; width: 340px; background: #111114; color: #fff; border-radius: 16px;
  overflow: hidden; box-shadow: 0 16px 48px rgb(0 0 0 / 0.4); display: flex; flex-direction: column; }
.call-ui.video.live { width: min(720px, calc(100vw - 40px)); }
.call-stage { position: relative; min-height: 220px; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, #3a0d12, #111114 70%); }
.call-stage video#call-remote { width: 100%; max-height: 70vh; background: #000; display: block; }
.call-ui.video:not(.live) video#call-remote { display: none; }
.call-ui.video.live .call-who { position: absolute; left: 12px; top: 10px; flex-direction: row; gap: 8px; text-shadow: 0 1px 3px #000; }
.call-ui.video.live .call-who .avatar { display: none; }
.call-who { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 12px; text-align: center; }
.call-who b { font-size: 1.1rem; }
.call-who span { color: #d6d6dc; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.call-self { position: absolute; right: 10px; bottom: 10px; width: 28%; max-width: 160px; border-radius: 8px; border: 2px solid rgb(255 255 255 / 0.6); background: #000; }
.call-bar { display: flex; justify-content: center; gap: 14px; padding: 14px; background: #1b1b1f; }
.call-ctl { display: grid; justify-items: center; gap: 4px; font: inherit; font-size: 0.75rem; color: #fff; background: none; border: 0; cursor: pointer; }
.call-ctl svg, .call-ctl .ico { width: 48px; height: 48px; padding: 13px; border-radius: 50%; background: #2e2e34; font-size: 1.2rem; line-height: 22px; box-sizing: border-box; }
.call-ctl[aria-pressed="true"] svg, .call-ctl[aria-pressed="true"] .ico { background: #fff; }
.call-ctl.accept svg { background: #1f9d55; }
.call-ctl.decline svg { background: #d10216; transform: rotate(135deg); }
@media (max-width: 820px) { .call-ui, .call-ui.video.live { left: 8px; right: 8px; bottom: 80px; width: auto; } }

/* ---------- Profile photos ---------- */
.avatar { overflow: visible; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.xs { width: 20px; height: 20px; font-size: 0.6rem; margin-left: -6px; border: 2px solid var(--surface); }
.avatar.xs:first-child { margin-left: 0; }
.avatar.xl { width: 96px; height: 96px; font-size: 2rem; }
.profile-head { justify-content: flex-start; align-items: center; gap: 20px; }
.profile-photo { display: grid; justify-items: center; gap: 8px; }
.profile-photo label.btn { cursor: pointer; }
.side-me { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; margin-bottom: 4px; }
.side-me .avatar.sm { width: 34px; height: 34px; }

/* ---------- Replies, stickers, files, seen ---------- */
.quote { display: grid; text-align: left; font: inherit; font-size: 0.82rem; width: fit-content; max-width: 100%; margin: 2px 0 4px;
  padding: 4px 10px; border: 0; border-left: 3px solid var(--stamp); border-radius: 4px; background: var(--paper); color: var(--ink-soft); cursor: pointer; }
.quote b { color: var(--ink); font-size: 0.78rem; }
.quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60ch; }
.msg.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--stamp-tint); } }
.reply-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 18px; padding: 6px 10px; font-size: 0.85rem;
  border-left: 3px solid var(--stamp); background: var(--paper); border-radius: 4px; }
.reply-bar[hidden] { display: none; }
.sticker { display: inline-grid; justify-items: center; gap: 2px; padding: 10px 14px 8px; border-radius: 16px; background: var(--paper);
  border: 1px solid var(--line); min-width: 96px; }
.sticker-emoji { font-size: 2.8rem; line-height: 1; }
.sticker-cap { font-weight: 800; font-size: 0.8rem; letter-spacing: 0.02em; text-transform: uppercase; color: var(--stamp); }
.pop-tabs { display: flex; margin-bottom: 6px; }
.pop-tabs button { flex: 1; font-size: 0.85rem !important; padding: 6px !important; }
.sticker-grid:not([hidden]) { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.emoji-pop .sticker-pick { padding: 0; font-size: inherit; }
.emoji-pop .sticker-pick .sticker { min-width: 0; width: 100%; padding: 8px 4px 6px; }
.emoji-pop .sticker-pick .sticker-emoji { font-size: 2rem; }
.emoji-pop .sticker-pick .sticker-cap { font-size: 0.62rem; }
.atts { display: grid; gap: 6px; margin: 2px 0; }
.att-img img { max-width: min(320px, 100%); max-height: 260px; border-radius: 10px; border: 1px solid var(--line); display: block; }
.att-file { display: inline-flex; gap: 10px; align-items: center; width: fit-content; max-width: 100%; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; color: inherit; text-decoration: none; background: var(--surface); }
.att-file:hover { border-color: var(--stamp); }
.att-file b { display: block; font-size: 0.9rem; overflow-wrap: anywhere; }
.att-icon { font-size: 1.6rem; }
.chat-main.drop { outline: 3px dashed var(--stamp); outline-offset: -8px; }
.seen-line { display: flex; justify-content: flex-end; min-height: 18px; font-size: 0.75rem; color: var(--ink-soft); padding: 2px 0 0; }
.seen-by { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 0.75rem; color: var(--ink-soft); background: none; border: 0; cursor: pointer; padding: 0; }
.seen-by:hover span { color: var(--stamp); }
label.emoji-btn { cursor: pointer; }

td.net, th.net { font-weight: 800; background: var(--paper); }
tfoot th { border-top: 2px solid var(--line); padding: 10px; color: var(--ink); font-size: 0.9rem; }

/* ---------- Attendance summary: month at a glance ---------- */
.month-cal .tiles { margin-top: 0; }
.month-cal .tile.quiet .tile-value { color: var(--ink); }
.off-days { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.off-days li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.cal-box { margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 14px; background: var(--surface); }
.cal-box summary { cursor: pointer; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 12px 0 8px; }
.cal-head { font-size: 0.75rem; color: var(--ink-soft); text-align: center; font-weight: 700; }
.cal-cell { min-height: 54px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: inherit; padding: 6px; text-align: left; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-cell small { font-size: 0.7rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-cell.blank { border: 0; background: none; }
.cal-cell.weekly { background: var(--paper); color: var(--ink-soft); }
.cal-cell.holiday { background: var(--leave-tint); border-color: var(--leave); color: var(--leave); font-weight: 700; }
button.cal-cell:not([disabled]) { cursor: pointer; }
button.cal-cell:not([disabled]):hover { border-color: var(--stamp); }
@media (max-width: 560px) { .cal-cell { min-height: 44px; padding: 4px; } .cal-cell small { display: none; } }

/* ---------- Tasks: filters, labels, board, checklist (Trello-style colours) ---------- */
:root {
  /* Label colours (Trello palette); dark text on all of them */
  --lb-green: #4bce97; --lb-yellow: #f5cd47; --lb-orange: #fea362; --lb-red: #f87168; --lb-purple: #9f8fef;
  --lb-blue: #579dff; --lb-sky: #6cc3e0; --lb-lime: #94c748; --lb-pink: #e774bb; --lb-gray: #8590a2; --lb-ink: #172b4d;
  /* Board */
  --list-bg: #f1f2f4; --card-bg: #ffffff; --card-ink: #172b4d; --card-soft: #44546f; --card-shadow: 0 1px 1px rgb(9 30 66 / .25), 0 0 1px rgb(9 30 66 / .31);
  /* Due badges */
  --due-soon: #f5cd47; --due-soon-ink: #533f04; --due-over: #c9372c; --due-over-ink: #ffffff; --due-done: #1f845a; --due-done-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --list-bg: #101204; --card-bg: #22272b; --card-ink: #b6c2cf; --card-soft: #8c9bab; --card-shadow: 0 1px 1px rgb(3 4 4 / .5);
    --due-over: #f87168; --due-over-ink: #1d0a08; --due-done: #4bce97; --due-done-ink: #0a2a1c;
  }
}
:root[data-theme="dark"] {
  --list-bg: #101204; --card-bg: #22272b; --card-ink: #b6c2cf; --card-soft: #8c9bab; --card-shadow: 0 1px 1px rgb(3 4 4 / .5);
  --due-over: #f87168; --due-over-ink: #1d0a08; --due-done: #4bce97; --due-done-ink: #0a2a1c;
}
.c-green { --lb: var(--lb-green); } .c-yellow { --lb: var(--lb-yellow); } .c-orange { --lb: var(--lb-orange); }
.c-red { --lb: var(--lb-red); } .c-purple { --lb: var(--lb-purple); } .c-blue { --lb: var(--lb-blue); }
.c-sky { --lb: var(--lb-sky); } .c-lime { --lb: var(--lb-lime); } .c-pink { --lb: var(--lb-pink); } .c-gray { --lb: var(--lb-gray); }

.task-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.task-filters input[type=search] { flex: 1 1 220px; min-width: 0; }
.task-filters select { width: auto; flex: 0 1 auto; }
.task-desc { max-width: 72ch; white-space: pre-wrap; margin-top: 2px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.link-btn:hover { color: var(--stamp); text-decoration: underline; }

/* Labels: solid colour pills */
.labels { display: flex; flex-wrap: wrap; gap: 4px; }
.label { border: 0; background: var(--lb); color: var(--lb-ink); border-radius: 4px; padding: 0 8px; min-height: 18px; min-width: 40px;
  font: inherit; font-size: 0.75rem; font-weight: 600; line-height: 18px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label:hover { filter: brightness(0.92); }
.label.wide { min-width: 120px; text-align: left; cursor: default; }

/* Badges: priority, due date, checklist, notes */
.badges { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--card-soft); border-radius: 4px; padding: 1px 4px; line-height: 1.4; }
.badge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.badge.due.soon { background: var(--due-soon); color: var(--due-soon-ink); }
.badge.due.overdue { background: var(--due-over); color: var(--due-over-ink); }
.badge.due.complete, .badge.steps.complete { background: var(--due-done); color: var(--due-done-ink); }
.badge.prio { font-weight: 700; }
.badge.prio.p-high { color: #c9372c; }
.badge.prio.p-medium { color: #a54800; }
.badge.prio.p-low { color: #0c66e4; }
:root[data-theme="dark"] .badge.prio.p-high { color: #fd9891; } :root[data-theme="dark"] .badge.prio.p-medium { color: #fea362; } :root[data-theme="dark"] .badge.prio.p-low { color: #85b8ff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.prio.p-high { color: #fd9891; }
  :root:not([data-theme="light"]) .badge.prio.p-medium { color: #fea362; }
  :root:not([data-theme="light"]) .badge.prio.p-low { color: #85b8ff; }
}
.who { display: inline-flex; align-items: center; gap: 6px; }
.avatar-xs { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--lb); color: var(--lb-ink);
  font-size: 0.68rem; font-weight: 700; flex: none; }

/* Board */
.board-wrap { border-radius: var(--radius-m); padding: 12px; margin-bottom: 14px; }
.board-wrap.bg-ocean { background: linear-gradient(135deg, #0c66e4, #6cc3e0); }
.board-wrap.bg-grape { background: linear-gradient(135deg, #5e4db2, #e774bb); }
.board-wrap.bg-forest { background: linear-gradient(135deg, #216e4e, #94c748); }
.board-wrap.bg-sunset { background: linear-gradient(135deg, #c9372c, #fea362); }
.board-wrap.bg-berry { background: linear-gradient(135deg, #943d73, #9f8fef); }
.board-wrap.bg-slate { background: linear-gradient(135deg, #2c3e5d, #8590a2); }
.board-wrap.bg-plain { background: var(--paper); border: 1px solid var(--line); }
.board-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; color: #fff; font-weight: 700; font-size: 1.05rem; }
.board-wrap.bg-plain .board-bar { color: var(--ink); }
.board-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.board-btn { display: inline-flex; align-items: center; gap: 6px; background: rgb(255 255 255 / .22); color: inherit; border: 0; border-radius: 6px;
  padding: 4px 10px; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.board-btn:hover { background: rgb(255 255 255 / .34); }
.board-wrap.bg-plain .board-btn { background: var(--list-bg); }
.board-btn select { width: auto; padding: 2px 4px; font-size: 0.8rem; border-radius: 4px; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.board-col { background: var(--list-bg); border-radius: 12px; padding: 8px; box-shadow: 0 1px 1px rgb(9 30 66 / .25); border-top: 4px solid var(--col);
  transition: box-shadow .15s, outline-color .15s; outline: 2px solid transparent; }
.board-col.s-todo { --col: var(--lb-blue); } .board-col.s-in_progress { --col: var(--lb-yellow); } .board-col.s-done { --col: var(--lb-green); }
.board-col.drop { outline-color: var(--col); }
.board-col header { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 8px; }
.board-col header h3 { margin: 0; font-size: 0.9rem; color: var(--card-ink); }
.col-count { background: var(--col); color: var(--lb-ink); border-radius: 99px; font-size: 0.75rem; font-weight: 700; padding: 0 8px; }
.board-cards { display: grid; gap: 8px; min-height: 8px; }
.card-task { background: var(--card-bg); color: var(--card-ink); border-radius: 8px; padding: 8px 10px; display: grid; gap: 6px; cursor: pointer;
  box-shadow: var(--card-shadow); outline: 2px solid transparent; }
.card-task:hover { outline-color: var(--lb-blue); }
.card-task:focus-visible { outline-color: var(--lb-blue); }
.card-task[draggable=true] { cursor: grab; }
.card-task.dragging { opacity: .45; transform: rotate(2deg); }
.card-task.is-done .card-title { color: var(--card-soft); }
.card-title { font-size: 0.92rem; line-height: 1.35; word-break: break-word; }
.card-people { margin-left: auto; display: inline-flex; }
.card-progress { height: 4px; border-radius: 99px; background: var(--list-bg); overflow: hidden; }
.card-progress > span { display: block; height: 100%; background: var(--lb-blue); border-radius: inherit; }
.add-card { margin-top: 8px; }
.add-card-open { width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 6px 8px; color: var(--card-soft); font: inherit; font-size: 0.88rem; cursor: pointer; }
.add-card-open:hover { background: rgb(9 30 66 / .08); color: var(--card-ink); }
.add-card-form textarea { width: 100%; resize: vertical; border-radius: 8px; margin-bottom: 6px; background: var(--card-bg); color: var(--card-ink); box-shadow: var(--card-shadow); }
.add-card-form .row { gap: 6px; }

/* Labels dialog */
.label-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.label-list li { display: grid; grid-template-columns: minmax(120px, 1fr) auto; gap: 4px 10px; align-items: center; }
.swatches { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 28px; height: 20px; border-radius: 4px; border: 0; background: var(--lb); cursor: pointer; outline: 2px solid transparent; outline-offset: 2px; }
.swatch.on { outline-color: var(--ink); }

/* Checklist */
.checklist-box { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px; margin-bottom: 14px; }
.checklist-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.checklist-head h3 { margin: 0; font-size: 1rem; }
.checklist { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.checklist li { display: flex; align-items: center; gap: 8px; }
.checklist label { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; font-weight: 400; }
.checklist input { width: auto; accent-color: var(--due-done); }
.checklist li.done label span { text-decoration: line-through; color: var(--ink-soft); }
.step-form { display: flex; gap: 6px; }
@media (max-width: 760px) { .board { grid-template-columns: 1fr; } }

/* ---------- Everyone's tasks (landing page overview) ---------- */
:root { --seg-todo: #579dff; --seg-progress: #e2a03f; --seg-done: #1f845a; --seg-created: #8590a2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --seg-todo: #5b8ff0; --seg-progress: #b07b10; --seg-done: #259f6c; --seg-created: #6b778c; } }
:root[data-theme="dark"] { --seg-todo: #5b8ff0; --seg-progress: #b07b10; --seg-done: #259f6c; --seg-created: #6b778c; }
.seg-todo { background: var(--seg-todo); } .seg-in_progress { background: var(--seg-progress); }
.seg-done { background: var(--seg-done); } .seg-created { background: var(--seg-created); }
.ov { margin-top: 16px; }
.ov .panel-head { gap: 12px; }
.ov .panel-head h2 { margin-right: auto; }
.ov h3 { font-size: 0.95rem; margin: 0 0 8px; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi { display: grid; gap: 2px; align-content: start; padding: 12px 14px; border-radius: var(--radius-m); background: var(--paper);
  border: 1px solid var(--line); border-top: 3px solid var(--k, var(--seg-todo)); text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
.kpi:hover { transform: translateY(-1px); border-color: var(--k, var(--seg-todo)); }
.kpi.bad { --k: var(--absent); } .kpi.warn { --k: var(--fill-late); } .kpi.good { --k: var(--seg-done); }
.kpi-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.kpi.bad .kpi-value { color: var(--absent); }
.kpi-label { font-weight: 600; font-size: 0.85rem; }
.kpi-sub { font-size: 0.75rem; color: var(--ink-soft); }
.kpi-meter { display: block; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 4px; }
.kpi-meter > span { display: block; height: 100%; background: var(--seg-done); border-radius: inherit; }
.ov-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr); min-width: 0; gap: 20px; align-items: start; }
.ov-grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.ov-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.ov-toolbar h3 { margin: 0 auto 0 0; }
.ov-toolbar input { width: 180px; } .ov-toolbar select { width: auto; }
.legend-row { list-style: none; display: flex; gap: 14px; margin: 4px 0 8px; padding: 0; font-size: 0.78rem; color: var(--ink-soft); }
.legend-row i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.st-bar { display: flex; gap: 2px; height: 10px; min-width: 110px; border-radius: 4px; overflow: hidden; background: var(--line); }
.st-bar > span { min-width: 4px; }
.bar-cell { min-width: 140px; } .bar-cell .num { display: block; margin-top: 3px; }
.ov-table td { vertical-align: middle; }
.ov-row { cursor: pointer; }
.ov-row:hover td, .ov-row:focus-visible td { background: var(--paper); }
.ov-row:focus-visible { outline: 2px solid var(--seg-todo); }
.ov-row .badge.prio { margin-left: 4px; }
.block { display: block; }
.clip { display: block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bad-ink { color: var(--absent); }
.ov-side { border-left: 1px solid var(--line); padding-left: 20px; }
.att-list, .feed, .dept-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.att-list a { display: grid; gap: 4px; padding: 8px 10px; border-radius: 8px; background: var(--paper); text-decoration: none; color: inherit; border-left: 3px solid var(--absent); }
.att-list a:hover { background: var(--line); }
.att-title { font-weight: 600; font-size: 0.9rem; }
.feed li { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; }
.dept-list li { display: grid; gap: 4px; }
.dept-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wk-chart { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; height: 150px; align-items: end; }
.wk { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 4px; }
.wk-bars { display: flex; gap: 2px; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.wk-bars > span { width: 40%; max-width: 16px; min-height: 2px; border-radius: 4px 4px 0 0; }
.wk-label { font-size: 0.7rem; color: var(--ink-soft); text-align: center; white-space: nowrap; }
.wk:hover .wk-bars { background: var(--paper); }
.ov-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 0.78rem;
  padding: 4px 8px; border-radius: 6px; max-width: 280px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--stamp-tint); color: var(--stamp); border-radius: 99px; padding: 4px 6px 4px 12px; font-weight: 600; font-size: 0.85rem; }
.filter-chip button { border: 0; background: none; color: inherit; cursor: pointer; font: inherit; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ov-grid { grid-template-columns: minmax(0, 1fr); } .ov-side { border-left: 0; padding-left: 0; } }
@media (max-width: 760px) { .ov-grid.two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .kpis { grid-template-columns: 1fr 1fr; } .ov-toolbar input { width: 100%; } }

/* ---------- Tasks: daily updates calendar ---------- */
:root {
  --du-1: #7ee2b8; --du-1-ink: #0b3d27; --du-2: #2abb7f; --du-2-ink: #ffffff; --du-3: #1f845a; --du-3-ink: #ffffff;
  --du-miss: #ffd5d2; --du-miss-ink: #ae2e24; --du-miss-line: #f87168;
  --du-pend: #fff7d6; --du-pend-ink: #7f5f01; --du-leave: var(--leave-tint); --du-leave-ink: var(--leave);
  --du-absent: #fedec8; --du-absent-ink: #a54800; --du-none: var(--paper); --du-none-ink: var(--ink-soft);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --du-1: #1c5a3f; --du-1-ink: #baf3db; --du-2: #23845a; --du-2-ink: #ffffff; --du-3: #4bce97; --du-3-ink: #0b2a1c;
  --du-miss: #42221f; --du-miss-ink: #fd9891; --du-miss-line: #c9372c; --du-pend: #3a2e17; --du-pend-ink: #f5cd47;
  --du-absent: #3d2a17; --du-absent-ink: #fea362; } }
:root[data-theme="dark"] {
  --du-1: #1c5a3f; --du-1-ink: #baf3db; --du-2: #23845a; --du-2-ink: #ffffff; --du-3: #4bce97; --du-3-ink: #0b2a1c;
  --du-miss: #42221f; --du-miss-ink: #fd9891; --du-miss-line: #c9372c; --du-pend: #3a2e17; --du-pend-ink: #f5cd47;
  --du-absent: #3d2a17; --du-absent-ink: #fea362; }
.du { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; border: 0; padding: 0; font: inherit;
  font-size: 0.72rem; font-weight: 700; background: var(--du-none); color: var(--du-none-ink); cursor: default; }
button.du-updated { cursor: pointer; } button.du-updated:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.du-updated.l1 { background: var(--du-1); color: var(--du-1-ink); }
.du-updated.l2 { background: var(--du-2); color: var(--du-2-ink); }
.du-updated.l3 { background: var(--du-3); color: var(--du-3-ink); }
.du-missed { background: var(--du-miss); color: var(--du-miss-ink); box-shadow: inset 0 0 0 1.5px var(--du-miss-line); }
.du-pending { background: var(--du-pend); color: var(--du-pend-ink); box-shadow: inset 0 0 0 1.5px currentColor; }
.du-leave { background: var(--du-leave); color: var(--du-leave-ink); }
.du-absent { background: var(--du-absent); color: var(--du-absent-ink); }
.du-off { background: repeating-linear-gradient(135deg, var(--paper) 0 4px, var(--line) 4px 5px); }
.du-future { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.du-legend { flex-wrap: wrap; gap: 6px 16px; }
.du-legend li { display: inline-flex; align-items: center; gap: 6px; }
.du-legend .du { width: 20px; height: 20px; font-size: 0.65rem; }
.du-ramp .du { margin-right: -4px; }
.du-wrap { overflow-x: auto; }
.du-table { border-collapse: separate; border-spacing: 0; }
.du-table th, .du-table td { padding: 3px 2px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.du-table .du-name { position: sticky; left: 0; background: var(--surface); z-index: 1; padding-right: 10px; min-width: 150px; }
.du-h { text-align: center; font-weight: 600; font-size: 0.68rem; color: var(--ink-soft); min-width: 26px; }
.du-sum { padding: 3px 6px !important; font-size: 0.85rem; }
.du-last { border-right: 1px solid var(--line); padding-right: 10px !important; }
.du-h span, .du-h b { display: block; line-height: 1.2; }
.du-h b { font-size: 0.8rem; color: var(--ink); }
.du-h.off b { color: var(--ink-soft); font-weight: 500; }
.du-h.today b { background: var(--stamp); color: var(--on-stamp); border-radius: 99px; padding: 0 5px; display: inline-block; }
.du-c { text-align: center; }
.du-rate { font-weight: 700; } .du-rate.good { color: var(--present); } .du-rate.warn { color: var(--late); } .du-rate.bad { color: var(--absent); }
.du-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.du-kpis > div, .du-stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; display: grid; }
.du-kpis strong, .du-stats strong { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.du-kpis span, .du-stats span { font-size: 0.8rem; color: var(--ink-soft); }
.du-kpis .bad strong { color: var(--absent); }
.du-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.du-stats > div { background: var(--paper); }
.du-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.du.big { width: auto; height: 64px; display: grid; grid-template-rows: auto 1fr; place-items: start; padding: 6px 8px; text-align: left; }
.du.big .du-day { font-size: 0.8rem; font-weight: 600; }
.du.big .du-sym { font-size: 1.1rem; align-self: end; justify-self: end; }
@media (max-width: 560px) { .du.big { height: 48px; padding: 4px; } .du-stats { grid-template-columns: 1fr 1fr 1fr; } .du-stats strong { font-size: 1.2rem; } }

/* ---------- Positions and organization chart ---------- */
:root { --lv1: #0b3d91; --lv2: #1a52b0; --lv3: #2a68cc; --lv4: #4583dc; --lv5: #6fa0e6; --lv6: #9bbfef; --lv7: #c6daf6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --lv1: #c6daf6; --lv2: #9bbfef; --lv3: #6fa0e6; --lv4: #4583dc; --lv5: #2f6fc9; --lv6: #2458a8; --lv7: #1b4483; } }
:root[data-theme="dark"] { --lv1: #c6daf6; --lv2: #9bbfef; --lv3: #6fa0e6; --lv4: #4583dc; --lv5: #2f6fc9; --lv6: #2458a8; --lv7: #1b4483; }
.pos { display: inline-block; font-size: 0.72rem; font-weight: 700; border-radius: 4px; padding: 0 6px; line-height: 18px; white-space: nowrap;
  background: color-mix(in srgb, var(--lv) 16%, var(--surface)); color: var(--ink); box-shadow: inset 3px 0 0 var(--lv); padding-left: 8px; }
.pos-1, .lvl-1 { --lv: var(--lv1); } .pos-2, .lvl-2 { --lv: var(--lv2); } .pos-3, .lvl-3 { --lv: var(--lv3); }
.pos-4, .lvl-4 { --lv: var(--lv4); } .pos-5, .lvl-5 { --lv: var(--lv5); } .pos-6, .lvl-6 { --lv: var(--lv6); } .pos-7, .lvl-7 { --lv: var(--lv7); } .lvl-0 { --lv: var(--line); }
.org { display: grid; gap: 0; }
.org-band { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--lv); border-radius: var(--radius-m); padding: 14px 16px; }
.org-band header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.org-band h2 { margin: 0; font-size: 1.05rem; }
.org-level { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--lv); color: #fff; font-weight: 800; flex: none; }
.lvl-5 .org-level, .lvl-6 .org-level, .lvl-7 .org-level, .lvl-0 .org-level { color: #0b1a33; }
.lvl-0 .org-level { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lvl-1 .org-level, :root:not([data-theme="light"]) .lvl-2 .org-level,
  :root:not([data-theme="light"]) .lvl-3 .org-level { color: #0b1a33; }
  :root:not([data-theme="light"]) .lvl-4 .org-level, :root:not([data-theme="light"]) .lvl-5 .org-level, :root:not([data-theme="light"]) .lvl-6 .org-level,
  :root:not([data-theme="light"]) .lvl-7 .org-level { color: #ffffff; } }
:root[data-theme="dark"] .lvl-1 .org-level, :root[data-theme="dark"] .lvl-2 .org-level, :root[data-theme="dark"] .lvl-3 .org-level { color: #0b1a33; }
:root[data-theme="dark"] .lvl-4 .org-level, :root[data-theme="dark"] .lvl-5 .org-level, :root[data-theme="dark"] .lvl-6 .org-level, :root[data-theme="dark"] .lvl-7 .org-level { color: #ffffff; }
.org-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.org-card { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font: inherit; color: inherit; cursor: default; }
.org-card[tabindex="0"], .org-card:not([tabindex]) { cursor: pointer; }
.org-card:not([tabindex]):hover { border-color: var(--lv); }
.org-who { display: grid; min-width: 0; }
.org-who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-empty { padding: 6px 2px; }
.org-link { width: 2px; height: 16px; background: var(--line); margin-left: 32px; }

/* ---------- Daily report ---------- */
.rep-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.rep-grid > .panel, .rep-side > .panel { margin-top: 0; }
.rep-side { display: grid; gap: 16px; }
.rep-side h3 { margin: 0 0 10px; font-size: 0.95rem; }
.rep-status { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.rep-body { min-height: 420px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.86rem; line-height: 1.55; tab-size: 3; }
.rep-actions { flex-wrap: wrap; }
.rep-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rep-stat { background: var(--paper); border-radius: 8px; padding: 8px 10px; display: grid; }
.rep-stat strong { font-size: 1.25rem; font-weight: 800; }
.rep-stat span { font-size: 0.75rem; color: var(--ink-soft); }
.rep-stat.good strong { color: var(--present); } .rep-stat.bad strong { color: var(--absent); }
.rep-warn { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--late-tint); color: var(--late); }
.rep-text { padding: 10px 12px 12px; white-space: pre-wrap; font-size: 0.85rem; line-height: 1.5; max-height: 420px; overflow: auto; overflow-wrap: anywhere; }
.rep-hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rep-hist .link-btn { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 4px 0; }
.rep-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; }
@media (max-width: 960px) { .rep-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .rep-row { grid-template-columns: 1fr auto; } .rep-stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Chat: delete for me / everyone, clear chat ---------- */
.chat-head-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.del-preview { background: var(--paper); border-left: 3px solid var(--line); border-radius: 6px; padding: 8px 10px; margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.del-actions { flex-wrap: wrap; }

/* ---------- "Are you sure?" window (askConfirm) ---------- */
.confirm-dlg { border: 0; border-radius: var(--radius-m); padding: 20px 22px; width: min(420px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: 0 10px 40px rgb(0 0 0 / .25); }
.confirm-dlg::backdrop { background: rgb(0 0 0 / .35); }
.confirm-msg { margin: 0 0 16px; line-height: 1.5; overflow-wrap: anywhere; }
.confirm-dlg .form-actions { margin-top: 0; }

/* ---------- Circulars: event dates ---------- */
.list > li.circular { padding-left: 16px; }
.list > li.circular.has-ev { padding-left: 76px; min-height: 64px; }
.circular.has-ev > .ev-tile { position: absolute; left: 16px; top: 14px; }
.circular.has-ev.unread::before { left: 0; }
.ev-tile { display: inline-grid; justify-items: center; width: 48px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line);
  background: var(--surface); line-height: 1.1; flex: none; }
.ev-tile b { display: block; width: 100%; text-align: center; background: var(--stamp); color: var(--on-stamp); font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: .04em; padding: 2px 0; }
.ev-tile span { font-size: 1.25rem; font-weight: 800; padding: 2px 0 4px; }
.ev-tile.past b { background: var(--ink-soft); }
.ev-line { display: block; font-size: 0.85rem; margin: 2px 0; color: var(--ink); }
.ev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ev-item { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font: inherit; color: inherit; text-decoration: none; cursor: pointer; }
.ev-item:hover { border-color: var(--stamp); }
.cal-cell.has-event { box-shadow: inset 0 -3px 0 var(--stamp); }
.cal-ev { color: var(--stamp); font-weight: 600; }

/* ---------- Office camps ---------- */
.camp-list { display: grid; gap: 14px; }
.camp-card { margin: 0; }
.camp-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: start; }
.camp-head h2 { margin: 0 0 2px; font-size: 1.1rem; }
.camp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.camp-steps { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 0; margin: 14px 0 12px; counter-reset: s; }
.camp-steps li { counter-increment: s; font-size: 0.75rem; color: var(--ink-soft); padding-top: 10px; border-top: 4px solid var(--line); position: relative; }
.camp-steps li::before { content: counter(s) ". "; font-weight: 700; }
.camp-steps li.done { border-top-color: var(--present); color: var(--ink); }
.camp-steps li.now { border-top-color: var(--fill-late); color: var(--ink); font-weight: 700; }
.camp-steps li.stop { border-top-color: var(--absent); color: var(--absent); font-weight: 700; }
.camp-figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.camp-figs > div { background: var(--paper); border-radius: 8px; padding: 8px 10px; display: grid; }
.camp-figs span { font-size: 0.75rem; color: var(--ink-soft); }
.camp-figs b { font-size: 1.05rem; }
.camp-notes { margin: 10px 0 0; color: var(--ink-soft); }
.camp-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }
.exp-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 12px; padding: 12px; background: var(--paper); border-radius: 10px; }
.exp-form .field { margin: 0; flex: 0 1 140px; }
.exp-form .field.grow { flex: 1 1 220px; }
.exp-table td, .exp-table th { white-space: nowrap; }
.exp-table td:nth-child(3) { white-space: normal; }
@media (max-width: 640px) { .camp-figs { grid-template-columns: 1fr 1fr; } .camp-steps li { font-size: 0.68rem; } }

/* ---------- Notification bell ---------- */
.bell { position: fixed; top: 14px; right: 18px; z-index: 20; width: 42px; height: 42px; border-radius: 99px; display: grid; place-items: center;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; }
.bell:hover { border-color: var(--stamp); }
.bell svg { width: 20px; height: 20px; }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px;
  background: #d10216; color: #ffffff; font-size: 0.72rem; font-weight: 700; display: grid; place-items: center; }
.bell-count[hidden] { display: none; }
.bell-panel { position: fixed; top: 62px; right: 18px; z-index: 30; width: min(380px, calc(100vw - 32px)); max-height: min(70vh, 560px);
  overflow-y: auto; padding: 14px; margin: 0; }
.bell-panel .panel-head { margin-bottom: 10px; }
.bell-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.bell-list a { display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 0.9rem; }
.bell-list a:hover { background: var(--paper); }
.bell-list a.unread { background: var(--paper); box-shadow: inset 3px 0 0 var(--stamp); font-weight: 600; }
main { padding-right: max(clamp(16px, 4vw, 48px), 70px); }
@media (max-width: 820px) { .bell { top: 7px; right: 12px; width: 40px; height: 40px; box-shadow: none; } .bell-panel { top: 60px; right: 12px; } main { padding-right: 16px; } }

/* ---------- Requests ---------- */
.kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }
.kind-card { display: grid; gap: 4px; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--ink); font: inherit; cursor: pointer; }
.kind-card:hover, .kind-card:focus-visible { border-color: var(--stamp); background: var(--paper); }
.kind-icon { font-size: 1.5rem; }
.st-line { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.st-line select, .st-line input { width: 100%; }
.req-history { list-style: none; margin: 8px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 10px; }
.req-history li { position: relative; font-size: 0.9rem; }
.req-history li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 99px; background: var(--stamp); }
.req-history li .muted { margin-left: 6px; }
@media print { .bell, .bell-panel, .no-print, .tabs, .page-head .btn { display: none !important; } main { padding-right: 0; } }
@media print {
  body.print-page #app { display: block !important; }
  body.print-page .side { display: none !important; }
  body.print-page .shell { display: block; background: none; }
  body.print-page .panel { box-shadow: none; break-inside: avoid; }
}

/* ---------- Loading ---------- */
#loadbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: linear-gradient(90deg, transparent, var(--stamp), transparent); background-size: 40% 100%; background-repeat: no-repeat; }
#loadbar.on { opacity: 1; animation: loadbar 1s linear infinite; }
@keyframes loadbar { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.skeleton { display: grid; gap: 14px; }
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--line) 25%, var(--paper) 50%, var(--line) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.sk-title { height: 30px; width: 40%; } .sk-line { height: 14px; width: 60%; }
.sk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; } .sk-box { height: 84px; }
.sk-panel { height: 260px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk, #loadbar.on { animation: none; } }

/* ---------- Phones: tables as cards (labels come from the column headers, see labelTables) ---------- */
@media (max-width: 640px) {
  main table:not(.du-table):not(.live):not(.no-stack) thead { display: none; }
  main table:not(.du-table):not(.live):not(.no-stack),
  main table:not(.du-table):not(.live):not(.no-stack) tbody,
  main table:not(.du-table):not(.live):not(.no-stack) tfoot { display: block; }
  main table:not(.du-table):not(.live):not(.no-stack) tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px;
    padding: 12px 0; border-bottom: 1px solid var(--line); }
  main table:not(.du-table):not(.live):not(.no-stack) tr:last-child { border-bottom: 0; }
  main table:not(.du-table):not(.live):not(.no-stack) :is(td, th) { display: block; padding: 0; border: 0; text-align: left; min-width: 0;
    white-space: normal; overflow-wrap: anywhere; }
  main table:not(.du-table):not(.live):not(.no-stack) :is(td, th):first-child,
  main table:not(.du-table):not(.live):not(.no-stack) td[data-label=""] { grid-column: 1 / -1; }
  main table:not(.du-table):not(.live):not(.no-stack) td[data-label=""]:last-child:not(:first-child) { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  main table:not(.du-table):not(.live):not(.no-stack) td[data-label]:not([data-label=""]):not(:first-child)::before { content: attr(data-label); display: block;
    font-size: 0.68rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
  main table:not(.du-table):not(.live):not(.no-stack) :is(td, th):first-child { font-size: 1rem; }
  main table:not(.du-table):not(.live):not(.no-stack) .st-bar, main table .bar-cell, main table .progress { min-width: 0; }
  main .table-wrap { overflow-x: visible; }
  main .table-wrap:has(.du-table) { overflow-x: auto; }
}

/* ---------- More menu (phones) ---------- */
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.more-head { display: flex; gap: 12px; align-items: center; margin: -4px 0 14px; }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.more-grid a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 600; background: var(--surface); }
.more-grid a.on { border-color: var(--stamp); background: var(--stamp-tint); color: var(--stamp); }

/* Phones: the summary tiles as one compact list (after the base .tile rules so these win) */
@media (max-width: 560px) {
  .tiles { grid-template-columns: minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden;
    background: var(--surface); box-shadow: var(--shadow); }
  .tile { grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px 14px; border: 0; border-radius: 0; box-shadow: none; }
  .tile + .tile { border-top: 1px solid var(--line); }
  .tile-icon { grid-row: auto; width: 32px; height: 32px; border-radius: 8px; }
  .tile-icon svg { width: 18px; height: 18px; }
  .tile-value { order: 3; font-size: 1.3rem; }
  .tile-label { font-size: 0.92rem; color: var(--ink); }
  a.tile:hover { transform: none; }
}@media (max-width: 560px) {
  .ov-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ov-toolbar h3, .ov-toolbar input { grid-column: 1 / -1; }
  .ov-toolbar select { width: 100%; }
}
.more-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; }
@media (max-width: 640px) {
  .filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters > * { grid-column: 1 / -1; min-width: 0; margin: 0; }
  .filters > label.field:has(input[type=date]), .filters > label.field:has(input[type=month]) { grid-column: auto; }
  .page-head .row { width: 100%; }
  .page-head .row .btn { flex: 1; }
  /* Denser table cards */
  main table:not(.du-table):not(.live):not(.no-stack) td { font-size: 0.9rem; }
  main table:not(.du-table):not(.live):not(.no-stack) td:empty { display: none; }
  main table:not(.du-table):not(.live):not(.no-stack) tr { gap: 6px 10px; padding: 10px 0; }
  main table:not(.du-table):not(.live):not(.no-stack) td.net { background: none; }
}
@media (max-width: 640px) {
  /* Who / what the row is about gets the full width; status sits next to the row's buttons */
  main table:not(.du-table):not(.live):not(.no-stack) td:is([data-label="Employee"], [data-label="Name"], [data-label="Person"],
    [data-label="Details"], [data-label="Note"], [data-label="Item"]) { grid-column: 1 / -1; }
  main table:not(.du-table):not(.live):not(.no-stack) td[data-label="Status"] { grid-column: span 2; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
  main table:not(.du-table):not(.live):not(.no-stack) td[data-label="Status"]::before { width: 100%; }
  main table:not(.du-table):not(.live):not(.no-stack) td[data-label=""]:last-child:not(:first-child) { grid-column: auto / -1; align-self: end; }
}
@media (max-width: 640px) {
  main table:not(.du-table):not(.live):not(.no-stack) td:is([data-label="Employee"], [data-label="Name"], [data-label="Person"])::before { display: none; }
  main table:not(.du-table):not(.live):not(.no-stack) td:is([data-label="Employee"], [data-label="Name"], [data-label="Person"]) { font-size: 1rem; }
}

/* ---------- Notification settings ---------- */
.switch-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { flex: none; width: 38px; height: 22px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #ffffff;
  box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--fill-present, #1f8a4c); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--stamp); outline-offset: 2px; }
.steps-list { margin: 10px 0 14px; padding-left: 20px; display: grid; gap: 8px; }
.app-get { display: block; text-align: center; margin: 4px 0 14px; }

/* ---------- Install the app ---------- */
.install-banner { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 14px; border-radius: var(--radius-m);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.install-banner img { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); }
.install-banner > div { flex: 1; min-width: 0; }
.install-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.install-col h3 { margin-bottom: 4px; }
.share-ic { display: inline-block; padding: 0 5px; border: 1px solid var(--line); border-radius: 5px; font-size: 0.85em; }
/* Installed on a phone: keep clear of the notch and the home bar */
@media (display-mode: standalone) and (max-width: 820px) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .bell { top: calc(7px + env(safe-area-inset-top)); }
  .bell-panel { top: calc(60px + env(safe-area-inset-top)); }
}
.machine-note { display: grid; gap: 2px; text-align: right; }
.machine-note b { font-size: 1.1rem; }
.machine-note span { color: var(--on-hero-soft); font-size: 0.9rem; }
@media (max-width: 640px) { .machine-note { text-align: left; } }
.warn-notice { background: var(--absent-tint); border-left-color: var(--absent); color: var(--ink); }
.warn-notice b { color: var(--absent); }
/* Attendance: every calendar day */
tr.row-off td { background: var(--paper); }
tr.row-off td:first-child { box-shadow: inset 3px 0 0 var(--line); }
tr.row-absent td:first-child { box-shadow: inset 3px 0 0 var(--absent); }
tr.row-upcoming td { opacity: .55; }
/* Shown before the app's script runs (and to agents that don't run scripts) */
.public-intro { max-width: 640px; margin: 12vh auto; padding: 0 16px; text-align: center; }
.public-intro h1 { margin-bottom: 8px; }
.public-intro p { color: var(--ink-soft); margin-top: 8px; }
