/* =====================================================================
   ERP Trading — style.css
   Mobile-first: this app runs inside an Android WebView.
   Design palette: deep indigo + warm paper neutral.
   This file THEMES Bootstrap rather than duplicating it.
   ===================================================================== */

/* ---- Design tokens ---- */
:root {
    --color-bg:          #F5F3EE;
    --color-surface:     #FFFFFF;
    --color-surface-alt: #FAFAF8;
    --color-border:      #E4DFDA;
    --color-ink:         #1E1D1B;
    --color-ink-muted:   #6B6760;

    --color-brand:       #2E3A59;   /* indigo */
    --color-brand-dark:  #1A2338;
    --color-brand-light: #4A5A82;
    --color-brand-pale:  #EEF1F8;

    --color-success:     #2E7D55;
    --color-success-bg:  #E6F4EC;
    --color-error:       #B0403A;
    --color-error-bg:    #FAEBE9;
    --color-warning:     #9A6A1A;
    --color-warning-bg:  #FDF3DC;

    --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --radius:        8px;
    --radius-lg:     12px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.07);
    --shadow-md:     0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:     0 8px 32px rgba(0,0,0,.13);

    --topbar-h:      56px;
    --sidebar-w:     260px;
    --tap:           44px;

    /* Bootstrap overrides */
    --bs-primary-rgb:     46,58,89;
    --bs-body-font-family: var(--font);
    --bs-body-bg:         var(--color-bg);
    --bs-body-color:      var(--color-ink);
    --bs-border-radius:   var(--radius);
    --bs-link-color:      var(--color-brand);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { -webkit-tap-highlight-color: transparent; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-ink);
    font-size: 14px;
    line-height: 1.55;
}
a { color: var(--color-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ======================================================================
   TOPBAR
====================================================================== */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    height: var(--topbar-h);
    background: var(--color-brand-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

.topbar-left  { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.app-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
    color: #fff;
}

.company-badge {
    background: rgba(255,255,255,.14);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.company-badge-super { background: #8A6D3B; }

.user-info { font-size: 12.5px; opacity: .85; display: none; }
.user-info small { opacity: .7; }

/* Hamburger — hidden on desktop, shown on mobile */
.sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    display: none;              /* shown via @media below */
    width: var(--tap);
    height: var(--tap);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.12); }
.sidebar-toggle span { font-size: 20px; line-height: 1; }

.btn-topbar-logout {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    font-size: 12.5px;
    padding: 6px 12px;
    min-height: 34px;
    border-radius: var(--radius);
    white-space: nowrap;
}
.btn-topbar-logout:hover {
    background: rgba(255,255,255,.2);
    color: #fff;
    text-decoration: none;
}

/* ======================================================================
   LAYOUT BODY
====================================================================== */
.app-body { display: flex; flex: 1; min-height: 0; }

/* ======================================================================
   SIDEBAR
====================================================================== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--color-brand-dark);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}

/* Flat items (Dashboard row, no section header) */
.sidebar-flat { padding: 4px 10px; }

/* Section accordion */
.sidebar-group { margin-bottom: 2px; }

.sidebar-group-title {
    width: 100%;
    background: none;
    border: none;
    color: rgba(255,255,255,.55);
    padding: 10px 16px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    transition: color .15s;
    user-select: none;
    -webkit-user-select: none;
}
.sidebar-group-title:hover { color: rgba(255,255,255,.8); }

.sidebar-group-arrow {
    display: inline-flex;
    transition: transform .2s ease;
    opacity: .6;
}
.sidebar-group-title[aria-expanded="false"] .sidebar-group-arrow {
    transform: rotate(-90deg);
}

.sidebar-group-items {
    overflow: hidden;
    max-height: 1200px;
    transition: max-height .25s ease;
}
.sidebar-group-items[aria-hidden="true"] {
    max-height: 0;
}

/* Every nav link */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    color: rgba(255,255,255,.72);
    font-size: 14px;
    min-height: var(--tap);
    text-decoration: none;
    border-radius: 6px;
    margin: 1px 8px;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.sidebar-item:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}
.sidebar-item.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    border-left-color: #FFD966;
    font-weight: 600;
}

/* Flat item (Dashboard) — slightly larger and distinguished */
.sidebar-item-flat {
    padding: 13px 16px;
    font-size: 14.5px;
    font-weight: 500;
    margin: 4px 8px;
}

.sidebar-item-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}
.sidebar-item-label { flex: 1; }

/* Sidebar footer */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}
.sidebar-footer-name {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,.85);
}
.sidebar-footer-role {
    font-size: 11px;
    color: rgba(255,255,255,.45);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 2px;
}

/* Backdrop (mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0,0,0,.4);
    z-index: 1030;
}
.sidebar-backdrop.show { display: block; }

/* ======================================================================
   MAIN CONTENT
====================================================================== */
.app-content {
    flex: 1;
    padding: 20px;
    overflow-x: hidden;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-header h1  { font-size: 20px; margin: 0; font-weight: 700; }
.page-header p   { color: var(--color-ink-muted); margin: 4px 0 0; font-size: 13px; }

/* ======================================================================
   CARDS
====================================================================== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    margin-bottom: 16px;
}

.card-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-box {
    flex: 1;
    min-width: 130px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px;
}
.stat-box .stat-value { font-size: 22px; font-weight: 700; color: var(--color-brand); }
.stat-box .stat-label { font-size: 11px; color: var(--color-ink-muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 3px; }

/* ======================================================================
   BUTTONS — re-theme Bootstrap, keep all Bootstrap classes working
====================================================================== */
.btn {
    font-weight: 500;
    min-height: var(--tap);
    border-radius: var(--radius);
    transition: all .15s ease;
}
.btn-sm { min-height: 36px; font-size: 13px; }

.btn-primary { background: var(--color-brand); border-color: var(--color-brand); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--color-brand-light); border-color: var(--color-brand-light); color: #fff; }
.btn-primary:active { background: var(--color-brand-dark); border-color: var(--color-brand-dark); }

.btn-secondary { background: var(--color-surface); border-color: var(--color-border); color: var(--color-ink); }
.btn-secondary:hover { background: var(--color-surface-alt); color: var(--color-ink); border-color: var(--color-brand-light); }

.btn-danger  { background: var(--color-error); border-color: var(--color-error); color: #fff; }
.btn-danger:hover { background: #8C3330; border-color: #8C3330; color: #fff; }

.btn-success { background: var(--color-success); border-color: var(--color-success); color: #fff; }

.btn-outline-secondary { border-color: var(--color-border); color: var(--color-ink); background: #fff; }
.btn-outline-secondary:hover { border-color: var(--color-brand); color: var(--color-brand); background: var(--color-brand-pale); }

.btn-link { color: var(--color-brand); text-decoration: none; }
.btn-link:hover { text-decoration: underline; }

/* ======================================================================
   FORMS
====================================================================== */
.form-group { margin-bottom: 16px; }
.form-group label,
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--color-ink);
}
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

.form-control, .form-select {
    min-height: var(--tap);
    border-color: var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    color: var(--color-ink);
    background: var(--color-surface);
}
.form-control:focus, .form-select:focus {
    border-color: var(--color-brand-light);
    box-shadow: 0 0 0 3px rgba(74,90,130,.15);
    outline: none;
}
textarea.form-control { min-height: 80px; resize: vertical; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ======================================================================
   ALERTS — compatible with Bootstrap alert classes
====================================================================== */
.alert { border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-danger, .alert-error {
    background: var(--color-error-bg);
    border-color: var(--color-error);
    color: var(--color-error);
}
.alert-success {
    background: var(--color-success-bg);
    border-color: var(--color-success);
    color: var(--color-success);
}
.alert-warning {
    background: var(--color-warning-bg);
    border-color: var(--color-warning);
    color: var(--color-warning);
}

/* ======================================================================
   BADGES
====================================================================== */
.badge-active   { background: var(--color-success-bg) !important; color: var(--color-success) !important; font-weight: 600; }
.badge-inactive { background: var(--color-error-bg)   !important; color: var(--color-error)   !important; font-weight: 600; }
.badge-role     { background: var(--color-warning-bg) !important; color: var(--color-warning) !important; font-weight: 600; }

/* ======================================================================
   TABLES (desktop/wide) + MOBILE CARDS
====================================================================== */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table.data-table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
    background: var(--color-surface);
    font-size: 13.5px;
}
table.data-table th, table.data-table td {
    padding: 11px 13px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    white-space: nowrap;
}
table.data-table th {
    background: var(--color-surface-alt);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--color-ink-muted);
}
table.data-table tbody tr:hover { background: var(--color-surface-alt); }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.table-actions a, .table-actions button {
    font-size: 12.5px;
    padding: 5px 11px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}

/* Mobile card layout (swap in on small screens) */
.data-cards { display: none; gap: 12px; flex-direction: column; }
.data-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 14px;
}
.data-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.data-card-title  { font-weight: 700; font-size: 15px; }
.data-card-row    { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-top: 1px solid var(--color-border); font-size: 13px; }
.data-card-row-label { color: var(--color-ink-muted); font-size: 12px; font-weight: 500; }
.data-card-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--color-border); margin-top: 6px; }
.data-card-actions .btn { flex: 1; min-width: 90px; font-size: 13px; min-height: 38px; }

/* ======================================================================
   LOGIN
====================================================================== */
.login-body {
    background: linear-gradient(135deg, var(--color-brand-dark) 0%, #2A3D6B 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-wrapper { width: 100%; max-width: 380px; }
.login-card { background: var(--color-surface); border-radius: var(--radius-lg); padding: 32px 28px; box-shadow: var(--shadow-lg); }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; color: var(--color-brand); }
.login-brand p  { color: var(--color-ink-muted); font-size: 13px; margin: 0; }

/* ======================================================================
   ERROR PAGE
====================================================================== */
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 48px; color: var(--color-error); margin: 0 0 12px; }

/* ======================================================================
   DASHBOARD
====================================================================== */

/* --- Money hero cards (To Pay / To Get) --- */
.dash-money-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.dash-money-card {
    border-radius: var(--radius-lg);
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-sm);
}
.dash-money-pay {
    background: linear-gradient(140deg, #B0403A 0%, #7A2B27 100%);
    color: #fff;
}
.dash-money-get {
    background: linear-gradient(140deg, #2E7D55 0%, #1F5439 100%);
    color: #fff;
}
.dash-money-capital {
    background: linear-gradient(140deg, #2E5FA3 0%, #1B3E70 100%);
    color: #fff;
}
.dash-money-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}
.dash-money-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    opacity: .85;
}
.dash-money-value {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
    word-break: break-word;
}
.dash-money-pending { font-size: 17px; opacity: .9; }
.dash-money-sub     { font-size: 11.5px; opacity: .8; line-height: 1.4; }

/* --- KPI stat row --- */
.dash-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.dash-kpi {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.dash-kpi-value { font-size: 20px; font-weight: 800; color: var(--color-brand); line-height: 1.1; }
.dash-kpi-label { font-size: 10.5px; color: var(--color-ink-muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 4px; }

/* --- Pipeline counters --- */
.dash-pipeline-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}
.dash-pipeline-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 6px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface-alt);
    text-decoration: none;
    transition: box-shadow .15s, transform .15s;
}
.dash-pipeline-stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.dash-pipeline-pending { border-top: 3px solid var(--color-warning); }
.dash-pipeline-active  { border-top: 3px solid var(--color-brand); }
.dash-pipeline-done    { border-top: 3px solid var(--color-success); }
.dash-pipeline-count { font-size: 26px; font-weight: 800; color: var(--color-ink); }
.dash-pipeline-pending .dash-pipeline-count { color: var(--color-warning); }
.dash-pipeline-active  .dash-pipeline-count { color: var(--color-brand); }
.dash-pipeline-done    .dash-pipeline-count { color: var(--color-success); }
.dash-pipeline-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--color-ink-muted); margin-top: 5px; text-align: center; }

/* --- Section headings --- */
.dash-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-ink);
    margin: 0 0 12px;
}
.dash-card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 8px;
}
.dash-card-header-row .dash-section-title { margin: 0; }
.dash-view-all {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-brand);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 5px 12px;
    white-space: nowrap;
    transition: all .15s;
}
.dash-view-all:hover { background: var(--color-brand-pale); border-color: var(--color-brand); text-decoration: none; }

.dash-subheading {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--color-ink-muted);
    margin: 16px 0 8px;
}

/* --- Outstanding balances --- */
.dash-owed-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-owed-col h6 {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .4px; color: var(--color-ink-muted); margin: 0 0 8px;
}
.dash-owed-list { list-style: none; margin: 0; padding: 0; }
.dash-owed-list li { margin-bottom: 6px; }
.dash-owed-list a {
    display: flex; justify-content: space-between; align-items: center;
    padding: 9px 12px; background: var(--color-surface-alt);
    border-radius: var(--radius); text-decoration: none;
    transition: background .15s;
    min-height: 40px;
}
.dash-owed-list a:hover { background: var(--color-brand-pale); text-decoration: none; }
.dash-owed-name { font-size: 13px; color: var(--color-ink); font-weight: 500; }
.dash-owed-amt  { font-size: 13px; font-weight: 700; color: var(--color-error); white-space: nowrap; }

/* --- Activity lists (recent purchases, active batches) --- */
.dash-activity-list { list-style: none; margin: 0; padding: 0; }
.dash-activity-list li { border-bottom: 1px solid var(--color-border); }
.dash-activity-list li:last-child { border-bottom: none; }
.dash-activity-list a {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 4px; text-decoration: none;
    min-height: var(--tap);
    transition: background .15s;
}
.dash-activity-list a:hover { background: var(--color-surface-alt); text-decoration: none; }
.dash-activity-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dash-activity-main strong { font-size: 14px; color: var(--color-ink); font-weight: 600; }
.dash-activity-meta { font-size: 12px; color: var(--color-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-activity-side { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; font-size: 13.5px; font-weight: 600; color: var(--color-ink); }
.dash-activity-date { font-size: 11px; color: var(--color-ink-muted); font-weight: 400; margin-top: 2px; }

/* ======================================================================
   RESPONSIVE
====================================================================== */
@media (min-width: 769px) {
    .user-info { display: inline; }
    /* Sidebar always visible, fixed width */
    .sidebar {
        position: static;
        height: auto;
        min-height: calc(100vh - var(--topbar-h));
    }
    .sidebar-toggle { display: none !important; }
}

@media (max-width: 768px) {
    .sidebar-toggle { display: flex !important; }

    /* Sidebar slides in from left */
    .sidebar {
        position: fixed !important;
        left: calc(-1 * var(--sidebar-w)) !important;
        top: var(--topbar-h) !important;
        width: var(--sidebar-w) !important;
        height: calc(100vh - var(--topbar-h)) !important;
        z-index: 1035 !important;
        transition: left .28s cubic-bezier(.4,0,.2,1) !important;
    }
    .sidebar.open {
        left: 0 !important;
        box-shadow: var(--shadow-lg);
    }

    .app-content { padding: 14px; }

    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .btn { width: 100%; text-align: center; }

    /* Show mobile cards, hide tables */
    .table-scroll { display: none; }
    .data-cards   { display: flex; }

    /* Dashboard: 2-col money grid, 3-col pipeline stays */
    .dash-money-grid    { grid-template-columns: 1fr 1fr; }
    .dash-money-grid-3  { grid-template-columns: 1fr 1fr; }
    .dash-owed-columns  { grid-template-columns: 1fr; }
    .dash-money-value   { font-size: 20px; }

    .card { padding: 14px; border-radius: var(--radius); }
}

@media (max-width: 400px) {
    .dash-money-grid   { grid-template-columns: 1fr; }
    .dash-money-grid-3 { grid-template-columns: 1fr; }
    .dash-kpi-row      { grid-template-columns: 1fr 1fr; }
    .dash-pipeline-row { grid-template-columns: repeat(3,1fr); }
    .dash-money-value  { font-size: 18px; }
}

/* ======================================================================
   SALE VIEW: invoice-style detail page, mobile-first.
   Distinct from the plain readonly-input pattern used by purchase_view,
   since this page's brief specifically calls for a polished, glanceable
   mobile layout - closer to a digital invoice than a data-entry form.
====================================================================== */
.sale-view-hero {
    background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
}
.sale-view-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}
.sale-view-number { font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.sale-view-date { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.sale-view-hero-amount { text-align: right; flex-shrink: 0; }
.sale-view-hero-amount .amt-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; opacity: .8; }
.sale-view-hero-amount .amt-value { font-size: 24px; font-weight: 800; line-height: 1.1; }

.sale-view-hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,.2);
}
.sale-view-hero-stats div { text-align: center; }
.sale-view-hero-stats .hs-label { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; opacity: .75; }
.sale-view-hero-stats .hs-value { font-size: 15px; font-weight: 700; margin-top: 2px; }

.sale-view-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-ink);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---- Customer info card ---- */
.sale-view-customer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.sale-view-field-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--color-ink-muted); margin-bottom: 3px; }
.sale-view-field-value { font-size: 13.5px; color: var(--color-ink); font-weight: 500; word-break: break-word; }

/* ---- Line item cards ---- */
.sale-line-view-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.sale-line-view-head {
    background: var(--color-surface-alt);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}
.sale-line-view-name { font-size: 14.5px; font-weight: 700; color: var(--color-ink); }
.sale-line-view-meta { font-size: 11.5px; color: var(--color-ink-muted); margin-top: 2px; }
.sale-line-view-total { text-align: right; flex-shrink: 0; }
.sale-line-view-total .lv-amt { font-size: 15px; font-weight: 800; color: var(--color-brand); }
.sale-line-view-total .lv-sub { font-size: 11px; color: var(--color-ink-muted); }

.sale-batch-list { padding: 10px 14px 12px; }
.sale-batch-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px 12px;
    padding: 10px 0;
    border-top: 1px dashed var(--color-border);
    font-size: 13px;
}
.sale-batch-row:first-child { border-top: none; padding-top: 4px; }
.sale-batch-row .sb-field { display: flex; flex-direction: column; }
.sale-batch-row .sb-label { font-size: 10px; text-transform: uppercase; letter-spacing: .3px; color: var(--color-ink-muted); }
.sale-batch-row .sb-value { font-weight: 600; color: var(--color-ink); margin-top: 1px; }
.sale-batch-row .sb-code { grid-column: 1 / -1; font-weight: 700; color: var(--color-brand); font-size: 13px; }

/* ---- Totals summary ---- */
.sale-view-totals {
    background: var(--color-brand-pale);
    border: 1px solid var(--color-brand-light);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.sale-view-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    font-size: 13.5px;
}
.sale-view-totals-row.grand {
    border-top: 1px solid var(--color-brand-light);
    margin-top: 6px;
    padding-top: 12px;
    font-size: 17px;
    font-weight: 800;
    color: var(--color-brand-dark);
}
.sale-view-totals-row .profit-positive { color: var(--color-success); font-weight: 700; }
.sale-view-totals-row .profit-negative { color: var(--color-error); font-weight: 700; }

.sale-view-notes {
    font-size: 13px;
    color: var(--color-ink);
    background: var(--color-surface-alt);
    border-radius: var(--radius);
    padding: 12px 14px;
    white-space: pre-wrap;
}

.sale-view-meta-footer {
    font-size: 11.5px;
    color: var(--color-ink-muted);
    text-align: center;
    margin-top: 4px;
}

@media (max-width: 480px) {
    .sale-view-hero-stats { grid-template-columns: repeat(3, 1fr); }
    .sale-view-hero-top { flex-direction: column; }
    .sale-view-hero-amount { text-align: left; }
}

/* ======================================================================
   SUPER ADMIN: COMPANY SWITCHER (topbar)
====================================================================== */
.company-switcher { display: flex; align-items: center; gap: 6px; }
.company-switcher label {
    font-size: 11px;
    color: rgba(255,255,255,.65);
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
    display: none;
}
.company-switcher select {
    background: rgba(255,255,255,.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 999px;
    padding: 5px 30px 5px 12px;
    font-size: 12.5px;
    min-height: 30px;
    max-width: 190px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23fff' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 7px;
    cursor: pointer;
}
.company-switcher select:focus { outline: none; border-color: #fff; }
.company-switcher select option { color: var(--color-ink); background: #fff; }
@media (min-width: 640px) {
    .company-switcher label { display: inline; }
}
@media (max-width: 480px) {
    .company-switcher select { max-width: 130px; font-size: 11.5px; padding-right: 26px; }
}
