:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #a855f7;
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.6);
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.15);
    --sidebar-bg: rgba(15, 23, 42, 0.85);
    --sidebar-text: #cbd5e1;
    --sidebar-active-bg: rgba(99, 102, 241, 0.15);
    --sidebar-active-text: #818cf8;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --dropdown-bg: #1e293b;
    --dropdown-border: rgba(148, 163, 184, 0.25);
    --dropdown-hover: rgba(148, 163, 184, 0.12);
    --dropdown-muted: #a8b6c8;
    --dropdown-accent: #a5b4fc;
    --dropdown-danger: #ff8585;

    /* One colour per Deal Costing Calculator section. These are the light tints
       for the dark themes; body.theme-light swaps in darker shades of the same
       hues, because a pastel heading on white is unreadable. */
    --sec-cargo: #38bdf8;
    --sec-logistics: #fbbf24;
    --sec-invest: #2dd4bf;
    --sec-pricing: #a78bfa;
    --sec-profit: #34d399;
    --sec-offer: #f472b6;
    --sec-saved: #94a3b8;
}

body.theme-light {
    --bg-color: #f1f5f9;
    --panel-bg: rgba(255, 255, 255, 0.85);
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: rgba(148, 163, 184, 0.3);
    --sidebar-bg: rgba(255, 255, 255, 0.95);
    --sidebar-text: #475569;
    --sidebar-active-bg: rgba(99, 102, 241, 0.1);
    --sidebar-active-text: #4f46e5;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --dropdown-bg: #ffffff;
    --dropdown-border: rgba(148, 163, 184, 0.4);
    --dropdown-hover: rgba(99, 102, 241, 0.08);
    --dropdown-muted: #55637a;
    --dropdown-accent: #4f46e5;
    --dropdown-danger: #d92d20;

    /* Darker shades of the calculator section colours, for legibility on white. */
    --sec-cargo: #0369a1;
    --sec-logistics: #b45309;
    --sec-invest: #0f766e;
    --sec-pricing: #6d28d9;
    --sec-profit: #047857;
    --sec-offer: #be185d;
    --sec-saved: #475569;
}

body.theme-light .card { background: var(--panel-bg); }
body.theme-light .topbar { background: var(--panel-bg); }
body.theme-light .sidebar { background: var(--sidebar-bg); }
body.theme-light .modal-content { background: #ffffff; }
body.theme-light .form-control { background: #ffffff; color: #1e293b; border-color: #cbd5e1; }
body.theme-light .form-control:focus { background: #ffffff; }
body.theme-light .form-control option { background: #ffffff; color: #1e293b; }
body.theme-light .btn-secondary { background: #ffffff; color: #1e293b; border-color: #cbd5e1; }
body.theme-light .btn-secondary:hover { background: #f8fafc; }
body.theme-light .data-table th { background-color: #f8fafc; color: #475569; border-bottom: 2px solid #e2e8f0; }

body.theme-brand {
    --bg-color: #001f3f;
    --panel-bg: rgba(0, 43, 89, 0.85);
    --text-color: #f8fafc;
    --text-muted: #b0c4de;
    --primary-color: #d4af37;
    --primary-hover: #b5952f;
    --secondary-color: #f1c40f;
    --border-color: rgba(212, 175, 55, 0.25);
    --sidebar-bg: rgba(0, 31, 63, 0.95);
    --sidebar-text: #e0e6ed;
    --sidebar-active-bg: rgba(212, 175, 55, 0.15);
    --sidebar-active-text: #d4af37;
    --dropdown-bg: #002b59;
    --dropdown-border: rgba(212, 175, 55, 0.3);
    --dropdown-hover: rgba(212, 175, 55, 0.14);
    --dropdown-muted: #b0c4de;
    --dropdown-accent: #e3c14a;
    --dropdown-danger: #ff7b7b;
}

body.theme-brand .data-table th { background-color: rgba(0, 43, 89, 0.95); color: #d4af37; border-bottom: 2px solid #d4af37; }
body.theme-brand .kpi-card { border-left: 4px solid #d4af37; }

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,60%,15%,0.7) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,50%,15%,0.4) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,60%,15%,0.4) 0, transparent 50%);
}

.erp-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(15px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    z-index: 10;
    transition: width 0.22s ease;
}

/* Collapsed on a desktop: the panel folds away and the page takes the width.
   The top-bar button brings it back, and the choice is remembered. */
.erp-layout.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    border-right: 0;
    overflow: hidden;
}

.erp-layout.sidebar-collapsed .sidebar-header,
.erp-layout.sidebar-collapsed .sidebar-nav {
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    }

/* Collapse control, sitting in the panel header so it is found without hunting
   the top bar. margin-left:auto pins it to the right of the logo row. */
.sidebar-toggle {
    margin-left: auto;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--text-color);
}

.sidebar-toggle i { font-size: 1.1rem; line-height: 1; }

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

.nav-section {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 1.5rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: color 0.2s ease;
}

.nav-section:hover {
    color: var(--sidebar-text);
}

.nav-section i {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.nav-section.collapsed i {
    transform: rotate(-90deg);
}

.nav-group {
    overflow: hidden;
}

.nav-group.collapsed {
    display: none;
}

.nav-section.mt-4 {
    margin-top: 1.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-item i {
    font-size: 1.25rem;
    margin-right: 1rem;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.nav-item:hover {
    background-color: rgba(99, 102, 241, 0.05);
    color: #f8fafc;
}

.nav-item:hover i {
    color: var(--primary-color);
}

.nav-item.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left-color: var(--primary-color);
}

.nav-item.active i {
    color: var(--primary-color);
}

/* Main Panel */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 70px;
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.breadcrumb {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

.content-wrapper {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    /* Without this a flex item refuses to shrink below its content, so one wide
       table pushed the whole page sideways instead of fitting into the space. */
    min-width: 0;
}

/* Cards & Glassmorphism */
.card {
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: rgba(148, 163, 184, 0.25);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.kpi-card {
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(148, 163, 184, 0.3);
}

.kpi-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

/* A flex child defaults to min-width:auto, so it refuses to shrink below its
   content and a long figure spills over the card edge and collides with the
   next one. min-width:0 lets it shrink and wrap where it must. */
.kpi-info {
    min-width: 0;
    flex: 1;
}

.kpi-info h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    letter-spacing: 0.05em;
}

.kpi-value {
    /* Scales with the viewport instead of a fixed 1.6rem, and wraps rather
       than overflowing if a figure is ever longer than expected. */
    font-size: clamp(1.15rem, 1.4vw, 1.6rem);
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: -0.02em;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.quick-actions-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Buttons */
button {
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn-secondary {
    background-color: rgba(30, 41, 59, 0.8);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(51, 65, 85, 0.8);
    border-color: rgba(148, 163, 184, 0.4);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    font-size: 1.2rem;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary-color);
}

/* =====================================================================
   Account dropdown (top-right)
   The panel uses an opaque background so page content never bleeds
   through it, and an explicit colour per theme - previously the
   background was a white fallback while the text inherited the
   near-white dark-theme colour, making the menu unreadable.
   ===================================================================== */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 1.35rem;
    color: var(--text-color);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.user-menu-btn:hover {
    background: var(--dropdown-hover);
    border-color: var(--primary-color);
    color: var(--text-color);
}

.user-menu-btn #user-label {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.user-menu-btn .user-menu-caret {
    font-size: 1rem;
    opacity: 0.7;
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 235px;
    /* Bottom padding is smaller than the top because the last row already
       carries 10px of its own padding - this makes the two gaps match. */
    padding: 8px 8px 4px;
    background: var(--dropdown-bg);
    color: var(--text-color);
    border: 1px solid var(--dropdown-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
}

.user-dropdown .ud-head {
    padding: 6px 10px 10px;
    border-bottom: 1px solid var(--dropdown-border);
    margin-bottom: 8px;
}

.user-dropdown .ud-name {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
}

.user-dropdown .ud-role {
    font-size: 11.5px;
    color: var(--dropdown-muted);
    line-height: 1.4;
    margin-top: 3px;
}

/* Both actions share one row style so the menu reads as a single list.
   Only the text colour distinguishes them. */
.user-dropdown a.ud-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    line-height: 1;
    text-decoration: none;
    color: inherit;
}

.user-dropdown a.ud-item i {
    font-size: 1.05rem;
    line-height: 1;
    width: 1.1rem;
    flex: 0 0 1.1rem;
    text-align: center;
}

.user-dropdown a.ud-item:hover { background: var(--dropdown-hover); }

.user-dropdown a.ud-item.ud-admin {
    font-weight: 700;
    color: var(--dropdown-accent);
}

.user-dropdown a.ud-item.ud-danger {
    color: var(--dropdown-danger);
    margin-top: 2px;
}
.user-dropdown a.ud-item.ud-danger:hover { background: rgba(239, 68, 68, 0.16); }

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th, .data-table td {
    /* Narrower gutters and wrapping cells, so a table fits the space it is given
       instead of forcing the page sideways. */
    padding: 0.7rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    overflow-wrap: anywhere;
}

.data-table th {
    background-color: rgba(15, 23, 42, 0.6);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-color);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

/* Fix dropdown options coloring in dark mode */
.form-control option {
    background: #1e293b;
    color: #f8fafc;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    animation: slideUp 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

/* Scrollbar customization for dark mode */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color); 
}
::-webkit-scrollbar-thumb {
    background: #475569; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #64748b; 
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Utilities */
.text-primary { color: var(--primary-color); }
.text-success { color: #34d399; }
.text-danger { color: #f87171; }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.bg-light { background-color: rgba(30, 41, 59, 0.5); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 1rem; }
.summary-line { display: flex; justify-content: space-between; padding: 0.25rem 0; }


/* =====================================================================
   ROLE DASHBOARDS, ENTRY FORMS, WORK LOGS
   Uses the existing theme tokens only - no new palette.
   ===================================================================== */

.date-stamp {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--sidebar-active-bg);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    white-space: nowrap;
}
.date-stamp b { color: var(--sidebar-active-text); }

/* Banner shown above an entry form while an existing entry is being edited */
.entry-edit-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: var(--sidebar-active-bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-color);
}

.entry-edit-banner i { color: var(--primary-color); }

.entry-edit-banner .btn-secondary {
    margin-left: auto;
    padding: 0.3rem 0.85rem;
    font-size: 0.8rem;
}

.card-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.card-head-row h3 { margin: 0; }

/* KPI tiles */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}
.kpi-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.1rem 1.25rem;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}
.kpi-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
}
.kpi-value {
    font-size: 1.9rem;
    font-weight: 700;
    margin-top: 0.4rem;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.kpi-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

/* Entry form grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.form-grid .fg { display: flex; flex-direction: column; gap: 0.4rem; }
.form-grid .fg.full { grid-column: 1 / -1; }
.form-grid label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 0.65rem 0.8rem;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 0.9rem;
    font-family: inherit;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
.form-grid textarea { resize: vertical; }
.input-pair { display: flex; gap: 0.5rem; }
.input-pair input { flex: 2; }
.input-pair select { flex: 1; min-width: 80px; }
.form-actions { flex-direction: row !important; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

/* Small helper line under a form control (e.g. "not listed? add one") */
.fg-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.fg-hint a {
    color: var(--sidebar-active-text);
    font-weight: 600;
    text-decoration: none;
}
.fg-hint a:hover { text-decoration: underline; }

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}
.filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}
.filter-bar input[type="date"] {
    padding: 0.55rem 0.7rem;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    font-family: inherit;
}

/* Status pills */
.pill {
    display: inline-block;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}
.pill-ok   { background: rgba(34, 197, 94, 0.16);  color: #4ade80; }
.pill-warn { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.pill-bad  { background: rgba(239, 68, 68, 0.16);  color: #f87171; }
.pill-info { background: rgba(99, 102, 241, 0.16); color: #a5b4fc; }
/* Domestic customers - present in the table but not shouted about. */
.pill-neutral { background: rgba(148, 163, 184, 0.16); color: var(--text-muted); }

/* Price-age badge under the price it describes in the product list. Only the
   rows that need attention render one, so this line is often absent entirely. */
.price-age { margin-top: 0.3rem; }
.price-age .pill { white-space: nowrap; }

/* Roll-up on a collapsed family header, where the individual price badges are
   still hidden inside the group. */
.price-age-summary { white-space: nowrap; }
.price-age-summary .pill { margin-left: 0.4rem; }

/* Stale-price warning on a quotation line: empty until a price is actually due,
   so a normal line carries no clutter. */
.ol-price-age { font-size: 0.78rem; line-height: 1.4; }
.ol-price-age:empty { display: none; }
.ol-price-age.warn { color: #fbbf24; margin-top: 0.35rem; }
.ol-price-age.bad { color: #f87171; margin-top: 0.35rem; }

.muted-sm { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Products Master: sortable price columns and the per-product supplier groups */
.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sortable:hover { color: var(--primary-color); }
.th-sortable i { font-size: 0.85em; opacity: 0.7; }
.group-row td {
    background: rgba(99, 102, 241, 0.08);
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}
.group-row .group-count { color: var(--text-muted); font-weight: 400; font-size: 0.8rem; }

/* Deal Costing Calculator: each section heading takes its own colour so the four
   steps are told apart at a glance. The icon inherits the heading colour. */
.sec-cargo h3 { color: var(--sec-cargo); }
.sec-logistics h3 { color: var(--sec-logistics); }
.sec-invest h3 { color: var(--sec-invest); }
.sec-pricing h3 { color: var(--sec-pricing); }
.sec-profit h3 { color: var(--sec-profit); }
.sec-offer h3 { color: var(--sec-offer); }
.sec-saved h3 { color: var(--sec-saved); }

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 2rem; opacity: 0.5; }
.empty-state p { margin: 0.5rem 0 0; font-size: 0.9rem; }

.btn-icon.danger { color: #f87171; }
.btn-icon.danger:hover { background: rgba(239, 68, 68, 0.14); }

/* =====================================================================
   RESPONSIVE / MOBILE
   ===================================================================== */

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .content-wrapper { padding: 1.25rem; }
}

@media (max-width: 768px) {
    /* Sidebar becomes an off-canvas drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 265px;
        max-width: 82vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1200;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, 0.6);
        backdrop-filter: blur(2px);
        z-index: 1100;
    }
    .sidebar-backdrop[hidden] { display: none; }

    .mobile-menu-btn { display: inline-flex !important; }

    .main-panel { width: 100%; }

    .topbar {
        height: auto;
        min-height: 60px;
        padding: 0.6rem 0.9rem;
        gap: 0.5rem;
        flex-wrap: nowrap;
    }
    .breadcrumb {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #user-label { display: none; }

    .content-wrapper { padding: 1rem 0.85rem 2.5rem; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }
    .page-header h2 { font-size: 1.15rem; }
    .page-header .btn-primary,
    .page-header .btn-secondary { width: 100%; justify-content: center; }

    /* Cards and tiles stack */
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
    .kpi-value { font-size: 1.45rem; }
    .kpi-card { padding: 0.85rem 0.9rem; }

    .form-grid { grid-template-columns: 1fr; gap: 0.85rem; }
    .card { padding: 1rem; }
    .card h3 { font-size: 1rem; }

    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar input[type="date"] { width: 100%; }

    .card-head-row { flex-direction: column; align-items: flex-start; }
    .date-stamp { font-size: 0.78rem; }

    /* Data tables now fit the width; nothing is parked off the right edge. */
    .data-table { min-width: 0; }
}

@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .user-menu { margin-left: 4px !important; }
}

/* Menu button. It is the phone drawer toggle and, on a desktop, the sidebar
   collapse toggle - so it is present at every width. */
.mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    padding: 0.4rem 0.55rem;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.2rem;
}


/* =====================================================================
   MOBILE REFINEMENTS
   Fixes overflow in the existing dashboard KPI cards and action bar so the
   whole app is usable one-handed on a phone.
   ===================================================================== */

@media (max-width: 768px) {
    /* KPI cards: icon on top, text below, no clipping */
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 0.7rem !important;
    }
    .kpi-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 0.9rem !important;
        gap: 0.5rem !important;
        min-width: 0 !important;
    }
    .kpi-card .kpi-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.1rem !important;
    }
    .kpi-card .kpi-info { min-width: 0; width: 100%; }
    .kpi-card .kpi-info h3 {
        font-size: 0.66rem !important;
        letter-spacing: 0.03em !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        line-height: 1.25;
        margin-bottom: 0.15rem !important;
    }
    .kpi-card .kpi-value {
        font-size: 1.15rem !important;
        overflow-wrap: anywhere;
        line-height: 1.2;
    }

    /* Action buttons stack full-width instead of overflowing */
    .quick-actions-bar {
        flex-direction: column !important;
        gap: 0.55rem !important;
    }
    .quick-actions-bar button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Dashboard cards and generic tables */
    .card { overflow: hidden; }
    .data-table th, .data-table td { padding: 0.6rem 0.5rem; font-size: 0.82rem; }

    /* Page headers keep their button usable */
    .page-header { width: 100%; }
    .page-header h2 { line-height: 1.25; }

    /* User dropdown must not run off the right edge */
    #user-menu-drop { right: 0 !important; left: auto !important; min-width: 185px !important; }
}

@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .content-wrapper { padding: 0.85rem 0.7rem 2.5rem; }
    .topbar { padding: 0.55rem 0.7rem; }
    .kpi-card .kpi-value { font-size: 1.05rem !important; }
}


/* =====================================================================
   MOBILE TABLE SCROLLING
   Existing dashboard/preview tables are not wrapped in a scroll container,
   so make the table itself scrollable on small screens instead of clipping.
   ===================================================================== */
@media (max-width: 768px) {
    .data-table {
        display: block;
        width: 100%;
    }
    .data-table tbody { display: table; width: 100%; }
    .data-table thead { display: table-header-group; }
    .data-table tr { display: table-row; }

    /* Tighter gutters so labels have room on narrow phones */
    .content-wrapper { padding: 0.9rem 0.75rem 2.5rem; }
    .kpi-card { padding: 0.75rem 0.7rem !important; }
    .kpi-card .kpi-info h3 { font-size: 0.62rem !important; }

    /* Give the top-bar icons comfortable touch targets */
    .topbar .btn-icon { padding: 0.35rem; }
    .user-menu { margin-left: 6px !important; }
}

@media (max-width: 360px) {
    .kpi-grid { grid-template-columns: 1fr !important; }
}

/* =====================================================================
   Master detail pages
   ---------------------------------------------------------------------
   A master's name in a list is a link into its own page, and that page
   shows the record's contact block, its numbers, and its activity.
   ===================================================================== */

/* The name itself is the click target; a dotted underline says so without
   competing with the header colours. */
.drill-name {
    cursor: pointer;
    border-bottom: 1px dotted currentColor;
    transition: opacity 0.15s ease;
}

.drill-name:hover {
    opacity: 0.75;
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.detail-stat {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-stat span {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.65;
}

.detail-stat strong {
    font-size: 1.35rem;
    line-height: 1.2;
}

/* Label on the left, value on the right, one row per field. */
.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row span {
    font-size: 0.85rem;
    opacity: 0.65;
}

.detail-row strong {
    font-size: 0.9rem;
    text-align: right;
    word-break: break-word;
}

/* A product with several suppliers starts closed: the header row shows one
   supplier, and clicking it reveals the rest. */
.group-row.group-clickable { cursor: pointer; }
.group-row.group-clickable:hover td { background: rgba(99, 102, 241, 0.18); }
.group-row .group-toggle { margin-right: 7px; font-size: 0.85rem; opacity: 0.75; }
.group-row .group-hint { color: var(--text-muted); font-size: 0.72rem; font-style: italic; }

/* Two-level grouping in Products Master: the product name is the top row, its
   variants sit indented beneath it, and supplier rows sit under those. */
.name-row.group-clickable { cursor: pointer; background: rgba(255, 255, 255, 0.05); }
.name-row.group-clickable:hover td { background: rgba(99, 102, 241, 0.22); }
.variant-row.group-clickable { cursor: pointer; }
.variant-row.group-clickable:hover td { background: rgba(99, 102, 241, 0.15); }
.variant-row td { padding-left: 2rem; }

/* The HSN code of a group, stated on its header so it can be read without
   expanding every group down to supplier level. Amber when nothing is filed
   yet, which is what makes the gaps findable. */
.hsn-tag { color: var(--text-muted); font-weight: 400; font-size: 0.78rem; }
.hsn-tag.hsn-unset { color: #fbbf24; }
.hsn-tag.hsn-mixed { font-style: italic; }

/* =====================================================================
   Needs Attention (dashboard)
   ---------------------------------------------------------------------
   A short list of things that need doing, each with a one-line reason and a
   button to the screen where it gets fixed.
   ===================================================================== */

.attention-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    border-left: 3px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 0.5rem;
}

.attention-row:last-child { margin-bottom: 0; }

.attention-text { min-width: 240px; flex: 1; }
.attention-text strong { display: block; margin-bottom: 2px; }

.attention-bad  { border-left-color: #f87171; background: rgba(248, 113, 113, 0.10); }
.attention-warn { border-left-color: #fbbf24; background: rgba(251, 191, 36, 0.10); }
.attention-ok   { border-left-color: #34d399; background: rgba(52, 211, 153, 0.10); }

.attention-note {
    margin-top: 0.6rem;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: 0.78rem;
}


/* =====================================================================
   Order fulfilment
   =====================================================================
   The stepper for an accepted order: shipment phases on one track, payment
   steps on another. A step is filled once it has been recorded, so the state
   of an order is readable without opening anything.
   ===================================================================== */

.fu-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1.4rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 1.4rem;
}

.fu-sum-item { display: flex; flex-direction: column; gap: 0.15rem; }
.fu-sum-item .k {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.fu-sum-item .v { font-size: 1.02rem; font-weight: 700; color: var(--text-color); }
.fu-sum-item.owed .v { color: #f0a04b; }
.fu-sum-item.clear .v { color: #4fd18b; }

.fu-track-head {
    margin: 1.6rem 0 0.7rem;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.fu-track-head:first-of-type { margin-top: 0.4rem; }

.fu-track { display: flex; flex-direction: column; }

.fu-step {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.7rem 0.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.fu-step:last-child { border-bottom: none; }

.fu-dot {
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    margin-top: 0.1rem;
}
.fu-step.done .fu-dot {
    background: rgba(79, 209, 139, 0.16);
    border-color: rgba(79, 209, 139, 0.5);
    color: #4fd18b;
}

.fu-body { flex: 1; min-width: 0; }
.fu-label { font-size: 0.92rem; color: var(--text-color); }
.fu-step.todo .fu-label { color: var(--text-muted); }
.fu-meta { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.15rem; }
.fu-meta strong { color: var(--text-color); font-weight: 600; }

.fu-act { flex: none; display: flex; gap: 0.4rem; align-items: center; }

.fu-editor {
    margin-top: 0.7rem;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: flex-end;
}
.fu-editor .f { display: flex; flex-direction: column; gap: 0.25rem; }
.fu-editor .f label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.fu-editor .f input {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 6px;
    padding: 0.42rem 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
}
.fu-editor .f input[type="date"] { min-width: 140px; }
.fu-editor .f input.amt { min-width: 120px; }
.fu-editor .f input.ref { min-width: 190px; }

/* Order status pills, used in the quotations list. */
.order-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border: 1px solid transparent;
}
.order-pill.issued    { background: rgba(255,255,255,0.08); color: var(--text-muted); }
.order-pill.confirmed { background: rgba(94,159,238,0.16); color: #7db4f5; border-color: rgba(94,159,238,0.4); }
.order-pill.sourcing  { background: rgba(94,159,238,0.16); color: #7db4f5; border-color: rgba(94,159,238,0.4); }
.order-pill.logistics { background: rgba(240,160,75,0.16); color: #f0a04b; border-color: rgba(240,160,75,0.4); }
.order-pill.customs   { background: rgba(240,160,75,0.16); color: #f0a04b; border-color: rgba(240,160,75,0.4); }
.order-pill.documents { background: rgba(167,123,240,0.16); color: #b79bf0; border-color: rgba(167,123,240,0.4); }
.order-pill.closed    { background: rgba(79,209,139,0.16); color: #4fd18b; border-color: rgba(79,209,139,0.4); }

/* Small inline action buttons used inside the fulfilment stepper. Deliberately
   compact so a row with four of them still fits the modal. */
.fu-btn {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.74rem;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.fu-btn:hover { background: rgba(255, 255, 255, 0.13); }
.fu-btn.go {
    background: rgba(94, 159, 238, 0.18);
    border-color: rgba(94, 159, 238, 0.45);
    color: #7db4f5;
}
.fu-btn.go:hover { background: rgba(94, 159, 238, 0.28); }
.fu-btn.danger { color: #f0837b; }
.fu-btn.danger:hover { background: rgba(240, 131, 123, 0.14); }

.hint { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }

/* Second line inside a table cell, used under the order status pill. */
.cell-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.22rem;
    white-space: nowrap;
}

/* Customer names are long; give the column room to wrap rather than squeezing
   every other column until the row overflows the card. */
#quotations-table td:nth-child(3) {
    max-width: 210px;
    white-space: normal;
    line-height: 1.35;
}

/* The sourcing and logistics block: three pickers and five text fields, laid
   out so it reads as one record rather than a form to fill in. */
.fu-ship { margin-bottom: 0.2rem; }

.fu-ship-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 0.7rem 0.9rem;
}

.fu-ship-grid .f { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.fu-ship-grid .f label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.fu-ship-grid .f input,
.fu-ship-grid .f select {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 6px;
    padding: 0.42rem 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
    width: 100%;
    min-width: 0;
}
.fu-ship-grid .f input::placeholder { color: var(--text-muted); opacity: 0.7; }

/* Documents attached to an order step - the buyer's PO on "Order confirmed",
   the supplier's quotation on "Sourcing". Sits inside the step row so the
   document lives with the thing it belongs to. */
.fu-attach {
    margin-top: 0.55rem;
    padding: 0.6rem 0.7rem;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.fu-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.28rem 0;
    font-size: 0.82rem;
    flex-wrap: wrap;
}
.fu-file i { color: var(--text-muted); flex: none; }
/* Underlined, not just tinted. A coloured filename with no underline did not
   read as a link, so people could not find the download. */
.fu-file a.fu-fname {
    color: #7db4f5;
    text-decoration: underline;
    word-break: break-all;
    cursor: pointer;
}
.fu-file a.fu-fname:hover { color: #a8cdfa; }
/* Note under a quotation line's margin controls. Mirrors the Deal Costing
   Calculator's note, including the warning state for a margin that cannot be
   met. Amber rather than red: the price is still usable, it just ignores the
   percentage until it is brought below 100. */
.ol-margin-note {
    font-size: .72rem;
    color: var(--text-muted);
    margin: 0 0 .5rem;
    line-height: 1.45;
}
.ol-margin-note.warn { color: #b45309; }

/* ---------------------------------------------------------------------
   Quotation line costing panel
   ---------------------------------------------------------------------
   The panel reuses the Costing Calculator's section cards - same classes,
   same headings, same order - so the two screens read as one thing. The cards,
   their surfaces and their section colours all come from the design system,
   which already defines them per theme; nothing about them is restated here.

   The one addition is the unit badge. It sits in a heading, so hard-coding a
   light pill for it would read wrongly on the dark and brand themes - it takes
   the theme's own muted ink and border instead. */
.badge-unit-type {
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

/* Groups the dashboard counters, so record totals and sourcing activity are not
   read as the same kind of number. The container is a block so each group owns a
   full row and its heading cannot sit beside another group's cards. */
.kpi-group { grid-column: 1 / -1; display: block; margin-bottom: 1.4rem; }
.kpi-group:last-child { margin-bottom: 0; }
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}
.kpi-group-title {
    margin: 1.25rem 0 .6rem;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.kpi-group-title:first-child { margin-top: 0; }

/* Procurement trends share the dashboard palette; SVG avoids a chart CDN dependency. */
.proc-performance { --proc-entries: #65c9fa; --proc-deals: #ffc479;
    --proc-suppliers: #6ee7a8; --proc-customers: #c4a7ff; min-width: 0; }
body.theme-light .proc-performance { --proc-entries: #0369a1; --proc-deals: #a34706;
    --proc-suppliers: #047857; --proc-customers: #6d28d9; }
.proc-performance .card-head-row { gap: .75rem; flex-wrap: wrap; }
.proc-trends { display: flex; gap: 1rem 2rem; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.proc-trend { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .85rem; }
.proc-legend-mark { display: inline-block; width: 1.5rem; border-top: 3px solid currentColor; }
.proc-legend-mark.proc-series-deals { border-top-style: dashed; }
.proc-series-entries { color: var(--proc-entries); }
.proc-series-deals { color: var(--proc-deals); }
.proc-series-suppliers { color: var(--proc-suppliers); }
.proc-series-customers { color: var(--proc-customers); }
.proc-trend-up { color: #69d9b3; }
.proc-trend-down { color: #ffabb0; }
.proc-trend-flat { color: var(--text-muted); }
body.theme-light .proc-trend-up { color: #047857; }
body.theme-light .proc-trend-down { color: #b91c1c; }
.proc-chart-scroll { overflow-x: auto; max-width: 100%; }
.proc-chart-scroll:focus-visible { outline: 2px solid var(--primary-color); }
/* The chart is drawn one user unit per pixel, so it must not be stretched: a
   cap keeps the axis text at the size the stylesheet sets instead of magnifying
   it on a wide card. Narrow cards scroll rather than shrink the labels. */
.proc-line-chart { display: block; width: 100%; max-width: 1180px; height: auto; margin: 0 auto; }
.proc-grid-line { stroke: var(--border-color); stroke-width: 1; }
.proc-axis-label, .proc-axis-caption { fill: var(--text-muted); font-size: 12px; }
.proc-axis-caption { font-weight: 600; }
.proc-partial-area { fill: var(--text-muted); opacity: .07; }
.proc-series-line { stroke: currentColor; stroke-width: 2.5; fill: none; }
.proc-series-line.proc-series-deals { stroke-dasharray: 7 4; }
.proc-point { fill: currentColor; stroke: var(--panel-bg); stroke-width: 1; }
.proc-point:focus { stroke: var(--text-color); stroke-width: 3; outline: none; }
.proc-point-label { fill: currentColor; font-size: 12px; font-weight: 600; }
.proc-chart-footnote, .proc-no-activity { font-size: .78rem; color: var(--text-muted); line-height: 1.5; }
.proc-swipe-hint { display: none; font-size: .75rem; color: var(--text-muted); }
.proc-chart-data { margin-top: .7rem; }
.proc-chart-data summary { cursor: pointer; color: var(--text-muted); font-size: .8rem; padding: .5rem 0; }
@media (max-width: 600px) {
    .proc-performance { padding: 1rem; }
    .proc-swipe-hint { display: block; }
    .proc-trends { flex-direction: column; gap: .7rem; }
    .proc-performance .date-stamp { white-space: normal; }
}

/* Search row above a master list. Shares the line with the record count, so a
   long list can be narrowed without hiding how many records exist. */
.master-list-toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .85rem;
}
.master-list-toolbar .form-control { flex: 1 1 16rem; min-width: 0; }
.master-list-toolbar .muted-sm { white-space: nowrap; }

/* Product sections use the active theme, including the navy/gold theme. */
.quotation-product-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.quotation-product-table td { padding: 0; border: 0; min-width: 0; }
.quotation-product-header { margin: 1.25rem 0 1rem; }
.quotation-section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quotation-product-inputs { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.35fr); gap: 1rem; }
.quotation-product-inputs .form-group { min-width: 0; margin: 0; }
.quotation-search { display: flex; gap: .5rem; margin-bottom: .5rem; }
.quotation-search > * { min-width: 0; flex: 1; }
.quotation-shipment-size { padding: .85rem; border: 1px solid rgba(59, 130, 246, .28); border-radius: var(--radius-md); background: rgba(59, 130, 246, .08); }
.quotation-container-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .8fr) minmax(90px, .55fr); gap: .5rem; align-items: center; }
.ol-container-note { margin-top: .45rem; color: #93c5fd; }
body.theme-light .quotation-shipment-size { background: #eff6ff; border-color: #bfdbfe; }
body.theme-light .ol-container-note { color: #2563eb; }
.quotation-product-header .form-control { width: 100%; min-width: 0; }
.quotation-line-total { display: grid; align-content: center; gap: .3rem; }
.quotation-line-total > strong { font-size: 1.4rem; }
.line-costing { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding-bottom: 1.5rem; color: var(--text-color); }
.line-costing > .card { min-width: 0; margin: 0 !important; background: var(--panel-bg); box-shadow: none; }
.line-costing > .card:last-child, .line-costing > .sec-offer, .line-costing > .sec-profit, .ol-empty-note { grid-column: 1 / -1; }
.line-costing .card > div[style*="grid"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)) !important; }
.line-costing h3 { font-size: 1.05rem; margin-bottom: .75rem; }
.line-costing .form-group, .line-costing .form-control { min-width: 0; width: 100%; }
.line-costing .summary-line { gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.line-costing .summary-line > :last-child { margin-left: auto; text-align: right; overflow-wrap: anywhere; }
.line-costing .muted-sm, .ol-empty-note { color: var(--text-muted); font-size: .85rem; line-height: 1.5; }
.quotation-sell-label { display: grid; gap: .5rem; margin: .8rem 0; font-weight: 600; }
.line-costing .ol-sell-kg { font-size: 1.5rem; padding: .7rem; border: 2px solid var(--sec-pricing); }
.line-costing .ol-use-margin { margin: .75rem 0 0; }
.line-costing .text-success { color: var(--sec-profit); }
.line-costing .text-danger { color: #fca5a5; }
.line-costing .text-primary, .line-costing .ol-lbl-sell-total { color: var(--sec-pricing) !important; }
body.theme-light .line-costing .text-danger { color: #b91c1c; }
body.theme-light .line-costing > .bg-light { background: #f8fafc; }
.line-costing .sec-profit .ol-lbl-profit-kg { font-size: 1.4rem; }
@media (max-width: 900px) {
    .quotation-product-inputs, .line-costing { grid-template-columns: minmax(0, 1fr); }
    .line-costing .card { padding: 1rem; }
    .line-costing .summary-line { font-size: 1rem !important; }
}

/* One selling-price input and the essential results; optional settings stay closed. */
.quotation-products [hidden] { display: none !important; }
.line-costing.quotation-simple { display: block; padding-bottom: 1.5rem; }
.quotation-simple > .quotation-price-summary { padding: 1.25rem; margin-bottom: .75rem !important; }
.quotation-price-summary h3 { color: var(--text-color); }
.cost-on-you-card { border-color: rgba(59, 130, 246, .42); background: linear-gradient(135deg, rgba(30, 64, 175, .22), rgba(14, 116, 144, .12)); }
.cost-on-you-card h3 { color: #93c5fd; }
.cost-on-buyer-card { border-color: rgba(245, 158, 11, .5); background: linear-gradient(135deg, rgba(146, 64, 14, .2), rgba(245, 158, 11, .1)); }
.cost-on-buyer-card h3 { color: #fbbf24; }
body.theme-light .cost-on-you-card { background: #eff6ff; border-color: #93c5fd; }
body.theme-light .cost-on-you-card h3 { color: #1d4ed8; }
body.theme-light .cost-on-buyer-card { background: #fffbeb; border-color: #f59e0b; }
body.theme-light .cost-on-buyer-card h3 { color: #b45309; }
.quotation-price-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; align-items: center; }
.quotation-cost-on-you-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.quotation-cost-on-buyer-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quotation-cost-note { margin: -.35rem 0 1rem; }
.cost-on-buyer-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; flex-wrap: wrap; }
.buyer-currency-select { min-width: 180px; margin: 0; }
.cost-on-you-main, .cost-on-buyer-card .quotation-price-entry { border: 1px solid rgba(59, 130, 246, .35); border-radius: var(--radius-md); padding: .85rem; background: rgba(59, 130, 246, .08); }
body.theme-light .cost-on-you-main, body.theme-light .cost-on-buyer-card .quotation-price-entry { background: #eff6ff; border-color: #bfdbfe; }
.quotation-metric { min-width: 0; display: grid; gap: .6rem; font-size: .85rem; color: var(--text-muted); }
.quotation-metric > span:first-child { line-height: 1.4; }
.quotation-metric > [class*="ol-lbl-"] { font-size: 1.35rem; font-weight: 700; color: var(--text-color); overflow-wrap: anywhere; }
.quotation-metric .text-success { color: var(--sec-profit); }
.quotation-metric .text-danger { color: #fca5a5; }
body.theme-light .quotation-metric .text-danger { color: #b91c1c; }
.quotation-price-entry { color: var(--text-color); font-weight: 600; }
.quotation-price-entry .ol-sell-kg { width: 100%; margin: 0; }
.quotation-simple-totals { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; border-top: 1px solid var(--border-color); padding-top: .8rem; margin-top: 1rem; color: var(--text-muted); font-size: .85rem; }
.quotation-simple-totals strong { color: var(--text-color); }
.quotation-simple .ol-empty-note { margin-top: .7rem; font-size: .8rem; }
.quotation-options { padding: .65rem .9rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); margin-bottom: .5rem; }
.quotation-options > summary { cursor: pointer; font-weight: 500; color: var(--text-muted); }
.quotation-options[open] > summary { color: var(--text-color); margin-bottom: .85rem; }
.quotation-options-body { display: grid; gap: 1rem; }
.quotation-options-body > .card { margin: 0 !important; min-width: 0; background: var(--panel-bg); box-shadow: none; }
.quotation-cost-options .quotation-options-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quotation-cost-options .sec-invest { grid-column: 1 / -1; }
.quotation-margin-options .quotation-options-body { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.quotation-margin-options .ol-margin-note { grid-column: 1 / -1; }
.quotation-simple .has-loss { border-color: #f87171; }
@media (max-width: 1000px) {
    .quotation-price-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .quotation-price-grid, .quotation-cost-options .quotation-options-body, .quotation-margin-options .quotation-options-body { grid-template-columns: minmax(0, 1fr); }
    .quotation-container-row { grid-template-columns: minmax(0, 1fr); }
    .quotation-price-summary { padding: 1rem !important; }
}

/* The at-a-glance pair under the Sale Price and Amount cells. Small and muted
   so the table keeps its proportions - these annotate the figures above them
   rather than becoming figures in their own right. */
.ol-per-kg,
.ol-profit-hint {
    font-size: .68rem;
    line-height: 1.3;
    margin-top: .15rem;
    white-space: nowrap;
}
.ol-per-kg { color: var(--text-muted); }
.ol-profit-hint { font-weight: 600; }
/* Read on the page background, not the white panel, so the light-theme greens
   and reds stay legible here. */
.ol-profit-hint.text-success { color: #6ee7b7; }
.ol-profit-hint.text-danger { color: #fca5a5; }
body.theme-light .ol-profit-hint.text-success { color: #047857; }
body.theme-light .ol-profit-hint.text-danger { color: #b91c1c; }
/* The button form of the same link. */
.fu-file a.fu-btn { text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.fu-file .muted-sm { margin-right: auto; }
.fu-file .fu-btn { flex: none; }

.fu-attach-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
