/* === RESET & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0f1729;
  --bg-secondary: #1a2342;
  --bg-card: #1e2a4a;
  --bg-input: #162040;
  --text-primary: #e8edf5;
  --text-secondary: #8b9bc0;
  --text-muted: #5a6a8a;
  --accent: #4a9eff;
  --accent-hover: #6ab4ff;
  --accent-glow: rgba(74, 158, 255, 0.25);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --border: #2a3a5c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --nav-height: 72px;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + 24px);
  overflow-x: hidden;
}

/* === NAVIGATION === */
#nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
  backdrop-filter: blur(12px);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 8px 6px;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-width: 56px;
}

.nav-btn .nav-icon {
  font-size: 24px;
  line-height: 1;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-btn:active {
  transform: scale(0.95);
}

/* === VIEWS === */
.view {
  display: none;
  padding: 20px 16px;
  max-width: 600px;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === HEADER === */
.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* === BARREL CARD === */
.barrel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.barrel-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.barrel-numbers {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-bottom: 16px;
}

.barrel-big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.barrel-sep {
  font-size: 1.5rem;
  color: var(--text-muted);
  margin: 0 4px;
}

.barrel-small {
  font-size: 1.5rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.barrel-unit {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-left: 4px;
}

/* === PROGRESS BAR === */
.progress-bar {
  height: 12px;
  background: var(--bg-input);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6dd5fa);
  border-radius: 6px;
  transition: width 0.6s ease;
  min-width: 2%;
}

.progress-fill.low {
  background: linear-gradient(90deg, var(--warning), var(--danger));
}

.barrel-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.barrel-meta strong {
  color: var(--text-primary);
}

/* === SECTIONS === */
.section {
  margin-bottom: 20px;
}

.section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

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

/* === REFUEL LIST === */
.refuel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.refuel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.refuel-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
  font-size: 1rem;
  flex-shrink: 0;
}

.refuel-info {
  flex: 1;
  min-width: 0;
}

.refuel-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.refuel-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

.refuel-note {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-style: italic;
}

.refuel-amount {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 0.9rem;
}

/* === DRIVER GRID === */
.driver-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.driver-btn {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 14px 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-btn:active {
  transform: scale(0.96);
}

.driver-btn.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* === MODE TOGGLE === */
.mode-toggle {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
}

.mode-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(74, 158, 255, 0.3);
}

/* === FIELD LABEL === */
.field-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
}

/* === INPUTS === */
.input-large {
  width: 100%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 700;
  padding: 16px 20px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  font-variant-numeric: tabular-nums;
}

.input-large:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.input-normal {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
}

.input-normal:focus {
  border-color: var(--accent);
}

input::placeholder {
  color: var(--text-muted);
}

/* Chrome/Safari number input spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

/* === PREVIEW BLOCK === */
.preview-block {
  background: var(--success-bg);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 16px;
  animation: slideDown 0.2s ease;
}

.preview-block strong {
  font-size: 1.3rem;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === WARNING === */
.warning-block {
  background: var(--warning-bg);
  border: 2px solid var(--warning);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--warning);
  font-weight: 600;
  margin-bottom: 16px;
}

/* === BUTTONS === */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  padding: 16px 32px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  letter-spacing: 0.02em;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-large {
  padding: 18px;
  font-size: 1.1rem;
  min-height: 56px;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  padding: 16px 32px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

.btn-danger-sm {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-danger-sm:hover {
  background: var(--danger-bg);
}

/* === SETTLEMENT === */
.settlement-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.settlement-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.settlement-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.settlement-rank.top {
  background: var(--accent-glow);
  color: var(--accent);
}

.settlement-name {
  flex: 1;
  font-weight: 600;
}

.settlement-liters {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-right: 8px;
}

.settlement-cost {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

/* === DRIVERS MANAGE === */
.add-driver-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.add-driver-row .input-normal {
  flex: 1;
}

.add-driver-row .btn-primary {
  width: auto;
  white-space: nowrap;
  padding: 12px 20px;
}

.drivers-manage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.driver-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.driver-manage-item span {
  font-weight: 500;
}

/* === REFUEL HISTORY === */
.refuel-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
}

.refuel-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.refuel-history-item .rh-info {
  flex: 1;
  min-width: 0;
}

.refuel-history-item .rh-driver {
  font-weight: 600;
}

.refuel-history-item .rh-amount {
  color: var(--accent);
  font-weight: 700;
  margin: 0 8px;
  flex-shrink: 0;
}

.refuel-history-item .rh-time {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* === TOAST === */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 200;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

/* === LANG TOGGLE === */
.lang-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 150;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.lang-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.lang-toggle:active {
  transform: scale(0.95);
}

/* === DAY BADGE === */
.day-badge {
  display: inline-block;
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 20px;
  margin-top: 8px;
  border: 1px solid var(--accent);
}

.day-badge.done {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}

/* === PIN LOCK === */
.settings-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: 40px 20px;
  text-align: center;
}

.lock-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.settings-lock h2 {
  color: var(--text-secondary);
  font-size: 1.2rem;
  margin-bottom: 24px;
}

.pin-input {
  max-width: 240px;
  letter-spacing: 0.5em;
  text-align: center;
  font-size: 1.8rem !important;
}

.pin-error {
  color: var(--danger);
  font-weight: 600;
  margin-top: 12px;
  font-size: 0.9rem;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* === CLOSE DAY === */
.close-day-info {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.close-day-btn {
  background: var(--warning) !important;
  color: #000 !important;
  font-weight: 700;
}

.close-day-btn:hover {
  background: #e8900a !important;
}

.close-day-final-info {
  color: var(--warning);
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.event-completed-msg {
  color: var(--success);
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  padding: 20px;
  background: var(--success-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--success);
}

/* === ARCHIVE === */
.archive-day-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.archive-day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.archive-day-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}

.archive-day-date {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.archive-day-stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.archive-day-stats strong {
  color: var(--text-primary);
}

.archive-day-cost {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding: 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.archive-day-cost strong {
  color: var(--accent);
  font-size: 1.1rem;
}

/* === HIDDEN === */
.hidden {
  display: none !important;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* === RESPONSIVE === */
@media (min-width: 480px) {
  .driver-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 600px) {
  .view {
    padding: 32px 24px;
  }
}
