/* TallyMyHours - shared stylesheet
   System fonts only: no webfont request, so first paint is immediate. */

:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #5b6b82;
  --primary: #1d4ed8;
  --primary-soft: #eff6ff;
  --money: #047857;
  --warn: #b45309;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .05);
  --maxw: 1140px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #121b2c;
    --surface-2: #1a2438;
    --border: #273449;
    --border-strong: #3a4a66;
    --text: #e8edf7;
    --muted: #9aabc2;
    --primary: #6ea8fe;
    --primary-soft: #15233c;
    --money: #34d399;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121b2c;
  --surface-2: #1a2438;
  --border: #273449;
  --border-strong: #3a4a66;
  --text: #e8edf7;
  --muted: #9aabc2;
  --primary: #6ea8fe;
  --primary-soft: #15233c;
  --money: #34d399;
  --warn: #fbbf24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
}

/* Pseudo-elements need this too - a ::after with width:100% plus padding
   will overflow the viewport without it. */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
a:hover { text-decoration: none; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---- Header ---------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 50;
}
.site-header .wrap {
  display: flex; align-items: center; gap: 16px;
  min-height: 60px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.06rem; letter-spacing: -.01em;
  color: var(--text); text-decoration: none; white-space: nowrap;
  flex: none;
}
.brand-mark {
  width: 22px; height: 22px; flex: none;
  color: var(--primary);
  /* Nudges the mark onto the text's optical centre - the stopwatch crown
     sits above the dial, so geometric centring reads as too low. */
  margin-top: -1px;
}
/* Scoped to .brand-text so it colours the "My" and not the whole lockup. */
.brand-text span { color: var(--primary); }
/* min-width:0 is required: a flex item defaults to min-width:auto, which
   refuses to shrink below its content and pushes the page wider than the
   viewport instead of letting overflow-x scroll inside the nav. */
.site-nav {
  margin-left: auto; display: flex; gap: 4px; align-items: center;
  overflow-x: auto; min-width: 0;
  scrollbar-width: none; -ms-overflow-style: none;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 500;
  padding: 7px 10px; border-radius: 8px; white-space: nowrap;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.theme-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; flex: none; font-size: 15px;
}
.theme-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* ---- Hero ------------------------------------------------------------ */

.hero { padding: 28px 0 8px; }
.hero h1 { font-size: 1.85rem; line-height: 1.2; margin: 0 0 8px; letter-spacing: -.02em; }
.hero .lede { color: var(--muted); margin: 0; font-size: 1.02rem; max-width: 62ch; }

/* ---- Calculator layout ----------------------------------------------- */

.calc { padding: 18px 0 8px; }
.calc-grid { display: grid; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.period-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

select, input[type="text"], input[type="number"], input[type="date"] {
  font-family: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 9px 10px; min-height: 42px;
}
select:focus, input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }

/* ---- Day grid -------------------------------------------------------- */

.grid-head { display: none; }

.day {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 8px;
}
.day-name {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 650; font-size: .95rem;
}
.day-name .date { font-weight: 400; color: var(--muted); font-size: .85rem; }

.cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cell > label { font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cell input { width: 100%; }
.cell .hint { font-size: .74rem; color: var(--muted); min-height: 1em; font-variant-numeric: tabular-nums; }
.cell input[aria-invalid="true"] { border-color: var(--warn); }
.cell .hint.bad { color: var(--warn); }

/* Sits beside the break field rather than on its own row: saves a line
   per day, which is 7 fewer lines of scrolling on a phone. */
.day-total {
  display: flex; flex-direction: column;
  align-items: flex-end; justify-content: flex-end; gap: 2px;
}
.day-total .lbl { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.day-total .val { font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.day-total .val.zero { color: var(--muted); font-weight: 500; }

.seg2 { grid-column: 1 / -1; display: none; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.split-on .seg2 { display: grid; }

/* ---- Advanced -------------------------------------------------------- */

.advanced { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.advanced > summary {
  cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--primary);
  list-style: none; padding: 6px 0; user-select: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before { content: "\25B8 "; display: inline-block; transition: transform .15s; }
.advanced[open] > summary::before { transform: rotate(90deg); }
.adv-grid { display: grid; grid-template-columns: 1fr; gap: 12px; padding-top: 10px; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: .95rem; }
.checkline input { width: 18px; height: 18px; accent-color: var(--primary); }
.adv-note { font-size: .82rem; color: var(--muted); margin: 2px 0 0; }

/* ---- Summary --------------------------------------------------------- */

.summary { position: sticky; bottom: 0; z-index: 30; }
.summary-inner {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.summary h2 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 6px;
}
.big {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.big .n { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; font-family: var(--mono); line-height: 1.1; }
.big .u { font-size: .85rem; color: var(--muted); font-weight: 600; }
.big .pay { margin-left: auto; text-align: right; display: flex; align-items: baseline; gap: 6px; }
.big .pay .n { font-size: 1.35rem; color: var(--money); }

/* Collapsed by default on phones so the sticky bar stays a slim strip
   instead of swallowing half the screen. Forced open on wide screens. */
.sum-more > summary {
  cursor: pointer; list-style: none; user-select: none;
  font-size: .82rem; font-weight: 600; color: var(--primary);
  padding: 8px 0 2px; display: flex; align-items: center; gap: 5px;
}
.sum-more > summary::-webkit-details-marker { display: none; }
.sum-more > summary::after { content: "\25BE"; transition: transform .15s; }
.sum-more[open] > summary::after { transform: rotate(180deg); }

.breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 0 0; }
.bd { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; }
.bd .k { display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.bd .v { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.bd.ot .v, .bd.dt .v { color: var(--warn); }
.bd.hide { display: none; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn {
  font-family: inherit; font-size: .9rem; font-weight: 600;
  padding: 9px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  min-height: 40px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { opacity: .92; color: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.saved-note { font-size: .78rem; color: var(--muted); margin-top: 8px; min-height: 1.2em; }

/* ---- Ads ------------------------------------------------------------- */

.ad-slot { margin: 26px 0; min-height: 90px; display: grid; place-items: center; }
.ad-slot:empty::after {
  content: "Advertisement";
  font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 8px;
  padding: 30px 40px; width: 100%; text-align: center;
}

/* ---- Prose ----------------------------------------------------------- */

.prose { max-width: 72ch; padding: 8px 0 40px; }
.prose h2 { font-size: 1.4rem; margin: 36px 0 10px; letter-spacing: -.01em; }
.prose h3 { font-size: 1.08rem; margin: 24px 0 6px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose code {
  font-family: var(--mono); font-size: .88em;
  background: var(--surface-2); padding: 2px 5px; border-radius: 5px;
}
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: .93rem; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.prose th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.prose td { font-variant-numeric: tabular-nums; }
.callout {
  background: var(--primary-soft); border-left: 3px solid var(--primary);
  padding: 12px 14px; border-radius: 0 8px 8px 0; margin: 0 0 18px;
}
.callout p:last-child { margin-bottom: 0; }

.faq details { border-bottom: 1px solid var(--border); padding: 4px 0; }
.faq summary {
  cursor: pointer; font-weight: 600; padding: 11px 0; list-style: none;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--primary); font-size: 1.25rem; font-weight: 400; flex: none; }
.faq details[open] summary::after { content: "\2212"; }
.faq details > p { margin: 0 0 12px; color: var(--muted); }

/* ---- Related --------------------------------------------------------- */

.related { display: grid; gap: 10px; grid-template-columns: 1fr; margin: 0 0 36px; }
.related a {
  display: block; padding: 14px; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; background: var(--surface);
}
.related a:hover { border-color: var(--primary); }
.related .t { font-weight: 650; color: var(--text); }
.related .d { font-size: .86rem; color: var(--muted); }

/* ---- Footer ---------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 26px 0; margin-top: 20px; font-size: .9rem;
}
.foot-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
.foot-grid h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; }
.foot-grid li { margin-bottom: 5px; }
.foot-grid a { color: var(--muted); text-decoration: none; }
.foot-grid a:hover { color: var(--primary); }
.foot-legal { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: .84rem; }

/* Translated out of view rather than parked at left:-9999px, which would
   itself extend the scrollable area and cause horizontal scroll. */
.skip {
  position: absolute; left: 0; top: 0; z-index: 100;
  transform: translateY(-130%);
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { transform: translateY(0); }

/* ---- Desktop --------------------------------------------------------- */

@media (min-width: 720px) {
  .hero { padding: 40px 0 10px; }
  .hero h1 { font-size: 2.3rem; }
  .adv-grid { grid-template-columns: repeat(2, 1fr); }
  .related { grid-template-columns: repeat(3, 1fr); }
  .foot-grid { grid-template-columns: repeat(4, 1fr); }

  .grid-head {
    display: grid;
    grid-template-columns: 116px 1fr 1fr 90px 104px;
    gap: 10px; padding: 0 12px 6px;
  }
  .grid-head span {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted);
  }
  .grid-head span:last-child { text-align: right; }

  .day {
    grid-template-columns: 116px 1fr 1fr 90px 104px;
    align-items: start; gap: 10px;
  }
  .day-name { grid-column: auto; flex-direction: column; gap: 0; padding-top: 6px; }
  .cell > label { display: none; }
  .day-total {
    grid-column: auto; border-top: none; padding-top: 6px; margin-top: 0;
    flex-direction: column; align-items: flex-end; gap: 0;
  }
  .day-total .lbl { display: none; }
  .seg2 { grid-column: 2 / 4; }
  .split-on .seg2 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1000px) {
  .calc-grid { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
  .summary { position: sticky; top: 76px; bottom: auto; }
  .big {
    flex-direction: column; align-items: flex-start; gap: 2px;
    padding-bottom: 10px; border-bottom: 1px solid var(--border);
  }
  .big .n { font-size: 2.3rem; }
  .big .pay { margin-left: 0; text-align: left; width: 100%; padding-top: 6px; }
  /* Always expanded on desktop - the toggle is a phone affordance only. */
  .sum-more > summary { display: none; }
  .breakdown { grid-template-columns: 1fr; }
  .bd { display: flex; justify-content: space-between; align-items: baseline; }
  .bd .k { display: inline; }
}

/* ---- Print ----------------------------------------------------------- */

@media print {
  .site-header, .site-footer, .ad-slot, .actions, .advanced,
  .prose, .related, .skip, .theme-btn, .saved-note { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .summary { position: static; }
  .card, .summary-inner, .day { border-color: #999; box-shadow: none; background: #fff; }
  .calc-grid { display: block; }
  .summary-inner { margin-top: 14px; }
  .hero { padding: 0 0 10px; }
  a { text-decoration: none; color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==== Time clock ====================================================== */

:root { --danger: #b91c1c; --danger-soft: #fef2f2; --ok: #047857; --ok-soft: #ecfdf5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --danger: #f87171; --danger-soft: #2a1414; --ok: #34d399; --ok-soft: #0f2a22; }
}
:root[data-theme="dark"] { --danger: #f87171; --danger-soft: #2a1414; --ok: #34d399; --ok-soft: #0f2a22; }

.clock-card { text-align: center; padding: 22px 16px; }

.clock-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding: 5px 11px; border-radius: 999px; margin-bottom: 12px;
}
.clock-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.clock-status.idle { color: var(--muted); background: var(--surface-2); }
.clock-status.on { color: var(--ok); background: var(--ok-soft); }
.clock-status.break { color: var(--warn); background: var(--primary-soft); }

.clock-face {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(2.6rem, 13vw, 4rem); font-weight: 800;
  letter-spacing: -.03em; line-height: 1; margin: 0 0 8px;
}
.clock-sub { color: var(--muted); font-size: .9rem; margin: 0 0 18px; min-height: 1.3em; }

.clock-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.btn-clock {
  font-family: inherit; font-size: 1.12rem; font-weight: 700;
  padding: 16px 24px; border-radius: 12px; cursor: pointer;
  border: 1px solid transparent; color: #fff; width: 100%; max-width: 340px;
  min-height: 58px;
}
.btn-clock.in { background: var(--ok); }
.btn-clock.out { background: var(--danger); }
.btn-clock:hover { opacity: .92; }
.btn-clock.secondary {
  background: var(--bg); color: var(--text); border-color: var(--border-strong);
  font-size: .98rem; padding: 12px 20px; min-height: 46px;
}
.btn-clock.secondary:hover { border-color: var(--primary); color: var(--primary); opacity: 1; }

.punch-day { margin-bottom: 14px; }
.punch-day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 0 2px 6px; border-bottom: 1px solid var(--border);
}
.punch-day-total { font-family: var(--mono); color: var(--text); font-size: .95rem; }

.punch {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 8px; align-items: center;
  padding: 9px 2px; border-bottom: 1px solid var(--border);
}
.punch.running { background: var(--ok-soft); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.punch-times { display: flex; align-items: center; gap: 6px; min-width: 0; }
.punch-times input {
  width: 88px; min-height: 36px; padding: 5px 7px; font-size: .9rem;
  font-family: var(--mono); text-align: center;
}
.punch-arrow { color: var(--muted); font-size: .8rem; flex: none; }
.punch-now { font-family: var(--mono); font-size: .9rem; color: var(--ok); font-weight: 700; }
.punch-brk { font-size: .78rem; color: var(--warn); font-family: var(--mono); min-width: 34px; text-align: right; }
.punch-total { font-family: var(--mono); font-weight: 700; min-width: 54px; text-align: right; font-variant-numeric: tabular-nums; }
.punch-del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1.3rem; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.punch-del:hover { color: var(--danger); background: var(--danger-soft); }

.empty { color: var(--muted); font-size: .92rem; text-align: center; padding: 18px 0; margin: 0; }

.clock-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (min-width: 720px) {
  .clock-actions { flex-direction: row; justify-content: center; }
  .btn-clock { width: auto; min-width: 220px; }
  .btn-clock.secondary { min-width: 150px; }
  .punch-times input { width: 100px; }
}

@media print {
  .clock-actions, .punch-del { display: none !important; }
  .punch.running { background: none; }
}

/* ---- Install (PWA) --------------------------------------------------- */

.install-btn {
  background: var(--primary); color: #fff; border: 1px solid var(--primary);
  font-family: inherit; font-size: .82rem; font-weight: 600;
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
  flex: none; white-space: nowrap; min-height: 34px;
}
.install-btn:hover { opacity: .92; }
.install-btn[hidden] { display: none; }

@media print { .install-btn { display: none !important; } }
