/* === Mona Maintenance Dashboard — Dark Theme + Amber Accents === */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1c2a4a;
  --bg-input: #0d1b30;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --amber: #f59e0b;
  --amber-light: #fbbf24;
  --amber-dark: #d97706;
  --amber-glow: rgba(245,158,11,0.15);
  --orange: #f97316;
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --yellow: #eab308;
  --yellow-bg: rgba(234,179,8,0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,0.12);
  --border: #2a2a40;
  --border-light: #3a3a55;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --tab-height: 64px;
  --header-height: 56px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: calc(var(--tab-height) + 16px);
}

/* === HEADER === */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.app-header h1 {
  font-size: 1.2rem; font-weight: 700;
  color: var(--amber);
  display: flex; align-items: center; gap: 8px;
}
.app-header h1 .van-icon { font-size: 1.4rem; }
.header-actions { display: flex; gap: 8px; }
.header-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: var(--radius-sm);
  padding: 6px 10px; cursor: pointer; font-size: 0.85rem;
  transition: all 0.2s;
}
.header-btn:hover { border-color: var(--amber); color: var(--amber); }

/* === BOTTOM TAB NAV === */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex; height: var(--tab-height);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; color: var(--text-muted);
  font-size: 0.65rem; font-weight: 600; cursor: pointer;
  transition: color 0.2s; text-transform: uppercase; letter-spacing: 0.5px;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.tab-btn .tab-icon { font-size: 1.4rem; line-height: 1; }
.tab-btn.active { color: var(--amber); }
.tab-btn.active .tab-icon { filter: drop-shadow(0 0 6px var(--amber)); }

/* === PAGES === */
.page { display: none; padding: 16px; max-width: 800px; margin: 0 auto; }
.page.active { display: block; }
.page-title {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 16px;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.page-title .icon { color: var(--amber); }

/* === CARDS === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-light); }
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.card-title {
  font-size: 1rem; font-weight: 600;
  color: var(--amber-light);
  display: flex; align-items: center; gap: 6px;
}
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); }

/* === VEHICLE INFO CARD === */
.vehicle-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, #1a2744 100%);
  border-color: var(--amber-dark);
  position: relative; overflow: hidden;
}
.vehicle-card::after {
  content: '🚐'; position: absolute; right: 12px; bottom: 8px;
  font-size: 3rem; opacity: 0.12;
}
.vehicle-info-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.vehicle-info-item { font-size: 0.85rem; }
.vehicle-info-label { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; }
.vehicle-info-value { color: var(--text-primary); font-weight: 500; }

/* === QUICK LINKS === */
.quick-links {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.quick-link {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px; text-align: center;
  cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.quick-link:hover, .quick-link:active {
  border-color: var(--amber); background: var(--amber-glow);
}
.quick-link .ql-icon { font-size: 1.5rem; }
.quick-link .ql-label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; }

/* === STATUS BADGES === */
.badge {
  display: inline-block; padding: 2px 10px;
  border-radius: 20px; font-size: 0.7rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-needed { background: var(--red-bg); color: var(--red); }
.badge-ordered { background: var(--yellow-bg); color: var(--yellow); }
.badge-received { background: var(--blue-bg); color: var(--blue); }
.badge-installed { background: var(--green-bg); color: var(--green); }
.badge-overdue { background: var(--red-bg); color: var(--red); }
.badge-due { background: var(--yellow-bg); color: var(--yellow); }
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-unknown { background: rgba(100,100,120,0.2); color: var(--text-muted); }

/* Priority badges */
.priority-high { color: var(--red); font-weight: 700; }
.priority-medium { color: var(--yellow); font-weight: 600; }
.priority-low { color: var(--green); }

/* === TABLES === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.85rem;
}
th {
  text-align: left; padding: 10px 12px;
  background: var(--bg-secondary);
  color: var(--amber-light); font-weight: 600;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid var(--amber-dark);
  white-space: nowrap;
}
td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-primary); vertical-align: top;
}
tr:hover td { background: var(--bg-card-hover); }

/* === SPECS TABLE === */
.specs-table { margin: 12px 0; }
.specs-table td:first-child { color: var(--text-secondary); font-weight: 500; white-space: nowrap; }
.specs-table td:last-child { color: var(--amber-light); font-family: var(--font-mono); font-size: 0.83rem; }

/* === GUIDE SECTIONS === */
.guide-nav {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.guide-nav-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 16px;
  color: var(--text-secondary); font-size: 0.78rem; font-weight: 600;
  white-space: nowrap; cursor: pointer; transition: all 0.2s;
  min-height: 44px; display: flex; align-items: center;
}
.guide-nav-btn.active {
  background: var(--amber); color: var(--bg-primary);
  border-color: var(--amber);
}
.guide-section { display: none; }
.guide-section.active { display: block; }

/* === STEP-BY-STEP === */
.step-list { list-style: none; }
.step-item {
  display: flex; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
  position: relative;
}
.step-item:last-child { border-bottom: none; }
.step-num {
  flex-shrink: 0; width: 32px; height: 32px;
  background: var(--amber); color: var(--bg-primary);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 0.85rem;
}
.step-content { flex: 1; }
.step-title { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; font-size: 0.95rem; }
.step-text { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.5; }
.step-action {
  margin-top: 8px; padding: 8px 12px;
  background: var(--amber-glow); border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem; color: var(--amber-light);
}
.step-visual {
  margin-top: 6px; font-size: 0.8rem; color: var(--text-muted);
  font-style: italic;
}

/* === SAFETY WARNINGS === */
.safety-box {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius); padding: 14px;
  margin-bottom: 16px;
}
.safety-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 0;
}
.safety-item:not(:last-child) { border-bottom: 1px solid rgba(239,68,68,0.15); }
.safety-icon { font-size: 1.3rem; flex-shrink: 0; }
.safety-text .safety-title { font-weight: 600; color: var(--red); font-size: 0.85rem; }
.safety-text .safety-desc { color: var(--text-secondary); font-size: 0.8rem; }

/* === SVG CONTAINER === */
.svg-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px; margin: 16px 0;
  text-align: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.svg-container svg {
  max-width: 100%; height: auto;
}
.svg-caption {
  font-size: 0.75rem; color: var(--text-muted);
  margin-top: 8px; text-align: center;
}

/* === FORMS === */
.form-group { margin-bottom: 12px; }
.form-label {
  display: block; font-size: 0.75rem;
  color: var(--text-muted); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.form-input, .form-select {
  width: 100%; padding: 10px 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.9rem; font-family: var(--font);
  transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-glow);
}
.form-select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23a0a0b8' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}
select option { background: var(--bg-secondary); color: var(--text-primary); }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: none; transition: all 0.2s;
  min-height: 44px; font-family: var(--font);
}
.btn-primary { background: var(--amber); color: var(--bg-primary); }
.btn-primary:hover { background: var(--amber-light); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--amber); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; min-height: 36px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }

/* === MODAL === */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 600px; max-height: 85vh;
  overflow-y: auto; padding: 20px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-title {
  font-size: 1.1rem; font-weight: 700; color: var(--amber);
  margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center;
}
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.5rem; cursor: pointer; padding: 4px; line-height: 1;
}

/* === FILTER BAR === */
.filter-bar {
  display: flex; gap: 8px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 14px;
  color: var(--text-secondary); font-size: 0.75rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  min-height: 36px;
}
.filter-btn.active {
  background: var(--amber-glow); border-color: var(--amber);
  color: var(--amber);
}

/* === COST CHART === */
.cost-summary {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 16px;
}
.cost-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; text-align: center;
}
.cost-stat-value {
  font-size: 1.5rem; font-weight: 700; color: var(--amber);
  font-family: var(--font-mono);
}
.cost-stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.bar-chart { margin: 16px 0; }
.bar-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.bar-label {
  flex-shrink: 0; width: 80px;
  font-size: 0.75rem; color: var(--text-secondary); text-align: right;
}
.bar-track {
  flex: 1; height: 24px;
  background: var(--bg-secondary); border-radius: 4px; overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--amber-dark), var(--amber));
  transition: width 0.5s ease;
  display: flex; align-items: center; padding-left: 8px;
  font-size: 0.7rem; font-weight: 600; color: var(--bg-primary);
  min-width: fit-content;
}

/* === ACTIVITY FEED === */
.activity-feed { max-height: 200px; overflow-y: auto; }
.activity-item {
  display: flex; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 0.82rem;
}
.activity-time { color: var(--text-muted); font-size: 0.72rem; white-space: nowrap; flex-shrink: 0; }
.activity-text { color: var(--text-secondary); }

/* === TOOL LIST === */
.tool-grid {
  display: grid; gap: 8px;
}
.tool-item {
  display: grid; grid-template-columns: 1fr auto;
  gap: 4px; padding: 10px 12px;
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.tool-name { font-weight: 600; color: var(--text-primary); }
.tool-size { color: var(--amber); font-family: var(--font-mono); font-size: 0.78rem; text-align: right; }
.tool-purpose { grid-column: 1/-1; color: var(--text-muted); font-size: 0.75rem; }

/* === SCHEDULE COLORS === */
.schedule-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px; cursor: pointer; transition: all 0.2s;
}
.schedule-item:hover { border-color: var(--border-light); }
.schedule-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.schedule-dot.overdue { background: var(--red); box-shadow: 0 0 6px var(--red); }
.schedule-dot.due { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.schedule-dot.ok { background: var(--green); }
.schedule-dot.unknown { background: var(--text-muted); }
.schedule-info { flex: 1; }
.schedule-task { font-weight: 600; font-size: 0.9rem; }
.schedule-interval { color: var(--text-muted); font-size: 0.75rem; }
.schedule-dates { font-size: 0.75rem; color: var(--text-secondary); }

/* === EMPTY STATE === */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; }

/* === BLEEDING SEQUENCE DIAGRAM === */
.bleed-order {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin: 16px 0;
}
.bleed-wheel {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; text-align: center;
}
.bleed-num {
  font-size: 1.8rem; font-weight: 800; color: var(--amber);
  font-family: var(--font-mono);
}
.bleed-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; }

/* === ESTIMATE BOX === */
.estimate-box {
  background: var(--amber-glow); border: 1px solid var(--amber-dark);
  border-radius: var(--radius); padding: 14px; margin: 16px 0;
}
.estimate-title { font-weight: 600; color: var(--amber); margin-bottom: 8px; font-size: 0.9rem; }
.estimate-line {
  display: flex; justify-content: space-between;
  font-size: 0.85rem; padding: 4px 0;
}
.estimate-label { color: var(--text-secondary); }
.estimate-value { color: var(--amber-light); font-weight: 600; font-family: var(--font-mono); }

/* === SEARCH / INPUT INLINE === */
.search-bar {
  position: relative; margin-bottom: 16px;
}
.search-bar input {
  width: 100%; padding: 10px 12px 10px 36px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.9rem;
}
.search-bar input:focus { outline: none; border-color: var(--amber); }
.search-bar .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.9rem;
}

/* === COST TABLE === */
.cost-item-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 8px; padding: 10px 0;
  border-bottom: 1px solid var(--border); align-items: center;
}
.cost-item-name { font-weight: 500; font-size: 0.85rem; }
.cost-item-vendor { color: var(--text-muted); font-size: 0.75rem; }
.cost-item-date { color: var(--text-muted); font-size: 0.72rem; }
.cost-item-amount {
  font-weight: 700; color: var(--amber); font-family: var(--font-mono);
}
.cost-item-actions { display: flex; gap: 4px; }

/* === RESPONSIVE — TABLET+ === */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .tab-bar {
    position: sticky; top: var(--header-height);
    bottom: auto; border-top: none; border-bottom: 1px solid var(--border);
    justify-content: center; gap: 8px; padding: 0 16px;
  }
  .tab-btn { flex: unset; padding: 0 24px; flex-direction: row; gap: 8px; }
  .page { padding: 24px; }
  .quick-links { grid-template-columns: repeat(4, 1fr); }
  .cost-summary { grid-template-columns: repeat(4, 1fr); }
  .modal { border-radius: var(--radius); margin: auto; max-height: 70vh; }
  .modal-overlay { align-items: center; }
}

/* === PRINT === */
@media print {
  :root { --bg-primary: #fff; --bg-secondary: #f5f5f5; --bg-card: #fff;
    --text-primary: #111; --text-secondary: #444; --text-muted: #777;
    --border: #ccc; --amber: #b45309; --amber-light: #92400e; }
  body { padding: 0; background: #fff; color: #111; font-size: 11pt; }
  .app-header, .tab-bar, .header-btn, .btn, .modal-overlay,
  .quick-links, .filter-bar, .search-bar { display: none !important; }
  .page { display: block !important; max-width: 100%; padding: 0; }
  .page:not(.print-target) { display: none !important; }
  .page.print-target { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .guide-section { display: block !important; page-break-before: always; }
  .guide-nav { display: none !important; }
  .svg-container { border: 1px solid #ccc; }
  .step-num { background: #333; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .safety-box { border: 2px solid #c00; }
  a { color: inherit; text-decoration: none; }
}
