/* ===== STR Hours – styles (palette shared with ExpenseFlow) ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #090d1a;
  --bg-surface:   #0e1428;
  --bg-elevated:  #131929;
  --border:       rgba(255,255,255,0.09);
  --hover:        rgba(255,255,255,0.06);

  --accent:       #6C63FF;
  --accent-hover: #7a72ff;
  --accent-soft:  rgba(108,99,255,0.16);
  --success:      #10b981;
  --success-soft: rgba(16,185,129,0.16);
  --warning:      #f59e0b;
  --warning-soft: rgba(245,158,11,0.16);
  --danger:       #ef4444;
  --danger-soft:  rgba(239,68,68,0.16);

  --text:         #f1f5f9;
  --text-2:       #94a3b8;
  --text-3:       #64748b;

  --radius:       14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --tabbar-h: 64px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-base:      #f4f6fb;
    --bg-surface:   #ffffff;
    --bg-elevated:  #eef1f8;
    --border:       rgba(15,23,42,0.10);
    --hover:        rgba(15,23,42,0.05);
    --accent-soft:  rgba(108,99,255,0.12);
    --text:         #0f172a;
    --text-2:       #475569;
    --text-3:       #64748b;
    color-scheme: light;
  }
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ===== Layout ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg-base) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; margin-right: auto; }
.brand.big { font-size: 24px; justify-content: center; margin: 0 0 6px; }
.logo {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 16px;
}
.brand.big .logo { width: 40px; height: 40px; font-size: 22px; border-radius: 12px; }
#year { width: auto; padding: 6px 10px; }
.user-chip {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 99px; background: var(--bg-elevated);
  font-size: 13px; font-weight: 600; max-width: 120px;
}
.user-chip:hover { background: var(--hover); }
.user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  display: grid; place-items: center; flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
}
.avatar.big { width: 44px; height: 44px; font-size: 16px; }
.who { display: flex; align-items: center; gap: 12px; }
@media (max-width: 380px) { .user-name { display: none; } .user-chip { padding: 3px; } }

main {
  max-width: 720px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
}
.tab { display: flex; flex-direction: column; gap: 14px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-surface); border-top: 1px solid var(--border);
}
.tabbar button {
  flex: 1; max-width: 140px; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 11px; font-weight: 600;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--accent); }

/* ===== Cards ===== */
.card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.card h2 { font-size: 18px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.stat { background: var(--bg-elevated); border-radius: 12px; padding: 12px; }
.stat { min-width: 0; }
.stat .k { font-size: 12px; color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-2); }
input, select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border); outline: none;
  font-size: 16px; /* stops iOS zoom */
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 12.5px; color: var(--warning); background: var(--warning-soft); padding: 8px 10px; border-radius: 8px; }

.seg { display: flex; background: var(--bg-elevated); border-radius: 10px; padding: 3px; gap: 3px; border: 1px solid var(--border); }
.seg label, .seg button {
  flex: 1; text-align: center; padding: 8px 6px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--text-2); border: 0; background: none;
}
.seg input { display: none; }
.seg label:has(input:checked), .seg button.active { background: var(--accent); color: #fff; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elevated); cursor: pointer; font-weight: 600; font-size: 14px;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-link { background: none; border: 0; color: var(--text-2); text-decoration: underline; cursor: pointer; font-size: 13px; padding: 6px; }
.icon-btn { background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-start, .btn-stop {
  width: 100%; border: 0; border-radius: 16px; cursor: pointer;
  padding: 18px; font-size: 19px; font-weight: 800; color: #fff; letter-spacing: .3px;
}
.btn-start { background: var(--success); box-shadow: 0 6px 24px rgba(16,185,129,.35); }
.btn-stop  { background: var(--danger);  box-shadow: 0 6px 24px rgba(239,68,68,.35); }
.btn-start:active, .btn-stop:active { transform: scale(.98); }

/* ===== Running timer ===== */
.running { text-align: center; border-color: rgba(16,185,129,.5); }
.running .label { font-weight: 700; font-size: 15px; }
.clock { font-size: 56px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; margin: 6px 0 2px; }
.running .sub { color: var(--text-2); font-size: 13.5px; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--success); margin-right: 6px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.gps-box { margin: 14px 0 6px; padding: 12px; border-radius: 12px; background: var(--bg-elevated); }
.gps-box b { font-size: 28px; font-variant-numeric: tabular-nums; }
.running .btn-stop { margin-top: 16px; }

/* ===== Progress bars ===== */
.bar { position: relative; height: 12px; border-radius: 99px; background: var(--bg-elevated); overflow: hidden; margin: 8px 0 6px; }
.bar > div { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }
.bar .b-maybe { background: repeating-linear-gradient(45deg, var(--warning-soft), var(--warning-soft) 5px, rgba(245,158,11,.32) 5px, rgba(245,158,11,.32) 10px); }
.bar .b-yes { background: var(--accent); }
.bar.done .b-yes { background: var(--success); }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.prog-head b { font-size: 20px; font-variant-numeric: tabular-nums; }
.prog-row + .prog-row { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.prog-head .name { font-size: 15px; }
.split { margin-top: 6px; }
.prop-row { cursor: pointer; border-radius: 8px; }
.prop-row:hover .name { color: var(--accent); }
.prop-row.dim { opacity: .5; }
.gen { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); border-bottom: 0; }
.card-head .small { text-align: right; }
.inline-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.inline-field input { width: 110px; padding: 6px 10px; font-size: 15px; text-align: right; }
a.btn { text-decoration: none; color: var(--text); }
a.btn.primary { color: #fff; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ===== Chips / badges ===== */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--bg-elevated); color: var(--text-2); white-space: nowrap; }
.chip.ok, .badge.yes  { background: var(--success-soft); color: var(--success); }
.chip.warn, .badge.maybe { background: var(--warning-soft); color: var(--warning); }
.chip.bad, .badge.no  { background: var(--danger-soft); color: var(--danger); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }

/* ===== Lists ===== */
.list { display: flex; flex-direction: column; }
.day-head { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; padding: 14px 4px 6px; display: flex; justify-content: space-between; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 6px;
}
.item:hover { background: var(--hover); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.item-side b { font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--text-2); padding: 36px 16px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filters.one { grid-template-columns: 1fr; }
.totals { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-2); padding: 0 4px; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-variant-numeric: tabular-nums; }

/* ===== Modal ===== */
dialog {
  margin: auto; border: 0; padding: 0; background: transparent; color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.modal-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 18px;
  display: flex; flex-direction: column; max-height: calc(100dvh - 24px);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.modal-foot .spacer { flex: 1; }
.stop-summary { font-size: 14px; color: var(--text-2); }
.stop-summary b { color: var(--text); font-size: 16px; }
.btn-link.left { align-self: flex-start; padding-left: 0; text-decoration: none; color: var(--accent); font-weight: 600; font-size: 14px; }
.osm { font-size: 11.5px; color: var(--text-3); margin-top: -6px; }

/* From → To: full addresses, tap to edit */
.route { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); padding: 0 12px; }
.route-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; cursor: text; }
.route-row + .route-row { border-top: 1px solid var(--border); }
.route-row .k { width: 40px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--text-2); padding-top: 2px; }
.route-row .edit { color: var(--text-3); font-size: 14px; padding-top: 1px; }
textarea.plain {
  flex: 1; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent;
  resize: none; overflow: hidden; line-height: 1.4; font-size: 15px;
}
textarea.plain:focus { box-shadow: 0 1.5px 0 var(--accent); }
.receipt-preview { max-width: 100%; max-height: 260px; border-radius: 10px; object-fit: contain; background: var(--bg-elevated); }

/* ===== Loading ===== */
.splash { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.spinner {
  display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner.dark { border-color: var(--border); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Auth ===== */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; text-align: center;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px 22px;
}
.auth-card .field { text-align: left; }
.alert { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg-base); padding: 10px 16px; border-radius: 12px;
  font-weight: 600; font-size: 14px; transition: .25s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--danger); color: #fff; }

.disclaimer { font-size: 12px; color: var(--text-3); line-height: 1.5; padding: 0 4px; }

@media (max-width: 420px) {
  .clock { font-size: 46px; }
  .stat { padding: 10px; }
  .stat .v { font-size: 19px; }
}
