:root {
    --bg: #f4f7fb;
    --bg-soft: #eef3f9;
    --text: #172033;
    --muted: #667085;
    --card: #ffffff;
    --line: #e4e7ec;
    --brand: #0b1220;
    --brand-2: #14213d;
    --accent: #f97316;
    --accent-dark: #ea580c;
    --accent-soft: #fff7ed;
    --success: #079455;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(249, 115, 22, .08), transparent 32rem),
        linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
    color: var(--text);
    min-height: 100vh;
}
a { color: #1d4ed8; text-decoration: none; font-weight: 600; }
a:hover { color: var(--accent-dark); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(11, 18, 32, .96);
    color: white;
    padding: 12px 28px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
    backdrop-filter: blur(14px);
}
.brand {
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 205px;
}
.brand:hover { color: white; }
.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #fb923c);
    color: white;
    font-weight: 900;
    box-shadow: 0 10px 22px rgba(249, 115, 22, .28);
}
.brand strong { display: block; font-size: 16px; line-height: 1.05; letter-spacing: .2px; }
.brand small { display: block; color: #cbd5e1; font-size: 12px; margin-top: 2px; }
.main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.main-nav a {
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 700;
    padding: 9px 11px;
    border-radius: 999px;
    transition: background .15s ease, color .15s ease;
}
.main-nav a:hover { background: rgba(255, 255, 255, .10); color: white; }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-chip {
    color: #e5e7eb;
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.08);
    border-radius: 999px;
    padding: 8px 10px;
    font-size: 13px;
}
.nav-button {
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    padding: 8px 11px;
    font-size: 13px;
}
.nav-button:hover { background: var(--accent); }
.container { max-width: 1280px; margin: 34px auto; padding: 0 24px 42px; }
h1 { margin: 0 0 18px; font-size: clamp(30px, 4vw, 52px); line-height: 1; letter-spacing: -.04em; color: var(--text); }
h2 { margin: 22px 0 14px; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin: 0 0 24px; }
.card, .panel, .form-card {
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(228, 231, 236, .95);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card { position: relative; overflow: hidden; }
.card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--accent), #fdba74);
    opacity: .85;
}
.card span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 9px; }
.card strong { font-size: 26px; letter-spacing: -.03em; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.page-head p { margin: 8px 0 0; color: var(--muted); }
.button-group { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.button, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--brand);
    color: white;
    border: 0;
    border-radius: 12px;
    padding: 11px 16px;
    cursor: pointer;
    font-weight: 800;
    font-size: 14px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, .12);
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.button:hover, button:hover { color: white; background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 16px 28px rgba(15, 23, 42, .16); }
.button.secondary { background: #475467; }
.button.danger { background: var(--danger); padding: 8px 11px; font-size: 12px; }
.full-width { width: 100%; }

.table-wrap, .line-table-wrap { width: 100%; overflow-x: auto; }
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 12px 0 26px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .05);
}
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
    background: #f1f5f9;
    color: #344054;
    font-size: 13px;
    letter-spacing: .02em;
    text-transform: uppercase;
}
tr:nth-child(even) td { background: #fbfdff; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }

form p { display: grid; gap: 7px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-section { margin-bottom: 26px; }
.form-section h2 { margin: 0 0 14px; font-size: 21px; }
.form-field { display: grid; gap: 7px; }
.form-field label, form label { font-weight: 800; font-size: 13px; color: #475467; }
.span-2 { grid-column: span 2; }
input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(249, 115, 22, .12); }
input[type="checkbox"] { width: auto; }
textarea { min-height: 96px; }
.actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.compact { margin-bottom: 10px; }
.delete-holder { display: none; }
.line-table input, .line-table select { min-width: 105px; }
.line-table td { vertical-align: middle; }

.summary {
    background: linear-gradient(135deg, #fff7ed, #eef2ff);
    border: 1px solid #fed7aa;
    padding: 16px;
    border-radius: var(--radius);
    margin: 16px 0 24px;
}
.totals-panel { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; align-items: center; }
.totals-panel div { background: rgba(255,255,255,.62); border: 1px solid rgba(255,255,255,.8); border-radius: 14px; padding: 12px; }
.totals-panel span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 5px; }
.grand-total { font-size: 22px; }
.muted-summary { background: #f8fafc; border-color: #e5e7eb; color: var(--muted); }
.messages { margin-bottom: 18px; }
.message { background: #ecfdf3; border: 1px solid #abefc6; color: #067647; padding: 13px 14px; border-radius: 14px; margin-bottom: 10px; }
.message.error { background: #fef3f2; border-color: #fecdca; color: var(--danger); }
.form-errors, .field-errors { background: #fef3f2; border: 1px solid #fecdca; color: var(--danger); border-radius: 12px; padding: 10px; margin-top: 6px; font-size: 13px; }
.field-errors ul, .form-errors ul { margin: 0; padding-left: 18px; }
.report-filter { margin-bottom: 18px; }

/* Login */
.auth-page {
    background:
        radial-gradient(circle at top left, rgba(249, 115, 22, .28), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(20, 33, 61, .34), transparent 34rem),
        #0b1220;
    display: grid;
    place-items: center;
    padding: 28px;
}
.auth-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 30px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,.35);
    backdrop-filter: blur(16px);
}
.auth-hero {
    min-height: 620px;
    padding: 54px;
    color: white;
    background:
        linear-gradient(135deg, rgba(11,18,32,.94), rgba(20,33,61,.74)),
        radial-gradient(circle at 80% 20%, rgba(249,115,22,.28), transparent 22rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.auth-logo-placeholder, .mobile-logo-placeholder {
    border: 2px dashed rgba(255,255,255,.55);
    border-radius: 22px;
    color: #fed7aa;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 900;
    letter-spacing: .06em;
}
.auth-logo-placeholder { width: 150px; height: 110px; margin-bottom: 34px; }
.mobile-logo-placeholder { display: none; color: var(--accent); border-color: #fdba74; height: 74px; margin-bottom: 18px; }
.eyebrow { color: #fdba74; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
.auth-hero h1 { color: white; max-width: 440px; }
.auth-hero p:not(.eyebrow) { color: #d0d5dd; font-size: 18px; line-height: 1.6; max-width: 500px; }
.auth-feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 26px; max-width: 420px; }
.auth-feature-grid span { background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; padding: 13px; font-weight: 800; }
.auth-card { background: #fff; padding: 58px; display: flex; flex-direction: column; justify-content: center; }
.auth-card h2 { font-size: 34px; margin: 0 0 8px; }
.login-form { display: grid; gap: 18px; margin-top: 24px; }
.login-form input { padding: 14px; }

.brand-logo-img {
    width: 168px;
    height: 46px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    padding: 5px 8px;
    box-shadow: 0 10px 22px rgba(255,255,255,.08);
}
.vat-checkbox-cell { text-align: center; white-space: nowrap; }
.vat-checkbox-cell label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: #475467; }
.checkbox-input { width: 18px; height: 18px; accent-color: var(--accent); }
.line-vat, .line-total { text-align: right; white-space: nowrap; font-weight: 800; }
.auth-logo {
    width: min(360px, 100%);
    display: block;
    background: #fff;
    border-radius: 22px;
    padding: 16px;
    margin-bottom: 34px;
    box-shadow: 0 20px 46px rgba(0,0,0,.24);
}
.mobile-auth-logo {
    width: min(320px, 100%);
    display: none;
    background: #fff;
    border-radius: 18px;
    padding: 12px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
}

@media (max-width: 1050px) {
    .topbar { grid-template-columns: 1fr; align-items: start; }
    .brand { min-width: 0; }
    .main-nav { justify-content: flex-start; }
    .user-menu { justify-content: flex-start; }
}
@media (max-width: 800px) {
    .container { margin: 22px auto; padding: 0 14px 34px; }
    .page-head { align-items: stretch; flex-direction: column; }
    .button-group { justify-content: flex-start; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .totals-panel { grid-template-columns: 1fr; }
    th, td { padding: 12px; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-card { padding: 32px 24px; }
    .mobile-logo-placeholder { display: inline-flex; }
    .mobile-auth-logo { display: block; }
}

@media print {
    .topbar, .no-print, .button-group, button, .button { display: none !important; }
    body { background: white; color: #111; }
    .container { max-width: 100%; margin: 0; padding: 0; }
    .panel, .card, .form-card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    .card::before { display: none; }
    a { color: #111; text-decoration: none; }
    table { page-break-inside: auto; box-shadow: none; }
    tr { page-break-inside: avoid; page-break-after: auto; }
}

.verify-panel {
    background: linear-gradient(135deg, #ecfeff, #f8fafc);
    border-color: #67e8f9;
}
.verify-panel h2 { margin-top: 0; }
.hash-chip {
    background: #0b1220;
    color: #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    word-break: break-all;
}

/* Compact dropdown navigation */
.main-nav {
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
}
.main-nav > a,
.nav-dropdown > summary {
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 800;
    padding: 10px 13px;
    border-radius: 999px;
    line-height: 1;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary::after {
    content: "▾";
    font-size: 10px;
    margin-left: 7px;
    opacity: .8;
}
.main-nav > a:hover,
.nav-dropdown[open] > summary,
.nav-dropdown > summary:hover {
    background: rgba(255, 255, 255, .10);
    color: white;
}
.nav-dropdown {
    position: relative;
}
.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    min-width: 230px;
    background: #ffffff;
    border: 1px solid rgba(228, 231, 236, .95);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 24px 50px rgba(15, 23, 42, .22);
    z-index: 80;
}
.nav-dropdown-menu::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 22px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-left: 1px solid rgba(228, 231, 236, .95);
    border-top: 1px solid rgba(228, 231, 236, .95);
    transform: rotate(45deg);
}
.nav-dropdown-menu a {
    display: block;
    color: #172033;
    font-size: 14px;
    font-weight: 800;
    padding: 11px 12px;
    border-radius: 12px;
    white-space: nowrap;
}
.nav-dropdown-menu a:hover {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

@media (max-width: 1050px) {
    .main-nav {
        flex-wrap: wrap;
        justify-content: flex-start;
        width: 100%;
    }
    .nav-dropdown-menu {
        left: auto;
        right: 0;
    }
    .nav-dropdown-menu::before {
        left: auto;
        right: 24px;
    }
}

@media (max-width: 700px) {
    .topbar { padding: 12px 16px; }
    .main-nav > a,
    .nav-dropdown > summary {
        padding: 9px 11px;
        font-size: 13px;
    }
    .nav-dropdown {
        position: static;
    }
    .nav-dropdown-menu {
        position: static;
        width: 100%;
        margin: 6px 0 4px;
        background: rgba(255,255,255,.08);
        border-color: rgba(255,255,255,.14);
        box-shadow: none;
    }
    .nav-dropdown-menu::before { display: none; }
    .nav-dropdown-menu a {
        color: #e5e7eb;
    }
    .nav-dropdown-menu a:hover {
        color: #ffffff;
        background: rgba(255,255,255,.10);
    }
}

.hidden-field { display: none; }
.customer-search-field .customer-preview {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafc;
}
.customer-preview-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.customer-preview-head strong { font-size: 17px; color: var(--text); }
.customer-preview-head span {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
}
.customer-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}
.customer-preview-grid div {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
}
.customer-preview-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 4px;
}
.customer-preview-grid strong {
    display: block;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    white-space: pre-wrap;
}

/* Quote customer search polish: hide real select and keep preview clean even with cached/base styles. */
.customer-search-field .hidden-field,
.customer-search-field .hidden-field select {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
}
.customer-search-field #customer-search { margin-bottom: 0; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.warning { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
