:root {
  --bg: #090b0f;
  --bg-elev: #11151d;
  --bg-card: #161b25;
  --bg-card-2: #1c222f;
  --border: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(228, 180, 75, 0.34);
  --gold-1: #fce7a2;
  --gold-2: #e4b44b;
  --gold-3: #c69228;
  --text: #f5f6f8;
  --text-muted: #9aa3b2;
  --text-dim: #6f7785;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #38bdf8;
  --radius: 16px;
  --radius-sm: 11px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #050608;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  display: block;
  min-height: 100dvh;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-width: 0;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.75);
}

@media (min-width: 500px) {
  .app-shell {
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: rgba(9, 11, 15, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-logo {
  height: 34px;
  width: auto;
  max-width: 100%;
  display: block;
}

.mode-switch {
  display: inline-flex;
  background: #141923;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  flex-shrink: 0;
}

.mode-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 9px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2) 55%, var(--gold-3));
  color: #111317;
  box-shadow: 0 2px 10px rgba(228, 180, 75, 0.25);
}

.mode-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mode-btn.active .mode-badge {
  background: #111317;
  color: var(--gold-1);
}

/* iOS Install Helper Banner */
.ios-banner {
  margin: 10px 14px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(228, 180, 75, 0.14), rgba(198, 146, 40, 0.05));
  border: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  line-height: 1.4;
}

.ios-banner strong {
  color: var(--gold-1);
}

.ios-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ios-guide-btn {
  border: 1px solid var(--border-gold);
  background: rgba(228, 180, 75, 0.16);
  color: var(--gold-1);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.ios-close-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}

/* Main Content */
.app-main {
  flex: 1;
  padding: 14px 14px calc(92px + var(--safe-bottom));
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 0 10px;
}

.section-title {
  margin: 0;
  font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.section-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Hero BMW Card */
.hero-card {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(160deg, #19202d 0%, #10141c 100%);
  border: 1px solid var(--border-gold);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
}

.hero-media {
  position: relative;
  width: 100%;
  aspect-ratio: 474 / 186;
  background: #0d1016;
  overflow: hidden;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(9, 11, 15, 0.28) 0%, transparent 28%, rgba(16, 20, 28, 0.92) 100%);
}

.hero-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #111317;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 999px;
}

.hero-branch-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: rgba(9, 11, 15, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 999px;
}

.hero-body {
  padding: 12px 14px 14px;
}

.hero-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.hero-variant {
  margin: 2px 0 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.deal-boxes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.deal-box {
  min-width: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
}

.deal-box.highlight {
  border-color: var(--border-gold);
  background: rgba(228, 180, 75, 0.08);
}

.deal-box-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 700;
}

.deal-box-val {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--gold-1);
  margin-top: 2px;
}

/* Filter Chips */
.chip-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip.active {
  background: rgba(228, 180, 75, 0.16);
  border-color: var(--gold-2);
  color: var(--gold-1);
}

/* Vehicle Grid / List */
.fleet-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.car-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.car-card-visual {
  position: relative;
  height: 124px;
  background: radial-gradient(circle at 60% 35%, rgba(228, 180, 75, 0.12), rgba(14, 18, 26, 0.96) 72%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.car-card-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.car-card-visual svg.car-sil {
  width: 82%;
  max-width: 260px;
  height: auto;
  opacity: 0.95;
}

.pill-top-left {
  position: absolute;
  top: 9px;
  left: 9px;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(9, 11, 15, 0.78);
  border: 1px solid var(--border);
  color: #e5e7eb;
}

.status-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pill-top-right {
  position: absolute;
  top: 9px;
  right: 9px;
}

.status-tersedia, .status-lunas, .status-sahkan, .status-ok {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.status-keluar, .status-reserved, .status-menunggu, .status-tamat, .status-warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.status-servis, .status-lewat, .status-ditolak, .status-urgent {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.status-info {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.car-card-body {
  padding: 12px 13px 13px;
}

.car-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.car-name {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.car-sub {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.car-price-col {
  text-align: right;
  flex-shrink: 0;
}

.car-price {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 800;
  color: var(--gold-1);
}

.car-price-unit {
  font-size: 10.5px;
  color: var(--text-muted);
}

.spec-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 9px 0 11px;
}

.spec-pill {
  font-size: 10.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 7px;
}

.sb-strip {
  background: rgba(228, 180, 75, 0.08);
  border: 1px solid var(--border-gold);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 11.5px;
  color: var(--gold-1);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn-row {
  display: flex;
  gap: 8px;
}

.btn {
  border: 0;
  border-radius: 11px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 11px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-full {
  width: 100%;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2) 55%, var(--gold-3));
  color: #111317;
}

.btn-dark {
  background: #202736;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-wa {
  background: #16a34a;
  color: #fff;
}

.btn-sm {
  padding: 8px 11px;
  font-size: 12px;
  border-radius: 9px;
}

.btn-danger-outline {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Forms & Cards */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.panel-gold {
  border-color: var(--border-gold);
}

.field {
  margin-bottom: 11px;
  min-width: 0;
}

.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: #0d1118;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px; /* Prevents iOS Safari zoom on focus */
  outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--gold-2);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 9px;
}

.quote-box {
  background: rgba(228, 180, 75, 0.08);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
}

.quote-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
  color: var(--text-muted);
}

.quote-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid rgba(228, 180, 75, 0.25);
  padding-top: 8px;
  margin-top: 6px;
}

.quote-total strong {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  color: var(--gold-1);
}

/* KPI & Ops */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  margin-top: 4px;
}

.kpi-value.gold {
  color: var(--gold-1);
}

.kpi-note {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 3px;
}

.branch-bar-row {
  margin-bottom: 10px;
}

.branch-bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
}

.progress-track {
  height: 7px;
  background: #0d1118;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-3), var(--gold-1));
}

/* 7-day Fleet Calendar */
.cal-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-header-row,
.cal-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) repeat(7, 23px);
  align-items: center;
  gap: 3px;
  padding: 9px 9px;
}

.cal-header-row {
  background: #121721;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.cal-header-row div:first-child {
  text-align: left;
}

.cal-item-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.cal-item-row:last-child {
  border-bottom: 0;
}

.cal-car-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-car-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.cal-dot {
  width: 24px;
  height: 22px;
  border-radius: 6px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
}

.d-0 { background: rgba(34, 197, 94, 0.16); color: #4ade80; }
.d-1 { background: rgba(245, 158, 11, 0.22); color: #fbbf24; }
.d-2 { background: rgba(56, 189, 248, 0.20); color: #7dd3fc; }
.d-3 { background: rgba(239, 68, 68, 0.22); color: #f87171; }

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  margin: 9px 0 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* Handover e-KYC & Signature */
.photo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.photo-slot {
  position: relative;
  min-width: 0;
  border: 1px dashed rgba(228, 180, 75, 0.42);
  border-radius: 12px;
  background: #0d1118;
  height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  padding: 6px;
}

.photo-slot input {
  display: none;
}

.photo-slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-slot-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-1);
}

.photo-slot-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.check-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 7px;
}

.check-pill {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  background: #0d1118;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 11px;
  cursor: pointer;
}

.check-pill input {
  accent-color: var(--gold-2);
  width: 16px;
  height: 16px;
  margin: 0;
}

.sig-box {
  background: #0b0e14;
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
}

.sig-canvas {
  width: 100%;
  height: 148px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.sig-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  background: #121721;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.range-input {
  width: 100%;
  accent-color: var(--gold-2);
}

/* Segmented sub-tabs */
.seg-tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  background: #121721;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 9px 6px;
  border-radius: 9px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--bg-card-2);
  color: var(--gold-1);
  border: 1px solid var(--border-gold);
}

/* Bottom Tab Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 45;
  background: rgba(11, 14, 20, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 7px 6px calc(7px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  padding: 5px 2px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  position: relative;
}

.nav-item svg {
  width: 21px;
  height: 21px;
}

.nav-item.active {
  color: var(--gold-1);
  background: rgba(228, 180, 75, 0.1);
}

/* Modal Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  overflow-y: auto;
  background: #121721;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border-top: 1px solid var(--border-gold);
  padding: 16px 16px calc(22px + var(--safe-bottom));
}

.modal-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 auto 12px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 800;
}

.modal-close {
  border: 1px solid var(--border);
  background: #1b2230;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(78px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  background: #1c2432;
  color: var(--gold-1);
  border: 1px solid var(--border-gold);
  padding: 10px 15px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  max-width: 90%;
  text-align: center;
}

.toast.hidden {
  display: none;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12px;
}
