/* ===================================================================
   Diamond Step BMS — Main Stylesheet
   Brand: dark navy #1a3a5c, gold accent #d4a017
   =================================================================== */

/* --- Variables ---------------------------------------------------- */
:root {
    --navy:          #1a3a5c;
    --navy-dark:     #0d2137;
    --navy-mid:      #224a72;
    --navy-light:    #2d5986;
    --gold:          #d4a017;
    --gold-light:    #f0c040;

    --bg:            #f0f4f8;
    --surface:       #ffffff;
    --surface-hover: #f7f9fc;
    --border:        #dde3eb;

    --text:          #1a2332;
    --text-mid:      #374151;
    --text-muted:    #6b7a8d;

    --success:       #15803d;
    --success-bg:    #dcfce7;
    --warning:       #b45309;
    --warning-bg:    #fef3c7;
    --danger:        #dc2626;
    --danger-bg:     #fee2e2;
    --info:          #1d4ed8;
    --info-bg:       #dbeafe;
    --purple:        #7c3aed;
    --purple-bg:     #ede9fe;
    --teal:          #0f766e;
    --teal-bg:       #ccfbf1;

    --sidebar-w:     240px;
    --topbar-h:      60px;
    --radius:        8px;
    --radius-sm:     4px;
    --shadow:        0 1px 4px rgba(0,0,0,.08), 0 2px 12px rgba(0,0,0,.06);
    --shadow-lg:     0 4px 24px rgba(0,0,0,.12);

    --transition:    180ms ease;
}

/* --- Reset -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 15px; }
body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

/* --- Typography --------------------------------------------------- */
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm      { font-size: .85rem; }
.text-right   { text-align: right; }
.fw-bold      { font-weight: 600; }

/* ===================================================================
   LOGIN PAGE
   =================================================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--navy-dark) 0%, var(--navy-light) 100%);
    padding: 24px;
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 48px 40px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo-mark {
    width: 72px;
    height: 72px;
    background: var(--navy);
    color: var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0 auto 16px;
    letter-spacing: 1px;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--navy);
    margin-bottom: 4px;
}

.login-header p {
    font-size: .85rem;
    color: var(--text-muted);
}

.login-footer-note {
    margin-top: 28px;
    text-align: center;
    font-size: .8rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ===================================================================
   APP SHELL
   =================================================================== */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar ------------------------------------------------------ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--navy);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 18px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-mark {
    width: 38px;
    height: 38px;
    background: var(--gold);
    color: var(--navy-dark);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: .5px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.brand-name {
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    color: rgba(255,255,255,.5);
    font-size: .72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-section-label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
    padding: 16px 18px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255,255,255,.7);
    font-size: .9rem;
    transition: background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
    position: relative;
}

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

.nav-link.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: var(--gold);
    font-weight: 600;
}

.nav-link svg { flex-shrink: 0; opacity: .8; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.1);
    padding: 14px 18px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--navy-light);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    color: #fff;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: rgba(255,255,255,.45);
    font-size: .72rem;
    text-transform: capitalize;
}

.btn-logout {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.5);
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: color var(--transition), background var(--transition);
}

.btn-logout:hover {
    color: #fff;
    background: rgba(255,255,255,.1);
}

/* --- Main area ---------------------------------------------------- */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--navy); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ===================================================================
   BUTTONS
   =================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.2;
    transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
    white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}
.btn-primary:hover:not(:disabled) {
    background: var(--navy-dark);
}

.btn-gold {
    background: var(--gold);
    color: var(--navy-dark);
    border-color: var(--gold);
}
.btn-gold:hover:not(:disabled) { background: var(--gold-light); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost {
    background: transparent;
    color: var(--text-mid);
    border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* ===================================================================
   FORM ELEMENTS
   =================================================================== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-mid);
    margin-bottom: 5px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(45,89,134,.15);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7a8d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===================================================================
   ALERTS
   =================================================================== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 12px;
    border: 1px solid;
}
.alert-error   { background: var(--danger-bg);  border-color: #fca5a5; color: #991b1b; }
.alert-success { background: var(--success-bg); border-color: #86efac; color: #166534; }
.alert-warning { background: var(--warning-bg); border-color: #fcd34d; color: #92400e; }
.alert-info    { background: var(--info-bg);    border-color: #93c5fd; color: #1e40af; }
.hidden { display: none !important; }

/* ===================================================================
   CARDS
   =================================================================== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
}

.card-title { font-size: 1rem; font-weight: 700; color: var(--navy); }

.card-body { padding: 20px; }

/* ===================================================================
   STAT CARDS (dashboard)
   =================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow);
}

.stat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.navy   { background: rgba(26,58,92,.12); color: var(--navy); }
.stat-icon.gold   { background: rgba(212,160,23,.15); color: #a07212; }
.stat-icon.green  { background: var(--success-bg); color: var(--success); }
.stat-icon.red    { background: var(--danger-bg); color: var(--danger); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1;
    margin-top: 12px;
}

.stat-label {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===================================================================
   STAGE BADGES ROW (dashboard)
   =================================================================== */
.stages-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow);
}

.stage-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition);
    border: 1px solid transparent;
}

.stage-chip:hover { opacity: .8; }
.stage-chip .chip-count {
    background: rgba(0,0,0,.12);
    border-radius: 10px;
    padding: 0 6px;
    font-size: .75rem;
    min-width: 20px;
    text-align: center;
}

.stage-chip.draft     { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.stage-chip.sent      { background: var(--info-bg); color: var(--info); border-color: #93c5fd; }
.stage-chip.follow_up { background: var(--warning-bg); color: var(--warning); border-color: #fcd34d; }
.stage-chip.approved  { background: var(--success-bg); color: var(--success); border-color: #86efac; }
.stage-chip.invoiced  { background: var(--purple-bg); color: var(--purple); border-color: #c4b5fd; }
.stage-chip.paid      { background: var(--teal-bg); color: var(--teal); border-color: #5eead4; }
.stage-chip.disqualified { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }

/* ===================================================================
   QUICK ACTIONS
   =================================================================== */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

/* ===================================================================
   TABLES
   =================================================================== */
.table-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.table-card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--navy);
}

.data-table { width: 100%; }

.data-table th {
    background: #f8fafc;
    padding: 10px 16px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 11px 16px;
    font-size: .875rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

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

.data-table tbody tr:hover td { background: var(--surface-hover); }

.data-table .col-amount { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.data-table .col-actions { text-align: right; white-space: nowrap; }

/* ===================================================================
   BADGES
   =================================================================== */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-blue   { background: var(--info-bg); color: var(--info); }
.badge-amber  { background: var(--warning-bg); color: var(--warning); }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-red    { background: var(--danger-bg); color: var(--danger); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-teal   { background: var(--teal-bg); color: var(--teal); }
.badge-navy   { background: rgba(26,58,92,.1); color: var(--navy); }

/* ===================================================================
   OVERDUE ALERT BLOCK
   =================================================================== */
.overdue-section {
    margin-bottom: 24px;
}

.overdue-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--danger-bg);
    border: 1px solid #fca5a5;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 10px 16px;
    font-size: .875rem;
    font-weight: 700;
    color: #991b1b;
    border-bottom: none;
}

/* ===================================================================
   LOADING & EMPTY STATES
   =================================================================== */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 60px 20px;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--navy);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state p { font-size: .95rem; }

/* ===================================================================
   TOAST NOTIFICATIONS
   =================================================================== */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    z-index: 9999;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    max-width: 360px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s ease, transform .25s ease;
}

.toast-show { opacity: 1; transform: translateY(0); }
.toast-info    { background: var(--navy); color: #fff; }
.toast-success { background: #166534; color: #fff; }
.toast-error   { background: #991b1b; color: #fff; }
.toast-warning { background: #92400e; color: #fff; }

/* ===================================================================
   SEARCH BAR
   =================================================================== */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    max-width: 320px;
}

.search-input-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    outline: none;
    transition: border-color var(--transition);
}

.search-input:focus { border-color: var(--navy-light); }

/* ===================================================================
   FILTER TABS
   =================================================================== */
.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
}

.filter-tab {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
}

.filter-tab:hover { background: var(--surface-hover); color: var(--text); }
.filter-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ===================================================================
   PAGE HEADER
   =================================================================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 { font-size: 1.25rem; color: var(--navy); }

/* ===================================================================
   CLIENT / DETAIL INFO GRID
   =================================================================== */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:nth-last-child(-n+2):not(.info-row-full) { border-bottom: none; }
.info-row:last-child { border-bottom: none; }

.info-row-full {
    grid-column: 1 / -1;
}

.info-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .info-grid { grid-template-columns: 1fr; }
    .info-row:last-child { border-bottom: none; }
}

/* ===================================================================
   TWO-COLUMN DASHBOARD GRID
   =================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
    .login-card { padding: 32px 24px; }
}

/* ===================================================================
   MISC
   =================================================================== */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.money { font-weight: 700; font-variant-numeric: tabular-nums; }
.money-receive { color: var(--success); }
.money-pay { color: var(--danger); }
.overdue-row td { color: var(--danger) !important; }
.row-overdue td { color: var(--danger); }
.nowrap { white-space: nowrap; }

/* ===================================================================
   BUTTON VARIANTS (Phase 4 additions)
   =================================================================== */
.btn-success {
    background: var(--success);
    color: #fff;
    border: 1px solid var(--success);
}
.btn-success:hover { background: #166534; }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border: 1px solid var(--danger);
}
.btn-danger:hover { background: #b91c1c; }

.btn-danger-ghost {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--border);
}
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger); }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    cursor: pointer;
    padding: 0;
}
.btn-icon:hover { background: var(--danger-bg); color: var(--danger); }

/* ===================================================================
   BREADCRUMB
   =================================================================== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--navy); }
.breadcrumb a:hover { text-decoration: underline; }
.bc-sep { color: var(--border); }

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ===================================================================
   STAGE BAR  (quote/invoice status + action buttons)
   =================================================================== */
.stage-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.stage-bar-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stage-label-text {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.stage-bar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===================================================================
   QUOTE DETAIL LAYOUT
   =================================================================== */
.quote-detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 960px) {
    .quote-detail-grid { grid-template-columns: 1fr; }
    .qd-right { order: -1; }
}

/* ===================================================================
   ITEMS TABLE (readonly — detail view)
   =================================================================== */
.items-table thead th {
    font-size: .78rem;
    padding: 10px 14px;
}
.items-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
}

/* ===================================================================
   TOTALS CARD
   =================================================================== */
.totals-card .card-body { padding: 16px 20px; }

.totals-grid { margin-bottom: 12px; }

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: .9rem;
}

.totals-row-total {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--navy);
}

.totals-divider {
    border-top: 1px solid var(--border);
    margin: 6px 0;
}

.amount-words {
    font-size: .8rem;
    color: var(--text-muted);
    font-style: italic;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    line-height: 1.4;
}

/* ===================================================================
   TERMS CARD
   =================================================================== */
.terms-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.terms-text {
    font-size: .83rem;
    color: var(--text-mid);
    line-height: 1.6;
    white-space: pre-line;
}

/* ===================================================================
   QUOTE FORM
   =================================================================== */
.quote-form-wrap { max-width: 960px; }

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.form-section-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.req-star { color: var(--danger); }

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 20px 0 8px;
}

.saving-text {
    font-size: .85rem;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ===================================================================
   CLIENT AUTOCOMPLETE
   =================================================================== */
.client-ac-wrap {
    position: relative;
}

.client-ac-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 260px;
    overflow-y: auto;
    z-index: 200;
}

.client-ac-dropdown.hidden { display: none; }

.ac-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    cursor: pointer;
    transition: background var(--transition);
    gap: 12px;
}

.ac-item:hover { background: var(--surface-hover); }

.ac-item-name {
    font-weight: 500;
    font-size: .9rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-item-sub {
    font-size: .78rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.ac-no-results {
    padding: 12px 14px;
    font-size: .85rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===================================================================
   LINE ITEMS EDITABLE TABLE
   =================================================================== */
.items-edit-card {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 0;
}

.items-edit-table thead th {
    font-size: .78rem;
    padding: 10px 10px;
    background: var(--navy);
    color: rgba(255,255,255,.85);
}

.items-edit-table tbody td {
    padding: 6px 6px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

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

.items-edit-table .form-control-sm {
    padding: 5px 8px;
    height: 34px;
    font-size: .85rem;
}

.items-add-row {
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface-hover);
}

/* ===================================================================
   VAT & TOTALS (form version)
   =================================================================== */
.vat-totals-wrap {
    display: flex;
    justify-content: flex-end;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
    padding-top: 16px;
}

.vat-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .9rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--navy);
}

.vat-pct-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.vat-pct-wrap.hidden { display: none; }

.totals-table {
    min-width: 280px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}

.totals-table .totals-row { font-size: .88rem; }
.totals-table .totals-row-total { font-weight: 700; color: var(--navy); font-size: 1rem; }
.totals-table .amount-words { font-size: .75rem; }

.vat-line.hidden { display: none; }

/* ===================================================================
   MODAL
   =================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 33, 55, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
    padding: 20px;
}

.modal-overlay.modal-open { opacity: 1; pointer-events: auto; }

.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(12px);
    transition: transform .22s ease;
}

.modal-overlay.modal-open .modal-box { transform: translateY(0); }

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

.modal-title { font-size: 1rem; font-weight: 700; color: var(--navy); }

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }

.modal-body { padding: 18px 22px; }
.modal-body p { font-size: .9rem; line-height: 1.6; color: var(--text-mid); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--border);
}

/* ===================================================================
   PAYMENT SUMMARY (invoice detail)
   =================================================================== */
.payment-summary-table { padding: 4px 0; }

.ps-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
}
.ps-row:last-child { border-bottom: none; }

.ps-row-balance { background: var(--surface-hover); }

.ps-label { font-size: .88rem; color: var(--text-mid); }
.ps-value  { font-size: .92rem; font-variant-numeric: tabular-nums; }

/* Stage bar overdue variant */
.stage-bar-overdue {
    border-color: var(--danger);
    background: #fff8f8;
}

/* ===================================================================
   SUPPLIER DETAIL
   =================================================================== */
.supplier-summary-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.ssb-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 20px 0 0;
}
.ssb-item:first-child { padding-left: 0; }

.ssb-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.ssb-value {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--navy);
}

.ssb-divider {
    width: 1px;
    height: 36px;
    background: var(--border);
    margin: 0 20px 0 0;
    flex-shrink: 0;
}

.supplier-detail-grid { display: block; }
.sd-left { max-width: 100%; }

/* ===================================================================
   BILLS TABLE
   =================================================================== */
.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.table-card-title {
    font-weight: 600;
    font-size: .92rem;
    color: var(--navy);
}

/* ===================================================================
   PHASE 8 — CSV IMPORT UI
   =================================================================== */
.import-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface);
    margin-bottom: 16px;
}
.import-zone:hover, .import-zone.drag-over {
    border-color: var(--navy-light);
    background: var(--surface-hover);
}
.import-zone-icon { font-size: 2rem; margin-bottom: 8px; color: var(--text-muted); }
.import-zone-text { font-size: .9rem; color: var(--text-muted); }
.import-zone-sub  { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

.import-results { margin-top: 12px; }
.import-stat-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.import-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 18px;
    text-align: center;
    min-width: 100px;
}
.import-stat-num  { font-size: 1.4rem; font-weight: 700; }
.import-stat-lbl  { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.import-stat.success .import-stat-num { color: var(--success); }
.import-stat.warning .import-stat-num { color: var(--warning); }
.import-stat.error   .import-stat-num { color: var(--danger); }

.import-errors {
    background: var(--danger-bg);
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    padding: 12px 16px;
    max-height: 200px;
    overflow-y: auto;
}
.import-error-row {
    font-size: .8rem;
    padding: 3px 0;
    color: var(--danger);
    border-bottom: 1px solid #fca5a5;
}
.import-error-row:last-child { border-bottom: none; }
