:root {
  --bg: #f6f4ef; --panel: #ffffff; --ink: #1f2420; --muted: #66706a; --line: #e2ded4;
  --brand: #2f6b4f; --brand-ink: #ffffff; --warn: #b3541e; --danger: #b3261e; --ok: #2f6b4f;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151816; --panel: #1e2320; --ink: #e9ece8; --muted: #9aa49e; --line: #2f3632; --brand: #5fb18a; --brand-ink: #0e1511; --warn: #e08a52; --danger: #f08178; --ok: #5fb18a; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 10px; }
button, input, select, textarea { font: inherit; color: inherit; }
.layout { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
nav { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
nav .logo { font-weight: 700; font-size: 18px; padding: 4px 10px 14px; color: var(--brand); }
nav a { padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; cursor: pointer; }
nav a:hover { background: var(--bg); }
nav a.active { background: var(--brand); color: var(--brand-ink); }
nav .spacer { flex: 1; }
nav .who { font-size: 13px; color: var(--muted); padding: 6px 10px; }
main { padding: 24px; max-width: 1100px; width: 100%; }
.bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.bar .grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stat { font-size: 26px; font-weight: 650; }
.muted { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: var(--brand); }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.danger { color: var(--danger); }
button.small { padding: 3px 8px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, nav a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; border: 1px solid var(--line); background: var(--bg); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.bad { color: var(--danger); border-color: var(--danger); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 10; }
.modal { background: var(--panel); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 640px; border: 1px solid var(--line); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.lines .line { display: grid; grid-template-columns: 1fr 90px 90px auto; gap: 8px; margin-bottom: 8px; align-items: end; }
.lines .line.two { grid-template-columns: 1fr 100px auto; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; min-height: 1em; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.login { max-width: 360px; margin: 12vh auto; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
#toast.show { opacity: 1; }
.week { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 8px; overflow-x: auto; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.day h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.day.today { border-color: var(--brand); }
.shift { background: var(--bg); border-radius: 6px; padding: 5px 7px; margin-bottom: 5px; font-size: 13px; cursor: default; }
.shift.mine { border-left: 3px solid var(--brand); }
.shift button { margin-top: 3px; }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  nav .logo, nav .spacer { display: none; }
  main { padding: 14px; }
  .lines .line { grid-template-columns: 1fr 1fr; }
}

/* Printable invoice / delivery note */
.print-sheet { display: none; }
@media print {
  body > *:not(.print-sheet) { display: none !important; }
  body { background: #fff; }
  .print-sheet { display: block; color: #000; background: #fff; max-width: 720px; margin: 0 auto; padding: 24px; }
  .print-sheet table, .print-sheet th, .print-sheet td { background: #fff; color: #000; border-color: #999; }
  .print-sheet .grand { font-size: 18px; font-weight: 700; margin-top: 12px; }
  .print-sheet .small { font-size: 12px; }
  .print-sheet .sign { margin-top: 48px; }
}

main > h2 { margin-top: 22px; }

.btn-link { display: inline-block; background: var(--brand); color: var(--brand-ink); border-radius: 6px; padding: 7px 12px; text-decoration: none; }
