/* Rig Tracker — iOS / Apple-style, mobile-first, no external assets. */

:root {
  color-scheme: light;
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --grouped: #ffffff;
  --grouped-2: #f2f2f7;
  --label: #000000;
  --secondary: rgba(60, 60, 67, 0.60);
  --tertiary: rgba(60, 60, 67, 0.30);
  --placeholder: rgba(60, 60, 67, 0.30);
  --separator: rgba(60, 60, 67, 0.29);
  --separator-light: rgba(60, 60, 67, 0.16);
  --fill: rgba(120, 120, 128, 0.16);
  --fill-2: rgba(120, 120, 128, 0.20);
  --fill-3: rgba(118, 118, 128, 0.12);
  --accent: #007aff;
  --accent-text: #007aff;
  --accent-tint: rgba(0, 122, 255, 0.12);
  --accent-strong: #0066d6;
  --destructive: #ff3b30;
  --success: #34c759;
  --success-tint: rgba(52, 199, 89, 0.16);
  --warning: #ff9500;
  --warning-tint: rgba(255, 149, 0, 0.16);
  --danger-tint: rgba(255, 59, 48, 0.14);
  --purple: #af52de;
  --purple-tint: rgba(175, 82, 222, 0.14);
  --orange: #ff9500;
  --orange-tint: rgba(255, 149, 0, 0.16);
  --nav-bg: rgba(242, 242, 247, 0.82);
  --tab-bg: rgba(249, 249, 249, 0.92);
  --overlay: rgba(0, 0, 0, 0.36);
  --sheet-bg: #f2f2f7;
  --hairline: 0.5px;
  --radius: 10px;
  --radius-lg: 16px;
  --tab-h: 49px;
  --nav-h: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI Variable", "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
  --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --grouped: #1c1c1e;
    --grouped-2: #2c2c2e;
    --label: #ffffff;
    --secondary: rgba(235, 235, 245, 0.60);
    --tertiary: rgba(235, 235, 245, 0.30);
    --placeholder: rgba(235, 235, 245, 0.30);
    --separator: rgba(84, 84, 88, 0.65);
    --separator-light: rgba(84, 84, 88, 0.45);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.32);
    --fill-3: rgba(118, 118, 128, 0.24);
    --accent: #0a84ff;
    --accent-text: #0a84ff;
    --accent-tint: rgba(10, 132, 255, 0.22);
    --accent-strong: #409cff;
    --destructive: #ff453a;
    --success: #30d158;
    --success-tint: rgba(48, 209, 88, 0.22);
    --warning: #ff9f0a;
    --warning-tint: rgba(255, 159, 10, 0.22);
    --danger-tint: rgba(255, 69, 58, 0.22);
    --purple: #bf5af2;
    --purple-tint: rgba(191, 90, 242, 0.22);
    --nav-bg: rgba(22, 22, 24, 0.82);
    --tab-bg: rgba(22, 22, 24, 0.92);
    --overlay: rgba(0, 0, 0, 0.55);
    --sheet-bg: #000000;
    --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.5);
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --grouped: #1c1c1e;
  --grouped-2: #2c2c2e;
  --label: #ffffff;
  --secondary: rgba(235, 235, 245, 0.60);
  --tertiary: rgba(235, 235, 245, 0.30);
  --placeholder: rgba(235, 235, 245, 0.30);
  --separator: rgba(84, 84, 88, 0.65);
  --separator-light: rgba(84, 84, 88, 0.45);
  --fill: rgba(120, 120, 128, 0.24);
  --fill-2: rgba(120, 120, 128, 0.32);
  --fill-3: rgba(118, 118, 128, 0.24);
  --accent: #0a84ff;
  --accent-text: #0a84ff;
  --accent-tint: rgba(10, 132, 255, 0.22);
  --accent-strong: #409cff;
  --destructive: #ff453a;
  --success: #30d158;
  --success-tint: rgba(48, 209, 88, 0.22);
  --warning: #ff9f0a;
  --warning-tint: rgba(255, 159, 10, 0.22);
  --danger-tint: rgba(255, 69, 58, 0.22);
  --purple: #bf5af2;
  --purple-tint: rgba(191, 90, 242, 0.22);
  --orange: #ff9f0a;
  --orange-tint: rgba(255, 159, 10, 0.22);
  --nav-bg: rgba(22, 22, 24, 0.82);
  --tab-bg: rgba(22, 22, 24, 0.92);
  --overlay: rgba(0, 0, 0, 0.55);
  --sheet-bg: #000000;
  --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
html { background: var(--bg); }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.29;
  color: var(--label);
  background: var(--bg);
  min-height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea {
  font-family: inherit;
  font-size: 17px;
  color: inherit;
}
button { background: none; border: 0; padding: 0; margin: 0; color: var(--accent-text); cursor: pointer; }
img { border: 0; }

#app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* ——— Nav ——— */
.nav {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  padding-top: var(--safe-top);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: var(--hairline) solid transparent;
}
.nav.is-scrolled {
  border-bottom-color: var(--separator);
}
.nav-bar {
  height: var(--nav-h);
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(88px, auto);
  align-items: center;
  padding: 0 4px 0 2px;
}
.nav-left, .nav-right {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 4px;
}
.nav-right { justify-content: flex-end; }
.nav-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav.is-scrolled .nav-title,
.nav.is-compact .nav-title { opacity: 1; transform: none; }
.nav-back { padding: 0 4px; justify-self: start; min-width: 44px; }
.nav-right { justify-self: end; display: flex; align-items: center; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 8px;
  font-size: 17px;
  color: var(--accent-text);
  border-radius: 8px;
}
.nav-btn:active { opacity: 0.5; }
.nav-btn[disabled] { opacity: 0.35; pointer-events: none; }
.nav-btn.strong { font-weight: 600; }
.nav-btn.destructive { color: var(--destructive); }
.nav-icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  color: var(--accent-text);
}
.nav-icon-btn:active { background: var(--fill); }
.nav-icon-btn svg { width: 26px; height: 26px; }

/* ——— Scroll / large title ——— */
.scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(var(--tab-h) + var(--safe-bot) + 24px);
}
.scroll.no-tabs { padding-bottom: calc(24px + var(--safe-bot)); }

.large-title-block {
  padding: 2px 20px 8px;
}
.large-title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.15;
}
.large-sub {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--secondary);
}

/* ——— Tab bar ——— */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--tab-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: var(--hairline) solid var(--separator);
  padding-bottom: var(--safe-bot);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}
.tabbar-row {
  height: var(--tab-h);
  display: flex;
  align-items: stretch;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  color: var(--secondary);
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}
.tab svg {
  width: 25px;
  height: 25px;
  display: block;
}
.tab span {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: -0.1px;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab.is-active { color: var(--accent); }
.tab:active { opacity: 0.55; }

/* ——— Lists & groups ——— */
.group {
  margin: 0 16px 24px;
  background: var(--grouped);
  border-radius: var(--radius);
  overflow: hidden;
}
.group.inset-flush { margin-top: 0; }
.group-header {
  margin: 0 32px 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.group-header + .group { margin-top: 0; }
.group-footer {
  margin: -16px 32px 24px;
  font-size: 13px;
  color: var(--secondary);
  line-height: 1.35;
}
.row {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  gap: 12px;
  position: relative;
  background: var(--grouped);
  text-decoration: none;
  color: inherit;
  width: 100%;
  text-align: left;
}
.row + .row::before,
.field-row + .field-row::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 0;
  top: 0;
  height: var(--hairline);
  background: var(--separator);
  pointer-events: none;
}
.row.chevron { padding-right: 28px; }
.row.chevron::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--tertiary);
  border-top: 2px solid var(--tertiary);
  transform: translateY(-50%) rotate(45deg);
}
.row:active, .tappable:active { background: var(--fill-3); }
.row-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff;
}
.row-icon svg { width: 18px; height: 18px; }
.row-body { flex: 1 1 auto; min-width: 0; }
.row-title {
  font-size: 17px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-title.strong { font-weight: 600; }
.row-sub {
  font-size: 13px;
  color: var(--secondary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  font-size: 16px;
  color: var(--secondary);
  flex: 0 0 auto;
}
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1px;
  background: var(--fill);
  color: var(--label);
  flex: 0 0 auto;
}
.badge.success { background: var(--success-tint); color: var(--success); }
.badge.danger { background: var(--danger-tint); color: var(--destructive); }
.badge.warning { background: var(--warning-tint); color: var(--warning); }

/* ——— Search / filters ——— */
.search-wrap {
  padding: 0 16px 10px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  background: var(--fill-3);
  border-radius: 10px;
  color: var(--secondary);
}
.search svg { width: 16px; height: 16px; flex: 0 0 auto; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  color: var(--label);
  height: 36px;
}
.search input::placeholder { color: var(--placeholder); }
.filter-row {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.filter-row::-webkit-scrollbar { display: none; }

/* ——— Buttons ——— */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}
.pill:active { opacity: 0.7; }
.pill.block { width: calc(100% - 32px); margin: 0 16px 12px; }
.pill.tinted {
  background: var(--accent-tint);
  color: var(--accent-text);
}
.pill.gray {
  background: var(--fill);
  color: var(--label);
}
.pill.destructive {
  background: var(--danger-tint);
  color: var(--destructive);
}
.pill svg { width: 18px; height: 18px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  background: var(--fill);
  color: var(--label);
  white-space: nowrap;
  flex: 0 0 auto;
}
.chip.is-on { background: var(--accent); color: #fff; }
.chip:active { opacity: 0.7; }

.btn-row {
  display: flex;
  gap: 10px;
  padding: 4px 16px 16px;
}
.btn-row .pill { flex: 1; margin: 0; width: auto; }

/* ——— Home dashboard ——— */
.hero {
  padding: 4px 20px 16px;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 0 16px 18px;
}
.stat-card {
  background: var(--grouped);
  border-radius: 14px;
  padding: 12px 12px 14px;
  text-align: left;
  min-height: 88px;
  color: inherit;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stat-card:active { opacity: 0.7; }
.stat-k {
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  letter-spacing: 0.1px;
}
.stat-v {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.1;
  margin-top: 8px;
}
.stat-card.blue .stat-v { color: var(--accent); }
.stat-card.purple .stat-v { color: var(--purple); }

/* ——— Forms ——— */
.field-row {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 16px;
  gap: 12px;
  position: relative;
  background: var(--grouped);
}
.field-row.stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.field-label {
  flex: 0 0 42%;
  max-width: 160px;
  font-size: 17px;
  color: var(--label);
}
.field-row.stacked .field-label {
  max-width: none;
  flex: none;
  font-size: 13px;
  font-weight: 400;
  color: var(--secondary);
}
.field-control {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.field-row.stacked .field-control { justify-content: flex-start; }
.field-control input[type="text"],
.field-control input[type="search"],
.field-control input[type="date"],
.field-control input[type="time"],
.field-control input[type="email"],
.field-control textarea,
.field-control select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: right;
  font-size: 17px;
  color: var(--label);
  min-height: 32px;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}
.field-row.stacked .field-control input,
.field-row.stacked .field-control textarea,
.field-row.stacked .field-control select { text-align: left; }
.field-control input::placeholder,
.field-control textarea::placeholder { color: var(--placeholder); }
.field-control textarea {
  text-align: left;
  resize: vertical;
  min-height: 88px;
  line-height: 1.35;
  padding: 6px 0;
}
.field-unit {
  font-size: 15px;
  color: var(--secondary);
  flex: 0 0 auto;
  min-width: 2.4em;
}
.field-hint {
  font-size: 12px;
  color: var(--secondary);
  padding: 0 16px 10px;
  background: var(--grouped);
  line-height: 1.35;
}
select.ios-select {
  background-image: none;
  padding-right: 0;
}
.req-dot { color: var(--destructive); font-weight: 600; }

/* Compact three-up pump SPM row */
.field-triple {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--grouped);
  padding: 10px 6px 12px;
  position: relative;
}
.field-row + .field-triple::before,
.field-triple + .field-row::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 0;
  top: 0;
  height: var(--hairline);
  background: var(--separator);
  pointer-events: none;
}
.field-mini {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  padding: 0 6px;
}
.field-mini + .field-mini {
  border-left: var(--hairline) solid var(--separator);
}
.field-mini-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--secondary);
  text-align: center;
  margin-bottom: 2px;
}
.field-mini input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--label);
  min-height: 32px;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}
.field-mini input::placeholder {
  color: var(--placeholder);
  font-weight: 500;
  font-size: 16px;
}
.field-mini-unit {
  font-size: 11px;
  color: var(--secondary);
  text-align: center;
  margin-top: 1px;
}
.field-row.is-live .field-live-value {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--label);
  text-align: right;
}

/* Segmented control */
.segmented {
  display: flex;
  background: var(--fill-3);
  border-radius: 9px;
  padding: 2px;
  width: 100%;
  min-height: 32px;
}
.segmented.lg {
  min-height: 36px;
  border-radius: 10px;
}
.seg {
  flex: 1;
  min-height: 28px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--label);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  white-space: nowrap;
}
.seg.is-on {
  background: var(--bg-elevated);
  box-shadow: 0 0.5px 1px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
}
[data-theme="dark"] .seg.is-on {
  background: var(--grouped-2);
  box-shadow: 0 0.5px 1px rgba(0,0,0,0.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seg.is-on {
    background: var(--grouped-2);
    box-shadow: 0 0.5px 1px rgba(0,0,0,0.5);
  }
}
.seg:active { opacity: 0.7; }

/* iOS switch */
.switch {
  position: relative;
  width: 51px;
  height: 31px;
  flex: 0 0 auto;
  border-radius: 16px;
  background: var(--fill-2);
  transition: background 180ms ease;
  border: 0;
}
.switch.is-on { background: var(--success); }
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25), 0 1px 1px rgba(0,0,0,0.12);
  transition: transform 180ms ease;
}
.switch.is-on::after { transform: translateX(20px); }

/* Collection cards */
.collection { margin: 0 16px 16px; }
.item-card {
  background: var(--grouped);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.item-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
}
.item-remove {
  width: 44px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--destructive);
}
.item-remove:active { opacity: 0.5; }
.item-remove svg { width: 22px; height: 22px; }
.add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  color: var(--accent-text);
  font-size: 17px;
  font-weight: 400;
  background: var(--grouped);
  border-radius: var(--radius);
}
.add-row:active { background: var(--fill-3); }
.add-row svg { width: 22px; height: 22px; }

/* Highlights / Health-style calc cards */
.hl-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0 16px 24px;
}
.hl-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.hl-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.hl-card {
  background: var(--grouped);
  border-radius: 14px;
  padding: 12px 14px 14px;
  min-height: 86px;
}
.hl-card.primary {
  background: var(--accent);
  color: #fff;
}
.hl-card.success { background: var(--success); color: #fff; }
.hl-card.danger { background: var(--destructive); color: #fff; }
.hl-card.warning { background: var(--warning); color: #fff; }
.hl-k {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1px;
  opacity: 0.72;
  color: inherit;
}
.hl-card:not(.primary):not(.success):not(.danger):not(.warning) .hl-k { color: var(--secondary); opacity: 1; }
.hl-v {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.15;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.hl-unit {
  font-size: 13px;
  font-weight: 600;
  margin-left: 4px;
  opacity: 0.8;
}
.hl-sub, .hl-hint {
  font-size: 12px;
  margin-top: 4px;
  opacity: 0.75;
}
.hl-card.status .hl-v { font-size: 20px; }

@media (max-width: 420px) {
  .hl-grid.cols-3 { grid-template-columns: 1fr; }
  .hl-grid.cols-3 .hl-card { min-height: 72px; }
  .hl-grid.cols-3 .hl-v { font-size: 24px; }
}

/* Chart */

/* FIT field log */
.ticket {
  margin: 0 16px 16px;
  background: var(--grouped);
  border-radius: 14px;
  padding: 14px 16px 12px;
  font-variant-numeric: tabular-nums;
}
.ticket pre, pre.ticket-text {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 600;
  white-space: pre-wrap;
}
.ticket .ticket-sub {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--secondary);
  line-height: 1.35;
}
.log-card {
  margin: 0 16px 16px;
  background: var(--grouped);
  border-radius: 14px;
  overflow: hidden;
}
.log-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.log-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary);
  text-align: right;
  padding: 8px 8px 6px;
  letter-spacing: 0.2px;
}
.log-table th.col-n, .log-table td.col-n,
.log-table th.col-time, .log-table td.col-time { text-align: center; }
.log-table th.col-note, .log-table td.col-note { text-align: left; }
.log-table td {
  border-top: var(--hairline) solid var(--separator);
  padding: 0 4px;
  height: 44px;
  vertical-align: middle;
}
.log-table td.col-n {
  width: 28px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}
.log-table td.col-time {
  width: 48px;
  color: var(--secondary);
  font-size: 13px;
}
.log-table td.col-stk, .log-table td.col-psi { width: 64px; }
.log-table input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  min-height: 44px;
  text-align: right;
  color: var(--label);
  padding: 0 4px;
}
.log-table td.col-note input { text-align: left; font-size: 15px; }
.log-table tr.is-hold td { background: rgba(175, 82, 222, 0.06); }
.log-table tr.is-switch td { background: rgba(175, 82, 222, 0.12); }
.log-switch {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--purple);
  padding: 6px 12px 2px;
  background: rgba(175, 82, 222, 0.08);
}
.log-actions { margin: 0 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.log-actions .add-row { margin: 0; }
.mini-now {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-tint);
}
.mini-now:active { opacity: 0.7; }


.chart-wrap {
  margin: 0 16px 16px;
  background: var(--grouped);
  border-radius: 14px;
  padding: 12px 8px 8px;
}
.chart-wrap h3 {
  margin: 0 8px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
}
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-empty {
  text-align: center;
  color: var(--secondary);
  font-size: 13px;
  padding: 24px 8px;
}

/* Empty states */
.empty {
  text-align: center;
  padding: 48px 32px 24px;
  color: var(--secondary);
}
.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--fill);
  color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-icon svg { width: 32px; height: 32px; }
.empty h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--label);
}
.empty p { margin: 0 0 18px; font-size: 15px; line-height: 1.4; }

/* Sheets / modals */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--overlay);
  opacity: 0;
  transition: opacity 220ms ease;
}
.overlay.is-in { opacity: 1; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--sheet-bg);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet.is-in { transform: none; }
.sheet .nav {
  background: var(--nav-bg);
}
.sheet .scroll { padding-bottom: calc(28px + var(--safe-bot)); }

.action-sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 8px calc(8px + var(--safe-bot));
  background: var(--overlay);
}
.action-card {
  background: var(--grouped-2);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 8px;
}
.action-title {
  text-align: center;
  font-size: 13px;
  color: var(--secondary);
  padding: 12px 16px 8px;
  line-height: 1.3;
}
.action-btn {
  display: block;
  width: 100%;
  min-height: 56px;
  text-align: center;
  font-size: 20px;
  color: var(--accent-text);
  background: transparent;
  position: relative;
}
.action-btn + .action-btn::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: var(--hairline);
  background: var(--separator);
}
.action-btn:active { background: var(--fill); }
.action-btn.destructive { color: var(--destructive); }
.action-btn.strong { font-weight: 600; }
.action-cancel {
  background: var(--bg-elevated);
  border-radius: 14px;
  font-weight: 600;
  min-height: 56px;
  font-size: 20px;
  color: var(--accent-text);
  width: 100%;
}
.action-cancel:active { opacity: 0.7; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-bot) + 16px);
  transform: translateX(-50%) translateY(12px);
  z-index: 90;
  background: rgba(30, 30, 32, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  max-width: calc(100% - 40px);
  text-align: center;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.toast.is-in { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Detail */
.detail-block { padding: 0 20px 12px; }
.kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  font-size: 15px;
}
.kv .k { color: var(--secondary); }
.kv .v { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.notes-body {
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  padding: 12px 16px 16px;
}

/* Install tip */
.banner {
  margin: 0 16px 20px;
  background: var(--accent-tint);
  color: var(--accent-text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.35;
}

/* On-screen + print report */
.report h1 { font-size: 28px; font-weight: 700; letter-spacing: 0.2px; margin: 8px 0 4px; }
.report .p-sub { color: var(--secondary); margin: 0 0 16px; font-size: 15px; line-height: 1.4; }
.report h2 {
  font-size: 13px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--secondary);
  margin: 20px 0 8px;
}
.report table { width: 100%; border-collapse: collapse; }
.report td { padding: 7px 0; font-size: 15px; vertical-align: top; }
.report .p-k { color: var(--secondary); width: 42%; }
.report .p-hl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 16px;
}
.report .p-hl div {
  background: var(--grouped);
  border-radius: 14px;
  padding: 12px 14px;
}
.report .p-hl span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
}
.report .p-hl b {
  display: block;
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.report .p-foot { margin-top: 20px; font-size: 12px; color: var(--secondary); line-height: 1.4; }
.report .chart-wrap { margin-left: 0; margin-right: 0; }

.print-root { display: none; }

@media print {
  body { background: #fff; color: #000; overflow: visible; }
  #app, .tabbar, .toast, .overlay, .sheet, .action-sheet-wrap, .nav { display: none !important; }
  .print-root {
    display: block !important;
    padding: 0;
    font-family: var(--font);
    color: #000;
    font-size: 11pt;
  }
  .print-root .report h1 { font-size: 18pt; margin: 0 0 2pt; color: #000; }
  .print-root .report .p-sub { color: #444; margin: 0 0 10pt; font-size: 10pt; }
  .print-root .report h2 { color: #000; font-size: 10pt; border-bottom: 0.6pt solid #bbb; padding-bottom: 2pt; }
  .print-root .report .p-hl div { border: 0.6pt solid #ccc; background: #fff; }
  .print-root .report .p-hl span { color: #555; font-size: 8pt; }
  .print-root .report .p-hl b { font-size: 14pt; }
  .print-root .report .p-k { color: #555; }
  .print-root .report .p-foot { font-size: 8pt; color: #666; }
}

@page { margin: 0.6in; }

/* Desktop / iPad: center a phone-like column, keep the tab bar */
@media (min-width: 700px) {
  .scroll-inner, .large-title-block, .search-wrap, .filter-row, .hero, .stat-grid,
  .group, .group-header, .group-footer, .hl-grid, .collection, .chart-wrap,
  .btn-row, .banner, .detail-block, .empty {
    max-width: 640px;
  }
  .scroll-inner { margin: 0 auto; }
  .large-title-block, .search-wrap, .filter-row, .hero, .stat-grid,
  .group, .group-header, .group-footer, .hl-grid, .collection, .chart-wrap,
  .btn-row, .banner, .detail-block, .empty, .pill.block {
    margin-left: auto;
    margin-right: auto;
  }
  .pill.block { max-width: 640px; }
  .hl-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .sheet {
    left: 50%;
    right: auto;
    width: 640px;
    margin-left: -320px;
    border-radius: 12px 12px 0 0;
    top: 24px;
    box-shadow: var(--shadow-sheet);
  }
}

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

/* Hidden file input */
.file-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }


/* Strokes home card + displacement log */
.strokes-home {
  display: flex;
  align-items: center;
  margin: 0 16px 16px;
  padding: 12px 14px;
  background: var(--grouped);
  border-radius: 14px;
  color: inherit;
  text-align: left;
  width: auto;
  gap: 8px;
}
.strokes-home .row-title { font-size: 17px; font-weight: 600; }
.strokes-home .row-sub { font-size: 13px; color: var(--secondary); margin-top: 2px; white-space: normal; }
.strokes-home:active { opacity: 0.7; }
.stat-card.orange .stat-v { color: var(--orange); }

.disp-table th:first-child, .disp-table td.col-bbl { text-align: left; }
.disp-table td.col-bbl { width: 88px; }
.bbl-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}
.bbl-cell input { flex: 1; text-align: right; min-width: 0; }
.bbl-read {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.side-btn {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
  padding: 0;
  color: #fff;
  background: var(--accent);
}
.side-btn.side-r { background: #5856d6; }
.side-btn.side-l { background: var(--accent); }
button.side-btn:active { opacity: 0.7; }
span.side-btn { display: inline-block; }
.disp-table tr.is-tag-dart td { background: rgba(255, 149, 0, 0.08); }
.disp-table tr.is-tag-bump td { background: rgba(52, 199, 89, 0.10); }
.disp-table tr.tag-row td {
  height: auto;
  padding: 0 8px 8px;
  border-top: 0;
  background: inherit;
}
.tag-row-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-chip {
  min-height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary);
  background: var(--fill-3);
  width: auto;
}
.tag-chip.is-on {
  color: #fff;
  background: var(--accent);
}
.tag-chip.is-on[data-tag="dart"] { background: var(--warning); }
.tag-chip.is-on[data-tag="bump"] { background: var(--success); }
.tag-chip.insert { color: var(--accent-text); background: var(--accent-tint); }
.tag-chip:active { opacity: 0.7; }
.disp-table th.col-act, .disp-table td.col-act { width: 36px; padding-right: 6px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--secondary); padding: 0 8px 8px; }

@media (prefers-color-scheme: dark) {
  .disp-table tr.is-tag-dart td { background: rgba(255, 159, 10, 0.12); }
  .disp-table tr.is-tag-bump td { background: rgba(48, 209, 88, 0.14); }
}
[data-theme="dark"] .disp-table tr.is-tag-dart td { background: rgba(255, 159, 10, 0.12); }
[data-theme="dark"] .disp-table tr.is-tag-bump td { background: rgba(48, 209, 88, 0.14); }
.field-cond[hidden]{display:none !important}
