/* ---------- tokens ---------- */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3ea;
  --text: #16191f;
  --muted: #6b7280;
  --accent: #1f7a4d;
  --accent-soft: #e6f4ec;
  --danger: #b3261e;
  --danger-on: #ffffff;
  --shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 8px 24px rgba(16, 20, 28, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2b313c;
    --text: #e8eaf0;
    --muted: #9aa3b2;
    --accent: #4ade80;
    --accent-soft: #14301f;
    --danger: #f87171;
    --danger-on: #2b0a0a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2b313c;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #4ade80;
  --accent-soft: #14301f;
  --danger: #f87171;
  --danger-on: #2b0a0a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

h1, h2 { margin: 0; line-height: 1.2; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- header ---------- */
.topbar { margin-bottom: 20px; }

.topbar h1 {
  font-size: 1.6rem;
  letter-spacing: -.02em;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .875rem;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- rate + estimate ---------- */
.earnings-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.rate-block label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.rate-field {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
}

.rate-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.currency, .per {
  color: var(--muted);
  font-size: 1rem;
}

.rate-field input {
  width: 6ch;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
}

.rate-field input:focus { outline: none; }

.rate-field input::-webkit-outer-spin-button,
.rate-field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rate-field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.estimate-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  margin-left: auto;
}

.estimate-label {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
}

.estimate-total {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.estimate-sub {
  font-size: .8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- clock button ---------- */
.clock-section {
  text-align: center;
  margin: 22px 0;
}

.clock-btn {
  width: 100%;
  max-width: 360px;
  padding: 18px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #05140c;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .06s ease, filter .15s ease;
}

.clock-btn:hover { filter: brightness(1.06); }
.clock-btn:active { transform: translateY(1px); }
.clock-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.clock-btn.is-out {
  background: var(--danger);
  color: var(--danger-on);
}

.clock-status {
  margin: 10px 0 0;
  font-size: .9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.clock-status.is-running { color: var(--text); }

.clock-status .dot {
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--danger);
  vertical-align: baseline;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

@media (prefers-reduced-motion: reduce) {
  .clock-status .dot { animation: none; }
  .clock-btn { transition: none; }
}

/* ---------- table ---------- */
.table-card { padding: 6px 8px 14px; margin-bottom: 16px; }

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 12px 8px;
}

.table-head h2 { font-size: 1.05rem; }

.table-actions { display: flex; gap: 8px; }

.ghost-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
}

.ghost-btn:hover { border-color: var(--accent); }
.ghost-btn.danger { color: var(--danger); }
.ghost-btn.danger:hover { border-color: var(--danger); }
.ghost-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

table.shifts[hidden] { display: none; }

table.shifts {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.shifts th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.shifts th.num, .shifts td.num { text-align: right; }

.shifts td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.shifts tbody tr:last-child td { border-bottom: 0; }

.shifts tr.is-running td { background: var(--accent-soft); }

.shifts input[type="date"],
.shifts input[type="time"] {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

.shifts input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.shifts input::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shifts input::-webkit-calendar-picker-indicator { filter: invert(1); }
}

.dur { font-weight: 600; white-space: nowrap; }
.pay { white-space: nowrap; }
.muted-cell { color: var(--muted); font-weight: 400; }

.running-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
}

.row-actions { width: 44px; text-align: right; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover { color: var(--danger); border-color: var(--border); background: var(--surface-2); }
.icon-btn:focus-visible { outline: 2px solid var(--danger); outline-offset: 1px; }

.empty-state {
  margin: 0;
  padding: 22px 12px 14px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}

.empty-state[hidden] { display: none; }

/* ---------- totals ---------- */
.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 20px;
}

.total-item {
  display: flex;
  flex-direction: column;
  flex: 1 1 160px;
}

.total-item + .total-item { align-items: flex-end; text-align: right; }

.total-label {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
}

.total-value {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.total-value.accent { color: var(--accent); }

.total-note { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.foot {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
}

.foot p { margin: 0; }

/* ---------- phone layout: rows become cards ---------- */
@media (max-width: 640px) {
  .wrap { padding: 20px 16px 48px; }

  .earnings-card { gap: 14px; }
  .estimate-total { font-size: 1.9rem; }

  .shifts thead { display: none; }

  .shifts, .shifts tbody, .shifts tr, .shifts td { display: block; width: 100%; }

  .shifts tr {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 8px;
    margin: 0 4px 10px;
    background: var(--surface-2);
  }

  .shifts tr.is-running { border-color: var(--accent); }

  .shifts td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 4px;
    border-bottom: 0;
    text-align: left;
  }

  .shifts td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .shifts td.num { text-align: right; }

  .shifts input[type="date"],
  .shifts input[type="time"] {
    width: auto;
    flex: 1 1 auto;
    max-width: 62%;
    background: var(--surface);
  }

  .shifts .row-actions {
    position: absolute;
    top: 4px; right: 4px;
    width: auto;
    padding: 0;
  }

  .shifts .row-actions::before { content: none; }

  /* keep the date input clear of the floating remove button */
  .shifts td:first-child { padding-right: 38px; }

  .shifts td.dur, .shifts td.pay { font-size: 1rem; }

  .totals { gap: 12px; padding: 16px; }
  .total-item { flex: 1 1 120px; }
  .total-value { font-size: 1.5rem; }
}
