/* ============================================================
   CarMaint Web App Styles
   ============================================================ */

:root {
  --color-bg: #0F1B26;
  --color-primary: #031B26;
  --color-secondary: #0A2A3A;
  --color-surface: #1A2B35;
  --color-border: #2A3A45;
  --color-text: #EFEFEF;
  --color-text-muted: #A8B8C8;
  --color-accent: #00C2FF;
  --color-danger: #FF5252;
  --color-ok: #4CAF50;
  --color-warn: #FF9800;
  --color-gray: #404040;
  --radius: 12px;
  --radius-sm: 8px;
  --spacing: 16px;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================================
   Messages / Flash
   ============================================================ */
.messages-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: calc(100% - 32px);
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity 0.4s ease;
}

.message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.message-success { border-color: var(--color-ok); }
.message-error { border-color: var(--color-danger); }
.message-warning { border-color: var(--color-warn); }
.message-info { border-color: var(--color-accent); }

.message-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Auth Layout
   ============================================================ */
.auth-outer {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--color-bg);
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.auth-app-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
}

.auth-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  background: var(--color-secondary);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.auth-tab.active {
  background: var(--color-surface);
  color: var(--color-text);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ============================================================
   App Layout
   ============================================================ */

/* safe-area-top spacer */
.safe-area-top {
  height: env(safe-area-inset-top, 0px);
  background: #0F1B26;
}

.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-content {
  flex: 1;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 16px);
}

/* ============================================================
   Bottom Tab Bar
   ============================================================ */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  background: rgba(3, 12, 20, 0.88);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: flex-start;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding-top: 10px;
  color: rgba(168, 184, 200, 0.7);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  min-height: 64px;
  transition: color 0.2s;
  position: relative;
}

.tab-item:hover { text-decoration: none; }

.tab-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 32px;
  border-radius: 12px;
  transition: background 0.2s, transform 0.15s;
}

.tab-item.active {
  color: #00C2FF;
}

.tab-item.active .tab-icon-wrap {
  background: rgba(0, 194, 255, 0.12);
  transform: translateY(-1px);
}

.tab-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 3px;
  background: #00C2FF;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 0 8px rgba(0, 194, 255, 0.6);
}

.tab-item ion-icon {
  display: block;
}

/* ============================================================
   Page Layout
   ============================================================ */
.page-wrap {
  padding: 16px 16px 24px;
  max-width: 600px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  min-height: 44px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  flex-shrink: 0;
}

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

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  height: 52px;
  background: var(--color-secondary);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 16px;
  padding: 0 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

textarea.form-input {
  height: auto;
  min-height: 80px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.5;
}

.form-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 194, 255, 0.15);
}

.form-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.form-error {
  font-size: 13px;
  color: var(--color-danger);
  margin-top: 4px;
}

.form-hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.form-optional {
  font-weight: 400;
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.required {
  color: var(--color-danger);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.form-messages {
  margin-bottom: 16px;
}

.form-message {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 8px;
}

.form-message-success { background: rgba(76, 175, 80, 0.15); border: 1px solid var(--color-ok); color: var(--color-ok); }
.form-message-error { background: rgba(255, 82, 82, 0.15); border: 1px solid var(--color-danger); color: var(--color-danger); }
.form-message-warning { background: rgba(255, 152, 0, 0.15); border: 1px solid var(--color-warn); color: var(--color-warn); }

.form-section {
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

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

.form-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

/* Password input wrapper */
.input-pw-wrap {
  position: relative;
}

.input-pw-wrap .form-input {
  padding-right: 52px;
}

.pw-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  opacity: 0.5;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
}

.pw-toggle:hover { opacity: 0.8; }

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text-muted);
  cursor: pointer;
  min-height: 44px;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* Char counter */
.char-counter {
  text-align: right;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Already done toggle */
.already-done-section {
  margin-bottom: 16px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 15px;
  color: var(--color-text);
}

.toggle-label input[type="checkbox"] {
  display: none;
}

.toggle-switch {
  width: 48px;
  height: 28px;
  background: var(--color-gray);
  border-radius: 14px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}

.toggle-label input:checked + .toggle-switch {
  background: var(--color-accent);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(20px);
}

/* Link subtle */
.link-subtle {
  font-size: 14px;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.link-subtle:hover {
  color: var(--color-accent);
  text-decoration: none;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  min-width: 44px;
  white-space: nowrap;
  line-height: 1;
}

.btn:active { transform: scale(0.97); }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--color-accent);
  color: #001A26;
}

.btn-primary:hover { opacity: 0.9; }

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-danger:hover { opacity: 0.9; }

.btn-ghost {
  background: var(--color-secondary);
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
}

.btn-ghost:hover { border-color: var(--color-accent); }

.btn-full {
  width: 100%;
  display: flex;
}

.btn-small {
  height: 36px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn-tiny {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-secondary);
  color: var(--color-text-muted);
  cursor: pointer;
  text-decoration: none;
}

.btn-icon:hover { color: var(--color-text); text-decoration: none; }

.btn-icon-danger { color: var(--color-danger); }

.btn-icon-tiny {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-secondary);
  color: var(--color-text-muted);
  cursor: pointer;
  text-decoration: none;
  font-size: 11px;
}

.btn-icon-tiny-danger {
  color: var(--color-danger);
  border-color: rgba(255, 82, 82, 0.3);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.card-highlight {
  border-color: var(--color-warn);
  background: rgba(255, 152, 0, 0.08);
}

.card-icon-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.card-text {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* Info rows */
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: 14px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.info-value {
  font-size: 14px;
  color: var(--color-text);
  text-align: right;
  word-break: break-all;
}

/* Settings rows */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  text-decoration: none;
  min-height: 52px;
}

.settings-row:last-child { border-bottom: none; }
.settings-row:hover { color: var(--color-accent); }

.settings-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================================
   Status Badges
   ============================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
}

.badge-danger {
  background: rgba(255, 82, 82, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(255, 82, 82, 0.3);
}

.badge-warn {
  background: rgba(255, 152, 0, 0.15);
  color: var(--color-warn);
  border: 1px solid rgba(255, 152, 0, 0.3);
}

.badge-ok {
  background: rgba(76, 175, 80, 0.15);
  color: var(--color-ok);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

/* ============================================================
   Car Carousel
   ============================================================ */
.car-carousel-section {
  padding: 16px 0 8px;
}

.car-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 16px 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.car-carousel::-webkit-scrollbar { display: none; }

.car-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  scroll-snap-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s;
}

.car-avatar:hover { text-decoration: none; }
.car-avatar[draggable="true"] { cursor: grab; }
.car-avatar[draggable="true"]:active { cursor: grabbing; }

.car-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--color-secondary);
  border: 2px solid var(--color-border);
}

.car-circle-add {
  border: 2.5px dashed var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
}

.car-avatar-add .car-circle-add:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.car-label {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.car-avatar-selected .car-label {
  color: var(--color-accent);
  font-weight: 600;
}

/* ============================================================
   Car Detail Card
   ============================================================ */
.car-detail-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin: 0 16px 16px;
  overflow: hidden;
}

.car-detail-stripe {
  height: 3px;
  background: var(--car-color, var(--color-accent));
}

.car-detail-inner {
  padding: 14px 16px 16px;
}

.car-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.car-detail-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.car-detail-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 3px;
}

.car-detail-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Two-column stat block */
.car-detail-stats {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-top: 1px solid var(--color-border);
  margin-top: 14px;
  padding-top: 14px;
}

.car-stat-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

@media (min-width: 768px) {
  .car-stat-col {
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
  }
  .car-stat-label {
    font-size: 16px !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    color: var(--color-text-muted) !important;
    font-weight: 700 !important;
  }
  .car-stat-value {
    font-size: 32px;
    font-weight: 800;
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: var(--color-text);
  }
  .car-stat-unit {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: lowercase;
  }
  .car-stat-action {
    margin-top: 0 !important;
    margin-left: auto;
    background-color: #007AFF !important;
    color: white !important;
    padding: 8px 20px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    align-self: center;
  }
}

.car-stat-divider {
  width: 1px;
  background: var(--color-border);
  margin: 0 16px;
  flex-shrink: 0;
}

.car-stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.car-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.car-stat-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.car-stat-action {
  margin-top: 8px;
  align-self: flex-start;
}

/* Health status */
.car-health {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.2;
}

.car-health-ok   { color: var(--color-ok); }
.car-health-warn { color: var(--color-warn); }
.car-health-danger { color: var(--color-danger); }

/* Car info card (small, in forms) */
.car-info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.car-info-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.car-info-km {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ============================================================
   Maintenance Section
   ============================================================ */
.maintenance-section {
  padding: 0 16px 24px;
}

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

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
}

.section-actions {
  display: flex;
  gap: 8px;
}

/* ============================================================
   Task Cards
   ============================================================ */
.task-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.task-card-overdue {
  border-color: rgba(255, 82, 82, 0.4);
}

.task-card-due_soon {
  border-color: rgba(255, 152, 0, 0.4);
}

.task-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px 12px;
  cursor: pointer;
  gap: 12px;
}

.task-card-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.task-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.dot-overdue { background: var(--color-danger); }
.dot-due_soon { background: var(--color-warn); }
.dot-ok { background: var(--color-ok); }

.task-card-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.task-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}


.task-meta {
  display: flex;
  align-items: center;
  gap: 5px;
}

.task-interval {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.task-meta-sep {
  color: var(--color-border);
  font-size: 11px;
  line-height: 1;
}

.task-last-date {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-accent);
}

.task-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 1px;
}

.task-chevron {
  color: var(--color-text-muted);
  transition: transform 0.25s ease;
  transform: rotate(-90deg);
}

/* Progress bar */
.task-progress-wrap {
  padding: 0 16px 16px;
}

.task-progress-bar {
  height: 8px;
  background: var(--color-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
  position: relative;
  border: 1px solid var(--color-border);
}

.task-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 4px;
  box-shadow: 0 0 10px rgba(0,0,0,0.2);
}

.progress-ok { 
  background: linear-gradient(90deg, var(--color-ok), #81C784); 
}
.progress-due_soon { 
  background: linear-gradient(90deg, var(--color-warn), #FFB74D); 
}
.progress-overdue { 
  background: linear-gradient(90deg, var(--color-danger), #EF5350); 
}

.task-progress-labels {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-size: 11px;
  font-weight: 400;
}

.task-label-left {
  color: var(--color-text-muted);
  text-align: left;
}

.task-label-middle {
  color: var(--color-text);
  text-align: center;
  background: var(--color-secondary);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
}

.task-label-right {
  color: var(--color-text-muted);
  text-align: right;
}


/* Expand animation */
@keyframes expandDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Expanded content */
.task-card-expanded {
  border-top: 1px solid var(--color-border);
  padding: 14px 16px;
}

.task-card-expanded.is-opening {
  animation: expandDown 0.2s ease forwards;
}

.task-section-body.is-opening {
  animation: expandDown 0.18s ease forwards;
}

.task-action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.task-action-row .btn {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
}

.task-details-text {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.task-section {
  margin-bottom: 8px;
}

.task-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  min-height: 44px;
}

.section-chevron {
  transition: transform 0.25s ease;
  transform: rotate(-90deg);
  flex-shrink: 0;
}

.task-section-toggle-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-section-body {
  padding: 10px 0;
}

/* ============================================================
   Parts Table
   ============================================================ */
/* ============================================================
   Parts Cards
   ============================================================ */
.parts-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.part-card {
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Shared label/value/sep tokens used in parts and history */
.pf-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.pf-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--color-text);
  white-space: nowrap;
  flex-shrink: 0;
}

.pf-sep {
  color: var(--color-border);
  font-size: 14px;
  flex-shrink: 0;
  padding: 0 2px;
  user-select: none;
}

.pf-name  { font-weight: 600; }
.pf-code  { font-family: monospace; font-size: 12px; }
.pf-price { font-weight: 600; color: var(--color-ok); }

.pf-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
  padding-left: 8px;
  margin-top: 2px;
}

/* Part card grid layout */
.part-info-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.part-field {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.part-field:last-child {
  border-bottom: none;
}

.part-field .pf-label {
  font-size: 11px;
  opacity: 0.7;
  width: 70px; /* Fixed width for label to create table-like alignment */
  flex-shrink: 0;
}

.part-field .pf-value {
  font-size: 14px;
  white-space: normal; /* Allow wrapping for long links/notes */
  word-break: break-all;
}

.part-card-code {
  font-family: monospace;
  font-size: 12px;
  color: var(--color-text-muted);
}

.part-card-link {
  font-size: 12px;
  color: var(--color-accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.part-card-link:hover { text-decoration: underline; }

.part-card-note {
  font-size: 12px;
  color: var(--color-text-muted);
}

.part-card-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ok);
}

.part-card-qty {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ============================================================
   Inline List — shared by Parts and History
   ============================================================ */
.inline-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.inline-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-top: 1px solid var(--color-border);
  min-height: 38px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.inline-row:first-child { border-top: none; }

.inline-row-expandable {
  cursor: pointer;
  user-select: none;
}

.inline-row-expandable:hover { background: rgba(255,255,255,0.02); }

/* Name — takes remaining space, truncates */
.il-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* KM — bold, fixed */
.il-km {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Code chip with copy/search */
.il-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 1px 2px 1px 7px;
  flex-shrink: 0;
}

.il-chip-text {
  font-size: 11px;
  font-family: monospace;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.il-chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 3px;
  padding: 0;
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.il-chip-btn:hover { color: var(--color-accent); text-decoration: none; }

/* Small muted tag (date, qty) */
.il-tag {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Service badge */
.il-service {
  font-size: 11px;
  color: var(--color-accent);
  background: rgba(0,194,255,0.08);
  border: 1px solid rgba(0,194,255,0.18);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Price */
.il-price {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-ok);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Link icon */
.il-link {
  display: inline-flex;
  align-items: center;
  color: var(--color-accent);
  font-size: 14px;
  flex-shrink: 0;
  text-decoration: none;
}

.il-link:hover { color: var(--color-accent); }

/* Note icon */
.il-note {
  display: inline-flex;
  align-items: center;
  color: var(--color-text-muted);
  font-size: 14px;
  flex-shrink: 0;
}

/* Push actions to the right */
.il-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

/* History expandable detail */
.history-detail {
  padding: 6px 10px 8px 10px;
  border-top: 1px dashed var(--color-border);
  background: rgba(255,255,255,0.015);
}

.history-notes {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
  border-left: 2px solid var(--color-border);
  padding-left: 8px;
  margin-bottom: 4px;
}

.history-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.history-file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--color-accent);
  padding: 2px 8px;
  background: rgba(0,194,255,0.08);
  border-radius: 4px;
  border: 1px solid rgba(0,194,255,0.2);
  text-decoration: none;
}

.history-file-link:hover { text-decoration: none; opacity: .85; }

/* Item rows (in task form) */
.item-row {
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
}

.item-fields {
  display: grid;
  grid-template-columns: 0.8fr 2fr 0.5fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.item-input {
  height: 40px;
  font-size: 14px;
  padding: 0 10px;
  border-radius: 8px;
}

.item-notes {
  height: 36px;
  width: 100%;
  background: var(--color-secondary);
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 14px;
  padding: 0 10px;
  outline: none;
  margin-bottom: 8px;
}

.item-notes:focus { border-color: var(--color-accent); }

.btn-remove-item {
  background: rgba(255, 82, 82, 0.1);
  border: 1px solid rgba(255, 82, 82, 0.3);
  color: var(--color-danger);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

/* ============================================================
   History Items
   ============================================================ */
.no-history {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 8px 0;
}

/* ============================================================
   Color Picker
   ============================================================ */
.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, outline 0.15s;
  min-width: 40px;
}

.color-swatch:hover { transform: scale(1.1); }

.color-swatch-more {
  background: var(--color-secondary);
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

.color-grid {
  margin-top: 12px;
}

.color-preview {
  transition: background-color 0.2s;
}

/* ============================================================
   File Upload
   ============================================================ */
.file-drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
  border-color: var(--color-accent);
  background: rgba(0, 194, 255, 0.05);
}

.file-drop-zone p {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
  margin: 0;
}

.file-drop-hint {
  font-size: 12px;
  color: var(--color-text-muted);
}

.file-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-text);
}

.file-existing-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--color-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.file-existing-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--color-accent);
}

/* ============================================================
   Info Card
   ============================================================ */
.info-card {
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.info-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.info-card-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
}

.info-card-detail {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.info-card-meta {
  font-size: 13px;
  color: var(--color-accent);
  margin-top: 4px;
}

/* ============================================================
   Profile
   ============================================================ */
.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 16px;
  gap: 8px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-secondary);
  border: 2px solid var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar-letter {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-accent);
}

.profile-username {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}

.profile-type-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 20px;
}

/* ============================================================
   KM Diff display
   ============================================================ */
.km-diff-display {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  padding: 8px 0 16px;
  min-height: 36px;
}

/* ============================================================
   Empty States
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  margin: 0 auto 16px;
  opacity: 0.4;
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.empty-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* ============================================================
   Dashboard wrap
   ============================================================ */
.dashboard-wrap {
  padding-bottom: 16px;
}

/* ============================================================
   Code input (password reset)
   ============================================================ */
.code-input {
  letter-spacing: 6px;
  font-size: 24px !important;
  text-align: center;
  font-weight: 700;
}

/* ============================================================
   Responsive / Mobile polish
   ============================================================ */
@media (max-width: 380px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .item-fields {
    grid-template-columns: 1fr 1fr;
  }

  .car-carousel {
    gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (min-width: 600px) {
  .car-stat-col:first-child {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0 10px;
  }

  .car-stat-col:first-child .car-stat-label {
    font-size: 11px;
    white-space: nowrap;
  }

  .car-stat-col:first-child .car-stat-label::after {
    content: ':';
  }

  .car-stat-col:first-child .car-stat-value {
    font-size: 18px;
    letter-spacing: -0.3px;
    white-space: nowrap;
  }

  .car-stat-col:first-child .car-stat-action {
    margin-top: 0;
    margin-left: 2px;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
