:root {
  /* IndianOil brand: flame orange + deep navy */
  --teal: #ea6a1e;      /* primary orange (kept var name for reuse) */
  --teal-d: #c9550f;    /* deep orange */
  --teal-l: #f7922e;    /* light orange */
  --navy: #013e7d;
  --navy-d: #01285a;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --blue: #2563eb;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --tap: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(76px + var(--safe-b));
  -webkit-font-smoothing: antialiased;
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 14px;
  background: linear-gradient(120deg, var(--navy), var(--navy-d));
  color: #fff;
  box-shadow: 0 2px 12px rgba(1,62,125,.28);
}
.appbar__title { font-size: 20px; font-weight: 800; letter-spacing: .3px; flex: 1; }
.appbar.center { justify-content: center; }
.appbar.center .appbar__title { flex: 0 0 auto; }
.appbar__brand { display: inline-flex; align-items: center; }
.appbar__brand:empty { display: none; }
.brandsvg { width: 30px; height: 30px; display: block; }
.brandimg { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; background: #fff; border-radius: 8px; padding: 2px; overflow: hidden; }
.brandimg img { width: 100%; height: 100%; object-fit: contain; display: block; }
.appbar__back {
  border: 0; background: rgba(255,255,255,.18); color: #fff;
  width: 38px; height: 38px; border-radius: 12px; font-size: 26px; line-height: 1;
  cursor: pointer;
}
.appbar__shift {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.16); padding: 7px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
}
.appbar__shift .dot {
  width: 9px; height: 9px; border-radius: 50%; background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74,222,128,.7); animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74,222,128,.7); }
  70% { box-shadow: 0 0 0 10px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

/* ---------- View ---------- */
.view { padding: 16px 14px 24px; max-width: 900px; margin: 0 auto; }
.section-title { font-size: 15px; font-weight: 800; color: var(--ink-2); margin: 22px 4px 12px; text-transform: uppercase; letter-spacing: .6px; }
.section-title:first-child { margin-top: 6px; }
.hero {
  background: linear-gradient(120deg, var(--teal), var(--teal-l));
  color: #fff; border-radius: var(--radius); padding: 18px 18px;
  box-shadow: var(--shadow); margin-bottom: 6px; text-align: center;
}
.hero h1 { margin: 0 0 4px; font-size: 22px; }
.hero p { margin: 0; opacity: .9; font-size: 14px; }
.hero__head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.hero__head h1 { margin: 0; }
.hero__head p { margin: 2px 0 0; }
.hero__logo { background: #fff; border-radius: 14px; padding: 6px; display: inline-flex; box-shadow: var(--shadow); }
.hero__logo .brandsvg { width: 44px; height: 44px; }
.hero__logo .brandimg { width: 44px; height: 44px; border-radius: 11px; }

/* brand picker in Setup */
.brandgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 620px) { .brandgrid { grid-template-columns: repeat(3, 1fr); } }
.brandopt { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; text-align: left; transition: border-color .12s, box-shadow .12s; }
.brandopt.sel { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(234,106,30,.16); }
.brandopt__logo { flex: 0 0 auto; display: inline-flex; }
.brandopt__logo .brandsvg { width: 36px; height: 36px; }
.brandopt__logo .brandimg { width: 36px; height: 36px; border-radius: 9px; }
.brandopt__name { font-weight: 800; font-size: 14px; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Card grid (big icon buttons) ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.cardbtn {
  appearance: none; border: 1px solid var(--line); background: var(--card);
  border-radius: var(--radius); padding: 20px 16px; min-height: 132px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  gap: 10px; cursor: pointer; text-align: left; box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .15s ease;
}
.cardbtn:active { transform: scale(.97); }
.cardbtn__ico {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  font-size: 28px; background: #fff2e6;
}
.cardbtn__label { font-size: 17px; font-weight: 800; color: var(--ink); }
.cardbtn__sub { font-size: 13px; color: var(--ink-3); margin-top: -6px; }
/* single-column stacked variant: horizontal row cards */
.grid.grid--stack { grid-template-columns: 1fr; }
.grid--stack .cardbtn { flex-direction: row; align-items: center; justify-content: flex-start; gap: 16px; min-height: 84px; }
.grid--stack .cardbtn > div:last-child { flex: 1; }

.cardbtn.accent { background: linear-gradient(120deg, var(--teal), var(--teal-d)); border-color: transparent; }
.cardbtn.accent .cardbtn__label, .cardbtn.accent .cardbtn__sub { color: #fff; }
.cardbtn.accent .cardbtn__ico { background: rgba(255,255,255,.2); }
.cardbtn.danger .cardbtn__ico { background: #fef2f2; }

/* ---------- Generic card / list ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 17px; }

.row {
  display: flex; align-items: center; gap: 12px; padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row__ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: #f1f5f9; flex: 0 0 auto; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 700; font-size: 16px; }
.row__sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* ---------- Chips / pills ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: #f1f5f9; color: var(--ink-2); }
.chip.on { background: #dcfce7; color: #15803d; }
.chip.off { background: #f1f5f9; color: var(--ink-3); }
.chip.fuel { background: #eef2ff; color: #4338ca; }
.badge { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 8px; }
.badge.active { background: #dcfce7; color: #15803d; }
.badge.closed { background: #e2e8f0; color: var(--ink-2); }

/* balance indicator: sales value vs payment collected */
.bbadge { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; font-size: 12px; font-weight: 800; padding: 6px 11px; border-radius: 999px; white-space: nowrap; }
.bbadge.ok { background: #dcfce7; color: #15803d; }
.bbadge.short { background: #fee2e2; color: #b91c1c; }
.bbadge.excess { background: #fef3c7; color: #b45309; }
@media (max-width: 480px) { .bbadge .lbl { display: none; } }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; border-radius: 14px; font-size: 16px; font-weight: 800;
  padding: 0 18px; min-height: var(--tap); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; width: 100%;
  transition: filter .12s ease, transform .08s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:active { filter: brightness(.94); }
.btn.stop { background: var(--red); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.small { min-height: 42px; font-size: 14px; width: auto; padding: 0 14px; }
.btn.block { margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.iconbtn { border: 0; background: transparent; font-size: 18px; cursor: pointer; width: 38px; height: 38px; border-radius: 10px; color: var(--ink-2); }
.iconbtn:active { background: #f1f5f9; }
.pillbtn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.pillbtn.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.actionbar { display: flex; gap: 10px; }
.actionbar .btn { width: auto; flex: 1; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; width: 52px; height: 30px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s; }
.switch .track::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::before { transform: translateX(22px); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: 14px;
  padding: 0 14px; font-size: 17px; background: #fff; color: var(--ink); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(234,106,30,.16); }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.field-inline { display: flex; gap: 10px; }
.field-inline .field { flex: 1; }

/* ---------- Reading grid ---------- */
.gtable { width: 100%; border-collapse: separate; border-spacing: 0; }
.gtable th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 6px 8px; }
.gtable td { padding: 8px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.gtable input { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; font-size: 16px; text-align: right; }
.gtable input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(234,106,30,.16); }
.gtable .liters { font-weight: 800; color: var(--teal); white-space: nowrap; }
.gtable .nz { font-weight: 700; }
.gtable .nz small { display: block; color: var(--ink-3); font-weight: 600; }

/* horizontally scrollable wrapper for the reading grid on small screens */
.gtable-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gtable-wrap .gtable { min-width: 460px; }
.gtable-wrap::-webkit-scrollbar { height: 6px; }
.gtable-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

/* sale vs collected summary rows */
.sumrow { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.sumrow > span:last-child { color: var(--ink); font-weight: 800; }
.sumrow.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 11px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat .v { font-size: 24px; font-weight: 900; color: var(--ink); }
.stat .l { font-size: 12px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }
.stat.teal { background: linear-gradient(120deg, var(--teal), var(--teal-l)); border: 0; }
.stat.teal .v, .stat.teal .l { color: #fff; }

/* ---------- Report accordion ---------- */
.acc { background: var(--card); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 12px; box-shadow: var(--shadow); overflow: hidden; }
.acc__head { display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; }
.acc__head .row__main { flex: 1; }
.acc__chev { transition: transform .2s; color: var(--ink-3); font-size: 18px; }
.acc.open .acc__chev { transform: rotate(90deg); }
.acc__body { display: none; padding: 0 14px 14px; }
.acc.open .acc__body { display: block; }

.segment { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; -webkit-overflow-scrolling: touch; }
.segment::-webkit-scrollbar { display: none; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty .big { font-size: 44px; margin-bottom: 8px; }
.empty p { margin: 4px 0; }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  box-shadow: 0 -2px 16px rgba(15,23,42,.06);
}
.navbtn {
  border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 12px; font-size: 11px; font-weight: 700; color: var(--ink-3);
}
.navbtn__ico { font-size: 22px; filter: grayscale(1); opacity: .7; }
.navbtn.active { color: var(--teal); }
.navbtn.active .navbtn__ico { filter: none; opacity: 1; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 620px) { .modal { align-items: center; } }
.modal__scrim { position: absolute; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px); }
.modal__card {
  position: relative; background: #fff; width: 100%; max-width: 560px;
  border-radius: 24px 24px 0 0; max-height: 92vh; display: flex; flex-direction: column;
  animation: slideup .25s ease;
}
@media (min-width: 620px) { .modal__card { border-radius: 24px; } }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 8px; }
.modal__head h2 { margin: 0; font-size: 20px; }
.modal__body { padding: 8px 18px; overflow-y: auto; }
.modal__foot { padding: 12px 18px calc(16px + var(--safe-b)); display: flex; gap: 10px; }
.modal__foot .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 700; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  animation: slideup .2s ease;
}

.mutedbox { background: #f8fafc; border: 1px dashed var(--line); border-radius: 14px; padding: 14px; color: var(--ink-2); font-size: 14px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.right { text-align: right; }
