/* Cost per Km — Web demo */

/* ─── Theme (change these to redesign globally) ─── */
:root {
  --primary: #2e7d32;
  --on-primary: #fff;
  --surface: #fff;
  --on-surface: #1c1b1f;
  --error: #b00020;
  --border: #ccc;
  --header-bg: #fff;
  --header-text: var(--primary);
  --drawer-bg: var(--surface);
  --drawer-text: var(--on-surface);

  /* Splash screen — design here */
  --splash-bg: #fff;
  --splash-text: var(--primary);
  --splash-title-size: 2rem;
  --splash-tagline-size: 1.125rem;
  --splash-cta-size: 0.875rem;

  /* Login screen — design here */
  --login-bg: var(--surface);
  --login-text: var(--on-surface);
  --login-title-size: 1.75rem;
  --login-max-width: 320px;
  --login-card-radius: 12px;
  --login-card-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  color: var(--on-surface);
  background: var(--surface);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ─── SPLASH SCREEN ───────────────────────────────
   Tweak: --splash-* in :root, or classes below.
   Structure: .splash > .splash-inner > .splash-brand, .splash-tagline, .splash-tap
   Optional: add .splash-logo inside .splash-brand in HTML.
   ─────────────────────────────────────────────── */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--splash-bg);
  color: var(--splash-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.splash.hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-inner {
  text-align: center;
  padding: clamp(1rem, 5vw, 2rem);
  max-width: min(360px, 92vw);
  width: 100%;
}

.splash-brand {
  margin-bottom: 0.5rem;
}

.splash-company {
  font-size: calc(1.25 * var(--splash-title-size));
  font-weight: 700;
  letter-spacing: 0.15em;
  margin: 0 0 0.75rem 0;
  text-transform: uppercase;
}

.splash-logo {
  display: block;
  margin: 0 auto 0.75rem;
  max-width: min(300px, 80vw);
  width: 100%;
  height: auto;
}

.splash-title {
  font-size: var(--splash-title-size);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.splash-tagline {
  font-size: var(--splash-tagline-size);
  margin: 0 0 2rem 0;
  opacity: 0.95;
  line-height: 1.4;
  text-transform: uppercase;
}

/* ─── LOGIN SCREEN ───────────────────────────────
   Tweak: --login-* in :root, or classes below.
   Structure: .login-screen > .login-inner > .login-header, .login-form, .login-footer
   ─────────────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: var(--login-bg);
  color: var(--login-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.login-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-inner {
  width: 100%;
  max-width: min(320px, 92vw);
  padding: clamp(1.25rem, 5vw, 2rem);
  border-radius: var(--login-card-radius);
  box-shadow: var(--login-card-shadow);
  background: var(--login-bg);
  margin: auto;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-company {
  font-size: calc(1.25 * var(--splash-title-size));
  font-weight: 700;
  letter-spacing: 0.15em;
  margin: 0 0 0.75rem 0;
  text-transform: uppercase;
  color: var(--primary);
}

.login-logo {
  display: block;
  margin: 0 auto;
  max-width: min(300px, 80vw);
  width: 100%;
  height: auto;
}

.login-number {
  display: block;
  margin: 0.15rem auto 0;
  width: 1em;
  font-size: clamp(4rem, 25vw, 8rem);
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Auth screens (Set PIN, Login) — reuse login layout */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: var(--login-bg);
  color: var(--login-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-inner {
  width: 100%;
  max-width: min(320px, 92vw);
  padding: clamp(1.25rem, 5vw, 2rem);
  border-radius: var(--login-card-radius);
  box-shadow: var(--login-card-shadow);
  background: var(--login-bg);
  margin: auto;
}

.auth-brand {
  text-align: center;
  margin-bottom: 1rem;
}

.auth-company {
  font-size: calc(1.25 * var(--splash-title-size));
  font-weight: 700;
  letter-spacing: 0.15em;
  margin: 0 0 0.75rem 0;
  text-transform: uppercase;
  color: var(--primary);
}

.auth-logo {
  display: block;
  margin: 0 auto;
  max-width: min(300px, 80vw);
  width: 100%;
  height: auto;
}

.auth-title {
  font-size: var(--login-title-size);
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

.auth-desc {
  font-size: 0.9375rem;
  margin: 0 0 1.25rem 0;
  opacity: 0.9;
  line-height: 1.4;
}

.auth-error {
  color: var(--error);
  font-size: 0.875rem;
  margin: 0 0 0.75rem 0;
}

.auth-error.hidden {
  display: none;
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
}

/* Settings screen */
.settings-block {
  margin-bottom: 2rem;
}

.settings-subtitle {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background: rgba(46, 125, 50, 0.08);
}

.app {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.app.hidden {
  display: none;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--header-bg);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-logo {
  height: 52px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.app-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
}

.menu-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 2.25rem;
  padding: 12px;
  min-width: 52px;
  min-height: 52px;
  cursor: pointer;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.header-lang-toggle {
  margin: 0 0 0 auto;
  display: inline-flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--primary);
  background: transparent;
}

.header-lang-toggle .lang-option {
  padding: 6px 14px;
  min-height: 36px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  border-radius: 0;
}

.header-lang-toggle .lang-option:hover {
  background: rgba(46, 125, 50, 0.1);
}

.header-lang-toggle .lang-option.active {
  background: var(--primary);
  color: var(--on-primary);
}

.header-lang-toggle .lang-option:first-child {
  border-right: 1px solid var(--primary);
}

/* Drawer */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  max-width: 85vw;
  height: 100vh;
  background: transparent;
  z-index: 20;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-surface {
  width: 100%;
  height: 100%;
  background: var(--drawer-bg);
  color: var(--drawer-text);
  padding: 24px;
  box-shadow: 4px 0 12px rgba(0,0,0,0.15);
}

.drawer-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 16px 0;
  text-transform: uppercase;
}

.drawer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.drawer-list li {
  margin: 0;
}

.drawer-link {
  display: block;
  padding: 14px 0;
  min-height: 44px;
  color: var(--drawer-text);
  text-decoration: none;
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.drawer-link:hover {
  text-decoration: underline;
}

.lang-toggle {
  margin-top: 24px;
  font-size: 0.875rem;
}

.lang-toggle button {
  margin-right: 8px;
  padding: 10px 14px;
  min-height: 44px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.lang-toggle button:hover {
  background: #bbb;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Main content */
.main {
  flex: 1;
  padding: 20px;
}

.screen {
  display: block;
}

.screen.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.fuel-price-display-row,
.fuel-price-edit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.fuel-price-display-row .fuel-price-value {
  flex: 1;
  min-width: 0;
  font-size: 1.75rem;
  font-weight: 700;
  padding: 12px 0;
}

.fuel-price-display-row .btn {
  flex: 0 0 auto;
  width: auto;
}

.fuel-price-edit-row input {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
}

.fuel-price-edit-row .btn {
  flex: 0 0 auto;
  width: auto;
}

.input-dollar-wrap {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.input-dollar-wrap:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.input-dollar-prefix {
  padding: 0 10px 0 14px;
  font-size: 1rem;
  font-weight: 600;
  color: #333;
}

.input-dollar-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 12px 14px 12px 0;
  font-size: 1.75rem;
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
}

/* All dollar amount inputs: same size/weight across the app */
.amount-input-wrap input,
.amount-input-wrap .input-dollar-prefix {
  font-size: 1.75rem;
  font-weight: 700;
}

#screen-vehicle .form-group input {
  font-size: 1.75rem;
  font-weight: 700;
}

.input-dollar-wrap input:focus {
  outline: none;
}

.btn-small {
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.9rem;
}

.btn-icon {
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon .fuel-tx-icon {
  display: block;
  flex-shrink: 0;
}

.screen-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin: 0 0 24px 0;
  text-transform: uppercase;
}

.screen-subtitle {
  font-size: 0.875rem;
  margin: -8px 0 24px 0;
  color: #555;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.form-group .form-note {
  font-size: 0.8125rem;
  margin: 6px 0 0 0;
  color: #666;
}

.form-group .input-dollar-wrap {
  width: 100%;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  min-height: 48px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.form-group input[type="number"]::-webkit-outer-spin-button,
.form-group input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-group input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

@media (max-width: 480px) {
  .main {
    padding: clamp(12px, 4vw, 20px);
  }

  .screen-title {
    font-size: 1.25rem;
  }

  .cost-per-km-value {
    font-size: 1.5rem;
  }

  .summary-value {
    font-size: 1.25rem;
  }

  .drawer-surface {
    padding: max(20px, env(safe-area-inset-left));
  }

  .header {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  /* Stack fuel price edit row so input and button are full width */
  .fuel-price-display-row,
  .fuel-price-edit-row {
    flex-wrap: wrap;
  }

  .fuel-price-edit-row .input-dollar-wrap {
    flex: 1 1 100%;
    min-width: 0;
  }

  .fuel-price-edit-row .btn {
    flex: 1 1 100%;
    width: 100%;
  }

  /* Slightly smaller amount inputs on small screens to avoid overflow */
  .amount-input-wrap input,
  .amount-input-wrap .input-dollar-prefix {
    font-size: 1.5rem;
  }

  #screen-vehicle .form-group input {
    font-size: 1.5rem;
  }
}

.btn {
  padding: 14px 20px;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn.btn-secondary {
  border: 2px solid var(--primary);
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.saved-msg {
  font-size: 0.875rem;
  margin: 8px 0 0 0;
  color: var(--primary);
}

/* Fuel: cost per km block */
.cost-per-km-block {
  margin-top: 32px;
  padding-top: 16px;
}

.cost-per-km-label {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.cost-per-km-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
}

/* One-time: total and list */
.total-line {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 24px 0 12px 0;
}

.expense-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
}

.expense-list li {
  padding: 4px 0;
  border-bottom: 1px solid #eee;
}

.fuel-tx-item {
  padding: 8px 0;
}

.fuel-tx-view,
.fuel-tx-edit {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.fuel-tx-view .fuel-tx-view-text {
  flex: 1 1 auto;
  min-width: 0;
}

.fuel-tx-view .btn,
.fuel-tx-edit .btn {
  flex: 0 0 auto;
  width: auto;
}

.fuel-tx-edit .fuel-tx-edit-time {
  flex: 0 0 auto;
  font-size: 0.875rem;
}

.fuel-tx-edit .fuel-tx-edit-input {
  flex: 1 1 0;
  min-width: 80px;
}

.fuel-tx-edit .input-dollar-wrap input {
  font-size: 1rem;
  font-weight: 600;
}

.onetime-tx-item,
.annual-tx-item,
.ride-tx-item {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.onetime-tx-edit .onetime-edit-note {
  flex: 1 1 100%;
  min-width: 0;
  padding: 8px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Rides list */
.ride-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  font-size: 1rem;
}

.ride-list li {
  padding: 4px 0;
}

/* Summary */
.summary-label {
  font-size: 1rem;
  margin: 0 0 4px 0;
}

.summary-desc {
  font-size: 0.9375rem;
  color: #555;
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 24px 0;
}

.summary-hero-label {
  font-size: 1.125rem;
  margin: 0 0 6px 0;
}

.summary-hero-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 28px 0;
}

.indicator {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 32px 0 0 0;
}

.indicator.profitable {
  color: var(--primary);
}

.indicator.losing {
  color: var(--error);
}

.indicator.warning {
  color: #b8860b;
}

/* Fuel: "Use different price" link */
.fuel-different-price-wrap {
  margin: 8px 0 0 0;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  color: #666;
  text-decoration: underline;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.link-btn:hover {
  color: var(--primary);
}

/* Vehicle locked view */
.vehicle-locked-note {
  font-size: 0.9375rem;
  color: #666;
  margin: 0 0 16px 0;
}

.vehicle-locked-fields {
  margin-bottom: 20px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.vehicle-locked-row {
  margin: 0 0 10px 0;
  font-size: 1rem;
}

.vehicle-locked-row:last-child {
  margin-bottom: 0;
}

.vehicle-locked-label {
  display: block;
  font-size: 0.8125rem;
  color: #666;
  margin-bottom: 2px;
}

.vehicle-locked-value {
  font-weight: 600;
  color: var(--on-surface);
}

/* Help screen */
.help-content {
  font-size: 1rem;
  line-height: 1.5;
}

.help-intro {
  margin: 0 0 24px 0;
  color: #555;
}

.help-section {
  margin-bottom: 24px;
}

.help-section-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 8px 0;
  text-transform: uppercase;
  color: var(--primary);
}

.help-section-desc {
  margin: 0 0 8px 0;
  color: #555;
  font-size: 0.9375rem;
}

.help-fields {
  margin: 0 0 8px 0;
  padding-left: 1.25rem;
  font-size: 0.9375rem;
}

.help-fields li {
  margin-bottom: 6px;
}
