/* PetroPump ERP design system: tokens, layout, components, motion. Bootstrap 5 provides the grid and base components. */
:root {
  --brand: #0b5cad;
  --brand-2: #0f766e;
  --accent: #f97316;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --bg: #f3f6fb;
  --card: #ffffff;
  --line: #e4e9f2;
  --muted: #64748b;
  --grad: linear-gradient(135deg, #0b5cad 0%, #0f766e 55%, #16a34a 100%);
  --grad-soft: linear-gradient(135deg, rgba(11, 92, 173, .10), rgba(15, 118, 110, .10));
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 248px;
}
[data-bs-theme="dark"] {
  --bg: #0b1020;
  --card: #141b2e;
  --line: #243049;
  --muted: #94a3b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
  --grad-soft: linear-gradient(135deg, rgba(56, 189, 248, .10), rgba(45, 212, 191, .08));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-bs-theme="light"]) {
    --bg: #0b1020; --card: #141b2e; --line: #243049; --muted: #94a3b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
    --grad-soft: linear-gradient(135deg, rgba(56, 189, 248, .10), rgba(45, 212, 191, .08));
  }
}

html, body { height: 100%; }
body {
  background: var(--bg);
  font-family: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
}
.num, .table td.num, .table th.num, .kpi-value, .tabular { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-body-secondary { color: var(--muted) !important; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Splash ---------- */
#splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--grad); color: #fff; z-index: 2000; }
#splash.d-none { display: none !important; }
.splash-logo { width: 84px; height: 84px; border-radius: 24px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 42px; animation: pop .7s var(--ease) both, bob 2.4s ease-in-out .7s infinite; }
.splash-name { font-weight: 700; letter-spacing: .3px; font-size: 1.25rem; }
.splash-bar { width: 160px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.25); margin-top: 18px; overflow: hidden; position: relative; }
.splash-bar::after { content: ''; position: absolute; inset: 0; width: 40%; background: #fff; border-radius: 4px; animation: slide 1.1s var(--ease) infinite; }

/* ---------- Auth (sign in / setup) ---------- */
.auth { min-height: 100vh; position: relative; overflow: hidden; background: #0b1426; color: #e2e8f0; }
.auth-bg { position: absolute; inset: 0; background: radial-gradient(1200px 600px at 10% -10%, #1e3a8a 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #0f766e 0%, transparent 60%), #0b1426; }
.auth-bg .blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .45; animation: drift 14s ease-in-out infinite alternate; }
.auth-bg .b1 { width: 380px; height: 380px; background: #0ea5e9; left: -80px; top: 10%; }
.auth-bg .b2 { width: 320px; height: 320px; background: #f97316; right: -60px; top: 40%; animation-delay: -4s; }
.auth-bg .b3 { width: 260px; height: 260px; background: #22c55e; left: 40%; bottom: -80px; animation-delay: -8s; }
.grid-lines { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 42px 42px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); }
.auth-inner { position: relative; z-index: 1; width: 100%; max-width: 1080px; min-height: 100vh; margin: 0 auto; padding: 32px 20px; box-sizing: border-box; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 40px; align-items: center; }
.auth-hero { animation: rise .8s var(--ease) both; }
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark { width: 52px; height: 52px; border-radius: 16px; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 28px; color: #fbbf24; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.brand-row .name { font-weight: 800; font-size: 1.1rem; color: #fff; }
.brand-row .tag { font-size: .8rem; color: #94a3b8; }
.auth-hero h1 { color: #fff; font-weight: 800; font-size: clamp(1.8rem, 3.2vw, 2.7rem); line-height: 1.15; letter-spacing: -.5px; }
.lead-sm { color: #cbd5e1; max-width: 520px; margin-top: 12px; }
.feature-chips { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.feature-chips li { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 6px 12px; font-size: .85rem; color: #e2e8f0; display: inline-flex; align-items: center; gap: 6px; }
.feature-chips i { color: #fbbf24; }
.hero-art { margin-top: 24px; max-width: 440px; }
.hero-art svg { width: 100%; height: auto; overflow: visible; }
.float-a { animation: float 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.float-b { animation: float 5s ease-in-out -2s infinite; transform-box: fill-box; transform-origin: center; }
.fuel-level { transform-box: fill-box; transform-origin: bottom; animation: fillUp 3.2s var(--ease) infinite alternate; }
.hose { stroke-dasharray: 6 6; animation: dash 1.6s linear infinite; }
.bar { transform-box: fill-box; transform-origin: bottom; animation: grow 2.4s var(--ease) infinite alternate; }

.auth-card { background: rgba(255,255,255,.96); color: #0f172a; border-radius: 24px; padding: 32px; box-shadow: 0 30px 80px -30px rgba(0,0,0,.6); animation: rise .9s var(--ease) .1s both; }
.auth-card h2 { font-weight: 800; font-size: 1.5rem; margin: 0; }
.auth-card .sub { color: #64748b; margin: 4px 0 22px; }
.auth-card .auth-note { color: #64748b !important; }
.field { position: relative; margin-bottom: 16px; }
.field input { width: 100%; height: 56px; border-radius: 14px; border: 1.5px solid #dbe3ef; padding: 22px 44px 6px 44px; font-size: 1rem; background: #f8fafc; transition: border-color .2s, box-shadow .2s, background .2s; outline: none; }
.field input:focus { border-color: #0b5cad; background: #fff; box-shadow: 0 0 0 4px rgba(11,92,173,.15); }
.field label { position: absolute; left: 44px; top: 17px; color: #64748b; pointer-events: none; transition: all .18s var(--ease); }
.field input:focus + .lead-icon + label, .field input:not(:placeholder-shown) + .lead-icon + label { top: 6px; font-size: .72rem; color: #0b5cad; }
.field .lead-icon { position: absolute; left: 14px; top: 19px; color: #94a3b8; }
.field .field-action { position: absolute; right: 6px; top: 8px; color: #64748b; }
.btn-grad { background: var(--grad); color: #fff; border: 0; border-radius: 14px; padding: 14px; font-weight: 700; box-shadow: 0 10px 24px -10px rgba(11,92,173,.7); transition: transform .15s var(--ease), box-shadow .2s; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn-grad:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(11,92,173,.8); }
.btn-grad:active { transform: translateY(0) scale(.99); }
.btn-login { font-size: 1rem; }
.shake { animation: shake .45s var(--ease); }

/* ---------- App shell ---------- */
#sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: linear-gradient(180deg, #0b1f3a, #0a2a33); color: #cbd5e1; padding: 16px 12px; z-index: 1020; }
#sidebar .sidebar-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; padding: 6px 8px 18px; }
#sidebar .logo { width: 38px; height: 38px; border-radius: 12px; background: rgba(255,255,255,.1); display: grid; place-items: center; color: #fbbf24; font-size: 22px; }
.nav-menu .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 10px 6px; }
.nav-menu .nav-link { display: flex; align-items: center; gap: 10px; color: #cbd5e1; border-radius: 12px; padding: 9px 12px; font-size: .92rem; transition: background .2s, color .2s, transform .2s var(--ease); }
.nav-menu .nav-link i { font-size: 1.05rem; opacity: .85; }
.nav-menu .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; transform: translateX(3px); }
.nav-menu .nav-link.active { background: linear-gradient(90deg, rgba(14,165,233,.28), rgba(34,197,94,.18)); color: #fff; box-shadow: inset 3px 0 0 #22d3ee; }
.offcanvas .nav-menu .nav-link { color: var(--bs-body-color); }
.offcanvas .nav-menu .nav-link.active { background: var(--grad-soft); color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.offcanvas .nav-menu .nav-section { color: var(--muted); }
.offcanvas .nav-menu .nav-link:hover { background: rgba(127,127,127,.08); color: inherit; transform: none; }
.app-main { min-height: 100vh; padding-left: 0; }
@media (min-width: 992px) { .app-main { padding-left: var(--sidebar-w); } }
.app-topbar { position: sticky; top: 0; z-index: 1010; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--line); }
.app-topbar #topbar-title { font-size: 1.02rem; }
.avatar-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .85rem; }
.conn-online { background: rgba(22,163,74,.14) !important; color: var(--ok) !important; }
.conn-offline { background: rgba(217,119,6,.16) !important; color: var(--warn) !important; }
#content { padding: 18px 16px 96px; max-width: 1280px; margin: 0 auto; }
@media (min-width: 992px) { #content { padding: 24px 28px 40px; } }

#bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
#bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .68rem; padding: 4px 0; transition: color .2s, transform .2s var(--ease); }
#bottom-nav a i { font-size: 1.2rem; }
#bottom-nav a.active { color: var(--brand); }
#bottom-nav a.active i { transform: translateY(-2px) scale(1.08); }
#bottom-nav .nav-sell i { display: grid; place-items: center; width: 46px; height: 46px; margin-top: -22px; border-radius: 16px; background: var(--grad); color: #fff; font-size: 1.35rem; box-shadow: 0 10px 22px -8px rgba(11,92,173,.7); }
#bottom-nav .nav-sell span { margin-top: 2px; }
#loading-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(2,6,23,.25); z-index: 3000; }
#loading-overlay.d-none { display: none; }
#loading-overlay > div { animation: rise .3s var(--ease) both; }

/* ---------- Page pieces ---------- */
.page-enter { animation: pageIn .45s var(--ease) both; }
.page-enter > * { animation: rise .5s var(--ease) both; }
.page-enter > *:nth-child(2) { animation-delay: .05s; }
.page-enter > *:nth-child(3) { animation-delay: .1s; }
.page-enter > *:nth-child(4) { animation-delay: .15s; }
.page-header h1 { font-weight: 800; letter-spacing: -.2px; }
.page-header .btn { border-radius: 12px; }
.stagger > * { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; transition: background .15s; }
.list-row:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.list-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.kpi { position: relative; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); transition: transform .25s var(--ease), box-shadow .25s; }
.kpi:hover { transform: translateY(-3px); box-shadow: 0 16px 36px -18px rgba(15,23,42,.35); }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--tint, var(--brand)); opacity: .09; }
.kpi .kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .kpi-value { font-size: clamp(.95rem, 3.7vw, 1.3rem); font-weight: 800; text-align: left; white-space: nowrap; }
.kpi .kpi-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--tint, var(--brand)) 16%, transparent); color: var(--tint, var(--brand)); font-size: 1.1rem; margin-bottom: 10px; }
.kpi .kpi-sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.hero-card { background: var(--grad); color: #fff; border-radius: 20px; padding: 22px; position: relative; overflow: hidden; box-shadow: 0 20px 40px -22px rgba(11,92,173,.9); }
.hero-card::before { content: ''; position: absolute; width: 260px; height: 260px; right: -80px; top: -120px; border-radius: 50%; background: rgba(255,255,255,.12); animation: drift 9s ease-in-out infinite alternate; }
.hero-card .kpi-value { color: #fff; font-size: 1.9rem; }

/* Tank gauges with an animated wave */
.tank { position: relative; width: 100%; max-width: 160px; margin: 0 auto; }
.tank svg { width: 100%; height: auto; }
.tank .liquid { transition: transform 1.2s var(--ease); }
.tank .wave { animation: wave 2.6s linear infinite; }
.tank.low .liquid { filter: hue-rotate(-30deg) saturate(1.3); }
.tank-meta { text-align: center; margin-top: 6px; }

/* Bars for charts */
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 10px; }
.chart-bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart-bars .fill { width: 100%; max-width: 46px; border-radius: 10px 10px 4px 4px; background: var(--grad); transform-origin: bottom; animation: growY .9s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); box-shadow: 0 8px 18px -10px rgba(11,92,173,.8); }
.chart-bars .lbl { font-size: .7rem; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.chart-bars .val { font-size: .72rem; font-weight: 700; margin-bottom: 4px; white-space: nowrap; }

.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(22,163,74,.6); animation: pulse 1.8s infinite; margin-right: 6px; vertical-align: middle; }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.tint-indigo { background: #4f46e5; } .tint-violet { background: #7c3aed; } .tint-green { background: #16a34a; }
.tint-amber { background: #d97706; } .tint-cyan { background: #0891b2; } .tint-pink { background: #db2777; }
.tint-red { background: #dc2626; } .tint-slate { background: #475569; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters > div:not(.d-flex) { flex: 0 0 auto; min-width: 140px; }
.table-report th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; }
.table-report td { vertical-align: middle; }
.table-report tfoot td { border-top: 2px solid var(--line); }
.empty-state { padding: 40px 16px; }
.empty-state .es-icon { font-size: 2.4rem; opacity: .45; margin-bottom: 8px; animation: bob 3s ease-in-out infinite; }
.skeleton { display: grid; gap: 12px; }
.skel { border-radius: 14px; background: linear-gradient(90deg, color-mix(in srgb, var(--line) 80%, transparent) 25%, color-mix(in srgb, var(--line) 30%, transparent) 37%, color-mix(in srgb, var(--line) 80%, transparent) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.toast { border-radius: 14px; }
.modal-content { border-radius: 20px; border: 1px solid var(--line); }
.modal.fade .modal-dialog { transition: transform .35s var(--ease), opacity .25s; }
.btn { transition: transform .12s var(--ease), box-shadow .2s, background-color .2s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: #094c8e; border-color: #094c8e; }
.form-control, .form-select { border-radius: 12px; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 .2rem rgba(11,92,173,.2); border-color: #7aa7d8; }
.badge { font-weight: 600; letter-spacing: .02em; }
.money-input { font-variant-numeric: tabular-nums; text-align: right; }
.summary-box { background: var(--grad-soft); border: 1px dashed color-mix(in srgb, var(--brand) 35%, transparent); border-radius: 14px; padding: 12px 14px; }
.summary-box .row-line { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.summary-box .total { font-weight: 800; font-size: 1.1rem; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.product-tile { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--card); text-align: left; width: 100%; transition: transform .15s var(--ease), border-color .2s, box-shadow .2s; }
.product-tile:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow); }
.product-tile .pt-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--grad-soft); color: var(--brand); font-size: 1.15rem; margin-bottom: 8px; }
.nozzle-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--card); }
.nozzle-card .diff { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(30px, -20px) scale(1.08); } }
@keyframes slide { from { left: -40%; } to { left: 100%; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes grow { from { transform: scaleY(.55); } to { transform: scaleY(1); } }
@keyframes growY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fillUp { from { transform: scaleY(.35); } to { transform: scaleY(1); } }
@keyframes dash { to { stroke-dashoffset: -24; } }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.6); } 70% { box-shadow: 0 0 0 10px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .auth-inner { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 24px 16px; min-height: 0; }
  .auth-hero { text-align: center; }
  .brand-row { justify-content: center; }
  .lead-sm { margin-inline: auto; }
  .feature-chips { justify-content: center; }
  .hero-art { display: none; }
  .auth-card { padding: 24px; }
  .page-header h1 { font-size: 1.05rem; }
}
@media (max-width: 575.98px) {
  .filters > div:not(.d-flex) { flex: 1 1 45%; }

  .table-report { font-size: .85rem; }
}

/* ---------- Print: receipts, statements and reports ---------- */
#print-area { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; color: #000 !important; }
  #splash, #view-login, #view-setup, #view-app > *:not(#content), .offcanvas, #toast-container, .modal, .modal-backdrop { display: none !important; }
  #view-app { display: block !important; }
  .app-main { padding: 0 !important; }
  #content { padding: 0 !important; max-width: none !important; }
  .no-print { display: none !important; }
  .card, .list-card, .kpi, .hero-card { box-shadow: none !important; border: 1px solid #bbb !important; background: #fff !important; color: #000 !important; }
  .table { color: #000 !important; }
  .table-report th { color: #000 !important; }
  .page-enter > *, .stagger > * { animation: none !important; }
  .print-title { display: block !important; }
}
.print-title { display: none; }
