/* Pontaj — a timesheet that has to be readable on a phone on a building site,
   and legible in sunlight. Hence the heavy weights and the generous rows. */

:root {
  color-scheme: light;

  --ink:        #15202b;
  --ink-soft:   #5b6b7c;
  --ink-faint:  #8695a5;
  --line:       #dde4ec;
  --line-soft:  #eef2f7;
  --bg:         #f4f7fa;
  --card:       #ffffff;

  --brand:      #1b3a5c;
  --brand-ink:  #ffffff;
  --accent:     #2f7fd4;
  --accent-soft:#eaf3fc;

  --good:       #1c7a4a;
  --good-soft:  #e7f5ed;
  --warn:       #9a6a00;
  --warn-soft:  #fdf4e0;
  --bad:        #b3261e;
  --bad-soft:   #fdecea;

  --weekend:    #fafbfd;
  --today:      #fff8e1;

  --radius:     10px;
  --radius-sm:  7px;
  --shadow:     0 1px 2px rgba(21,32,43,.06), 0 4px 12px rgba(21,32,43,.05);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink:        #e8eef5;
    --ink-soft:   #a3b2c2;
    --ink-faint:  #76879a;
    --line:       #2a3744;
    --line-soft:  #222d38;
    --bg:         #141b22;
    --card:       #1b232c;
    --brand:      #24456a;
    --accent:     #5aa6ea;
    --accent-soft:#1c2c3d;
    --good:       #5fcc92;
    --good-soft:  #15301f;
    --warn:       #e0b253;
    --warn-soft:  #2e2616;
    --bad:        #f08b84;
    --bad-soft:   #331b19;
    --weekend:    #171f27;
    --today:      #2b2718;
    --shadow:     0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink:        #e8eef5;
  --ink-soft:   #a3b2c2;
  --ink-faint:  #76879a;
  --line:       #2a3744;
  --line-soft:  #222d38;
  --bg:         #141b22;
  --card:       #1b232c;
  --brand:      #24456a;
  --accent:     #5aa6ea;
  --accent-soft:#1c2c3d;
  --good:       #5fcc92;
  --good-soft:  #15301f;
  --warn:       #e0b253;
  --warn-soft:  #2e2616;
  --bad:        #f08b84;
  --bad-soft:   #331b19;
  --weekend:    #171f27;
  --today:      #2b2718;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--brand); color: var(--brand-ink);
  padding: 10px 16px; border-radius: 0 0 var(--radius) 0; z-index: 100;
}
.skip:focus { left: 0; top: 0; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: var(--accent); }

/* ── chrome ───────────────────────────────────────────────────────────── */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
  background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 1px 0 rgba(0,0,0,.1);
}
.top h1 { font-size: 17px; letter-spacing: .02em; }
.top .grow { flex: 1; }
.top nav { display: flex; gap: 2px; }

.tab {
  appearance: none; border: 0; cursor: pointer;
  background: transparent; color: rgba(255,255,255,.75);
  font: inherit; font-weight: 550; font-size: 14px;
  padding: 7px 13px; border-radius: var(--radius-sm);
}
.tab:hover { background: rgba(255,255,255,.1); color: #fff; }
.tab[aria-current="page"] { background: rgba(255,255,255,.18); color: #fff; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 18px 64px; }

/* ── month switcher ───────────────────────────────────────────────────── */

.monthbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.monthbar h2 { font-size: 22px; flex: 1; min-width: 180px; }
.monthbar h2 small {
  display: block; font-size: 13px; font-weight: 450; color: var(--ink-soft);
  letter-spacing: 0;
}

/* ── buttons and fields ───────────────────────────────────────────────── */

.btn {
  appearance: none; cursor: pointer;
  font: inherit; font-weight: 550; font-size: 14px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--ink-faint); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 7px 9px; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, .tab:focus-visible, .cell-input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
label { font-size: 13px; font-weight: 550; color: var(--ink-soft); display: block; margin-bottom: 5px; }

/* ── cards ────────────────────────────────────────────────────────────── */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 18px; overflow: hidden;
}
.card > header {
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}
.card > header h3 { font-size: 15px; flex: 1; }
.card-body { padding: 16px; }

/* ── summary tiles ────────────────────────────────────────────────────── */

.tiles {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.tile dt {
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .06em; margin: 0 0 6px;
}
.tile dd {
  margin: 0; font-size: 24px; font-weight: 680;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.tile dd small { font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.tile-total { background: var(--brand); border-color: var(--brand); }
.tile-total dt { color: rgba(255,255,255,.72); }
.tile-total dd { color: #fff; }
.tile-ot dd { color: var(--warn); }

/* ── the week grid ────────────────────────────────────────────────────── */

.week { margin-bottom: 14px; }
.week > header {
  display: flex; align-items: baseline; gap: 10px;
  padding: 0 4px 7px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .05em;
}
.week > header .wtotal {
  margin-left: auto; text-transform: none; letter-spacing: 0;
  font-variant-numeric: tabular-nums; color: var(--ink);
}

.grid {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}

.row {
  display: grid; align-items: center;
  grid-template-columns: 112px 74px 74px 56px minmax(120px, 1fr) 96px;
  gap: 1px;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0; }
.row-head {
  background: var(--line-soft); border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .05em;
}
.row-head > * { padding: 8px 10px; }
.row-weekend { background: var(--weekend); }
.row-today { background: var(--today); }
.row-empty .day-name { color: var(--ink-faint); }

.day-name { padding: 6px 10px; font-weight: 600; font-size: 14px; }
.day-name small {
  display: block; font-weight: 450; font-size: 12px; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.cell { padding: 5px 6px; }
.cell-input {
  width: 100%; text-align: center; font-variant-numeric: tabular-nums;
  font-weight: 600; border: 1px solid transparent; background: transparent;
  border-radius: var(--radius-sm); padding: 7px 4px;
}
.cell-input:hover { border-color: var(--line); }
.cell-input:focus { border-color: var(--accent); background: var(--card); }
.cell-input::placeholder { color: var(--ink-faint); font-weight: 400; }
.cell-input.over { color: var(--warn); }

.cell select {
  border-color: transparent; background: transparent; padding: 7px 6px;
  font-size: 13px; text-overflow: ellipsis;
}
.cell select:hover { border-color: var(--line); }
.cell select:focus { border-color: var(--accent); background: var(--card); }

.diurna {
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 6px;
}
.diurna input { width: 19px; height: 19px; margin: 0; accent-color: var(--good); cursor: pointer; }

.day-total {
  padding: 6px 12px; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14px;
}
.day-total .zero { color: var(--ink-faint); font-weight: 400; }
.day-total small { display: block; font-size: 11px; font-weight: 500; color: var(--warn); }

.row-total {
  background: var(--line-soft); font-weight: 650;
  border-top: 1px solid var(--line); border-bottom: 0;
}
.row-total > * { padding: 8px 10px; font-variant-numeric: tabular-nums; }
.row-total .day-name { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.row-total .sum { text-align: center; }
.row-total .day-total { text-align: right; }

/* ── tables (sites, rates, year) ──────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); }
th {
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .05em; background: var(--line-soft);
}
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 680; background: var(--line-soft); border-top: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 650; letter-spacing: .02em;
}
.pill-on  { background: var(--good-soft); color: var(--good); }
.pill-off { background: var(--line-soft); color: var(--ink-soft); }

/* ── forms in a row ───────────────────────────────────────────────────── */

.formrow {
  display: grid; gap: 12px; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.formrow .btn { height: 38px; }
.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500; color: var(--ink); margin: 0;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* ── notices ──────────────────────────────────────────────────────────── */

.note {
  display: flex; gap: 9px; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; line-height: 1.45; margin-bottom: 14px;
}
.note-info { background: var(--accent-soft); color: var(--ink); }
.note-warn { background: var(--warn-soft); color: var(--ink); }
.note-bad  { background: var(--bad-soft);  color: var(--ink); }
.note b { font-weight: 650; }

.empty { padding: 36px 20px; text-align: center; color: var(--ink-soft); }
.empty p { margin: 0 0 4px; }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; }

/* ── toast ────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed; z-index: 60;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: calc(100% - 32px); max-width: 420px;
}
.toast {
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 99px; font-size: 13.5px; font-weight: 550;
  box-shadow: var(--shadow); animation: rise .18s ease-out;
}
.toast-bad { background: var(--bad); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ── dialog ───────────────────────────────────────────────────────────── */

.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(21,32,43,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.dialog {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0,0,0,.3);
  width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
}
.dialog > header {
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center;
}
.dialog > header h3 { flex: 1; font-size: 16px; }
.dialog-body { padding: 18px; display: grid; gap: 14px; }
.dialog-foot {
  padding: 13px 18px; border-top: 1px solid var(--line-soft);
  display: flex; justify-content: flex-end; gap: 9px;
}

/* ── sign in ──────────────────────────────────────────────────────────── */

.signin {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.signin form {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px; width: 100%; max-width: 340px; display: grid; gap: 14px;
}
.signin h1 { font-size: 21px; text-align: center; }
.signin p.sub { margin: -6px 0 4px; text-align: center; color: var(--ink-soft); font-size: 13.5px; }

/* ── phone ────────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .wrap { padding: 14px 12px 56px; }
  .top { padding-inline: 12px; gap: 8px; }
  .top h1 { font-size: 15px; }
  .tab { padding: 6px 9px; font-size: 13px; }

  /* The grid becomes a stack of cards: six columns cannot be read at 380px,
     and a horizontal scroller hides the totals, which are the point. */
  .row {
    grid-template-columns: 1fr 1fr;
    gap: 0 8px; padding: 9px 12px;
    border-bottom: 1px solid var(--line);
  }
  .row-head { display: none; }
  .day-name { grid-column: 1 / -1; padding: 0 0 7px; }
  .day-name small { display: inline; margin-left: 7px; }
  .cell, .diurna { padding: 3px 0; }
  .cell::before, .diurna::before {
    content: attr(data-label);
    display: block; font-size: 11px; font-weight: 650; color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px;
  }
  .cell-input, .cell select { text-align: left; padding-inline: 8px; border-color: var(--line); }
  /* `.diurna` is a flex row, so its ::before label became a flex item and sat
     beside the checkbox while every other field had its label above. Wrapping
     puts it back on its own line. */
  .diurna { justify-content: flex-start; flex-wrap: wrap; align-content: center; }
  .diurna::before { flex: 0 0 100%; }
  .cell-site { grid-column: 1 / -1; }
  .day-total {
    grid-column: 1 / -1; text-align: left; padding: 8px 0 0;
    border-top: 1px dashed var(--line-soft); margin-top: 6px;
  }
  .day-total small { display: inline; margin-left: 8px; }
  .row-total { grid-template-columns: 1fr; padding: 10px 12px; }
  .row-total .sum, .row-total .day-total { text-align: left; }
  .row-total .sum::before {
    content: attr(data-label) " ";
    font-size: 11px; font-weight: 650; color: var(--ink-soft); text-transform: uppercase;
  }
  .tile dd { font-size: 20px; }
}

@media print {
  .top, .monthbar .btn, .toasts, .scrim { display: none !important; }
  body { background: #fff; }
  .card, .grid, .tile { box-shadow: none; border-color: #ccc; }
  .week { break-inside: avoid; }
}

/* ── classes replacing inline styles ──────────────────────────────────────
   The policy is `style-src 'self'`, which blocks style attributes outright.
   Setting one does nothing and only reports to the console, so every rule
   the interface needs lives here. */

.year-input { width: 92px; }
.picker { display: flex; gap: 8px; align-items: center; }
.monthbar .grow { flex: 1; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sub-line { display: block; color: var(--ink-soft); }
.field-narrow { max-width: 240px; }
.tight { margin: 0 0 10px; }
.tight:last-child { margin-bottom: 0; }
.muted { color: var(--ink-soft); font-size: 13.5px; }
.row-faint td { color: var(--ink-faint); }

/* ── touch targets ────────────────────────────────────────────────────────
   A 19px checkbox and a 30px select are fine with a mouse and unreliable
   with a thumb, which is how this will mostly be used — standing on a site,
   entering the day just worked. Everything tappable gets 44px of height on a
   touch screen. */

@media (pointer: coarse), (max-width: 720px) {
  .diurna { min-height: 44px; }
  .diurna input { width: 24px; height: 24px; }
  .cell select,
  .cell-input { min-height: 44px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }

  /* The tabs get the height but not the extra side padding: at 390px the
     title, four tabs and "Ieși" do not fit, and widening them put the whole
     page into a horizontal scroll. The title goes instead — the tab marked
     current says where you are, and the browser tab says what this is. */
  .tab { min-height: 40px; padding-inline: 9px; }
  .top h1 { display: none; }
  .top { gap: 4px; }
  .top nav { flex: 1; }
}
