/* ================================================================
   FuelDesk POS — Design tokens & core styles
   Palette grounded in real fuel-pump nozzle color coding:
   Diesel = yellow, Premium = red, Unleaded = green, Kerosine = blue.
   Numeric displays use a monospace face to read like a pump's
   digital totalizer.
================================================================ */

:root {
  --navy-950: #0A1826;
  --navy-900: #0F2A43;
  --navy-800: #17395A;
  --navy-700: #1F4870;

  --amber-500: #E8A33D;
  --amber-600: #CC8B25;
  --amber-50: #FDF3E3;

  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --text: #16232E;
  --text-muted: #62717E;
  --border: #E3E8EE;

  --diesel: #EAA400;
  --premium: #C1272D;
  --unleaded: #1E7B45;
  --kerosine: #1D5C9E;

  --danger: #C1272D;
  --danger-bg: #FBEAEA;
  --success: #1E7B45;
  --success-bg: #E9F4EE;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-1: 0 1px 2px rgba(15, 42, 67, 0.06), 0 1px 1px rgba(15, 42, 67, 0.04);
  --shadow-2: 0 8px 24px rgba(15, 42, 67, 0.10);

  --sidebar-width: 250px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.mono, .figure {
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

a { text-decoration: none; }

/* ----------------------------------------------------------------
   App shell
---------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 100%);
  color: #DCE6EF;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand img {
  width: 34px; height: 34px; object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 3px;
}

.sidebar-brand .brand-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--amber-500);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--navy-950);
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar-brand-tag {
  font-size: 0.72rem;
  color: #94A9BC;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-nav { padding: 1rem 0.75rem; flex: 1; overflow-y: auto; }

.sidebar-nav .nav-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6F8699;
  padding: 0.9rem 0.75rem 0.35rem;
}

.sidebar-nav a.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: #C4D3E0;
  padding: 0.62rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.sidebar-nav a.nav-link i { width: 18px; text-align: center; opacity: 0.85; }

.sidebar-nav a.nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar-nav a.nav-link.active {
  background: var(--amber-500);
  color: var(--navy-950);
  font-weight: 600;
}
.sidebar-nav a.nav-link.active i { opacity: 1; }

.sidebar-foot {
  padding: 0.9rem 1.1rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.78rem;
  color: #7E93A6;
}

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar .page-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.topbar .page-sub { font-size: 0.82rem; color: var(--text-muted); margin: 0; }

.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  color: var(--navy-900);
}

.user-chip {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.35rem 0.6rem 0.35rem 0.35rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy-900); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.8rem;
}
.user-chip .name { font-size: 0.85rem; font-weight: 600; line-height: 1.1; }
.user-chip .role { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; }

.content { padding: 1.5rem; flex: 1; }

/* ----------------------------------------------------------------
   Cards & surfaces
---------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.panel-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
}
.panel-header h2, .panel-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.panel-body { padding: 1.25rem; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-1);
}
.stat-card .stat-label {
  font-size: 0.78rem; color: var(--text-muted); font-weight: 500;
}
.stat-card .stat-value {
  font-size: 1.65rem; font-weight: 700; margin-top: 0.15rem;
  font-family: 'IBM Plex Mono', monospace;
}
.stat-card .stat-delta { font-size: 0.78rem; margin-top: 0.3rem; }

/* ----------------------------------------------------------------
   Tank gauges (dashboard stock visualization)
---------------------------------------------------------------- */
.tank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}

.tank-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  box-shadow: var(--shadow-1);
}

.tank-visual {
  width: 56px;
  height: 130px;
  border-radius: 10px;
  border: 3px solid var(--navy-900);
  position: relative;
  overflow: hidden;
  background: #EEF1F5;
}

.tank-visual .fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  transition: height 0.4s ease;
}

.tank-visual .fill::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: rgba(255,255,255,0.35);
}

.tank-label { font-weight: 600; font-size: 0.9rem; text-align: center; }
.tank-pct { font-size: 0.75rem; color: var(--text-muted); }
.tank-liters { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 0.85rem; }

.tank-swatch {
  width: 10px; height: 10px; border-radius: 3px; display: inline-block;
}

/* ----------------------------------------------------------------
   Fuel sales breakdown (cashier history)
---------------------------------------------------------------- */
.fuel-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.fuel-breakdown-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--fuel-color, var(--navy-900));
  border-radius: var(--radius-lg);
  background: var(--bg);
  padding: 0.9rem 1.1rem;
}

.fuel-breakdown-name {
  display: flex; align-items: center; gap: 0.45rem;
  font-weight: 600; font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.02em;
}
.fuel-breakdown-name .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.fuel-breakdown-liters {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.1rem; font-weight: 600;
  margin-top: 0.4rem;
}

.fuel-breakdown-amount {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.35rem; font-weight: 700;
  color: var(--fuel-color, var(--navy-900));
  margin-top: 0.15rem;
}

/* ----------------------------------------------------------------
   Renew-contract notice (login screen)
---------------------------------------------------------------- */
.renew-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--danger-bg);
  border: 1px solid rgba(193, 39, 45, 0.25);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.renew-notice i { color: var(--danger); font-size: 1.3rem; margin-top: 0.1rem; }
.renew-notice-title { font-weight: 700; color: var(--danger); font-size: 0.95rem; }
.renew-notice-text { color: var(--text); font-size: 0.85rem; margin-top: 0.15rem; }

/* ----------------------------------------------------------------
   Branch switcher (admin header)
---------------------------------------------------------------- */
.branch-switcher {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.7rem;
}
.branch-switcher select {
  border: none; background: transparent; font-weight: 600; font-size: 0.85rem;
  padding: 0; color: var(--text);
}
.branch-switcher select:focus { outline: none; box-shadow: none; }

/* ----------------------------------------------------------------
   Tenant / contract badges (super admin panel)
---------------------------------------------------------------- */
.tenant-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 1.1rem 1.25rem;
}
.contract-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
}
.contract-badge.state-active { color: var(--success); background: var(--success-bg); }
.contract-badge.state-expiring { color: #9A6700; background: #FFF3D6; }
.contract-badge.state-expired,
.contract-badge.state-disabled { color: var(--danger); background: var(--danger-bg); }

.badge-fuel {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
}
.badge-fuel .dot { width: 8px; height: 8px; border-radius: 50%; }

.badge-status-active { color: var(--success); background: var(--success-bg); border-color: transparent; }
.badge-status-disabled { color: var(--danger); background: var(--danger-bg); border-color: transparent; }

/* ----------------------------------------------------------------
   Buttons
---------------------------------------------------------------- */
.btn-brand {
  background: var(--amber-500);
  border-color: var(--amber-500);
  color: var(--navy-950);
  font-weight: 600;
}
.btn-brand:hover, .btn-brand:focus {
  background: var(--amber-600);
  border-color: var(--amber-600);
  color: var(--navy-950);
}
.btn-navy {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: #fff;
  font-weight: 600;
}
.btn-navy:hover, .btn-navy:focus { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }

.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--amber-500);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------
   Tables
---------------------------------------------------------------- */
.table-clean thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}
.table-clean td { vertical-align: middle; border-color: var(--border); font-size: 0.9rem; }
.table-clean tbody tr:hover { background: var(--bg); }

/* ----------------------------------------------------------------
   POS (cashier) screen
---------------------------------------------------------------- */
.fuel-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
}

.fuel-option {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 1rem 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.fuel-option:hover { transform: translateY(-1px); }
.fuel-option.selected {
  border-color: var(--fuel-color, var(--navy-900));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fuel-color, var(--navy-900)) 18%, transparent);
}
.fuel-option .fuel-name { font-weight: 700; font-size: 1rem; }
.fuel-option .fuel-price {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.1rem; font-weight: 700;
  margin-top: 0.3rem;
  color: var(--fuel-color, var(--navy-900));
}
.fuel-option .fuel-stock { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }

.quick-liters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.quick-liters button {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.quick-liters button:hover { border-color: var(--navy-700); }

.pos-total-panel {
  background: var(--navy-950);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.4rem;
}
.pos-total-panel .label { font-size: 0.8rem; color: #9FB2C4; text-transform: uppercase; letter-spacing: 0.05em; }
.pos-total-panel .amount {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 2.4rem; font-weight: 700; color: var(--amber-500);
  line-height: 1.15;
}

/* ----------------------------------------------------------------
   Auth (login) screen
---------------------------------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, var(--navy-800), var(--navy-950) 65%);
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 2.1rem 1.9rem;
}
.auth-logo { width: 52px; height: 52px; border-radius: 12px; object-fit: contain; }

/* ----------------------------------------------------------------
   Receipt (thermal print)
---------------------------------------------------------------- */
.receipt-preview {
  width: 300px;
  margin: 0 auto;
  background: #fff;
  border: 1px dashed var(--border);
  padding: 1rem 1.1rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: #111;
}
.receipt-preview hr { border-top: 1px dashed #999; }
.receipt-preview .r-center { text-align: center; }
.receipt-preview .r-row { display: flex; justify-content: space-between; gap: 0.5rem; }
.receipt-preview .r-title { font-weight: 700; font-size: 0.95rem; }

@media print {
  body * { visibility: hidden; }
  #receiptArea, #receiptArea * { visibility: visible; }
  #receiptArea {
    position: absolute; top: 0; left: 0; width: 80mm;
    border: none; padding: 4mm;
  }
}

/* ----------------------------------------------------------------
   Responsive
---------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-2); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(10,24,38,0.45); z-index: 1025;
  }
  .sidebar-backdrop.show { display: block; }
}

@media (max-width: 575.98px) {
  .content { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; }
  .pos-total-panel .amount { font-size: 1.9rem; }
  .auth-card { padding: 1.6rem 1.3rem; }
}
