/* =========================================================================
   Jae Tutoring — hours and billing log

   Palette
     Carbon Black  #1A1F16   ink on light, ground on dark
     Platinum      #EEF1EF   ground on light, ink on dark
     Pine Blue     #587B7F   the single accent

   Ochre (money owed), moss (settled) and brick (destructive) are the only
   additions — each earns its place by carrying meaning, not decoration.
   ========================================================================= */

:root {
  /* ground & ink */
  --paper:      #eef1ef;
  --surface:    #ffffff;
  --surface-2:  #e5e9e6;
  --ink:        #1a1f16;
  --muted:      #58604f;
  --faint:      #848b7f;
  --line:       rgba(26, 31, 22, .14);
  --line-soft:  rgba(26, 31, 22, .07);

  /* accent */
  --accent:      #587b7f;
  --accent-ink:  #44656a;
  --accent-wash: rgba(88, 123, 127, .12);
  --accent-line: rgba(88, 123, 127, .38);
  --accent-text: #527276;   /* pine, darkened just enough to read as text on paper */
  --on-accent:   #ffffff;

  /* money owed */
  --amber:      #85590f;
  --amber-bg:   rgba(196, 150, 60, .16);
  --amber-line: rgba(196, 150, 60, .45);

  /* settled */
  --green:      #416b4d;
  --green-bg:   rgba(65, 107, 77, .12);

  /* destructive */
  --danger:     #9f4539;
  --danger-bg:  rgba(159, 69, 57, .11);

  /* form */
  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 1px 2px rgba(26, 31, 22, .05), 0 10px 28px -18px rgba(26, 31, 22, .30);
  --shadow-lg:  0 2px 8px rgba(26, 31, 22, .08), 0 26px 60px -28px rgba(26, 31, 22, .45);

  --sans:  "Public Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --disp:  "Bricolage Grotesque", var(--sans);
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #12160f;
    --surface:    #1a1f16;
    --surface-2:  #232a1e;
    --ink:        #eef1ef;
    --muted:      #a0a899;
    --faint:      #737b6c;
    --line:       rgba(238, 241, 239, .13);
    --line-soft:  rgba(238, 241, 239, .07);

    --accent:      #8fb4b8;
    --accent-ink:  #a8c7cb;
    --accent-wash: rgba(143, 180, 184, .16);
    --accent-line: rgba(143, 180, 184, .42);
    --accent-text: #8fb4b8;
    --on-accent:   #12160f;

    --amber:      #dcaf5e;
    --amber-bg:   rgba(220, 175, 94, .14);
    --amber-line: rgba(220, 175, 94, .34);

    --green:      #74ac83;
    --green-bg:   rgba(116, 172, 131, .15);

    --danger:     #df8b80;
    --danger-bg:  rgba(223, 139, 128, .14);

    --shadow:     0 1px 2px rgba(0, 0, 0, .45), 0 10px 28px -18px rgba(0, 0, 0, .85);
    --shadow-lg:  0 2px 8px rgba(0, 0, 0, .5), 0 26px 60px -28px rgba(0, 0, 0, .95);
  }
}

:root[data-theme="dark"] {
  --paper:      #12160f;
  --surface:    #1a1f16;
  --surface-2:  #232a1e;
  --ink:        #eef1ef;
  --muted:      #a0a899;
  --faint:      #737b6c;
  --line:       rgba(238, 241, 239, .13);
  --line-soft:  rgba(238, 241, 239, .07);

  --accent:      #8fb4b8;
  --accent-ink:  #a8c7cb;
  --accent-wash: rgba(143, 180, 184, .16);
  --accent-line: rgba(143, 180, 184, .42);
  --accent-text: #8fb4b8;
  --on-accent:   #12160f;

  --amber:      #dcaf5e;
  --amber-bg:   rgba(220, 175, 94, .14);
  --amber-line: rgba(220, 175, 94, .34);

  --green:      #74ac83;
  --green-bg:   rgba(116, 172, 131, .15);

  --danger:     #df8b80;
  --danger-bg:  rgba(223, 139, 128, .14);

  --shadow:     0 1px 2px rgba(0, 0, 0, .45), 0 10px 28px -18px rgba(0, 0, 0, .85);
  --shadow-lg:  0 2px 8px rgba(0, 0, 0, .5), 0 26px 60px -28px rgba(0, 0, 0, .95);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 940px; margin: 0 auto; padding: 0 20px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Every interactive element gets the same focus ring. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- masthead -- */
.masthead {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.masthead-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 13px; padding-bottom: 13px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong {
  font-family: var(--disp); font-weight: 800; font-size: 17px;
  letter-spacing: -.015em;
}
.brand-text span {
  font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.masthead-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lock-state {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--green);
  background: var(--green-bg); border: 1px solid transparent;
  padding: 5px 10px; border-radius: 999px;
}
.lock-state svg { width: 13px; height: 13px; }

/* -------------------------------------------------------------- buttons -- */
.btn {
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 7px; white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, transform .06s;
}
.btn:hover { border-color: var(--accent-line); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--accent-wash); border-color: var(--accent-line); }

.btn-start {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  font-size: 15px; padding: 11px 22px;
}
.btn-start:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

.btn-stop {
  background: var(--danger); border-color: var(--danger); color: #fff;
  font-size: 15px; padding: 11px 22px;
}
.btn-stop:hover { filter: brightness(1.06); }

main { padding-bottom: 72px; }

.viewer-note {
  margin: 18px 0 0; padding: 11px 14px;
  background: var(--accent-wash);
  border: 1px solid var(--accent-line); border-left-width: 3px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--muted);
}

/* ----------------------------------------------------------------- card -- */
/* One card language across the whole page. */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ----------------------------------------------------------- pay period -- */
.period-card {
  margin-top: 16px; padding: 20px 22px;
  position: relative; overflow: hidden;
}
.period-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--accent);
}
.period-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}
.eyebrow {
  margin: 0; font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
}
.period-range {
  margin: 3px 0 0; font-family: var(--disp); font-weight: 700;
  font-size: clamp(19px, 3.4vw, 25px); letter-spacing: -.015em;
  text-wrap: balance;
}
.period-range .dash { color: var(--accent-text); margin: 0 6px; font-weight: 500; }
.period-payday { text-align: right; }
.period-payday strong {
  display: block; font-family: var(--disp); font-size: 15px; font-weight: 700;
  margin-top: 2px;
}
.days-left { font-size: 12px; color: var(--muted); }

.period-figures {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px;
}
.figure {
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.figure-accent { background: var(--amber-bg); border-color: var(--amber-line); }
.figure-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.figure-value {
  display: block; font-size: clamp(22px, 4.6vw, 30px); font-weight: 600;
  letter-spacing: -.02em; line-height: 1.15;
}
.figure-accent .figure-value { color: var(--amber); }

.period-live {
  margin: 13px 0 0; font-size: 12.5px; color: var(--accent-text);
  display: flex; align-items: center; gap: 7px; font-weight: 500;
}
.pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.9s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------------------------------------------------------------- timer -- */
.timer-card {
  margin-top: 16px; padding: 24px 22px;
  transition: border-color .25s, box-shadow .25s;
}
.timer-card.is-running {
  border-color: var(--accent-line);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-wash);
}
.timer-main {
  display: flex; align-items: center; justify-content: space-between;
  gap: 26px; flex-wrap: wrap;
}
.timer-readout { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.clock {
  font-size: clamp(40px, 9vw, 60px); font-weight: 500; line-height: 1;
  letter-spacing: -.03em; color: var(--ink);
}
.timer-card.is-running .clock { color: var(--accent-text); }
.accrued {
  font-size: clamp(17px, 3.2vw, 22px); font-weight: 600; color: var(--amber);
  letter-spacing: -.01em;
}
.timer-side { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.timer-status { margin: 0; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.timer-rate { margin: 0 0 10px; font-size: 12.5px; color: var(--faint); }
.timer-buttons { display: flex; gap: 9px; flex-wrap: wrap; }

/* --------------------------------------------------------------- totals -- */
.totals {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px;
}
.tot {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 15px;
}
.tot-owed { border-color: var(--amber-line); background: var(--amber-bg); }
.tot-label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.tot-value { display: block; font-size: 19px; font-weight: 600; letter-spacing: -.015em; }
.tot-owed .tot-value { color: var(--amber); }

/* ------------------------------------------------------------- sections -- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 34px 0 12px;
}
.section-head h2 {
  margin: 0; font-family: var(--disp); font-size: 19px; font-weight: 700;
  letter-spacing: -.015em;
}

/* ------------------------------------------------------------ month/rows -- */
.month-group { margin-bottom: 22px; }
.month-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 0 4px 7px;
  border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.month-name {
  font-family: var(--disp); font-size: 12.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.month-sum { font-family: var(--mono); font-size: 12.5px; color: var(--faint); }

.row {
  display: grid;
  grid-template-columns: 74px 1fr auto auto auto;
  align-items: center; gap: 12px;
  padding: 11px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 7px;
  transition: border-color .14s;
}
.row:hover { border-color: var(--accent-line); }
.row.is-paid { background: var(--surface-2); border-color: var(--line-soft); }
.row-date {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  display: flex; flex-direction: column; line-height: 1.3;
}
.row-date .dow {
  font-size: 10.5px; color: var(--faint);
  text-transform: uppercase; letter-spacing: .05em;
}
.row-main { min-width: 0; }
.row-subject { font-weight: 600; font-size: 14px; }
.row-meta { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.row-meta .sep { color: var(--faint); margin: 0 5px; }
.row-notes { font-size: 12px; color: var(--faint); font-style: italic; }
.row-dur { font-family: var(--mono); font-size: 13px; color: var(--muted); text-align: right; }
.row-amt {
  font-family: var(--mono); font-size: 15px; font-weight: 600;
  text-align: right; letter-spacing: -.01em; min-width: 78px;
  font-variant-numeric: tabular-nums;
}
.row.is-paid .row-amt { color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 4px; }

.chip {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; font-family: var(--sans);
  letter-spacing: .02em; transition: filter .14s;
}
.chip-paid   { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 32%, transparent); }
.chip-unpaid { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.chip:hover { filter: brightness(.96); }
.chip[disabled] { cursor: default; opacity: .85; }
span.chip { cursor: default; }

.icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 7px; border: 1px solid transparent; background: transparent;
  color: var(--faint); cursor: pointer;
}
.icon-btn:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn svg { width: 14px; height: 14px; }

.empty {
  padding: 40px 20px; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty strong {
  display: block; font-family: var(--disp); font-size: 16px;
  color: var(--ink); margin-bottom: 4px;
}

/* ---------------------------------------------------------------- forms -- */
.add-form, .settings-form {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  padding: 18px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-wide { grid-column: span 2; }
.field label {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  letter-spacing: .01em;
}
.field input, .field select {
  font-family: var(--sans); font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { border-color: transparent; }
.add-actions {
  grid-column: 1 / -1; display: flex; gap: 9px; align-items: center;
  padding-top: 4px;
}
.hint { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--faint); }

/* --------------------------------------------------------------- dialog -- */
.dialog {
  border: none; border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg); max-width: 380px; width: calc(100% - 32px);
}
.dialog::backdrop { background: rgba(26, 31, 22, .6); backdrop-filter: blur(3px); }
.dialog form { padding: 24px; }
.dialog h2 {
  margin: 0 0 6px; font-family: var(--disp); font-size: 19px;
  font-weight: 700; letter-spacing: -.015em;
}
.dialog-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.code-input {
  width: 100%; font-family: var(--mono); font-size: 30px; font-weight: 500;
  text-align: center; letter-spacing: .34em; text-indent: .34em;
  padding: 13px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.code-input:focus { border-color: transparent; }
.dialog-error {
  margin: 11px 0 0; font-size: 13px; color: var(--danger);
  background: var(--danger-bg); padding: 8px 11px; border-radius: var(--radius-sm);
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

/* ---------------------------------------------------------------- toast -- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; z-index: 60; max-width: calc(100% - 40px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* ----------------------------------------------------------------- foot -- */
.foot {
  margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--faint);
}

/* ----------------------------------------------------------- responsive -- */
@media (max-width: 720px) {
  .totals { grid-template-columns: repeat(2, 1fr); }
  .add-form, .settings-form { grid-template-columns: repeat(2, 1fr); }
  .field-wide { grid-column: span 2; }
  .period-figures { grid-template-columns: 1fr; }
  .timer-main { gap: 16px; }
  .row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "date amt" "main amt" "dur actions";
    row-gap: 6px;
  }
  .row-date { grid-area: date; flex-direction: row; gap: 6px; align-items: baseline; }
  .row-main { grid-area: main; }
  .row-dur  { grid-area: dur; text-align: left; }
  .row-amt  { grid-area: amt; align-self: center; }
  .row-actions { grid-area: actions; justify-content: flex-end; }
}
@media (max-width: 460px) {
  .period-head { flex-direction: column; gap: 10px; }
  .period-payday { text-align: left; }
  .masthead-inner { flex-wrap: wrap; }
  .brand-text span { white-space: normal; }
  .timer-side { width: 100%; }
  .timer-buttons { width: 100%; }
  .timer-buttons .btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
