:root {
  /* Precision (default theme) */
  --primary: #1e3a8a;
  --primary-dark: #172554;
  --primary-light: #dbeafe;
  --accent: #7B2B3A;
  --accent-light: #fce7e9;
  --steel: #6B7280;
  --steel-light: #F3F4F6;
  --charcoal: #1f2937;
  --green: #10b981;
  --green-light: #d1fae5;
  --orange: #f59e0b;
  --orange-light: #fef3c7;
  --red: #ef4444;
  --red-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --white: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(30,58,138,0.12);
  --shadow-lg: 0 8px 24px rgba(30,58,138,0.16);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--charcoal);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  font-size: 15px;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* ===== Login ===== */
.login-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 40px 30px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
}
.login-logo {
  width: 180px; margin-bottom: 20px;
  background: var(--white); padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.login-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; letter-spacing: 0.5px; }
.login-subtitle { font-size: 14px; opacity: 0.7; margin-bottom: 30px; }
.pin-display { display: flex; gap: 15px; margin-bottom: 30px; }
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5); background: transparent;
  transition: all 0.2s;
}
.pin-dot.filled { background: var(--white); border-color: var(--white); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 280px; }
.pin-btn {
  width: 70px; height: 70px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1); color: var(--white); font-size: 24px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.pin-btn:active { background: rgba(255,255,255,0.3); transform: scale(0.95); }
.pin-btn-empty { visibility: hidden; }
.pin-btn-delete { font-size: 20px; }
.pin-error { color: #fca5a5; font-size: 14px; margin-top: 15px; min-height: 20px; }
.pin-hint { font-size: 12px; opacity: 0.5; margin-top: 10px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ===== Header ===== */
.app-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header-logo { height: 36px; }
.header-title {
  font-size: 17px; font-weight: 700;
  color: var(--primary); letter-spacing: 0.3px;
}
.header-user {
  flex: 1;
  margin-left: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600, #666);
  background: var(--gray-100, #f3f4f6);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.header-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--primary-light); color: var(--primary); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.header-btn:active { background: var(--primary); color: var(--white); }

/* ===== Content ===== */
.app-content {
  padding: 16px; padding-bottom: 90px;
  min-height: calc(100vh - 60px - 70px);
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 8px 0;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 2px);
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
}
.nav-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; border: none; background: none; cursor: pointer;
  color: var(--gray-400); font-size: 10px; transition: color 0.2s;
  overflow: hidden;
}
.nav-btn.active { color: var(--primary); }
.nav-icon {
  width: 22px;
  height: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.nav-label {
  font-weight: 600; font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ===== Page Title ===== */
.page-title {
  font-size: 22px; font-weight: 700; color: var(--charcoal);
  margin-bottom: 4px; letter-spacing: 0.2px;
}
.page-subtitle {
  font-size: 13px; color: var(--gray-500); margin-bottom: 20px;
}

/* ===== Cards ===== */
.card {
  background: var(--white); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.card-title {
  font-size: 14px; font-weight: 600; color: var(--charcoal);
  margin-bottom: 8px;
}
.card-meta {
  font-size: 12px; color: var(--gray-500);
}

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--gray-700); margin-bottom: 6px;
}
.form-label .required { color: var(--accent); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; background: var(--white);
  color: var(--charcoal); transition: all 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-helper {
  font-size: 12px; color: var(--gray-500); margin-top: 4px;
}

/* ===== Section Title (within forms) ===== */
.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--primary);
  margin: 24px 0 12px; padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-light);
}
.section-title:first-of-type { margin-top: 0; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 24px; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(1px); box-shadow: var(--shadow); }
.btn-secondary {
  background: var(--white); color: var(--primary);
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:active { background: var(--gray-100); }
.btn-accent {
  background: var(--accent); color: var(--white);
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 16px 28px; font-size: 16px; }

.btn-row { display: flex; gap: 10px; margin-top: 20px; }

/* ===== Calculator Result ===== */
.result-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white); border-radius: var(--radius);
  padding: 24px; margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.result-card .label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px;
  opacity: 0.7; margin-bottom: 4px;
}
.result-card .calc-id {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px; opacity: 0.8;
  background: rgba(255,255,255,0.1); padding: 4px 10px;
  border-radius: 6px; display: inline-block; margin-bottom: 16px;
}
.result-card .total {
  font-size: 42px; font-weight: 700; line-height: 1;
  margin: 12px 0 4px;
}
.result-card .total-meta {
  font-size: 13px; opacity: 0.8;
}

.breakdown {
  background: var(--white); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.breakdown-row {
  display: flex; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}
.breakdown-row:last-child {
  border-bottom: none; padding-top: 14px;
  font-weight: 700; font-size: 16px; color: var(--primary);
}
.breakdown-row .label { color: var(--gray-600); }
.breakdown-row .value { color: var(--charcoal); font-weight: 500; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%);
  background: var(--charcoal); color: var(--white);
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 200;
  max-width: 90%;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--primary); }

/* ===== Empty State ===== */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--gray-500);
}
.empty-state .icon { font-size: 56px; margin-bottom: 12px; opacity: 0.4; }
.empty-state .title { font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
.empty-state .desc { font-size: 13px; }

/* ===== History List Items ===== */
.history-item {
  background: var(--white); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow); border: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 12px;
}
.history-item .info { flex: 1; min-width: 0; }
.history-item .title {
  font-size: 14px; font-weight: 600; color: var(--charcoal);
  margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item .meta {
  font-size: 12px; color: var(--gray-500);
}
.history-item .price {
  font-size: 16px; font-weight: 700; color: var(--primary);
}

/* ===== Status Badge ===== */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 100px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-sent { background: var(--primary-light); color: var(--primary); }
.badge-approved { background: var(--green-light); color: var(--green); }
.badge-stale { background: var(--gray-200); color: var(--gray-600); }
.badge-used { background: var(--accent-light); color: var(--accent); }

/* ===== Loader ===== */
.loader {
  display: inline-block; width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Settings ===== */
.settings-section {
  background: var(--white); border-radius: var(--radius);
  margin-bottom: 16px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--gray-200);
}
.settings-section .section-header {
  padding: 14px 16px; background: var(--gray-50);
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}
.settings-section .section-body { padding: 16px; }

/* ===== Tabs (for History page) ===== */
.tabs {
  display: flex; background: var(--white); border-radius: var(--radius);
  padding: 4px; margin-bottom: 16px; gap: 4px;
  border: 1px solid var(--gray-200);
}
.tab-btn {
  flex: 1; padding: 10px; border: none; background: none;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  color: var(--gray-500); cursor: pointer; transition: all 0.2s;
}
.tab-btn.active { background: var(--primary); color: var(--white); }

/* ===== Business Themes ===== */
body.biz-ryde {
  --primary: #EE7F2E;
  --primary-dark: #C65E12;
  --primary-light: #FFF3E8;
  --accent: #1a1a1a;
  --accent-light: #f3f4f6;
}

/* ===== Login Logos ===== */
.login-logos {
  display: flex; gap: 20px; margin-bottom: 24px;
  background: white; padding: 20px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  flex-wrap: wrap; justify-content: center;
}
.login-logos .login-logo {
  width: 130px; margin: 0; padding: 0; background: transparent;
  box-shadow: none; border-radius: 0;
}

/* ===== Business Selector ===== */
.biz-container {
  min-height: 100vh; padding: 40px 24px 80px;
  background: linear-gradient(135deg, #f0f4f9 0%, #e5e7eb 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.biz-title {
  font-size: 28px; font-weight: 700; color: var(--charcoal);
  margin-bottom: 8px; text-align: center;
}
.biz-sub {
  font-size: 15px; color: var(--gray-500); margin-bottom: 40px; text-align: center;
}
.biz-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  max-width: 700px; width: 100%;
}
@media (max-width: 600px) {
  .biz-cards { grid-template-columns: 1fr; }
}
.biz-card {
  background: white; border: 2px solid transparent;
  border-radius: var(--radius); padding: 30px 20px;
  cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.biz-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.biz-card.biz-precision:hover { border-color: #1e3a8a; }
.biz-card.biz-ryde:hover { border-color: #EE7F2E; }
.biz-card-logo {
  max-width: 200px; max-height: 80px; object-fit: contain;
}
.biz-card-name {
  font-size: 17px; font-weight: 700; color: var(--charcoal);
  text-align: center; line-height: 1.3;
}
.biz-card-markup {
  font-size: 12px; font-weight: 600; color: var(--gray-500);
  background: var(--gray-100); padding: 4px 10px; border-radius: 100px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ===== Business Banner (in calculator) ===== */
.biz-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 13px;
}
.biz-banner.biz-precision { background: #dbeafe; color: #1e3a8a; }
.biz-banner.biz-ryde { background: #FFF3E8; color: #C65E12; }
.biz-banner .biz-label {
  text-transform: uppercase; letter-spacing: 1px; font-weight: 600;
  opacity: 0.7; font-size: 11px;
}
.biz-banner .biz-name { flex: 1; font-weight: 700; }
.biz-banner .biz-markup {
  background: rgba(255,255,255,0.7); padding: 3px 8px;
  border-radius: 100px; font-weight: 700; font-size: 12px;
}

/* ===== Result Card Business Variants ===== */
.result-card.biz-ryde {
  background: linear-gradient(135deg, #EE7F2E, #C65E12);
}

/* ===== Header smaller button ===== */
.header-btn-sm {
  width: 32px; height: 32px; font-size: 14px;
  margin-right: 4px;
}

/* ===== Accessory Items ===== */
.accessory-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  background: var(--white);
}
.accessory-item label {
  flex: 1; display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 14px;
}
.accessory-item .acc-name { flex: 1; }
.accessory-item .acc-price {
  font-weight: 600; color: var(--primary);
  font-size: 13px;
}
.acc-qty { text-align: center; font-weight: 600; }

/* ===== Dynamic logo swap ===== */
body.biz-ryde .header-logo { height: 28px; }

/* ===== Expandable History Items ===== */
.history-item-expandable {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.history-item-expandable summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: background 0.15s;
}
.history-item-expandable summary::-webkit-details-marker { display: none; }
.history-item-expandable summary:hover { background: var(--gray-50); }
.history-item-expandable .expand-icon {
  font-size: 16px; color: var(--gray-400);
  transition: transform 0.2s; flex-shrink: 0;
}
.history-item-expandable[open] .expand-icon { transform: rotate(180deg); }

.history-summary { box-shadow: none !important; border: none !important; margin: 0 !important; border-radius: 0 !important; }

.history-details {
  padding: 0 16px 16px 16px;
  border-top: 1px solid var(--gray-100);
  padding-top: 14px;
}

.detail-grid {
  display: flex; flex-direction: column; gap: 2px;
}
.detail-row {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--gray-100);
  font-size: 13px; gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  color: var(--gray-500); font-weight: 500;
  flex-shrink: 0; min-width: 120px;
}
.detail-value {
  color: var(--charcoal); font-weight: 500;
  text-align: right; word-break: break-word;
}
.detail-row a {
  color: var(--primary); text-decoration: none;
}
.detail-row a:hover { text-decoration: underline; }
.detail-total {
  margin-top: 6px; padding-top: 12px !important;
  border-top: 2px solid var(--gray-200) !important;
  border-bottom: none !important;
}
.detail-total .detail-label { color: var(--charcoal); font-weight: 700; font-size: 14px; }
.detail-total .detail-value { color: var(--primary); font-weight: 700; font-size: 18px; }

/* ===== Dashboard ===== */
.dashboard-wrap {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.dashboard-tile {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 12px;
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.dashboard-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.dashboard-tile.tile-warn {
  background: linear-gradient(135deg, #fff7ed, #ffffff);
  border-color: #fed7aa;
}
.dashboard-tile .tile-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 4px;
}
.dashboard-tile.tile-warn .tile-value { color: #ea580c; }
.dashboard-tile .tile-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-600);
}
.dashboard-tile .tile-sub {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}
.dashboard-tile.skeleton {
  height: 86px;
  background: linear-gradient(90deg, #f5f5f5 0%, #eeeeee 50%, #f5f5f5 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ======================================================== */
/* ===== MOBILE LAYOUT (≤ 640px) — stack, tighten ========== */
/* ======================================================== */
@media (max-width: 640px) {
  /* Header: tighter, smaller buttons, trim the brand title (logo carries brand) */
  .app-header {
    padding: 10px 12px;
    gap: 8px;
  }
  .header-logo { height: 30px; }
  .header-title { font-size: 15px; }
  .header-user {
    font-size: 11px;
    padding: 4px 9px;
    max-width: 100px;
    margin-left: 2px;
  }
  .header-btn { width: 34px; height: 34px; font-size: 16px; }
  .header-btn-sm { width: 30px; height: 30px; font-size: 13px; margin-right: 2px; }

  /* Content: less side padding so inputs/buttons get more width */
  .app-content { padding: 14px 12px; padding-bottom: 90px; }

  /* Page titles smaller + tighter */
  .page-title { font-size: 20px; }
  .page-subtitle { font-size: 12.5px; margin-bottom: 16px; }

  /* Cards */
  .card { padding: 14px; }

  /* FORMS — stack two-column rows into single column */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .form-input, .form-select, .form-textarea {
    padding: 11px 12px;
    font-size: 15px;
  }

  /* Section titles inside forms */
  .section-title { font-size: 13px; margin-top: 18px; }

  /* Business banner — tighter */
  .biz-banner { padding: 8px 12px; font-size: 12px; gap: 8px; margin-bottom: 12px; }
  .biz-banner .biz-label { font-size: 10px; letter-spacing: 0.8px; }

  /* Result card — smaller headline total */
  .result-card { padding: 20px 18px; }
  .result-card .total { font-size: 36px; }
  .result-card .calc-id { font-size: 12px; padding: 3px 8px; }

  /* Breakdown rows */
  .breakdown { padding: 14px; }
  .breakdown-row { font-size: 13px; padding: 8px 0; }
  .breakdown-row:last-child { font-size: 15px; }

  /* Accessory items — tighter padding */
  .accessory-item { padding: 8px 10px; gap: 8px; }
  .accessory-item label { font-size: 13px; gap: 8px; }
  .accessory-item .acc-price { font-size: 12px; }

  /* History list */
  .history-item { gap: 8px; padding: 12px 14px; }
  .history-item .title { font-size: 13.5px; }
  .history-item .price { font-size: 14px; }

  .history-item-expandable summary { padding: 12px 14px; gap: 8px; }
  .history-details { padding: 0 14px 14px; padding-top: 12px; }

  /* Detail rows — STACK label above value (was squashing side-by-side) */
  .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 9px 0;
  }
  .detail-label {
    min-width: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
  }
  .detail-value {
    text-align: left;
    width: 100%;
    font-size: 14px;
  }
  .detail-total .detail-label { font-size: 12px; }
  .detail-total .detail-value { font-size: 20px; }

  /* Dashboard tiles: 3-col → 2-col */
  .dashboard-wrap { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .dashboard-tile { padding: 12px 10px; }
  .dashboard-tile .tile-value { font-size: 20px; }
  .dashboard-tile.skeleton { height: 74px; }

  /* Button rows — allow wrap so 2 buttons always fit */
  .btn-row { flex-wrap: wrap; gap: 8px; }
  .btn { font-size: 14px; padding: 11px 16px; }
  .btn-lg { font-size: 15px; padding: 13px 20px; }

  /* Bottom nav: smaller icons + label */
  .nav-btn { padding: 5px 2px; gap: 2px; }
  .nav-icon { width: 20px; height: 20px; }
  .nav-label { font-size: 9.5px; letter-spacing: -0.1px; }
}

/* Swap long labels for short ones on ≤640px via CSS — no HTML change needed */
@media (max-width: 640px) {
  .nav-btn[data-page="quote"] .nav-label { font-size: 0; }
  .nav-btn[data-page="quote"] .nav-label::before {
    content: "Quote"; font-size: 9.5px; font-weight: 600;
  }
  .nav-btn[data-page="maintenance"] .nav-label { font-size: 0; }
  .nav-btn[data-page="maintenance"] .nav-label::before {
    content: "Maint"; font-size: 9.5px; font-weight: 600;
  }
  .nav-btn[data-page="calculator"] .nav-label { font-size: 0; }
  .nav-btn[data-page="calculator"] .nav-label::before {
    content: "Calc"; font-size: 9.5px; font-weight: 600;
  }

  /* Settings sections — compact */
  .settings-section { margin-bottom: 12px; }
  .section-header { font-size: 13px; padding: 12px 14px; }
  .section-body { padding: 14px; }

  /* Login screen — pin pad already responsive via max-width:280px */
  .login-title { font-size: 22px; }
  .login-subtitle { font-size: 13px; }
}

/* ======================================================== */
/* ===== VERY NARROW PHONES (≤ 380px) — extra tweaks ====== */
/* ======================================================== */
@media (max-width: 380px) {
  /* Hide brand title so the header isn't cramped — logo + user pill stay */
  .header-title { display: none; }

  /* Dashboard → single column */
  .dashboard-wrap { grid-template-columns: 1fr; }

  /* Extra-tight content padding */
  .app-content { padding: 12px 10px; padding-bottom: 90px; }

  /* Accessory name/price can wrap if needed */
  .accessory-item { flex-wrap: wrap; }

  /* History summary price can drop below info if very long */
  .history-item .meta { font-size: 11.5px; }
}
