/* Rig Log — mobile-first maintenance tracker */
:root {
  --green-950: #0c2f20;
  --green-900: #14532d;
  --green-800: #166534;
  --green-700: #1b7a4e;
  --green-600: #22824a;
  --green-500: #2d9a5b;
  --green-200: #b7e0c4;
  --green-100: #dcefe3;
  --green-50: #f0f7f3;
  --cream: #f4f2eb;
  --cream-2: #ebe8df;
  --card: #ffffff;
  --ink: #1a1f1c;
  --ink-soft: #3a443e;
  --muted: #5d6b63;
  --line: #d8ddd8;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --ok: #1b7a4e;
  --ok-bg: #ecfdf3;
  --info: #175cd3;
  --info-bg: #eff8ff;
  --shadow: 0 1px 2px rgba(20, 40, 28, 0.06), 0 8px 24px rgba(20, 40, 28, 0.06);
  --nav-h: 64px;
  --header-h: 56px;
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "ui-monospace", "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --cream: #121614;
  --cream-2: #191e1b;
  --card: #1c2320;
  --ink: #e8efe9;
  --ink-soft: #c5d0c8;
  --muted: #9aab9f;
  --line: #2a342f;
  --green-50: #15241c;
  --green-100: #1a2e24;
  --green-200: #2a4a38;
  --danger-bg: #3b1614;
  --warn-bg: #3b2a10;
  --ok-bg: #14301f;
  --info-bg: #152033;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.45;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--green-700); }
button { cursor: pointer; background: none; border: none; }

#app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  position: relative;
  background: var(--cream);
}

/* Header */
.app-header {
  min-height: var(--header-h);
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-900);
  color: #f4f2eb;
  flex-shrink: 0;
  z-index: 20;
}
.app-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.app-header .brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #f4f2eb;
  flex-shrink: 0;
}
.app-header .icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: #f4f2eb;
  flex-shrink: 0;
}
.app-header .icon-btn:hover,
.app-header .icon-btn:focus-visible { background: rgba(255,255,255,0.12); }

/* Main scroll */
.main {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(var(--nav-h) + 20px + env(safe-area-inset-bottom, 0px));
}

/* Bottom nav */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 30;
  box-shadow: 0 -4px 16px rgba(16, 32, 24, 0.05);
}
.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  min-height: 48px;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--green-700); }
[data-theme="dark"] .tabbar button.active { color: var(--green-500); }

/* Banner / toast */
.banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.92rem;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.banner.danger { background: var(--danger-bg); color: var(--danger); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.info { background: var(--info-bg); color: var(--info); }
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--cream);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 50;
  box-shadow: var(--shadow);
  max-width: 90%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

/* Cards & typography */
.page-title { font-size: 1.35rem; font-weight: 750; margin-bottom: 4px; }
.lede { color: var(--muted); font-size: 0.92rem; margin-bottom: 14px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2, .section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }

/* Grid of stats */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-grid.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.stat .lbl { font-size: 0.75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .val { font-size: 1.35rem; font-weight: 750; margin-top: 2px; letter-spacing: -0.02em; }
.stat .sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.stat.alert { border-color: #f5c2be; background: var(--danger-bg); }
.stat.warn { border-color: #f5d5a6; background: var(--warn-bg); }
.delta.up { color: var(--danger); }
.delta.down { color: var(--ok); }

/* Category chips */
.cat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--green-50);
  color: var(--green-900);
  font-size: 0.8rem;
  font-weight: 650;
  border: 1px solid var(--green-100);
}
[data-theme="dark"] .chip { color: var(--green-200); }
.chip .n {
  background: var(--green-700);
  color: #fff;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  font-size: 0.72rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 650;
  font-size: 0.95rem;
  background: var(--green-700);
  color: #fff;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost {
  background: transparent;
  color: var(--green-700);
  border-color: var(--green-200);
}
.btn.danger { background: var(--danger); }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row .btn { flex: 1; }

/* Lists */
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  min-height: 48px;
  text-align: left;
  width: 100%;
  color: inherit;
  background: none;
}
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }
.list-item .meta { color: var(--muted); font-size: 0.82rem; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow .name {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--green-100);
  color: var(--green-800);
  display: grid; place-items: center;
  font-weight: 750;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--cream-2);
  color: var(--muted);
}
.badge.overdue { background: var(--danger-bg); color: var(--danger); }
.badge.soon { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.high { background: var(--danger-bg); color: var(--danger); }
.badge.medium { background: var(--warn-bg); color: var(--warn); }
.badge.low { background: var(--green-50); color: var(--green-800); }

.empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
}
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* Forms */
form, .form { display: flex; flex-direction: column; gap: 12px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; font-weight: 650; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  width: 100%;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--green-600);
  outline-offset: 1px;
  border-color: var(--green-600);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.help { font-weight: 500; color: var(--muted); font-size: 0.78rem; }

/* Fill type: Partial / Full */
.fill-type-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--cream-2);
}
.fill-type-seg label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 0 8px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.fill-type-seg label + label { border-left: 1px solid var(--line); }
.fill-type-seg input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.fill-type-seg label:has(input:checked) {
  background: var(--green-700);
  color: #fff;
}
.fill-type-seg label:has(input:focus-visible) {
  outline: 2px solid var(--green-600);
  outline-offset: -2px;
}

/* Equipment cards */
.eq-card {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  color: inherit;
  min-height: 72px;
}
.eq-card .name { font-weight: 700; }
.thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--green-100);
  flex-shrink: 0;
}

/* Task board */
.board { display: flex; flex-direction: column; gap: 12px; }
.col { background: var(--cream-2); border-radius: var(--radius); padding: 10px; }
.col h3 { font-size: 0.8rem; margin-bottom: 8px; }
.task {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  text-align: left;
  width: 100%;
  color: inherit;
}
.task .t { font-weight: 650; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.cal-grid .dow { font-size: 0.7rem; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal-day {
  min-height: 48px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid transparent;
  padding: 4px 2px;
  font-size: 0.8rem;
  color: var(--ink);
  position: relative;
}
.cal-day.out { color: var(--muted); background: transparent; }
.cal-day.today { border-color: var(--green-700); font-weight: 750; }
.cal-day .dots { display: flex; justify-content: center; gap: 2px; margin-top: 2px; flex-wrap: wrap; }
.cal-day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green-700); }
.cal-day .dot.warn { background: var(--warn); }
.cal-day .dot.overdue { background: var(--danger); }

/* Charts */
.chart { width: 100%; overflow: hidden; }
.chart svg { width: 100%; height: auto; display: block; }
.hbar { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 0.85rem; }
.hbar .lab { width: 88px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { flex: 1; height: 10px; background: var(--cream-2); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--green-700); border-radius: 99px; }
.hbar .amt { width: 64px; text-align: right; font-variant-numeric: tabular-nums; font-size: 0.8rem; color: var(--muted); }

/* QR */
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px; }
.qr-wrap { max-width: 100%; }
.qr-wrap canvas, .qr-wrap img { background: #fff; padding: 8px; border-radius: 8px; max-width: 100%; height: auto; }
.qr-label { width: 100%; text-align: center; overflow-wrap: anywhere; word-break: break-word; line-height: 1.4; }
.qr-label .qr-name { font-weight: 700; }
.qr-label .qr-url { font-size: 0.75rem; }

/* Photos / docs */
.media-row { display: flex; gap: 8px; flex-wrap: wrap; }
.media-row img, .photo-thumb {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.doc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--cream-2); font-size: 0.8rem;
}

/* More menu */
.menu a, .menu button.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 4px;
  min-height: 52px;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  font-weight: 650;
  background: none;
}
.menu a:first-child, .menu button.menu-item:first-child { border-top: 0; }
.menu .ico {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--green-50);
  color: var(--green-800);
  display: grid; place-items: center;
  flex-shrink: 0;
}

/* Filters */
.seg {
  display: flex;
  background: var(--cream-2);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 12px;
}
.seg button {
  flex: 1;
  min-height: 44px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 0.85rem;
  color: var(--muted);
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* Work queue items */
.q-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  margin-bottom: 8px;
  text-align: left;
  width: 100%;
  color: inherit;
}
.q-item.overdue { border-color: #f5c2be; background: var(--danger-bg); }
.q-item.soon { border-color: #f5d5a6; background: var(--warn-bg); }

/* Utility */
.hidden { display: none !important; }
.spacer { height: 8px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.right { margin-left: auto; }
.fab {
  position: absolute;
  right: 16px;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--green-700);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(20, 83, 45, 0.35);
  z-index: 25;
}

/* Print / reports */
.report { background: var(--card); padding: 16px; border-radius: var(--radius); }
.report table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.report th, .report td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.report th { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }

@media print {
  body { overflow: auto; background: #fff; }
  #app { max-width: none; height: auto; display: block; }
  .app-header, .tabbar, .fab, .btn-row, .report-actions, .no-print { display: none !important; }
  .main { padding: 0; overflow: visible; }
  .card, .report { box-shadow: none; border: none; }
}

@media (min-width: 760px) {
  #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* Upgrade / pricing */
.plan-grid { display: flex; flex-direction: column; gap: 12px; }
.plan {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.plan.current { border-color: var(--green-700); box-shadow: 0 0 0 2px var(--green-200); }
.plan.featured { border-color: var(--green-700); }
.plan.budget {
  box-shadow: none;
  background: var(--cream-2);
  border-color: var(--line);
  padding: 14px;
}
.plan.budget h3 { font-size: 1.05rem; }
.plan.budget .price { font-size: 0.98rem; font-weight: 650; color: var(--ink-soft); }
.plan.budget .plan-note { font-size: 0.84rem; }
.plan h3 { font-size: 1.15rem; margin-bottom: 4px; }
.plan h3 .badge { margin-left: 6px; vertical-align: middle; }
.plan .price { font-size: 1.05rem; font-weight: 750; margin: 6px 0 8px; }
.plan .price .alt { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-top: 2px; }
.plan ul { margin: 8px 0 12px 18px; color: var(--ink-soft); font-size: 0.92rem; }
.plan li { margin: 4px 0; }
.plan-note { font-size: 0.88rem; color: var(--ink-soft); margin: 0 0 10px; line-height: 1.4; }
.plan-trial { font-size: 0.85rem; color: var(--ink-soft); margin: 0 0 8px; }
.plan-foot { font-size: 0.88rem; color: var(--ink-soft); margin: 4px 2px 0; line-height: 1.4; }
.plan-buys { flex-direction: column; align-items: stretch; gap: 8px; }
.plan-buys .btn { flex: none; width: 100%; height: auto; white-space: normal; line-height: 1.25; padding: 10px 12px; text-align: center; }
.plan-year-buy { display: flex; flex-direction: column; gap: 6px; }
.plan-year-buy .badge.value { align-self: flex-start; }
.badge.value {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.75rem;
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.budget {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.7rem;
  font-weight: 650;
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
}
[data-theme="dark"] .badge.value { color: #b7e0c4; }
[data-theme="dark"] .plan.budget { background: var(--card); }
[data-theme="dark"] .badge.budget { background: var(--cream-2); }
.locked {
  opacity: 0.95;
  position: relative;
}
.locked-note {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--cream-2);
  font-size: 0.9rem;
}

/* File picker */
.file-btn input[type="file"] { display: none; }

/* Install hint */
.install-bar {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--green-50);
  border: 1px solid var(--green-100);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

/* Tappable dashboard summary cards */
a.stat-link { display: block; position: relative; color: inherit; text-decoration: none; cursor: pointer; padding-right: 26px; -webkit-tap-highlight-color: transparent; transition: transform .08s ease, box-shadow .15s ease; }
a.stat-link::after { content: "\203A"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 1.4rem; font-weight: 600; color: var(--muted); }
a.stat-link:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
a.stat-link:active { transform: scale(0.98); }
a.stat-link:focus-visible { outline: 2px solid var(--green-800); outline-offset: 2px; }

/* VIN decoder on the equipment form */
.vin-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.vin-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.vin-row .btn {
  flex: 0 0 auto;
  min-width: 6.6rem;
}
.vin-status {
  font-weight: 500;
  font-size: 0.8rem;
  min-height: 1.15em;
  color: var(--muted);
}
.vin-status.is-ok { color: var(--ok); }
.vin-status.is-error { color: var(--danger); }
.vin-status.is-pending { color: var(--muted); }

/* Persistent save-failure notice */
.save-error {
  position: fixed; left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border-radius: 12px;
  background: #b42318; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.35);
  max-width: 560px; margin: 0 auto; font-size: 0.92rem; line-height: 1.35;
}
.save-error[hidden] { display: none; }
.save-error-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.save-error .btn { background: #fff; color: #7a1a12; border-color: #fff; }
.save-error .btn.secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }

/* Files: photos, documents */
.media-item { position: relative; display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 6px 0; }
.media-item.doc { display: flex; flex-wrap: wrap; }
.photo-btn { padding: 0; border-radius: 8px; line-height: 0; min-width: 44px; min-height: 44px; }
.photo-btn:active, .doc-chip:active, .doc-open:active { transform: scale(0.97); }
.photo-btn:focus-visible, .doc-chip:focus-visible, .doc-open:focus-visible, .media-rm:focus-visible { outline: 2px solid var(--green-800); outline-offset: 2px; }
.photo-thumb.missing { opacity: .35; }
.doc-chip { min-height: 44px; cursor: pointer; text-align: left; }
.doc-open { min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: 0.8rem; font-weight: 650; }
.media-rm { min-width: 44px; min-height: 44px; border-radius: 8px; color: var(--danger); font-weight: 700; }
.media-item:not(.doc) .media-rm { position: absolute; top: -14px; right: -14px; min-width: 44px; min-height: 44px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); }

/* Cross-links: stretched main link, secondary links stay separately tappable (never nested) */
.x-item, .x-card { position: relative; }
.x-item { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--line); }
.x-item:first-child { border-top: 0; }
.x-item .grow, .x-card .grow { flex: 1; min-width: 0; }
.x-item .meta { color: var(--muted); font-size: 0.82rem; }
.x-main {
  display: flex; align-items: center; min-height: 44px;
  font-weight: 650; color: inherit; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.x-main::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.x-main:focus-visible { outline: none; }
.x-main:focus-visible::after { outline: 2px solid var(--green-800); outline-offset: -2px; }
.x-item:has(.x-main:active), .x-card:has(.x-main:active) { background: var(--green-50); }
.x-card > .x-main { font-weight: 650; }
.x-card .btn, .x-item .btn, .x-item button, .x-card button { position: relative; z-index: 1; }
.x-link {
  position: relative; z-index: 2; display: inline-block; cursor: pointer;
  padding: 10px 6px; margin: -10px -2px; color: var(--green-700);
  font-weight: 650; text-decoration: underline; text-underline-offset: 2px;
  -webkit-tap-highlight-color: transparent;
}
.x-link:active { opacity: .6; }
.x-link:focus-visible { outline: 2px solid var(--green-800); outline-offset: -2px; border-radius: 6px; }
.x-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 2px; font-size: 0.85rem; }
.x-linkbar { margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-height: 44px; font-size: 0.88rem; }
.card h2 .x-link { margin: -10px -6px; font-size: inherit; text-decoration: none; }
.card h2 .x-link::after { content: " \203A"; }
a.hbar.x-row { color: inherit; text-decoration: none; min-height: 44px; cursor: pointer; border-radius: 8px; padding: 0 4px; margin: 0 -4px; -webkit-tap-highlight-color: transparent; }
a.hbar.x-row:active { background: var(--green-50); }
a.hbar.x-row:focus-visible { outline: 2px solid var(--green-800); outline-offset: 1px; }
.task.x-card .meta { margin-top: 2px; }
.banner .grow { flex: 1; }

/* Calendar tap targets */
.cal-nav { min-width: 44px; font-size: 1.3rem; }
.cal-day { min-height: 48px; min-width: 44px; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .08s ease, background .15s ease; }
.cal-day:not(.out):hover { background: var(--green-50); }
.cal-day:not(.out):active { transform: scale(0.94); background: var(--green-100); }
.cal-day:focus-visible { outline: 2px solid var(--green-800); outline-offset: 1px; }
.cal-day.selected { background: var(--green-100); border-color: var(--green-800); font-weight: 750; }
.cal-panel { margin-top: 12px; }
.cal-event .chip { text-transform: capitalize; }

/* App version */
.reset-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; }
.app-version { white-space: nowrap; }
.more-version { text-align: center; margin: 14px 0 0; }

/* Whole-row links with a chevron */
.chev { align-self: center; flex-shrink: 0; color: var(--muted); font-size: 1.5rem; line-height: 1; font-weight: 600; padding: 0 2px; }
.x-item .x-main, .x-card .x-main { min-height: 44px; }
.q-item.x-card:has(.x-main:active), .x-item:has(.x-main:active) { background: var(--green-100); }
.x-card { transition: background .12s ease; }
.welcome h2 { margin-bottom: 6px; }
.welcome .btn-row { margin-top: 14px; }

.task-actions { align-items: center; }
.save-note { min-width: 64px; }
.save-note.error { color: var(--danger); font-weight: 650; }

.install-card { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-color: var(--green-200); background: var(--green-50); }
.install-card .grow { flex: 1; min-width: 180px; }

.form-error { color: var(--danger); background: var(--danger-bg); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 10px; font-size: 0.92rem; font-weight: 600; }
.form-error[hidden] { display: none; }
.toast { display: flex; align-items: center; gap: 12px; width: max-content; }
.toast.has-action { pointer-events: auto; padding-right: 6px; border-radius: 14px; }
.toast .toast-btn { min-height: 44px; min-width: 56px; padding: 0 14px; border-radius: 10px; font-weight: 750; color: inherit; text-decoration: underline; }

.report-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 10px 0 14px; }
.report-actions .btn { width: 100%; white-space: normal; text-align: center; line-height: 1.2; padding-top: 6px; padding-bottom: 6px; }

/* Danger buttons that are "secondary" were dark text on solid red; make them a clear red outline */
.btn.danger.secondary { background: var(--card); color: var(--danger); border-color: var(--danger); }
[data-theme="dark"] .btn.danger.secondary { color: #f97066; border-color: #f97066; }
