:root {
  --bg: #f3f1ec;
  --card: #ffffff;
  --ink: #1d2327;
  --muted: #667077;
  --line: #e1ddd3;
  --brand: #1d2327;
  --accent: #f2a900;
  --accent-ink: #1d2327;
  --ok: #1f7a4d;
  --ok-bg: #e2f3ea;
  --warn: #8a5a00;
  --warn-bg: #fff1cc;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --radius: 14px;
  --tabbar: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181b; --card: #1f2529; --ink: #eef0f1; --muted: #9aa5ab; --line: #2f383d;
    --ok-bg: #173a29; --ok: #6fd3a0; --warn-bg: #3d2f08; --warn: #f2c14e; --bad-bg: #44201d; --bad: #ff9b93;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; }
.hidden { display: none !important; }

.topbar {
  background: var(--brand); color: #fff; padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.topbar .brand i { width: 14px; height: 14px; background: var(--accent); border-radius: 3px; display: inline-block; }
.topbar .who { font-size: .85rem; opacity: .85; text-align: right; }
.topbar button.link { color: #fff; opacity: .8; }

main { padding: 16px 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px); max-width: 720px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 { margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack > * + * { margin-top: 12px; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--card); min-height: 48px;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; border-color: var(--accent); }

button { cursor: pointer; border: 0; border-radius: 12px; padding: 12px 16px; min-height: 48px; font-weight: 700; background: var(--line); }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.dark { background: var(--brand); color: #fff; }
button.danger { background: var(--bad-bg); color: var(--bad); }
button.ok { background: var(--ok-bg); color: var(--ok); }
button.link { background: none; padding: 6px 8px; min-height: 0; font-weight: 600; text-decoration: underline; }
button.block { width: 100%; }
button.sm { min-height: 40px; padding: 8px 12px; font-size: .9rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

.timer-card { text-align: center; }
.timer-clock { font-size: 3.2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; margin: 6px 0 2px; }
.timer-job { font-weight: 700; font-size: 1.1rem; }
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); margin-right: 8px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }
.bigbtn { min-height: 64px; font-size: 1.15rem; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.chip.pending { background: var(--warn-bg); color: var(--warn); }
.chip.approved { background: var(--ok-bg); color: var(--ok); }
.chip.rejected { background: var(--bad-bg); color: var(--bad); }
.chip.odoo { background: #e9e4f7; color: #4b3a8f; }

.day { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 4px 8px; display: flex; justify-content: space-between; }
.entry { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.entry .job { font-weight: 700; }
.entry .hrs { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry .note { color: var(--muted); font-size: .9rem; margin-top: 2px; overflow-wrap: anywhere; }
.entry .reason { color: var(--bad); font-size: .9rem; margin-top: 4px; }
.entry .acts { display: flex; gap: 8px; margin-top: 10px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line);
  display: flex; z-index: 10;
}
.tabbar button { flex: 1; background: none; border-radius: 0; font-size: .72rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); position: relative; padding: 6px 2px; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--ink); }
.tabbar button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }
.badge { position: absolute; top: 4px; left: 54%; background: var(--bad); color: #fff; border-radius: 999px; font-size: .65rem; padding: 1px 6px; min-width: 18px; text-align: center; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
td { padding: 10px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tablewrap { overflow-x: auto; margin: 0 -4px; }

.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 40px; padding: 6px; background: transparent; font-size: .85rem; border-radius: 10px; }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.15); }

.login { max-width: 380px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 56px) 20px 20px; }
.login .logo { width: 56px; height: 56px; margin-bottom: 14px; }
.login h1 { font-size: 1.7rem; margin-bottom: 4px; }
.err { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: 10px; font-size: .92rem; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px);
  background: var(--brand); color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; text-align: center; font-weight: 600;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); }

dialog { border: 0; border-radius: 16px; padding: 18px; width: min(92vw, 420px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.5); }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } #toast { transition: none; } }

/* tasks */
.timer-task { display: inline-block; margin-top: 6px; background: var(--accent); color: var(--accent-ink); font-weight: 800; padding: 4px 14px; border-radius: 999px; }
label.check { display: flex; align-items: center; gap: 10px; font-size: 1rem; color: var(--ink); font-weight: 500; margin: 10px 0 0; min-height: 44px; }
label.check input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 0 18px; }
.checks label.check { margin-top: 4px; }
.okbox { background: var(--ok-bg); color: var(--ok); padding: 10px 12px; border-radius: 10px; font-size: .92rem; }
tr.grp td { background: var(--bg); padding: 8px 6px; border-bottom: 1px solid var(--line); }
details.jobblock { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
details.jobblock summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; gap: 10px; min-height: 48px; }
details.jobblock summary::-webkit-details-marker { display: none; }
details.jobblock summary::after { content: "›"; font-size: 1.4rem; color: var(--muted); transition: transform .15s; }
details.jobblock[open] summary::after { transform: rotate(90deg); }
.jobbody { padding: 0 14px 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.taskrow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.taskrow .sm { padding: 6px 10px; min-height: 36px; font-size: .8rem; }
.previewlist { max-height: 38vh; overflow-y: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; }
.previewlist .taskrow:last-child { border-bottom: 0; }
dialog textarea { min-height: 140px; font-size: .9rem; }
tr.tap { cursor: pointer; }
tr.tap:hover td, tr.tap:focus-visible td { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.taskrow { flex-wrap: wrap; }

/* ---------- laptop / desktop (900px and wider): denser layout, tab bar at the top ---------- */
.nowrap { white-space: nowrap; }
.cardgrid > .card, .cardcol > .card { margin-bottom: 14px; }
@media (min-width: 900px) {
  html, body { font-size: 15px; }
  #app { display: flex; flex-direction: column; min-height: 100dvh; }
  .topbar { position: static; order: 0; padding: 8px 20px; }
  .topbar .who { display: flex; align-items: center; gap: 4px; }
  .topbar .who br { display: none; }
  .topbar .who > button:first-of-type { margin-left: 10px; }
  .tabbar {
    order: 1; position: sticky; top: 0; bottom: auto; height: auto; padding: 0 12px;
    border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; gap: 2px;
  }
  .tabbar button { flex: 0 0 auto; flex-direction: row; gap: 8px; font-size: .9rem; padding: 10px 16px; min-height: 44px; }
  .tabbar button svg { width: 18px; height: 18px; }
  .tabbar button[aria-current="page"]::before { top: auto; bottom: 0; left: 12px; right: 12px; border-radius: 3px 3px 0 0; }
  .badge { position: static; margin-left: 2px; }
  main { order: 2; width: 100%; max-width: 1240px; padding: 18px 24px 40px; }
  #toast { bottom: 24px; }

  input, select, textarea { min-height: 38px; padding: 7px 10px; border-radius: 8px; }
  button { min-height: 38px; padding: 7px 14px; border-radius: 8px; }
  button.sm, .taskrow .sm { min-height: 30px; padding: 4px 10px; font-size: .82rem; }
  .bigbtn { min-height: 46px; font-size: 1rem; }
  .card { padding: 14px 16px; border-radius: 10px; }
  .card.flush { padding: 0; overflow: hidden; }
  .seg { max-width: 560px; }
  .seg button { min-height: 32px; }
  label.check { min-height: 32px; }
  .stack > * + * { margin-top: 10px; }

  /* staff screens stay a single readable column */
  #tf, #f, .timer-card { max-width: 560px; margin-left: auto; margin-right: auto; }

  table.dense { font-size: .9rem; }
  table.dense th { padding: 8px 10px; background: var(--bg); }
  table.dense td { padding: 6px 10px; vertical-align: middle; }
  table.dense tr.grp td { padding: 8px 10px; }
  table.dense tbody tr:not(.grp):hover td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
  .card.flush .tablewrap { margin: 0; }
  td.acts-cell, th.acts-cell { text-align: right; white-space: nowrap; width: 1%; }
  td.notecell { color: var(--muted); max-width: 320px; overflow-wrap: anywhere; }
  tr.muted td { color: var(--muted); }

  .cardgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .cardgrid > .card { margin-bottom: 0; }
  .cardcol { display: flex; flex-direction: column; gap: 14px; }
  .cardcol > .card { margin-bottom: 0; }

  form.formgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; align-items: end; }
  form.formgrid > * + * { margin-top: 0; }
  form.formgrid > h2 { grid-column: 1 / -1; margin-bottom: 0; }
  form.formgrid > #nud { grid-column: 1 / -1; }
  form.formgrid > button { grid-column: 3; }

  details.jobblock { border-radius: 8px; margin-bottom: 6px; }
  details.jobblock summary { padding: 8px 12px; min-height: 0; }
  .jobbody { padding: 8px 12px 12px; }
  .taskrow { padding: 4px 0; flex-wrap: nowrap; }
  .entry { padding: 10px 12px; }
  dialog { padding: 16px; }
}
