:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2530;
  --muted: #6b7686;
  --line: #e2e7ee;
  --accent: #2f6bd8;
  --accent-ink: #ffffff;
  --pos: #1f9d63;
  --neg: #d1425a;
  --wd-blue: #dde9fb;   /* light blue for alternating weekdays */
  --weekend: #e4e7ee;   /* light grey */
  --today: #cfe0fb;     /* current-day row highlight */
  --holiday: #fff3e0;
  --holiday-line: #f0c98a;
  --vacation: #e6f4ff;
  --comp: #f0e9ff;
  --sick: #ffe9ec;
  --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 3px 12px rgba(20, 30, 45, .05);
  --radius: 12px;
}
/* dark values: applied when the OS prefers dark (unless user forced light),
   or when the user explicitly picks dark via the settings switch */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --card: #1b212a; --ink: #e7ecf3; --muted: #93a0b2;
    --line: #2a323d; --accent: #5b8def; --wd-blue: #17222f; --weekend: #171d25; --today: #24344c;
    --holiday: #33280f; --holiday-line: #6a5326; --vacation: #10293d; --comp: #241a3a; --sick: #3a1620;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 3px 12px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --card: #1b212a; --ink: #e7ecf3; --muted: #93a0b2;
  --line: #2a323d; --accent: #5b8def; --wd-blue: #17222f; --weekend: #171d25; --today: #24344c;
  --holiday: #33280f; --holiday-line: #6a5326; --vacation: #10293d; --comp: #241a3a; --sick: #3a1620;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 3px 12px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; }
button, input, select { font: inherit; }

/* header */
.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 550; }
.nav a.active { background: var(--accent); color: var(--accent-ink); }

/* burger dropdown menu */
.burger { font-size: 18px; line-height: 1; }
.menu {
  position: absolute; top: calc(100% + 4px); left: 12px; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; min-width: 190px;
}
.menu[hidden] { display: none; }
.menu a, .menu button {
  text-align: left; background: none; border: none; color: var(--ink); font: inherit; cursor: pointer;
  text-decoration: none; padding: 9px 12px; border-radius: 7px; white-space: nowrap;
}
.menu a:hover, .menu button:hover { background: var(--bg); }
.menu a.active { color: var(--accent); font-weight: 650; }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 14px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 20px; }

/* stat row */
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: var(--shadow); min-width: 150px;
}
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* controls */
.bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.btn {
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 550;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.icon { padding: 7px 10px; }
input[type=text], input[type=time], input[type=date], input[type=number], input[type=month], input[type=password], select {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px;
}
.grow { flex: 1; min-width: 200px; }
.range-title { font-weight: 650; font-size: 16px; min-width: 220px; text-align: center; }

/* quick add */
.quick { display: flex; gap: 8px; align-items: center; }
.hint { color: var(--muted); font-size: 13px; }
.msg { font-size: 13px; }
.msg.ok { color: var(--pos); }
.msg.err { color: var(--neg); }

/* day rows (input view) — compact, row-like, wraps on mobile */
.day {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; margin-bottom: 6px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.day.wd-a { background: var(--card); }
.day.wd-b { background: var(--wd-blue); }
.day.weekend { background: var(--weekend); }
.day.holiday { background: var(--holiday); border-color: var(--holiday-line); }
.day.vacation { background: var(--vacation); }
.day.compensation { background: var(--comp); }
.day.sickness { background: var(--sick); }
.day.today { outline: 2px solid var(--accent); outline-offset: -1px; }
.day .dhead { flex: 0 0 130px; }
.day .dname { font-weight: 650; }
.day .dsub { color: var(--muted); font-size: 12px; }
.segs { flex: 1 1 220px; display: flex; flex-flow: row wrap; align-items: center; gap: 8px; }
.seg { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 2px 4px 2px 9px; }
.seg .x { color: var(--neg); cursor: pointer; border: none; background: none; font-size: 14px; padding: 0 3px; }
.seg .snote { color: var(--muted); font-size: 12px; }
.addrow { display: inline-flex; gap: 6px; align-items: center; }
.addseg { display: inline-flex; gap: 6px; align-items: center; }
.addseg.hidden { display: none; }
.addseg .tinp { width: 62px; text-align: center; }
.setdef { padding: 5px 10px; white-space: nowrap; }
.day select[data-labelsel] { flex: 0 0 130px; }
.day .labelnote { flex: 0 0 150px; }
.daymeta { flex: 0 0 165px; margin-left: auto; text-align: right; display: flex; flex-direction: column; gap: 2px;
  font-variant-numeric: tabular-nums; font-size: 13px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 20px; background: var(--line); }

/* table (overview) */
table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2), td.lbl, th.lbl { text-align: left; }
th { background: var(--card); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; position: sticky; top: 0; }
tr.wd-a td { background: var(--card); }
tr.wd-b td { background: var(--wd-blue); }
tr.weekend td { background: var(--weekend); }
tr.holiday td { background: var(--holiday); }
tr.vacation td { background: var(--vacation); }
tr.compensation td { background: var(--comp); }
tr.sickness td { background: var(--sick); }
tr.today td { background: var(--today); font-weight: 600; }

/* charts */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.chart { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); }
.chart h3 { font-size: 14px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* login */
.login { max-width: 340px; margin: 12vh auto; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.login h1 { font-size: 20px; margin-bottom: 18px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.login input { width: 100%; }
.login button { width: 100%; margin-top: 20px; }

/* settings dialog */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  color: var(--ink); box-shadow: var(--shadow); padding: 0; max-width: 460px; width: 92vw; }
dialog::backdrop { background: rgba(10, 15, 22, .45); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 650; }
.dlg-body { padding: 16px 20px; }
.dlg-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.field { margin-bottom: 12px; }
.dlg-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); margin: 16px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.wk-hours { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wk-hours label { text-align: center; font-size: 12px; }
.wk-hours input { width: 100%; text-align: center; padding: 6px 2px; }
.default-day { display: flex; gap: 8px; margin-bottom: 6px; }
.default-day input { flex: 1; min-width: 0; }
.slot-lbl { align-self: center; min-width: 48px; font-size: 12px; color: var(--muted); }
.editday { display: inline-block; text-decoration: none; padding: 3px 9px; }
td:last-child, th:last-child { text-align: center; }
.tablewrap { overflow-x: auto; }
.times { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#setTheme { width: 100%; }
.pw-sect { border-top: 1px solid var(--line); }
.pw-sect input { width: 100%; margin-bottom: 8px; }

.daynav { display: none; } /* phone-only day navigation */

@media (max-width: 720px) {
  .day { flex-direction: column; align-items: stretch; }
  .day .dhead, .segs, .daymeta, .day select[data-labelsel], .day .labelnote { flex-basis: auto; width: 100%; }
  .daymeta { margin-left: 0; text-align: left; }
  .charts { grid-template-columns: 1fr; }
  .stat { flex: 1; min-width: 120px; }
  /* Input on a phone: quick-entry + one day with prev/next arrows; stats at the bottom */
  .wrap { display: flex; flex-direction: column; }
  .stats { order: 99; margin-bottom: 0; margin-top: 4px; }
  .weeknav { display: none; }
  .daynav { display: flex; }
}
