/* Design Tokens - Monochrome Graphite & Charcoal */
:root {
  --bg-base: #0a0a0c;
  --bg-surface: #141417;
  --bg-input: #1b1b1f;
  --bg-input-hover: #222227;
  
  --border-light: #26262b;
  --border-focus: #4b4b54;
  
  --text-main: #f4f4f7;
  --text-muted: #8e8e9b;
  --text-dim: #5c5c66;
  
  --accent-white: #ffffff;
  --accent-gray: #c7c7cc;
  --accent-dark: #2c2c35;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.7);
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 24px 16px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-focus);
}

/* Layout Container */
.app-container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.brand-icon[role="button"] {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.brand-icon[role="button"]:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

/* Section/Card Styles */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

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

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  padding: 12px;
  outline: none;
  transition: var(--transition);
}

input:hover, textarea:hover, select:hover {
  background-color: var(--bg-input-hover);
  border-color: var(--border-focus);
}

input:focus, textarea:focus, select:focus {
  background-color: var(--bg-input-hover);
  border-color: var(--accent-white);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.btn-primary {
  background-color: var(--text-main);
  color: var(--bg-base);
  width: 100%;
}

.btn-primary:hover {
  background-color: var(--accent-white);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background-color: var(--bg-input-hover);
  border-color: var(--border-focus);
}

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

.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

.btn-icon-only {
  padding: 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-icon-only:hover {
  color: var(--text-main);
  background-color: var(--bg-input);
  border-color: var(--border-light);
}

/* Stats Widget */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.stat-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* History List / Table Replacement */
.history-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-input);
}

.history-item {
  border-bottom: 1px solid var(--border-light);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background-color: var(--bg-input-hover);
}

.history-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  width: 100%;
}

.history-col-date {
  font-weight: 600;
  color: var(--text-main);
  min-width: 70px;
  flex-shrink: 0;
}

.history-col-route {
  color: var(--text-muted);
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-col-time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 95px;
  text-align: center;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 2px 6px;
  border-radius: 4px;
}

.history-col-km {
  font-weight: 700;
  color: var(--text-main);
  min-width: 65px;
  text-align: right;
  flex-shrink: 0;
}

.history-col-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Info Icon Button */
.btn-info {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
  width: 24px;
  height: 24px;
}

.btn-info:hover {
  color: var(--text-main);
  background-color: var(--border-light);
}

.history-item.expanded .btn-info {
  color: var(--accent-white);
  background-color: var(--border-focus);
}

/* Collapsible Details Panel */
.history-details {
  max-height: 0;
  overflow: hidden;
  transition: all 0.2s ease-out;
  opacity: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.history-item.expanded .history-details {
  max-height: 50px;
  opacity: 1;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px dashed var(--border-light);
}

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

.history-detail-mileage span {
  font-weight: 600;
  color: var(--text-main);
}

.history-detail-actions {
  display: flex;
  gap: 6px;
}


/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--text-main);
  color: var(--bg-base);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* Modal Window */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 16px;
}

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

.modal {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  transform: translateY(20px);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-main);
}

.modal-body {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* File input hidden style */
#importFile {
  display: none;
}

/* Helper / Utility Utility */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

/* Responsive Utilities */
@media(max-width: 480px) {
  body {
    padding: 16px 12px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .btn-group {
    flex-direction: column;
  }
}

/* Three-column form row layout */
.form-row-three {
  grid-template-columns: 1.2fr 0.9fr 0.9fr;
}

/* Fuel icon button inside card title */
.btn-fuel {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}

.btn-fuel:hover {
  background-color: var(--bg-input-hover);
  border-color: var(--border-focus);
  color: var(--text-main);
}

.btn-fuel.active {
  background-color: var(--text-main);
  color: var(--bg-base);
  border-color: var(--text-main);
}

/* Two-column stats layout */
.stats-grid-two {
  grid-template-columns: 1fr 1fr;
}

/* Fuel badge in shift list row */
.fuel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  vertical-align: middle;
  margin-left: 6px;
  opacity: 0.8;
}

.fuel-badge svg {
  vertical-align: middle;
}
