/* ==========================================================================
   PSMS Design System v2 — "Gauge & Ledger"
   A visual language grounded in fuel-pump dials and paper ledger books.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
    --ink-teal-900: #0B2E3D;
    --ink-teal-800: #0F3B4D;
    --ink-teal-700: #124A5F;
    --ink-teal-600: #1B5C74;
    --paper-bg: #EEF1F0;
    --paper-bg-alt: #E4E9E7;
    --card-white: #FFFFFF;
    --brass-500: #D98E2B;
    --brass-600: #B8741C;
    --brass-100: #FBEAD1;
    --success-600: #2F9E6E;
    --success-100: #DFF3EA;
    --danger-600: #C1443C;
    --danger-100: #FBE4E2;
    --ink-900: #16232A;
    --ink-700: #33454E;
    --muted-500: #64748B;
    --border-soft: #DDE3E1;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(11,46,61,0.06), 0 4px 16px rgba(11,46,61,0.06);
    --shadow-hover: 0 6px 24px rgba(11,46,61,0.12);
}

* { box-sizing: border-box; }

body {
    background: var(--paper-bg);
    font-family: var(--font-body);
    color: var(--ink-900);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .page-title, .brand-mark {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
}

code, .mono, .receipt-box, .code-cell {
    font-family: var(--font-mono);
}

/* ---------------------------------------------------------------------
   App shell: fixed sidebar + top bar + content
   --------------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--ink-teal-900);
    background-image: radial-gradient(circle at 10% 0%, var(--ink-teal-800) 0%, var(--ink-teal-900) 55%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1030;
}

.app-sidebar .brand {
    padding: 1.5rem 1.25rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.app-sidebar .brand-icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--brass-500);
    display: flex; align-items: center; justify-content: center;
    color: var(--ink-teal-900);
    font-size: 1.1rem;
}
.app-sidebar .brand-mark {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.1;
}
.app-sidebar .brand-sub {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.5);
}

.app-nav {
    padding: 0.9rem 0.75rem;
    flex: 1;
    overflow-y: auto;
}
.app-nav .nav-section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: rgba(255,255,255,0.38);
    padding: 0.8rem 0.6rem 0.35rem;
}
.app-nav a.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: rgba(255,255,255,0.78);
    padding: 0.55rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .12s, color .12s;
}
.app-nav a.nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.app-nav a.nav-link:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}
.app-nav a.nav-link.active {
    background: var(--brass-500);
    color: var(--ink-teal-900);
    font-weight: 600;
}

.app-sidebar .sidebar-foot {
    padding: 0.9rem 1.1rem 1.1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.72rem;
    color: rgba(255,255,255,0.4);
}

.app-main {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    background: var(--card-white);
    border-bottom: 1px solid var(--border-soft);
    padding: 0.9rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.app-topbar .topbar-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--ink-teal-900);
}
.sidebar-toggle {
    display: none;
    background: none; border: none; font-size: 1.3rem; color: var(--ink-teal-900);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--paper-bg);
    border-radius: 999px;
    padding: 0.35rem 0.9rem 0.35rem 0.4rem;
    cursor: pointer;
    border: 1px solid var(--border-soft);
}
.user-chip .avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--ink-teal-900); color: var(--brass-500);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
}
.user-chip .u-name { font-size: 0.85rem; font-weight: 600; color: var(--ink-900); }
.user-chip .u-role { font-size: 0.68rem; color: var(--muted-500); }

.app-content {
    padding: 1.75rem;
    flex: 1;
}

/* ---------------------------------------------------------------------
   Page title
   --------------------------------------------------------------------- */
.page-title {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--ink-teal-900);
    margin-bottom: 1.25rem;
}
.page-title .eyebrow {
    display: block;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--brass-600);
    margin-bottom: 0.2rem;
}

/* ---------------------------------------------------------------------
   Gauge KPI cards (signature element)
   --------------------------------------------------------------------- */
.gauge-card {
    background: var(--card-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.3rem 1rem;
    box-shadow: var(--shadow-card);
    height: 100%;
    transition: box-shadow .15s, transform .15s;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    overflow: hidden;
}
.gauge-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); color: inherit; }

.gauge-card .gauge-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.gauge-card .gauge-label .gicon {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    color: #fff;
}

.gauge-dial {
    position: relative;
    width: 100%;
    height: 52px;
    margin-top: 0.2rem;
}
.gauge-dial svg { width: 100%; height: 100%; display: block; overflow: visible; }
.gauge-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.55rem;
    color: var(--ink-teal-900);
    margin-top: 0.35rem;
}
.gauge-value small {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted-500);
    margin-left: 0.3rem;
}

.icon-blue { background: var(--ink-teal-700); }
.icon-dark { background: var(--ink-900); }
.icon-brass { background: var(--brass-500); }
.icon-teal { background: var(--success-600); }

/* ---------------------------------------------------------------------
   Cards / panels
   --------------------------------------------------------------------- */
.card-panel {
    background: var(--card-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    box-shadow: var(--shadow-card);
}

.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
}
.btn-primary {
    background: var(--brass-500);
    border-color: var(--brass-500);
    color: var(--ink-teal-900);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--brass-600);
    border-color: var(--brass-600);
    color: #fff;
}
.btn-dark { background: var(--ink-teal-900); border-color: var(--ink-teal-900); }
.btn-dark:hover { background: var(--ink-teal-700); border-color: var(--ink-teal-700); }
.btn-outline-danger { --bs-btn-color: var(--danger-600); --bs-btn-border-color: var(--danger-600); }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
table.dataTable, .table {
    font-size: 0.89rem;
}
.table thead th {
    font-family: var(--font-body);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-500);
    border-bottom: 2px solid var(--border-soft);
    font-weight: 700;
}
.table td { vertical-align: middle; }
.receipt-code { font-family: var(--font-mono); font-weight: 600; color: var(--ink-teal-800); }

.badge-status-active { background: var(--success-100); color: var(--success-600); font-weight: 600; }
.badge-status-inactive { background: var(--danger-100); color: var(--danger-600); font-weight: 600; }

/* ---------------------------------------------------------------------
   Login / change password (outside app shell)
   --------------------------------------------------------------------- */
.login-body {
    min-height: 100vh;
    background: var(--ink-teal-900);
    background-image:
        radial-gradient(circle at 15% 20%, rgba(217,142,43,0.18), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(27,92,116,0.5), transparent 50%);
}
.login-card {
    width: 400px;
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--brass-500);
    color: var(--ink-teal-900);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto;
}

/* ---------------------------------------------------------------------
   POS — pump-button tiles + paper receipt ticket
   --------------------------------------------------------------------- */
.petrol-tile {
    background: var(--card-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg) var(--radius-lg) 6px 6px;
    padding: 1rem 1.1rem 0.85rem;
    cursor: pointer;
    transition: all .12s;
    position: relative;
}
.petrol-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 50%; transform: translateX(-50%);
    width: 34%; height: 5px;
    background: var(--border-soft);
    border-radius: 0 0 4px 4px;
    transition: background .12s;
}
.petrol-tile span:first-child { font-weight: 600; font-size: 0.92rem; color: var(--ink-900); display: block; }
.petrol-tile .price {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--brass-600);
    font-size: 1.05rem;
    margin-top: 0.3rem;
    display: block;
}
.petrol-tile:hover { border-color: var(--brass-500); box-shadow: var(--shadow-card); }
.petrol-tile.selected {
    background: var(--ink-teal-900);
    border-color: var(--ink-teal-900);
}
.petrol-tile.selected::before { background: var(--brass-500); }
.petrol-tile.selected span:first-child { color: #fff; }
.petrol-tile.selected .price { color: var(--brass-500); }

.pos-panel {
    background: var(--ink-teal-900);
    background-image: radial-gradient(circle at 100% 0%, var(--ink-teal-700), var(--ink-teal-900) 60%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    position: relative;
}
.pos-panel label {
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.55);
    margin-top: 0.9rem;
    display: block;
}
.pos-panel label:first-child { margin-top: 0; }
.pos-panel .form-control, .pos-panel .form-select {
    background: rgba(255,255,255,0.06);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    font-family: var(--font-mono);
}
.pos-panel .form-control:disabled { background: rgba(255,255,255,0.03); color: rgba(255,255,255,0.5); }
.pos-panel .form-control:focus, .pos-panel .form-select:focus {
    background: rgba(255,255,255,0.09);
    border-color: var(--brass-500);
    box-shadow: 0 0 0 0.2rem rgba(217,142,43,0.25);
    color: #fff;
}
.pos-panel .form-select option { color: #000; }

.receipt-box { font-family: var(--font-mono); }
.receipt-box table { width: 100%; }
.receipt-box th, .receipt-box td { padding: 4px 2px; }

@media print {
    body * { visibility: hidden; }
    #printArea, #printArea * { visibility: visible; }
    #printArea { position: absolute; top: 0; left: 0; width: 100%; }
}

/* ---------------------------------------------------------------------
   Mobile
   --------------------------------------------------------------------- */
@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
}

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--brass-500);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
