@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  
  /* Premium Water-Utility Theme Palette */
  --bg: #090f1d;
  --panel: #131c2e;
  --ink: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, 0.08);
  --field: #0d1527;
  --field-border: rgba(255, 255, 255, 0.15);
  
  /* Status Signals */
  --brand: #0ea5e9;
  --brand-dark: #075985;
  --brand-soft: rgba(14, 165, 233, 0.15);
  --warn: #f43f5e;
  --warn-soft: rgba(244, 63, 94, 0.15);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.15);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.15);
  
  /* Gradients */
  --grad-brand: linear-gradient(135deg, #38bdf8 0%, #0369a1 100%);
  --grad-ok: linear-gradient(135deg, #34d399 0%, #047857 100%);
  --grad-warn: linear-gradient(135deg, #fb7185 0%, #be123c 100%);
  
  /* Structural Shadows */
  --shadow-sheet: 0 -10px 30px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.2);
  
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

[hidden] {
  display: none !important;
}

body {
  background-color: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-top: 0;
  line-height: 1.5;
}

/* Header UI Components */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(19, 28, 46, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  flex: 0 0 40px;
  height: 40px;
  object-fit: cover;
  padding: 4px;
  width: 40px;
}

.brand-block h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 50%, #bae6fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-block p {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 1px;
}

.threshold-pill {
  background: var(--warn-soft);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fca5a5;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Main Display Scopes */
main {
  margin: 0 auto;
  max-width: 920px;
  padding: 16px 16px calc(90px + env(safe-area-inset-bottom));
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Segmented Sub-Tab Bar for Multi-tool Calculators */
.sub-tab-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow-x: visible;
  background-color: rgba(19, 28, 46, 0.6);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}

.sub-tab-btn {
  background: transparent;
  border: none;
  min-height: 38px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 4px;
  white-space: normal;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sub-tab-btn:hover {
  color: var(--ink);
  background-color: rgba(255, 255, 255, 0.03);
}

.sub-tab-btn.active {
  background-color: var(--brand);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.calc-sub-panel {
  display: none;
}

.calc-sub-panel.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

/* Functional Containers / Panels */
.calculator-shell,
.saved-panel {
  background-color: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.section-heading p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1px;
}

.section-heading.compact {
  margin-bottom: 12px;
  padding-bottom: 8px;
}

/* Custom Uniform Status Chips */
.flow-status, .count-pill, .badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.flow-status.pending, .count-pill {
  background-color: var(--field);
  color: var(--muted);
  border: 1px solid var(--field-border);
}

.badge-warn {
  background-color: var(--warn-soft);
  color: var(--warn);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Heavy Work Input Grid Layout Systems */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }

.input-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-text {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #bae6fd;
}

.label-text .unit {
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: 2px;
}

/* Field Inputs Optimized for Physical Touch Interacting */
input, textarea, select {
  width: 100%;
  min-height: 48px;
  background-color: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 500;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  background-color: #121b2f;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

/* Button UI Components */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

button {
  width: 100%;
  min-height: 48px;
  background-color: var(--field);
  border: 1px solid var(--field-border);
  color: #ffffff;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.25);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button.primary {
  background: var(--grad-brand);
  border: none;
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--shadow-glow);
}

button.primary:hover:not(:disabled) {
  opacity: 0.95;
  box-shadow: 0 0 24px rgba(14, 165, 233, 0.35);
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-muted {
  background-color: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-muted:hover:not(:disabled) {
  color: var(--ink);
  background-color: rgba(255, 255, 255, 0.02);
}

.btn-warn {
  background-color: var(--warn-soft);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fda4af;
}
.btn-warn:hover:not(:disabled) {
  background-color: rgba(244, 63, 94, 0.25);
  border-color: var(--warn);
}

/* Structured Results Block Displays */
.results-panel {
  margin-top: 20px;
  background-color: #0c1322;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.result-card {
  background-color: var(--panel);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 80px;
  box-shadow: var(--shadow-card);
}

.result-card span {
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.v-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
}

.result-card strong {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
}

.result-card .u {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

/* Primary Hero Result Optimization */
.results .primary-result {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.08) 0%, rgba(3, 105, 161, 0.2) 100%);
  border: 1px solid var(--brand);
  box-shadow: var(--shadow-glow);
}

.results .primary-result strong {
  font-size: 2.2rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}

.results .primary-result .u {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand);
}

/* Reports Layout Helpers */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.summary-card {
  background-color: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.summary-card span {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.summary-card strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 4px;
  color: #ffffff;
}

.vertical-action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-action-row {
  justify-content: flex-start;
  text-align: left;
  background-color: var(--panel);
}

.btn-action-row svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--brand);
}

.row-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-secondary {
  font-size: 0.85rem;
}

/* Field Logs & Filters */
.filter-bar {
  background-color: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-field label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

/* Hard-working Map Frameworks */
.map-panel {
  padding: 12px;
}

.map-toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.map-toolbar button {
  min-height: 40px;
  font-size: 0.75rem;
  padding: 4px;
  font-weight: 600;
}

.field-map {
  width: 100%;
  height: 380px;
  background-color: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--line);
  z-index: 1;
}

.map-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.4;
}

/* Fixed Bottom Touch Nav System */
.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  background-color: rgba(19, 28, 46, 0.9);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(6, 1fr); /* 6 tabs */
  padding: 4px 4px env(safe-area-inset-bottom);
  z-index: 200;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.tab-button {
  background: transparent;
  border: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.65rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  border-radius: 6px;
  padding: 4px 2px;
  cursor: pointer;
  min-height: auto;
  transition: all 0.2s ease;
}

.tab-button:hover {
  color: var(--ink);
}

.tab-button.is-active {
  color: var(--brand);
  background-color: rgba(255, 255, 255, 0.03);
}

.tab-svg {
  width: 20px;
  height: 20px;
}

/* Overlay Dialog Sheets (Bottom Sheet Pattern for Handheld Use) */
.modal-backdrop {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(9, 15, 29, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
}

.modal {
  width: 100%;
  max-width: 600px;
  background-color: var(--panel);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-sheet);
  max-height: 92vh;
  overflow-y: auto;
}

.drag-handle-accent {
  width: 40px;
  height: 4px;
  background-color: var(--line);
  border-radius: 2px;
  margin: -6px auto 14px;
}

.input-embedded-action-row {
  display: flex;
  gap: 8px;
}

.btn-side-action {
  min-height: 48px;
  width: auto;
  flex-shrink: 0;
}

.form-micro-hint {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 4px;
}

.modal-readonly input {
  background-color: rgba(0, 0, 0, 0.2) !important;
  border-color: var(--line);
  color: var(--muted) !important;
}

.modal-actions-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.btn-flat {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-flat:hover {
  color: var(--ink);
}

/* Reference Guide layout styles */
.reference-warning {
  background: var(--gold-soft);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  color: #fde047;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 16px;
  padding: 12px;
}

.reference-list {
  display: grid;
  gap: 12px;
}

.reference-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 12px;
  padding: 14px;
}

.reference-card-top {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.reference-card-badges {
  display: grid;
  flex: 0 0 auto;
  gap: 6px;
  justify-items: end;
  max-width: 140px;
}

.reference-kicker {
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.reference-card h3 {
  color: #ffffff;
  font-size: 1.1rem;
  line-height: 1.2;
  margin-top: 2px;
  font-family: 'Outfit', sans-serif;
}

.reference-card p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.reference-confidence {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 8px;
  text-align: right;
  text-transform: uppercase;
}

.reference-type-pill {
  background: var(--brand-dark);
  border-radius: 4px;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 8px;
  text-align: right;
  text-transform: uppercase;
}

.reference-meta-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.reference-meta {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 52px;
  padding: 8px 10px;
}

.reference-meta span,
.reference-source span {
  color: var(--muted);
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.reference-meta strong,
.reference-source strong {
  color: #ffffff;
  display: block;
  font-size: 0.82rem;
  margin-top: 2px;
}

.reference-list-block {
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.reference-list-block h4 {
  color: #bae6fd;
  font-size: 0.85rem;
  margin-bottom: 8px;
  font-family: 'Outfit', sans-serif;
}

.reference-list-block ul {
  display: grid;
  gap: 6px;
  margin-left: 18px;
}

.reference-list-block li {
  color: var(--ink);
  font-size: 0.82rem;
}

.torque-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 8px;
}

.torque-table-header,
.torque-table-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1.35fr) minmax(86px, 0.65fr);
}

.torque-table-header {
  background: var(--brand-dark);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 8px 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.torque-table-row {
  background: rgba(0, 0, 0, 0.1);
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.8rem;
  padding: 8px 10px;
}

.torque-table-row strong {
  color: var(--brand);
  font-size: 0.8rem;
}

.reference-source {
  background: rgba(14, 165, 233, 0.03);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.reference-source em,
.reference-source small {
  color: var(--muted);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 600;
}

.reference-source a {
  color: var(--brand);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
}
.reference-source a:hover {
  text-decoration: underline;
}

/* Document / Scanner panel layout styles */
.document-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

.document-capture-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 12px;
  padding: 14px;
}

.scan-doc-camera-panel {
  margin-top: 0;
}

.scan-doc-camera-placeholder {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(14, 165, 233, 0.16), rgba(16, 185, 129, 0.08)),
    var(--field);
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 6px;
  min-height: 220px;
  padding: 24px;
  text-align: center;
}

.scan-doc-camera-placeholder strong {
  color: #ffffff;
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
}

.scan-doc-camera-placeholder span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.scan-doc-camera-actions button {
  flex: 1 1 150px;
}

.scan-doc-options {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.scan-doc-options summary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  list-style: none;
  padding: 12px;
}

.scan-doc-options summary::-webkit-details-marker {
  display: none;
}

.scan-doc-options summary::after {
  color: var(--brand);
  content: "+";
  float: right;
  font-size: 1.1rem;
}

.scan-doc-options[open] summary::after {
  content: "-";
}

.scan-doc-options .form-grid {
  padding: 12px;
}

.scan-doc-preview {
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.scan-doc-preview img {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  max-height: 320px;
  object-fit: contain;
  width: 100%;
}

.scan-doc-preview small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.scan-doc-pages {
  display: grid;
  gap: 10px;
}

.scan-doc-page {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.scan-doc-page img {
  background: rgba(0, 0, 0, 0.2);
  display: block;
  max-height: 260px;
  object-fit: contain;
  width: 100%;
}

.scan-doc-page-body {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.scan-doc-page-body strong {
  color: #ffffff;
  font-size: 0.9rem;
  font-family: 'Outfit', sans-serif;
}

.scan-doc-page-body span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.scan-doc-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 12px;
}

.scan-doc-page-actions button {
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 12px;
  min-height: 36px;
}

.scan-doc-page-actions button:disabled {
  opacity: 0.45;
}

.field-guide-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.flow-status.good {
  background-color: var(--ok-soft);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

.flow-status.low,
.text-warn {
  color: #fda4af;
}

.flow-status.low {
  background-color: var(--warn-soft);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.save-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.save-action:not(:disabled) {
  background-color: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.save-action.is-low-flow:not(:disabled) {
  background-color: var(--warn);
  border-color: var(--warn);
  color: #ffffff;
}

.input-card.has-error input,
.input-card.has-error textarea,
input[aria-invalid="true"] {
  border-color: var(--warn);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2);
}

.input-progress {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 14px;
}

.input-progress span {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  height: 5px;
}

.input-progress span.filled {
  background: var(--brand);
}

.wide {
  grid-column: 1 / -1;
}

.empty-state,
.record-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.empty-state {
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.record-top {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.record-title {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.record-subtitle,
.record-notes {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.record-fields {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.field-chip {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 48px;
  padding: 8px 10px;
}

.field-chip span {
  color: var(--muted);
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.field-chip strong {
  color: #ffffff;
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  margin-top: 2px;
}

.low-badge,
.ok-badge {
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.low-badge {
  background: var(--warn-soft);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.ok-badge {
  background: var(--ok-soft);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.workflow-control {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
}

.delete-record {
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
  margin-top: 14px;
}
.delete-record:hover {
  background-color: var(--warn-soft);
  border-color: var(--warn);
}

.record-photo,
.photo-preview img,
.photo-preview-box img {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin-top: 14px;
  max-height: 220px;
  object-fit: cover;
  width: 100%;
}

.scanner-stream-panel,
.scanner-panel {
  background: #020617;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
}

.scanner-stream-panel video,
.scanner-panel video {
  background: #000;
  border-radius: 6px;
  display: block;
  max-height: 320px;
  object-fit: cover;
  width: 100%;
}

.hydrant-map-marker span {
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  display: block;
  height: 22px;
  width: 22px;
}

.map-popup {
  display: grid;
  gap: 4px;
  min-width: 180px;
  color: #000000; /* Leaflet popup needs dark text on default light bubbles */
}

.map-popup h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.map-popup .low {
  color: #b91c1c;
  font-weight: 700;
}

.map-popup .ok {
  color: #047857;
  font-weight: 700;
}

.is-tracking {
  background: var(--ok) !important;
  border-color: var(--ok) !important;
  color: #fff !important;
}

/* Responsive Desktop Media Layout Alterations */
@media (min-width: 600px) {
  .actions, .modal-actions-footer {
    flex-direction: row-reverse;
  }
  .actions button, .modal-actions-footer button {
    flex: 1;
  }
  .filter-bar {
    flex-direction: row;
  }
  .filter-field {
    flex: 1;
  }
}

@media (max-width: 680px) {
  .form-grid,
  .results,
  .record-fields,
  .summary-grid,
  .reference-meta-grid {
    grid-template-columns: 1fr;
  }

  .span-1,
  .span-2,
  .wide {
    grid-column: 1 / -1;
  }
}

@media print {
  .app-header,
  .calculator-shell,
  .actions,
  .modal-backdrop,
  .bottom-tabs {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .saved-panel {
    border: 0;
    box-shadow: none;
    page-break-inside: avoid;
  }
}
