/* ============================================================
   Endurance Enterprises — Hybrid ERP
   Design concept: a printed ledger — paper, carbon ink, one red, used
   only where something is a total or an alert. Zero border-radius. Same
   system as taxslab/assets/taxslab.css, so the two apps read as one
   product. Sticky topbar; navigation lives on the home page's menu.
   ============================================================ */

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

:root {
    /* Paper / carbon / red */
    --ink: #0E0E0E;
    --red: #DA251D;
    --red-hover: #c21f18;
    --red-dark: #a81a14;
    --red-glow: rgba(218, 37, 29, 0.28);
    --red-subtle: #fbe9e8;
    --red-border: #f0c4c1;

    --paper: #F4F4F4;
    --white: #FFFFFF;
    --rule: #DCDCDC;
    --muted: #6B6B6B;
    --faint: #B7B7B7;

    --font-display: 'Archivo', 'Arial Narrow', sans-serif;
    --font-mono: 'IBM Plex Mono', 'Consolas', monospace;

    --good: #1f7a4d;
    --good-bg: #e7f3ec;
    --warning: #a86a00;
    --warning-bg: #fbeed9;

    /* ---- Back-compat aliases: the old token names, mapped onto the
       system above, so a page not yet converted off them still renders
       correctly — flat, zero radius, no shadow, just under the new
       names' colours. ---- */
    --ground: var(--paper);
    --surface: var(--white);
    --surface-alt: #ececec;
    --border: var(--rule);
    --border-light: #e8e8e8;
    --text-primary: var(--ink);
    --text-secondary: var(--muted);
    --text-muted: var(--muted);
    --ink-surface: var(--ink);
    --ink-card: #1a1a1a;
    --ink-border: rgba(255, 255, 255, 0.08);
    --ink-muted: #9a9a9a;

    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;
    --radius-xl: 0;
    --shadow-sm: none;
    --shadow-card: none;
    --shadow-elevated: none;
    --shadow-red: none;

    color-scheme: light;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-display);
}

html, body {
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

/* ---------- MAIN LAYOUT WRAPPER ---------- */
.wrap, .wrapper {
    display: block;
    min-height: 100vh;
    width: 100%;
    background: var(--paper);
    position: relative;
}

/* ---------- MAIN CONTENT AREA ---------- */
.main, .main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--paper);
}

/* Topbar Header */
header.topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    background: rgba(244, 244, 244, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ink);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.topbar-brand-link {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.topbar-brand-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}
.breadcrumb-area {
    display: flex;
    flex-direction: column;
}
.breadcrumb {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 6px;
}
.breadcrumb .sep {
    color: var(--rule);
}
.page-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.3px;
    margin-top: 1px;
}
.page-sub {
    font-size: 12px;
    color: var(--muted);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--white);
    color: var(--good);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--rule);
}
.status-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--good);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--white);
    border: 1px solid var(--rule);
}
.topbar-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--white);
    font-weight: 800;
    font-size: 11px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.topbar-user-info {
    min-width: 0;
    line-height: 1.25;
}
.topbar-user-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.topbar-user-client {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--red);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.btn-logout {
    border-color: var(--red) !important;
    color: var(--red) !important;
}
.btn-logout:hover {
    background: var(--red) !important;
    color: var(--white) !important;
}

/* Main Content Body */
.content-body, .content {
    flex: 1;
    padding: 24px 28px 36px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1600px;
    width: 100%;
}

/* ---------- CARDS & CONTAINERS ---------- */
.container, .card {
    background: var(--white);
    border: 1px solid var(--rule);
    padding: 22px 24px;
    margin-bottom: 0;
    position: relative;
}

.card-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--paper);
}
.card-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--ink);
}
.card-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}
.card-body {
    padding: 18px 20px;
}

/* Action Toolbar */
.top-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--rule);
}
.top-buttons-left, .top-buttons-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- TABLES ---------- */
.table-scroll, .table-box, .fixTableHead, .table-container {
    overflow-x: auto;
    border: 1px solid var(--rule);
    background: var(--white);
    max-height: 540px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    min-width: 600px;
}

thead th, th {
    background: var(--ink);
    color: var(--white);
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    padding: 10px 14px;
    text-align: left;
    white-space: nowrap;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

td {
    padding: 9px 14px;
    vertical-align: middle;
    border: none;
    border-bottom: 1px solid var(--rule);
    color: var(--ink);
    white-space: nowrap;
}

tbody tr {
    background: var(--white);
    transition: background-color 0.15s ease;
}
tbody tr:nth-child(even) {
    background: #fafafa;
}
tbody tr:hover {
    background: var(--red-subtle) !important;
}

tr.row-total td, tfoot td {
    font-weight: 700;
    background: var(--ink) !important;
    color: var(--white);
    border-top: 3px solid var(--red);
    border-bottom: none;
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.right { text-align: right; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- FORM CONTROLS ---------- */
label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    display: block;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control, input[type=text], input[type=date], input[type=password],
input[type=search], select, textarea {
    height: 40px;
    border: 1px solid var(--rule);
    padding: 0 12px;
    width: 100%;
    font-size: 13px;
    font-weight: 500;
    background: var(--white);
    color: var(--ink);
    transition: border-color 0.15s ease;
}
textarea {
    height: auto;
    padding: 10px 12px;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--red);
    outline-offset: 1px;
    border-color: var(--red);
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.form-group {
    flex: 1;
    min-width: 160px;
}

/* Filter Column Box */
.filter-select-column {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    background: var(--paper);
    border: 1px solid var(--rule);
    padding: 16px 18px;
    margin-top: 14px;
    margin-bottom: 18px;
}
.filter-select-column > div {
    flex: 1;
    min-width: 160px;
}

/* ---------- BUTTONS ---------- */
.btn-save, button.btn-primary, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--white);
    background: var(--ink);
    border: 1px solid var(--ink);
    padding: 9px 20px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn-save:hover, button.btn-primary:hover, .btn:hover {
    background: var(--red);
    border-color: var(--red);
    transform: translateY(-1px);
    color: var(--white);
}

.btn-tertiary, .toggle-edit, .btn-unsave, .btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    background: var(--white);
    border: 1px solid var(--ink);
    padding: 8px 16px;
    cursor: pointer;
    text-decoration: none;
    color: var(--ink);
    transition: background 0.15s ease, color 0.15s ease;
}
.btn-tertiary:hover, .toggle-edit:hover, .btn-outline:hover {
    background: var(--ink);
    color: var(--white);
}

:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ---------- SUMMARY METRIC CARDS ---------- */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2px;
    background: var(--rule);
    margin-bottom: 22px;
}
.summary .card, .stat {
    background: var(--white);
    border: none;
    border-left: 4px solid var(--red);
    padding: 16px 18px;
}
.summary .card .label, .stat-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.summary .card .value, .stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.5px;
}
.stat.is-primary {
    border-left: 4px solid var(--red);
    background: var(--white);
}
.stat.is-total {
    border-left: 4px solid var(--ink);
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.stat-icon {
    font-size: 18px;
}
.stat-foot {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

/* Grid helper */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    background: var(--red-subtle);
    color: var(--red-dark);
    border: 1px solid var(--red-border);
}

/* Avatar badge in tables */
.party {
    display: flex;
    align-items: center;
    gap: 10px;
}
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--white);
    font-weight: 800;
    font-size: 11px;
    flex-shrink: 0;
    background: var(--ink);
}

/* ---------- FOOTER ---------- */
.site-footer {
    text-align: center;
    padding: 24px 0 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
    margin-top: auto;
    border-top: 1px solid var(--rule);
    background: rgba(255, 255, 255, 0.5);
}
.site-footer a {
    color: var(--red);
    text-decoration: none;
    font-weight: 700;
}
.site-footer a:hover {
    text-decoration: underline;
}

/* ---------- RESPONSIVE BREAKPOINTS ---------- */
@media (max-width: 900px) {
    .content-body, .content {
        padding: 16px 14px;
    }
    header.topbar {
        padding: 12px 16px;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    .summary {
        grid-template-columns: repeat(2, 1fr);
    }
    .top-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    .top-buttons a, .top-buttons button {
        width: 100%;
        text-align: center;
    }
    .status-pill span:last-child, .topbar-user-info {
        display: none;
    }
}

/* ---------- PRINT MODE ---------- */
@media print {
    .topbar, .top-buttons, .site-footer {
        display: none !important;
    }
    .main, .main-wrapper {
        padding: 0 !important;
        background: var(--white) !important;
    }
    .container, .card {
        border: 1px solid var(--ink) !important;
    }
}
