/* =========================================
   Fuel Inventory — V3
   National Foam: #E8003D / black / white
   ========================================= */

:root {
  --bg:           #0a0a0a;
  --card:         #111111;
  --card2:        #1a1a1a;
  --border:       #2a2a2a;
  --border2:      #3a3a3a;
  --text:         #f0f0f0;
  --muted:        #888888;
  --accent:       #E8003D;
  --accent2:      #c4002f;
  --accent-glow:  rgba(232,0,61,.18);
  --green:        #22c55e;
  --green-bg:     rgba(34,197,94,.12);
  --yellow:       #f59e0b;
  --yellow-bg:    rgba(245,158,11,.12);
  --red:          #E8003D;
  --red-bg:       rgba(232,0,61,.12);
  --shadow:       0 8px 32px rgba(0,0,0,.7);
  --radius:       12px;
  font-family: 'SF Pro Display', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(232,0,61,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232,0,61,.035) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(1400px, calc(100vw - 24px));
  margin: 14px auto;
}

/* ── Header ── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.headerLeft { display: flex; flex-direction: column; gap: 4px; }
.header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: #fff;
}
.nf { color: var(--accent); font-weight: 900; }

.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--card);
  font-size: 11px;
  color: var(--muted);
}
.linkbtn {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
}
.linkbtn:hover { text-decoration: underline; }

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.headerRight {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

input, select {
  width: 100%;
  font-size: 14px;
  padding: 9px 10px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  outline: none;
  background: var(--card2);
  color: var(--text);
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
.field { display: grid; gap: 4px; min-width: 0; }
.lbl {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}


input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
@supports (-webkit-touch-callout: none) {
  input, select { font-size: 16px; }
}

/* ── Buttons ── */
.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--card2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:active { background: var(--accent2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255,255,255,.05); }
.btn.danger { border-color: rgba(232,0,61,.35); color: var(--red); background: transparent; }
.btn.danger:hover { background: var(--red-bg); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn.useBtn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  border-radius: 7px;
  letter-spacing: .2px;
}
.btn.useBtn:active { background: var(--accent2); }

.iconBtn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.iconBtn:hover { color: var(--text); }

/* ── Status Bar ── */
.statusBar {
  position: sticky;
  bottom: 0;
  margin: 10px 0;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(17,17,17,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
}
.statusBarInner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.statusLeft, .statusRight {
  display: flex;
  align-items: center;
  gap: 8px;
}
.statusDot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 7px var(--accent);
}
.statusBar[data-error="1"] .statusDot { background: #ff4d72; box-shadow: 0 0 7px #ff4d72; }
.statusBar[data-error="1"] .statusText { color: #ff4d72; }

.tally {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(232,0,61,.3);
  color: #ff4d72;
  background: var(--red-bg);
}
.tally:empty { display: none; }

/* ── Inventory Root ── */
.inventoryRoot { display: grid; gap: 16px; margin-top: 4px; }

.emptyState {
  text-align: center;
  padding: 52px 24px;
  color: var(--muted);
  font-size: 14px;
}
.emptyState h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; }

/* ── Container Block ── */
.containerBlock {}

.containerHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 0 2px;
}
.containerName {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.containerLine { flex: 1; height: 1px; background: var(--border); }
.containerMeta {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ── Fuel Table ── */
.tableWrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

table.fuelTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

table.fuelTable thead tr {
  background: var(--card2);
  border-bottom: 1px solid var(--border);
}

table.fuelTable th {
  padding: 8px 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
table.fuelTable th.right { text-align: right; }
table.fuelTable th.center { text-align: center; }

/* Column widths */
table.fuelTable th:nth-child(1) { width: 28%; }  /* Fuel */
table.fuelTable th:nth-child(2) { width: 14%; }  /* Drums */
table.fuelTable th:nth-child(3) { width: 24%; }  /* Remaining */
table.fuelTable th:nth-child(4) { width: 12%; }  /* Use */
table.fuelTable th:nth-child(5) { width: 16%; }  /* Status */
table.fuelTable th:nth-child(6) { width: 6%; }   /* ✕ */

table.fuelTable tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
table.fuelTable tbody tr:last-child { border-bottom: none; }
table.fuelTable tbody tr:hover { background: rgba(255,255,255,.025); }

table.fuelTable td {
  padding: 10px 10px;
  font-size: 13px;
  vertical-align: middle;
  overflow: hidden;
}
table.fuelTable td.right { text-align: right; }
table.fuelTable td.center { text-align: center; }

/* Fuel type cell */
.fuelTypeName {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fuelDot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Drum count */
.drumCount {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* Remaining bar */
.galWrap { display: grid; gap: 3px; min-width: 80px; }
.galPct {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.galBar {
  height: 10px;
  background: var(--card2);
  border-radius: 4px;
  overflow: visible;
  border: 1px solid var(--border);
  position: relative;
}
.galFill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.galFill.low  { background: var(--accent); }
.galFill.mid  { background: var(--yellow); }
.galFill.high { background: var(--green); }

/* Drum tick marks */
.galTick {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--bg);
  transform: translateX(-50%);
  z-index: 2;
  border-radius: 1px;
  pointer-events: none;
}

/* Status chip */
.statusChip {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.chip-ok       { background: var(--green-bg);  color: #4ade80; border: 1px solid rgba(34,197,94,.25); }
.chip-low      { background: var(--yellow-bg); color: #fbbf24; border: 1px solid rgba(245,158,11,.25); }
.chip-empty    { background: var(--red-bg);    color: #ff4d72; border: 1px solid rgba(232,0,61,.25); }

/* Delete row btn */
.deleteRowBtn {
  border: none;
  background: transparent;
  color: var(--border2);
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}
.deleteRowBtn:hover { color: var(--accent); }

/* ── Use Dialog ── */
.dialog { border: none; padding: 0; background: transparent; max-width: 100%; }
.dialog::backdrop {
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.dialogCard {
  width: min(400px, calc(100vw - 24px));
  border-radius: 16px;
  border: 1px solid var(--border2);
  background: var(--card);
  box-shadow: var(--shadow), 0 0 0 1px rgba(232,0,61,.08);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.dialogHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.dialogFuelName {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.dialogContainerName {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: .6px;
}

.useStats {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.useStat {
  flex: 1;
  padding: 12px 10px;
  text-align: center;
}
.useStatVal {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}
.useStatLbl {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.useStatDivider {
  width: 1px;
  height: 40px;
  background: var(--border);
  flex-shrink: 0;
}

.usePreview {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
  line-height: 1.4;
}
.usePreview.warn { color: var(--yellow); }
.usePreview.danger { color: #ff4d72; }

.dialogBtns { display: flex; gap: 8px; }
.dialogBtns .btn { flex: 1; text-align: center; padding: 11px; }

.dialogCard h2 { margin: 0 0 4px; font-size: 17px; color: #fff; }
.dialogCard p  { margin: 0 0 4px; color: var(--muted); font-size: 12px; }

/* ── Edit Container Button ── */
.editContainerBtn {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.editContainerBtn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Edit Dialog ── */
.editDialogEl { max-width: 100%; }
.editDialogCard {
  width: min(560px, calc(100vw - 20px));
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.editDialogCard .dialogHeader { margin-bottom: 14px; }

.editDialogBody {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}

/* Edit row — drums only + reset note */
.editRow {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.editRowNote {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  font-style: italic;
}
.editRowFuel {
  display: flex;
  align-items: center;
  gap: 8px;
}
.editFuelName {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.editField {
  display: grid;
  gap: 3px;
}
.editField input, .editField select {
  padding: 7px 9px;
  font-size: 14px;
}
.editDeleteBtn {
  justify-self: center;
}

/* Add new fuel row inside edit dialog */
.editAddRow {
  display: grid;
  grid-template-columns: 1.6fr 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 10px 12px;
  background: rgba(232,0,61,.05);
  border: 1px dashed rgba(232,0,61,.25);
  border-radius: 8px;
  margin-top: 6px;
}
.editAddRow select, .editAddRow input {
  padding: 7px 9px;
  font-size: 14px;
}
.editAddRow .btn {
  padding: 8px 14px;
  font-size: 12px;
}

/* ── Fuel Types Dialog ── */
.fuelTypeList {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.fuelTypeRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.fuelTypeName2 {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.fuelRemoveBtn {
  color: var(--border2);
  transition: color .15s;
}
.fuelRemoveBtn:hover { color: var(--accent); }

.fuelAddRow {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.fuelAddRow input { flex: 1; }
.fuelAddRow .btn { flex-shrink: 0; padding: 9px 16px; }

/* ── Responsive ── */
@media (max-width: 680px) {
  .wrap { width: calc(100vw - 16px); margin: 8px auto; }
  .header { flex-wrap: wrap; gap: 6px; }
  .headerRight { gap: 6px; }
  .headerRight .btn { padding: 8px 12px; font-size: 12px; }

  /* Tighter table on mobile */
  table.fuelTable th { padding: 7px 8px; font-size: 9px; }
  table.fuelTable td { padding: 9px 8px; }
  .drumCount { font-size: 18px; }
  .fuelDot { width: 7px; height: 7px; }
  .statusChip { font-size: 9px; padding: 2px 5px; }
  .btn.useBtn { padding: 6px 10px; font-size: 11px; }
  .containerHeader { gap: 6px; }
  .editContainerBtn { padding: 4px 9px; font-size: 10px; }

  /* Dialogs full-width on mobile */
  .editDialogCard { width: calc(100vw - 20px); }
  .editRow { grid-template-columns: 1fr 0.8fr 0.8fr auto; gap: 6px; padding: 8px; }
  .editAddRow { grid-template-columns: 1.4fr 1fr auto; gap: 6px; padding: 8px; }
}
