/* =====================================================================
   Press Manager — style.css
   Mobile-first: used mostly from a phone (PWA).
   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;
    --app-footer-h:  36px;
    --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 { height: 100%; -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;
    overflow: hidden;
}
a { color: var(--color-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.topbar {
    height: var(--topbar-h);
    flex-shrink: 0;
    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; overflow: hidden; }

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

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

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

/* 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: auto;
    min-width: 0;
    min-height: 0;
    overscroll-behavior: contain;
}

.app-footer {
    height: var(--app-footer-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    background: var(--color-brand-dark);
    color: rgba(255,255,255,.72);
    font-size: 11px;
}

.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: 0;
    }
    .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;
        bottom: var(--app-footer-h) !important;
        width: var(--sidebar-w) !important;
        height: auto !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; }
}

/* ======================================================================
   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; }
}

/* ======================================================================
   RESPONSIVE-STACK TABLES
   Used on the Purchase Add / Edit / View pages, where the rows contain
   live form inputs (item pickers, weight/rate fields, action buttons)
   that can't easily be duplicated into a separate ".data-cards" markup
   and kept in sync via JS. Instead of hiding the table completely on
   mobile (the generic ".table-scroll { display:none }" rule above,
   which previously left these pages showing only the surrounding form
   fields and none of the line items), tables tagged "responsive-stack"
   turn each row into a stacked label/value card using nothing but CSS -
   every field, button and value that exists on desktop is still shown
   on mobile, just stacked instead of side-by-side in a wide table.
   The two classes together give this higher specificity than the plain
   ".table-scroll" mobile rule, so it always wins.
====================================================================== */
@media (max-width: 768px) {
    .table-scroll.responsive-stack {
        display: block !important;
        overflow: visible;
    }
    .responsive-stack table.data-table {
        min-width: 0;
        width: 100%;
    }
    .responsive-stack table.data-table thead { display: none; }
    .responsive-stack table.data-table tbody tr {
        display: block;
        margin-bottom: 14px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        padding: 10px 12px;
        background: var(--color-surface);
    }
    .responsive-stack table.data-table tbody tr:last-child { margin-bottom: 0; }
    .responsive-stack table.data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        white-space: normal;
        border-bottom: 1px dashed var(--color-border);
        padding: 8px 2px;
        text-align: right;
    }
    .responsive-stack table.data-table td:last-child { border-bottom: none; }
    .responsive-stack table.data-table td[data-label=""]::before { display: none; }
    .responsive-stack table.data-table td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .4px;
        color: var(--color-ink-muted);
        flex: 0 0 auto;
        text-align: left;
        margin-right: auto;
    }
    .responsive-stack table.data-table td > select,
    .responsive-stack table.data-table td > input,
    .responsive-stack table.data-table td > textarea {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 62%;
    }
    .responsive-stack table.data-table td .btn { width: 100%; }
}


/* ======================================================================
   ADDITIONS FOR PRESS MANAGER
   Everything below builds on the tokens defined at the top of this file.
====================================================================== */

/* ---- Extra tokens (info colour + soft shadows) ---- */
:root {
    --color-info:      #2E5FA3;
    --color-info-bg:   #E8EFFA;
    --color-neutral-bg: #EFEDE8;
    --shadow-card:     0 1px 2px rgba(20, 24, 38, .06), 0 4px 14px rgba(20, 24, 38, .06);
    --shadow-hover:    0 2px 4px rgba(20, 24, 38, .08), 0 10px 24px rgba(20, 24, 38, .12);
}

.card { box-shadow: var(--shadow-card); }

/* ---- Topbar extras ---- */
.btn-topbar-install {
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff;
    font-size: 12.5px;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: var(--radius);
    white-space: nowrap;
}
.btn-topbar-install.show { display: inline-flex; }
.btn-topbar-install:hover { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---- Sidebar extras ---- */
.sidebar-hint {
    margin: 14px 16px;
    padding: 12px;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, .7);
    background: rgba(255, 255, 255, .07);
    border-radius: var(--radius);
}

/* ---- Page header ---- */
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }
.table-actions .inline-form { display: inline-flex; }

/* ---- Badges ---- */
.badge { font-weight: 600; letter-spacing: .2px; padding: .42em .75em; border-radius: 999px; }
.badge-neutral  { background: var(--color-neutral-bg) !important; color: var(--color-ink-muted) !important; }
.badge-success  { background: var(--color-success-bg) !important; color: var(--color-success) !important; }
.badge-warning  { background: var(--color-warning-bg) !important; color: var(--color-warning) !important; }
.badge-danger   { background: var(--color-error-bg) !important; color: var(--color-error) !important; }
.badge-info     { background: var(--color-info-bg) !important; color: var(--color-info) !important; }
.badge-brand    { background: var(--color-brand-pale) !important; color: var(--color-brand) !important; }

/* ---- Tables ---- */
.table-toolbar { margin-bottom: 12px; max-width: 360px; }
table.data-table tfoot td {
    background: var(--color-surface-alt);
    font-weight: 700;
    border-top: 2px solid var(--color-border);
}
table.data-table td.text-end, table.data-table th.text-end { text-align: right; }
.data-card-totals { background: var(--color-brand-pale); border-color: var(--color-brand-light); }
.text-money-positive { color: var(--color-success); font-weight: 700; }
.text-money-negative { color: var(--color-error); font-weight: 700; }

/* ---- Cards with a titled header strip ---- */
.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.card-title-row h2 { font-size: 16px; font-weight: 700; margin: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-title-row { padding: 16px 18px 0; }
.card-flush .data-cards { padding: 0 14px 14px; }
.card-flush .alert { margin: 0 18px 18px; }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-hint { font-size: 12px; color: var(--color-ink-muted); margin-top: 4px; }
.required::after { content: ' *'; color: var(--color-error); }
.form-control[readonly] { background: var(--color-surface-alt); }
.input-money { text-align: right; }

/* ---- Statistic tiles ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-brand-light);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow-card);
}
.stat-tile-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--color-ink-muted); }
.stat-tile-value { font-size: 19px; font-weight: 800; color: var(--color-ink); margin-top: 3px; word-break: break-word; }
.stat-tile.tone-success { border-left-color: var(--color-success); }
.stat-tile.tone-danger  { border-left-color: var(--color-error); }
.stat-tile.tone-warning { border-left-color: #D9A441; }
.stat-tile.tone-info    { border-left-color: var(--color-info); }
.stat-tile.tone-muted   { border-left-color: #9A958C; }

/* ---- Hero card on view pages ---- */
.doc-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);
}
.doc-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.doc-hero-number { font-size: 20px; font-weight: 800; }
.doc-hero-sub { font-size: 12.5px; opacity: .85; margin-top: 3px; }
.doc-hero-amount { text-align: right; }
.doc-hero-amount .amt-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; opacity: .8; }
.doc-hero-amount .amt-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.info-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--color-ink-muted); margin-bottom: 3px; }
.info-value { font-size: 13.5px; font-weight: 500; word-break: break-word; }

/* ---- Modals ---- */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { background: var(--color-brand-pale); border-bottom: 1px solid var(--color-border); padding: 14px 18px; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--color-brand-dark); }
.modal-body { padding: 18px; }
.modal-footer { border-top: 1px solid var(--color-border); padding: 12px 18px; gap: 8px; }
.modal-footer > * { margin: 0; }

#globalNoticeModal .modal-body { display: flex; gap: 14px; align-items: flex-start; }
.notice-icon {
    flex: 0 0 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    background: var(--color-info-bg);
    color: var(--color-info);
}
.notice-text { flex: 1; min-width: 0; word-break: break-word; }
.notice-text ul { margin: 0; padding-left: 18px; }
#globalNoticeModal.notice-success .notice-icon { background: var(--color-success-bg); color: var(--color-success); }
#globalNoticeModal.notice-success .modal-header { background: var(--color-success-bg); }
#globalNoticeModal.notice-error .notice-icon { background: var(--color-error-bg); color: var(--color-error); }
#globalNoticeModal.notice-error .modal-header { background: var(--color-error-bg); }
#globalNoticeModal.notice-warning .notice-icon { background: var(--color-warning-bg); color: var(--color-warning); }
#globalNoticeModal.notice-warning .modal-header { background: var(--color-warning-bg); }

/* ---- Login ---- */
.login-brand .login-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: var(--shadow-md);
}
.login-footer { text-align: center; margin-top: 18px; font-size: 12px; color: rgba(255, 255, 255, .7); }

/* ---- Dashboard extras ---- */
.dash-money-card { text-decoration: none; color: #fff; }
a.dash-money-card:hover { color: #fff; text-decoration: none; box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.dash-money-card { transition: box-shadow .15s, transform .15s; }
.dash-money-brand { background: linear-gradient(140deg, var(--color-brand) 0%, var(--color-brand-dark) 100%); color: #fff; }
.dash-kpi-row { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.dash-pipeline-row { grid-template-columns: repeat(4, 1fr); }
.dash-pipeline-created { border-top: 3px solid #9A958C; }
.dash-pipeline-delivered { border-top: 3px solid var(--color-info); }
.dash-pipeline-created .dash-pipeline-count { color: #6B6760; }
.dash-pipeline-delivered .dash-pipeline-count { color: var(--color-info); }
.company-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-alt);
}
.theme-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex-shrink: 0; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--color-border); }

/* ---- Order / batch status colours ---- */
.row-batch-created   { border-left: 4px solid #9A958C; }
.row-batch-in_progress { border-left: 4px solid #D9A441; }
.row-batch-completed { border-left: 4px solid var(--color-success); }
.row-batch-delivered { border-left: 4px solid var(--color-info); }
.row-unbatched       { border-left: 4px solid var(--color-error); }

/* ---- Batch process timeline ---- */
.process-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.process-step { position: relative; padding: 0 0 18px 38px; }
.process-step::before {
    content: '';
    position: absolute;
    left: 13px; top: 28px; bottom: 0;
    width: 2px;
    background: var(--color-border);
}
.process-step:last-child { padding-bottom: 0; }
.process-step:last-child::before { display: none; }
.process-step-dot {
    position: absolute;
    left: 0; top: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--color-success);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.process-step.is-active .process-step-dot { background: #D9A441; animation: stepPulse 1.8s ease-in-out infinite; }
.process-step-body {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.process-step-name { font-weight: 700; }
.process-step-meta { font-size: 12px; color: var(--color-ink-muted); }
@keyframes stepPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 164, 65, .5); } 50% { box-shadow: 0 0 0 7px rgba(217, 164, 65, 0); } }
@media (prefers-reduced-motion: reduce) { .process-step.is-active .process-step-dot { animation: none; } }

/* ---- Design / size line editor (quotation, order) ---- */
.design-card { border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 14px; background: var(--color-surface); overflow: hidden; }
.design-card-head { background: var(--color-surface-alt); padding: 12px 14px; border-bottom: 1px solid var(--color-border); }
.design-card-body { padding: 12px 14px; }
.line-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; color: var(--color-ink-muted); margin-bottom: 3px; display: block; }
.line-row { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px dashed var(--color-border); }
.line-row:last-child { border-bottom: 0; margin-bottom: 0; }
.totals-box {
    margin-left: auto;
    max-width: 380px;
    background: var(--color-brand-pale);
    border: 1px solid var(--color-brand-light);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}
.totals-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; }
.totals-row.grand { border-top: 1px solid var(--color-brand-light); margin-top: 6px; padding-top: 10px; font-size: 17px; font-weight: 800; color: var(--color-brand-dark); }

/* ---- Filters row ---- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filter-bar .form-group { margin: 0; min-width: 150px; }
.filter-bar .form-control, .filter-bar .form-select { min-height: 38px; }

/* ---- Misc ---- */
.empty-state { text-align: center; padding: 34px 16px; color: var(--color-ink-muted); }
.text-muted-small { font-size: 12px; color: var(--color-ink-muted); }
.nowrap { white-space: nowrap; }
.search-select-note { font-size: 11px; color: var(--color-ink-muted); }

@media (max-width: 768px) {
    .form-grid .span-2 { grid-column: span 1; }
    .dash-pipeline-row { grid-template-columns: repeat(2, 1fr); }
    .doc-hero-amount { text-align: left; }
    .totals-box { max-width: 100%; }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1; }
}

/* ---- Small helpers referenced by the shared PHP helpers ---- */
.data-card-row-value { text-align: right; font-weight: 500; margin-left: 12px; word-break: break-word; }
.sidebar-group-label { flex: 1; text-align: left; }

/* ---- Company profile: logo / signature preview ---- */
.image-preview {
    background: #fff;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 8px;
    text-align: center;
}
.image-preview img { max-width: 100%; max-height: 90px; }
