:root {
  /* ================= DESIGN TOKENS ================= */
  --bg: #0f172a;
  --card: #1e293b;
  --text: #fff;
  --accent: #22c55e;

  --surface-dark: #020617;
  --surface-light: #e2e8f0;

  --border: rgba(255,255,255,0.12);
  --border-light: rgba(0,0,0,0.15);

  --shadow: 0 1px 3px #f7f5f585;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --gap-sm: 8px;
  --gap-md: 12px;
  --gap-lg: 20px;
}

/* ================= LIGHT THEME ================= */

.light {
  --bg: #f1f5f9;
  --card: #fff;
  --text: #111;

  --surface-dark: #e2e8f0;
  --surface-light: #ffffff;

  --border: rgba(0,0,0,0.15);
  --shadow: 0 1px 3px #000;
}

/* ================= BASE ================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: system-ui;
  background: var(--bg);
  color: var(--text);
}

/* ================= HEADER ================= */

header {
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  background: var(--surface-dark);
  color: var(--text);
}

header div {
  font-weight: 500;
  font-size: 1.3rem;
  color: #abcdef;
}

header button {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    margin-right: 0.9rem;
    padding: .5rem;
    cursor: pointer;
}

.light header div {
  color: #00f;
}

/* ================= TABS ================= */

.tabs {
  display: flex;
  justify-content: space-around;
  background: var(--surface-dark);
  color: var(--text);
  font-weight: 500;
}

.tab {
  padding: 8px 80px 13px;
  opacity: 0.6;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: inherit;
}

.tab.active {
  opacity: 1;
  background: var(--bg);
}

.light .tab {
  background: #d1d4d6;
  color: #000;
}

.light .tab.active {
  background: #f1f5f9;
}

/* ================= GRID ================= */

.viewport {
  height: calc(100% - 100px);
}

.pages {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.page {
  min-width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 12px;
  padding: 12px;
  scroll-snap-align: start;
}

/* ================= CARD ================= */

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  text-align: center;
  box-shadow: var(--shadow);
}

.icon {
  font-size: 4rem;
  margin: 1.25rem 0;
}

.value {
  font-size: 1.25rem;
  padding: 13px 25px 15px;
  border-radius: 25px;
  border: 3px solid #f00;
  margin: 10px 0;
}

.name {
  font-size: 1.75rem;
  font-weight: 600;
}

.chart-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 2.2rem;
  padding: 10px;
}

/* ================= FAB ================= */

.fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 30px;
  font-weight: 700;
  text-shadow: 1px 2px 2px #000;
}

.admin-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 60px;
  height: 60px;
  background: #444;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 30px;
  font-weight: 700;
  text-shadow: 1px 2px 2px #000;
  cursor: pointer;
}

/* ================= BACKDROP ================= */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: none;
}

.backdrop.open {
  display: block;
}

/* ================= DRAWER ================= */

.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: -100%;
  height: 80%;
  background: var(--bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  transition: .3s;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  bottom: 0;
}

.drawer-content {
  flex: 1;
  overflow: auto;
  padding: 12px;
}

.close-btn {
    position: absolute;
    right: 12px;
    top: 10px;
    font-size: 1rem;
    cursor: pointer;
    border: 3px solid #f44336;
    padding: 8px 12px;
    border-radius: 50%;
    margin: 10px 20px 0 0;
    color: #f44336;
    font-weight: 600;
}

/* ================= LCD ================= */

.lcd {
  background: #111;
  color: #0f0;
  font-family: monospace;
  font-size: 32px;
  padding: 10px;
  border-radius: var(--radius-sm);
  text-align: right;
  margin-top: 10px;
}

/* ================= KEYPAD ================= */

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
}

.key {
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 20px;
}

/* ================= MODAL ================= */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-box {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius-md);
  width: 340px;
}

.modal input,
.modal select {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
}

/* ================= ICON SYSTEM ================= */

.icon-carousel {
  display: flex;
  overflow-x: auto;
  gap: 10px;
  margin-top: 10px;
}

.icon-option {
  min-width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: #0002;
  border-radius: 10px;
}

.icon-option.selected {
  outline: 3px solid var(--accent);
  background: #0004;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 10px 0;
}

.icon-cell {
  font-size: 24px;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  background: rgba(0,0,0,0.05);
}

.icon-cell.selected {
  background: #4caf50;
  color: #fff;
}

.grid-nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

/* ================= BUTTONS ================= */

.btn {
  background: var(--accent);
  border: none;
  padding: 12px;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  width: 100%;
  color: #fff;
  font-size: 16px;
}

.btn.secondary {
  background: #475569;
}

/* ================= RADIO ================= */

.radio-group {
  display: flex;
  justify-content: space-around;
  margin-top: 10px;
}

/* ================= TABLE ================= */

table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
}

th, td {
  padding: 6px;
  text-align: left;
  border: 1px solid var(--border);
}

.light th,
.light td {
  border: 1px solid var(--border-light);
}

tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.05);
}

.light tbody tr:nth-child(even) {
  background: rgba(0,0,0,0.05);
}

thead#adminHead button {
    background-color: var(--bg);
    outline: 0;
    border: 0;
    color: var(--accent);
    width: 110px;
    text-align: left;
}

/* ================= INVENTORY ================= */

#inventoryPanel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
  padding: 10px;
}

.inventory-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.05);
}

.inventory-icon {
  font-size: 20px;
  width: 30px;
  text-align: center;
}

.inventory-name {
  flex: 1;
  font-weight: 500;
}

.inventory-meta {
  font-size: 12px;
  opacity: 0.7;
  min-width: 110px;
  text-align: right;
}

.fuel-track {
  flex: 2;
  height: 10px;
  background: #ddd;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.fuel-fill {
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}

/* ================= SORT ================= */

.sort-bar {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  background: var(--card);
  align-items: center;
}

.sort-bar select {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.sort-bar button {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

/* ================= FILTER ================= */

#filterDrawer input,
#filterDrawer select {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border-radius: 8px;
  border: none;
}

.filter-modal-box {
  backdrop-filter: blur(6px);
  background: rgba(30, 41, 59, 0.85);
}

.light .filter-modal-box {
  background: rgba(255,255,255,0.9);
}

/* ================= ANIMATION ================= */

.cards-updating {
  animation: pulseUpdate 0.25s ease;
}

@keyframes pulseUpdate {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.98); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* ================= HISTORY ================= */

#historyDrawer canvas {
  max-height: 150px;
  background-color: #a6cbc3;
  padding: 15px 5px;
  margin: 20px;
}
.light #historyDrawer canvas { 
background-color: var(--bg);

}


/* USER SELECTABLE THEMES */

.forest {
  --bg: #0b1f17;
  --card: #132e24;
  --text: #e6f4ea;
  --accent: #22c55e;

  --surface-dark: #06140f;
  --surface-light: #1b3a2d;

  --border: rgba(255, 255, 255, 0.10);
  --border-light: rgba(0, 0, 0, 0.2);

  --shadow: 0 1px 4px rgba(0, 0, 0, 0.6);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --gap-sm: 8px;
  --gap-md: 12px;
  --gap-lg: 20px;
}

.light.forest {
    --bg: #75ef9b;
    --card: #b6ffc2;
    --text: #052e16;
    --surface-dark: #7fc597;
    --surface-light: #a7e3a7;
    --border: rgba(0, 0, 0, 0.12);
    --shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ocean {
    --bg: #0a1624;
    --card: #161641;
    --text: #65c1fd;
    --accent: #01b1ff;
    --surface-dark: #020617;
    --surface-light: #1b2d45;
    --border: rgba(255, 255, 255, 0.10);
    --border-light: rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 4px rgb(221 253 250 / 18%);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --gap-sm: 8px;
    --gap-md: 12px;
    --gap-lg: 20px;
}
.light.ocean {
    --bg: #43b4ff;
    --card: #46a7e7;
    --text: #0c4a6e;
    --surface-dark: #92cef5;
    --surface-light: #ffffff;
    --border: rgba(0, 0, 0, 0.12);
    --shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.plum {
  --bg: #1a1023;
  --card: #2a1838;
  --text: #f5e9ff;
  --accent: #c084fc;

  --surface-dark: #0f0715;
  --surface-light: #3b1f52;

  --border: rgba(255, 255, 255, 0.10);
  --border-light: rgba(0, 0, 0, 0.25);

  --shadow: 0 1px 5px rgba(0, 0, 0, 0.7);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --gap-sm: 8px;
  --gap-md: 12px;
  --gap-lg: 20px;
}

.light.plum {
    --bg: #b79cd3;
    --card: #8567a5;
    --text: #3b0764;
    --surface-dark: #8567a5;
    --surface-light: #ffffff;
    --border: rgba(0, 0, 0, 0.12);
    --shadow: 0 1px 3px rgb(0 0 0 / 86%);
}

div#themePicker {
    display: inline-block;
}