:root {
  --accent: #007AFF;
  --accent-rgb: 0, 122, 255;
  --red: #FF3B30;
  --green: #34C759;
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --separator: rgba(60, 60, 67, 0.18);
  --text: #000;
  --text-secondary: rgba(60, 60, 67, 0.7);
  --text-tertiary: rgba(60, 60, 67, 0.45);
  --tab-bar-bg: rgba(249, 249, 249, 0.85);
  --tab-bar-border: rgba(0, 0, 0, 0.18);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-elev: #1c1c1e;
    --bg-card: #1c1c1e;
    --separator: rgba(84, 84, 88, 0.6);
    --text: #fff;
    --text-secondary: rgba(235, 235, 245, 0.6);
    --text-tertiary: rgba(235, 235, 245, 0.3);
    --tab-bar-bg: rgba(22, 22, 22, 0.85);
    --tab-bar-border: rgba(255, 255, 255, 0.18);
  }
}

[data-theme="light"] {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --separator: rgba(60, 60, 67, 0.18);
  --text: #000;
  --text-secondary: rgba(60, 60, 67, 0.7);
  --text-tertiary: rgba(60, 60, 67, 0.45);
  --tab-bar-bg: rgba(249, 249, 249, 0.85);
  --tab-bar-border: rgba(0, 0, 0, 0.18);
}

[data-theme="dark"] {
  --bg: #000;
  --bg-elev: #1c1c1e;
  --bg-card: #1c1c1e;
  --separator: rgba(84, 84, 88, 0.6);
  --text: #fff;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --text-tertiary: rgba(235, 235, 245, 0.3);
  --tab-bar-bg: rgba(22, 22, 22, 0.85);
  --tab-bar-border: rgba(255, 255, 255, 0.18);
}

/* Boot-state: visa antingen auth-skärm ELLER app, aldrig båda eller blank.
   Beslutet tas synkront i inline-scriptet i <head>. */
html[data-boot="auth"] #app,
html[data-boot="auth"] #tab-bar { display: none !important; }
html[data-boot="app"] #auth-screen { display: none !important; }
html:not([data-boot]) #app,
html:not([data-boot]) #auth-screen,
html:not([data-boot]) #tab-bar { visibility: hidden; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.3;
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* Dölj native upp/ner-pilar på number-input — de överlappar talet i
   Safari/iOS och tillför inget (vi har inputmode=decimal för rätt
   keypad ändå). */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

button { cursor: pointer; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(56px + var(--safe-bottom));
  overflow: hidden;
}

.view {
  display: none;
  flex-direction: column;
  min-height: 0;
}
.view.active { display: flex; flex: 1; min-height: 0; }
.detail-view.active { display: flex; flex: 1; min-height: 0; }

/* Nav bars */
.nav-large {
  padding: calc(var(--safe-top) + 8px) 20px 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background: var(--bg);
}
.nav-large h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.37px;
}
.nav-inline {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(var(--safe-top) + 8px) 16px 12px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--bg);
  border-bottom: 0.5px solid var(--separator);
}
.nav-inline h2 {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}
.nav-spacer { width: 1px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--accent);
  font-size: 17px;
  padding: 4px 0;
  justify-self: start;
}

.icon-btn {
  color: var(--accent);
  padding: 4px;
  border-radius: 8px;
}
.icon-btn:active { opacity: 0.5; }

/* Content area */
.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 24px;
}

/* List groups (iOS-style insetGrouped) */
.list-grouped {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 8px 0;
}
.list-section {
  display: flex;
  flex-direction: column;
}
.list-section-header {
  font-size: 13px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  padding: 0 32px 6px;
}
.list-section-footer {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 32px 0;
  line-height: 1.35;
}
.list-section-body {
  background: var(--bg-card);
  border-radius: 12px;
  margin: 0 16px;
  overflow: clip;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 44px;
  border-bottom: 0.5px solid var(--separator);
  width: 100%;
  text-align: left;
  background: transparent;
}
.list-row:last-child { border-bottom: none; }
.list-row.tappable:active { background: rgba(120, 120, 128, 0.16); }
.list-row.tappable {
  cursor: pointer;
}
.list-row .label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.list-row .label .title { font-size: 17px; color: var(--text); }
.list-row .label .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.list-row .value {
  color: var(--text-secondary);
  font-size: 17px;
  text-align: right;
}
.list-row .chevron {
  color: var(--text-tertiary);
  font-size: 14px;
}
.list-row .check {
  color: var(--accent);
  font-size: 18px;
}
.list-row.destructive .label .title { color: var(--red); }
.list-row input[type="text"],
.list-row input[type="number"],
.list-row input[type="date"],
.list-row input[type="datetime-local"] {
  flex: 1;
  text-align: right;
  font-size: 17px;
  color: var(--text-secondary);
  min-width: 0;
}
.list-row .inline-input {
  flex: 1;
  text-align: left;
  font-size: 17px;
  color: var(--text);
}
.list-row select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  text-align: right;
  font-size: 17px;
  color: var(--text-secondary);
  padding-right: 18px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  background-size: 11px 7px;
}
.list-row .add-btn {
  color: var(--accent);
  font-size: 17px;
  font-weight: 500;
}
.list-row .add-btn:disabled { color: var(--text-tertiary); }
.list-row.empty {
  color: var(--text-secondary);
  font-size: 15px;
  justify-content: center;
  padding: 20px;
}

/* Timer view */
.timer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 24px 24px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.selection-header {
  text-align: center;
  margin-top: 16px;
  margin-bottom: 28px;
}
.selection-header .customer {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.selection-header .activity {
  font-size: 17px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.selection-header.empty .customer { color: var(--text-secondary); font-weight: 600; }
.selection-header.empty .activity { color: var(--text-tertiary); }

.timer-display {
  font-size: 76px;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  margin: 16px 0 4px;
}
.timer-display.running { color: var(--text); }
.timer-display.idle { color: var(--text-secondary); }
.earnings-display {
  font-size: 20px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-height: 26px;
  margin-bottom: 12px;
}

.timer-buttons {
  margin-top: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.primary-btn {
  width: 100%;
  height: 60px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  transition: opacity 0.12s, transform 0.12s;
}
.primary-btn:disabled {
  opacity: 0.45;
}
.primary-btn:active:not(:disabled) {
  transform: scale(0.985);
  opacity: 0.88;
}
.primary-btn.stop { background: var(--red); }
.secondary-link {
  color: var(--accent);
  font-size: 15px;
  padding: 6px 12px;
}

/* Sheet */
.sheet-host {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  pointer-events: none;
}
.sheet-host.open {
  display: block;
  pointer-events: auto;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.25s;
}
.sheet-host.open .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  border-radius: 14px 14px 0 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-bottom: var(--safe-bottom);
}
.sheet-host.open .sheet { transform: translateY(0); }
.sheet-handle {
  width: 36px;
  height: 5px;
  background: var(--text-tertiary);
  border-radius: 3px;
  margin: 8px auto;
  opacity: 0.6;
}
.sheet-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 16px 12px;
  border-bottom: 0.5px solid var(--separator);
}
.sheet-header h3 { font-size: 17px; font-weight: 600; text-align: center; }
.sheet-cancel, .sheet-confirm {
  color: var(--accent);
  font-size: 17px;
  padding: 6px 0;
}
.sheet-cancel { justify-self: start; }
.sheet-confirm { justify-self: end; font-weight: 600; }
.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
  -webkit-overflow-scrolling: touch;
}

/* Tab bar */
#tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--tab-bar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}
#tab-bar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-tertiary);
  transition: color 0.1s;
}
#tab-bar .tab.active { color: var(--accent); }
#tab-bar .tab svg { stroke-width: 1.8; }
#tab-bar .tab.active svg { stroke-width: 2.2; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 32px;
  gap: 8px;
  text-align: center;
}
.empty-state .title { font-size: 20px; font-weight: 600; }
.empty-state .desc { color: var(--text-secondary); font-size: 15px; }
.empty-state .icon { color: var(--text-tertiary); margin-bottom: 8px; }

/* Global quick-action knapp — dold som default, visas bara på desktop-web */
.quick-action { display: none; }

/* Confirm dialog (in-app, ersätter browser-confirm) */
.confirm-host {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  pointer-events: none;
}
.confirm-host.open {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.18s;
}
.confirm-host.open .confirm-backdrop { opacity: 1; }
.confirm-dialog {
  position: relative;
  background: var(--bg-card);
  border-radius: 14px;
  padding: 20px 24px 0;
  max-width: 320px;
  width: calc(100% - 48px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  transform: scale(0.94);
  opacity: 0;
  transition: transform 0.18s, opacity 0.18s;
}
.confirm-host.open .confirm-dialog {
  transform: scale(1);
  opacity: 1;
}
.confirm-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
}
.confirm-message {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.4;
}
.confirm-buttons {
  display: flex;
  gap: 0;
  border-top: 0.5px solid var(--separator);
  margin: 0 -24px;
}
.confirm-buttons button {
  flex: 1;
  padding: 14px;
  font-size: 17px;
  color: var(--accent);
  background: transparent;
  border-radius: 0;
  cursor: pointer;
}
.confirm-buttons button + button { border-left: 0.5px solid var(--separator); }
.confirm-buttons button:active { background: rgba(120, 120, 128, 0.16); }
.confirm-buttons button:hover { background: rgba(120, 120, 128, 0.08); }
.confirm-buttons .confirm-ok.destructive {
  color: var(--red);
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2000;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Fakturering — badges, select-mode, invoice-cta */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-invoiced {
  background: rgba(52, 199, 89, 0.15);
  color: var(--green);
}
.badge-unbilled {
  background: rgba(120, 120, 128, 0.16);
  color: var(--text-secondary);
}
.row-invoiced { background: rgba(52, 199, 89, 0.04); }
.row-invoiced .label .title { color: var(--text-secondary); }
.row-selected { background: rgba(var(--accent-rgb), 0.10); }
.row-selected.tappable:hover { background: rgba(var(--accent-rgb), 0.14); }

.check-box {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--text-tertiary);
  flex-shrink: 0;
  display: inline-block;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}
.check-box.on {
  background: var(--accent);
  border-color: var(--accent);
}
.check-box.on::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  margin-bottom: 12px;
}
.filter-bar .segmented {
  flex: 1;
  margin: 0;
}
.link-btn {
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  padding: 6px 10px;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.link-btn:disabled { color: var(--text-tertiary); cursor: default; }
.link-btn:active:not(:disabled) { opacity: 0.5; }

.select-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
  margin-bottom: 12px;
}
.select-bar .select-count {
  font-size: 14px;
  color: var(--text-secondary);
}
.invoice-action {
  display: flex;
  gap: 8px;
  align-items: stretch;
  padding: 0 16px 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.invoice-action input[type="text"] {
  flex: 1;
  font-size: 16px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 0.5px solid var(--separator);
  color: var(--text);
}
.primary-btn.small {
  width: auto;
  height: auto;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  flex-shrink: 0;
}
.primary-btn:disabled { opacity: 0.45; cursor: default; }

.invoice-cta {
  padding: 12px 16px 4px;
}
.invoice-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px 8px;
  font-size: 15px;
}

.sheet-confirm:disabled { color: var(--text-tertiary); cursor: default; }

.stat-card .stat-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.stat-card.stat-billed .stat-value { color: var(--green); }
.stat-card.stat-unbilled .stat-value { color: var(--accent); }

/* Stats summary: auto-fit på desktop så 4 OCH 6 kort ser rimliga ut */
@media (min-width: 768px) and (display-mode: browser) {
  .stat-summary { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* Misc */
.muted { color: var(--text-secondary); }
.mono { font-variant-numeric: tabular-nums; }
.row-spread { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-title-large { padding: 16px 16px 8px; font-size: 14px; color: var(--text-secondary); }

/* Stats summary cards */
.stat-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); }
.stat-card .stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Segmented control */
.segmented {
  display: flex;
  background: rgba(120, 120, 128, 0.12);
  border-radius: 9px;
  padding: 2px;
  margin: 0 16px 16px;
}
.segmented button {
  flex: 1;
  padding: 6px 4px;
  font-size: 13px;
  color: var(--text);
  border-radius: 7px;
  white-space: nowrap;
}
.segmented button.active {
  background: var(--bg-card);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0,0,0,0.06);
}

/* Inline add */
.inline-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 44px;
}
.inline-add input {
  flex: 1;
  font-size: 17px;
  color: var(--text);
}
.inline-add button {
  color: var(--accent);
  font-weight: 500;
}
.inline-add button:disabled { color: var(--text-tertiary); }

/* Auth screen */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-screen[hidden] { display: none; }
.auth-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-card h1 {
  font-size: 40px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.4px;
}
.auth-sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: -8px;
  margin-bottom: 8px;
}
.auth-card input[type="email"],
.auth-card input[type="password"] {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 17px;
  color: var(--text);
  border: 0.5px solid var(--separator);
}
.auth-status {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: 10px;
}
.auth-status.error { color: var(--red); }
.auth-status.success { color: var(--green); }

/* Desktop / web version: vanlig webbsida med top-nav + centrerat innehåll.
   Mobil (<768px) och installerad PWA i standalone-läge är opåverkade. */
@media (min-width: 768px) and (display-mode: browser) {
  :root { --content-max: 1100px; --topnav-h: 64px; }

  html {
    height: 100%;
    overflow-y: auto;
  }
  body {
    height: auto;
    min-height: 100%;
    overflow: visible;
    background: var(--bg);
  }

  /* Reset flex-magic från mobil — naturligt block-flöde på desktop */
  #app {
    display: block;
    height: auto;
    min-height: 100vh;
    padding-top: var(--topnav-h);
    padding-bottom: 0;
    overflow: visible;
  }
  .view, .view.active, .detail-view.active {
    display: none;
    flex: none;
    height: auto;
    min-height: 0;
  }
  .view.active, .detail-view.active { display: block; }
  .content {
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 8px 0 48px;
  }

  /* Topp-nav: 3-sektioners layout — iTime vänster, flikar centrerade,
     + knapp till höger (fixed-positioned separat). ::before fyller
     vänster halva, ::after fyller höger halva som motvikt, så flikarna
     hamnar exakt i mitten av content-ramen. */
  #tab-bar {
    position: fixed;
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--topnav-h);
    padding-left: max(32px, calc(50vw - 534px));
    padding-right: max(32px, calc(50vw - 534px));
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    background: var(--bg-elev);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: none;
    border-bottom: 0.5px solid var(--separator);
    z-index: 50;
  }
  #tab-bar::before {
    content: 'iTime';
    flex: 1;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--text);
  }
  #tab-bar::after {
    content: '';
    flex: 1;
  }
  #tab-bar .tab {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 8px;
    padding: 8px 14px;
    height: 36px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
  }
  #tab-bar .tab:hover { background: rgba(120, 120, 128, 0.12); color: var(--text); }
  #tab-bar .tab.active {
    background: rgba(var(--accent-rgb), 0.12);
    color: var(--accent);
  }
  #tab-bar .tab svg { width: 16px; height: 16px; stroke-width: 2; }
  #tab-bar .tab.active svg { stroke-width: 2.2; }
  #tab-bar .tab span { display: inline; font-size: 14px; }

  /* Nav-headers och content: centrerat med max-bredd */
  .nav-large,
  .nav-inline {
    max-width: var(--content-max);
    margin: 0 auto;
    width: 100%;
    padding-left: 32px;
    padding-right: 32px;
    background: transparent;
  }
  .nav-large {
    padding-top: 32px;
    padding-bottom: 16px;
  }
  .nav-large h1 { font-size: 32px; }
  .nav-inline { position: static; border-bottom: none; }
  .content {
    max-width: var(--content-max);
    margin: 0 auto;
    width: 100%;
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Timer-vyn på desktop: dölj duplicerad "iTime"-rubrik, men behåll
     nav-large-containern så picker-ikonen kan flyta upp till höger. */
  #view-timer > .nav-large > h1 { display: none; }
  #view-timer > .nav-large {
    padding: 0;
    height: 0;
    overflow: visible;
  }
  #view-timer .content.timer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: none;
    height: auto;
    min-height: calc(100vh - var(--topnav-h));
    overflow: visible;
    max-width: 520px;
    margin: 0 auto;
    padding: 48px 24px;
    gap: 8px;
  }
  .timer-display { font-size: 88px; margin: 24px 0 4px; }
  .timer-buttons { margin-top: 32px; }

  /* Stats: 4 kolumner */
  .stat-summary { grid-template-columns: repeat(4, 1fr); }

  /* Hover-states för interaktiva rader */
  .list-row.tappable { transition: background 0.12s; }
  .list-row.tappable:hover { background: rgba(120, 120, 128, 0.08); }
  .primary-btn { transition: background 0.12s, transform 0.12s, filter 0.12s; }
  .primary-btn:hover:not(:disabled) { filter: brightness(1.08); }

  /* --- Top-höger åtgärdsknappar -----------------------------------------
     Höger-kanten av 1100px content-kolumnen: calc(50vw - 534px),
     min 32px på smala viewportar (16px content-padding + 16px andrum).
     Global + Ny kund sitter där. Vy-specifika knappar (+ Ny tid, picker)
     skjuts en knappbredd till vänster för att inte krocka. */

  /* Global + Ny kund — synlig på alla vyer */
  .quick-action {
    position: fixed;
    top: 12px;
    right: max(32px, calc(50vw - 534px));
    z-index: 61;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.35);
    cursor: pointer;
    transition: filter 0.12s, transform 0.12s, box-shadow 0.12s;
  }
  .quick-action:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 10px rgba(var(--accent-rgb), 0.45);
  }
  .quick-action:active { transform: scale(0.96); }
  .quick-action svg { width: 20px; height: 20px; }

  /* Inga vy-specifika ikon-knappar på desktop. Den globala + Ny kund
     räcker som top-höger-åtgärd. Manuell tid läggs till från Historik
     via mobil-flödet eller framtida UI; picker öppnas via klick på
     kundnamnet i Timer-vyn. */
  .nav-large .icon-btn { display: none; }

  /* Sheet: centrerad bottom-sheet i mitten av sidan */
  .sheet {
    max-width: 560px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border-radius: 14px;
    max-height: 80vh;
    bottom: 5vh;
  }
  .sheet-host.open .sheet { transform: translateX(-50%) translateY(0); }

  /* Toast: behåll horisontell centrering från mobil, justera bara y
     (på desktop finns ingen bottom tab bar att hoppa över). */
  .toast {
    bottom: 32px;
    top: auto;
  }
}

/* PWA i standalone (installerad app): behåll telefon-kolumnen på desktop */
@media (min-width: 768px) and (display-mode: standalone) {
  :root { --app-max: 480px; }
  body { background: #000; }
  @media (prefers-color-scheme: light) {
    body { background: #d1d1d6; }
  }
  [data-theme="light"] body { background: #d1d1d6; }
  [data-theme="dark"] body { background: #000; }

  #app {
    max-width: var(--app-max);
    margin: 0 auto;
    background: var(--bg);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
  }
  #tab-bar {
    max-width: var(--app-max);
    left: 50%;
    transform: translateX(-50%);
  }
  .sheet {
    max-width: var(--app-max);
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border-radius: 14px 14px 0 0;
  }
  .sheet-host.open .sheet {
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== Körning tur & retur — toggle på timer-vyn ===== */
.travel-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  margin-top: 4px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--separator);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.travel-toggle.on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  font-weight: 600;
}
