/* ================================================================
   Wrench — design system
   Mechanics accounting SaaS · dark warm workshop · amber accent
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ---------- Tokens --------------------------------------------------- */
:root {
    color-scheme: dark;

    /* Surfaces — warm charcoal workshop */
    --bg:            #13110E;
    --surface-1:     #1C1916;
    --surface-2:     #25211C;
    --surface-3:     #2E2922;
    --surface-hover: #2A251F;

    /* Borders */
    --border:        #2D2820;
    --border-strong: #3D362C;

    /* Text — warm off-white */
    --text:          #F2EEE6;
    --text-muted:    #948A7B;
    --text-subtle:   #6B6258;

    /* Accent — amber, automotive tool brand */
    --accent:        #F59E0B;
    --accent-hover:  #FBBF24;
    --accent-pressed:#D97706;
    --accent-soft:   rgba(245, 158, 11, 0.12);
    --accent-ring:   rgba(245, 158, 11, 0.30);
    --accent-text:   #FCD34D;

    /* Status */
    --success:       #10B981;
    --success-soft:  rgba(16, 185, 129, 0.12);
    --info:          #3B82F6;
    --info-soft:     rgba(59, 130, 246, 0.12);
    --danger:        #EF4444;
    --danger-soft:   rgba(239, 68, 68, 0.12);
    --warning:       #F59E0B;
    --warning-soft:  rgba(245, 158, 11, 0.12);

    /* Typography */
    --font: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

    /* Radii */
    --r-sm: 4px;
    --r:    8px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:    0 4px 12px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.4);

    /* Layout */
    --container: 1240px;
    --header-h:   64px;
}

/* ---------- Reset / base --------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    font-feature-settings: 'ss01', 'cv11', 'kern';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* Subtle ambient gradient backdrop — gives the app atmosphere without
   being a generic bluish-purple. Very low contrast. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(245, 158, 11, 0.06), transparent 60%),
        radial-gradient(800px 600px at 0% 0%, rgba(245, 158, 11, 0.03), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font);
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; line-height: 1.3; }
h3 { font-size: 1.0625rem; line-height: 1.4; }

p { margin: 0; }
a {
    color: var(--accent);
    text-decoration: none;
    transition: color 120ms ease;
}
a:hover { color: var(--accent-hover); }

code, kbd, samp, pre {
    font-family: var(--font-mono);
    font-size: 0.875em;
}
code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: var(--r-sm);
    color: var(--text);
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* ---------- Layout helpers ------------------------------------------- */
.app-container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}
@media (min-width: 768px) {
    .app-container { padding: 0 32px; }
}

.app-main {
    padding: 32px 0 64px;
}

/* Page header — title left, actions right */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.page-head h1 { margin: 0; }
.page-head .page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}
.page-head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- Navbar --------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(19, 17, 14, 0.85);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
}
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 24px;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: -0.01em;
}
.nav-brand:hover { color: var(--text); }
.nav-brand svg { color: var(--accent); }
.nav-links {
    display: none;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}
@media (min-width: 900px) {
    .nav-links { display: flex; }
}
.nav-links a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 7px 12px;
    border-radius: var(--r);
    transition: color 120ms ease, background 120ms ease;
}
.nav-links a:hover {
    color: var(--text);
    background: var(--surface-2);
}
.nav-links a.is-active {
    color: var(--text);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}
.nav-links a svg { opacity: 0.7; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.user-menu {
    position: relative;
}
.user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.user-trigger:hover { background: var(--surface-2); border-color: var(--border-strong); }
.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    border: 1px solid var(--accent-ring);
}
.user-menu-pop {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: none;
    z-index: 60;
}
.user-menu.is-open .user-menu-pop { display: block; }
.user-menu-pop a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--r);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
}
.user-menu-pop a:hover { background: var(--surface-2); color: var(--text); }
.user-menu-pop .menu-label {
    padding: 8px 10px 4px;
    color: var(--text-subtle);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Mobile menu button */
.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    cursor: pointer;
}
@media (min-width: 900px) { .nav-toggle { display: none; } }
.nav-toggle:hover { background: var(--surface-2); }

.mobile-menu {
    display: none;
    border-top: 1px solid var(--border);
    background: var(--surface-1);
    padding: 12px 16px 16px;
}
.mobile-menu.is-open { display: block; }
@media (min-width: 900px) { .mobile-menu { display: none !important; } }
.mobile-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mobile-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    padding: 10px 12px;
    border-radius: var(--r);
    font-weight: 500;
}
.mobile-menu a:hover, .mobile-menu a.is-active { background: var(--surface-2); }
.mobile-menu .menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* ---------- Buttons -------------------------------------------------- */
.btn {
    --btn-bg: var(--surface-2);
    --btn-fg: var(--text);
    --btn-bd: var(--border-strong);
    --btn-bg-hover: var(--surface-3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 14px;
    height: 38px;
    background: var(--btn-bg);
    color: var(--btn-fg);
    border: 1px solid var(--btn-bd);
    border-radius: var(--r);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: -0.005em;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    white-space: nowrap;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 60ms ease;
}
.btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.btn[disabled], .btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.btn svg { flex: 0 0 auto; }

.btn-sm  { height: 30px; padding: 0 10px; font-size: 0.8125rem; border-radius: var(--r-sm); }
.btn-lg  { height: 44px; padding: 0 18px; font-size: 0.9375rem; }
.btn-block { width: 100%; }

.btn-primary {
    --btn-bg: var(--accent);
    --btn-fg: #1A1208;
    --btn-bd: var(--accent);
    --btn-bg-hover: var(--accent-hover);
    font-weight: 600;
    box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 1px 2px rgba(0,0,0,0.2);
}
.btn-primary:hover { color: #1A1208; }

.btn-ghost {
    --btn-bg: transparent;
    --btn-fg: var(--text-muted);
    --btn-bd: transparent;
    --btn-bg-hover: var(--surface-2);
}
.btn-ghost:hover { color: var(--text); }

.btn-soft {
    --btn-bg: var(--surface-2);
    --btn-fg: var(--text);
    --btn-bd: var(--border);
    --btn-bg-hover: var(--surface-3);
}

.btn-info {
    --btn-bg: var(--info-soft);
    --btn-fg: #93C5FD;
    --btn-bd: rgba(59,130,246,0.3);
    --btn-bg-hover: rgba(59,130,246,0.2);
}

.btn-success {
    --btn-bg: var(--success);
    --btn-fg: #06281F;
    --btn-bd: var(--success);
    --btn-bg-hover: #34D399;
    color: #06281F;
    font-weight: 600;
}

.btn-danger {
    --btn-bg: var(--danger-soft);
    --btn-fg: #FCA5A5;
    --btn-bd: rgba(239,68,68,0.3);
    --btn-bg-hover: rgba(239,68,68,0.2);
}

.btn-warning {
    --btn-bg: var(--warning-soft);
    --btn-fg: var(--accent-text);
    --btn-bd: var(--accent-ring);
    --btn-bg-hover: rgba(245,158,11,0.2);
}

.btn-icon {
    width: 36px;
    padding: 0;
}
.btn-icon.btn-sm { width: 28px; }
.btn-icon.btn-lg { width: 44px; }

/* Button group */
.btn-group {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-group-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ---------- Forms ---------------------------------------------------- */
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- Combobox (category dropdown) --------------------------- */
.combobox { position: relative; }
.combo-list {
    display: none;
    position: absolute;
    z-index: 50;
    top: 100%;
    left: 0;
    right: 0;
    margin: 2px 0 0;
    padding: 4px 0;
    list-style: none;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    max-height: 200px;
    overflow-y: auto;
}
.combo-list li {
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    transition: background 80ms ease;
}
.combo-list li:hover,
.combo-list li.is-highlighted { background: var(--surface-hover); }
.combo-list li:active { background: var(--surface-3); }

label, .label {
    display: block;
    color: var(--text);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 6px;
    letter-spacing: -0.005em;
}
.help-text {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 6px;
    line-height: 1.4;
}
.help-text a { color: var(--accent); }

.input, .select select, .textarea {
    width: 100%;
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    padding: 0 12px;
    height: 38px;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.4;
    transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.textarea { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .select select:hover, .textarea:hover { border-color: #4A4238; }
.input:focus, .select select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
    background: var(--surface-1);
}
.input[readonly] {
    background: var(--surface-2);
    color: var(--text-muted);
}
.input[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.input-sm { height: 32px; font-size: 0.875rem; }

.input-mono { font-family: var(--font-mono); }
.input-upper { text-transform: uppercase; letter-spacing: 0.04em; }

/* Select wrapper */
.select {
    position: relative;
    display: block;
    width: 100%;
}
.select select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    cursor: pointer;
}
.select::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}
.select-sm select { height: 32px; font-size: 0.875rem; }

/* Select dropdown options — limited browser control but we set what we can */
option { background: var(--surface-1); color: var(--text); }

/* Input with leading/trailing icon */
.input-affix {
    position: relative;
    display: flex;
    align-items: center;
}
.input-affix svg {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}
.input-affix .input { padding-left: 36px; }
.input-affix .input.has-trailing { padding-right: 36px; }
.input-affix .trailing-icon {
    position: absolute;
    right: 8px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

/* Checkboxes / radios */
.checkbox, .radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}
.checkbox input, .radio input {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--surface-1);
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    flex: 0 0 auto;
    transition: background 120ms ease, border-color 120ms ease;
}
.radio input { border-radius: 50%; }
.checkbox input:checked, .radio input:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.checkbox input:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 0px;
    width: 5px;
    height: 9px;
    border: solid #1A1208;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.radio input:checked::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: #1A1208;
    border-radius: 50%;
}

/* ---------- Cards / boxes ------------------------------------------- */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-pad-lg { padding: 24px; }
.card-pad-sm { padding: 14px; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 20px; }
.card-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
    border-bottom-left-radius: var(--r-md);
    border-bottom-right-radius: var(--r-md);
}

/* Soft inset card for cost breakdowns, sidebar blocks */
.panel {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px;
}

/* ---------- Flash messages ------------------------------------------ */
.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}
.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--r);
    border: 1px solid;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}
.flash svg { flex: 0 0 auto; margin-top: 1px; }
.flash-success {
    background: var(--success-soft);
    color: #6EE7B7;
    border-color: rgba(16, 185, 129, 0.3);
}
.flash-error {
    background: var(--danger-soft);
    color: #FCA5A5;
    border-color: rgba(239, 68, 68, 0.3);
}
.flash-info {
    background: var(--info-soft);
    color: #93C5FD;
    border-color: rgba(59, 130, 246, 0.3);
}

/* Inline notice (within a card) */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r);
    background: var(--warning-soft);
    color: var(--accent-text);
    border: 1px solid var(--accent-ring);
    font-size: 0.875rem;
    line-height: 1.45;
}
.notice-success { background: var(--success-soft); color: #6EE7B7; border-color: rgba(16,185,129,0.3); }
.notice-info    { background: var(--info-soft);    color: #93C5FD; border-color: rgba(59,130,246,0.3); }
.notice-danger  { background: var(--danger-soft);  color: #FCA5A5; border-color: rgba(239,68,68,0.3); }

/* ---------- Tables -------------------------------------------------- */
.table-wrap {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    overflow-x: auto;
}
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data thead th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: var(--surface-hover); }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.data .mono { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-muted); }
.data .muted { color: var(--text-muted); }
.data .row-actions { text-align: right; white-space: nowrap; }
.data .row-actions .btn { margin-left: 4px; }
.data a { color: var(--text); font-weight: 500; }
.data a:hover { color: var(--accent); }

/* Compact table (for line items, cost breakdown) */
table.compact {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.compact th, .compact td {
    padding: 8px 12px;
    text-align: left;
}
.compact th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.compact td { border-bottom: 1px solid var(--border); }
.compact tbody tr:last-child td { border-bottom: 0; }
.compact .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Cost breakdown table (right-aligned) */
table.breakdown {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.breakdown td {
    padding: 8px 0;
    color: var(--text);
}
.breakdown td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.breakdown tr.divider td { border-top: 1px solid var(--border); padding-top: 12px; }
.breakdown tr.total td { font-weight: 700; font-size: 1rem; padding-top: 8px; }
.breakdown tr.grand td { font-weight: 700; font-size: 1.125rem; padding-top: 12px; }
.breakdown tr.grand td { border-top: 2px solid var(--border-strong); }
.breakdown tr.balance td { color: var(--accent-text); font-weight: 700; }
.breakdown tr.deposit td:last-child { color: var(--success); }

/* ---------- Badges / status pills ---------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.4;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}
.badge-quote {
    background: var(--warning-soft);
    color: var(--accent-text);
    border-color: var(--accent-ring);
}
.badge-invoice {
    background: var(--info-soft);
    color: #93C5FD;
    border-color: rgba(59,130,246,0.3);
}
.badge-paid {
    background: var(--success-soft);
    color: #6EE7B7;
    border-color: rgba(16,185,129,0.3);
}
.badge-voided {
    background: var(--danger-soft);
    color: #FCA5A5;
    border-color: rgba(239,68,68,0.3);
    text-decoration: line-through;
    text-decoration-color: rgba(239,68,68,0.5);
}
.badge-neutral {
    background: var(--surface-2);
    color: var(--text-muted);
    border-color: var(--border-strong);
}
.badge-dot-only { padding-left: 0; }
.badge-dot-only::before { margin: 0 4px; }

.badge-lg { font-size: 0.8125rem; padding: 5px 12px; }

/* ---------- Page-level search/filter row --------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.toolbar .toolbar-search {
    flex: 1 1 280px;
    min-width: 200px;
    max-width: 480px;
}
.toolbar .toolbar-spacer { flex: 1; }
.toolbar .toolbar-count {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-right: auto;
}

/* ---------- Empty states ------------------------------------------- */
.empty {
    text-align: center;
    padding: 48px 24px;
    background: var(--surface-1);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
}
.empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: var(--r);
    background: var(--surface-2);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.empty h3 {
    font-size: 1.0625rem;
    margin: 0 0 4px;
}
.empty p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 16px;
}

/* ---------- Pagination --------------------------------------------- */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.pager .pager-info {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-right: 12px;
}
.pager a, .pager span {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-radius: var(--r);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    background: transparent;
    border: 1px solid transparent;
}
.pager a:hover { background: var(--surface-2); color: var(--text); }
.pager .current {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
}
.pager .disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.pager .ellipsis { padding: 0 4px; }

/* ---------- Invoice view layout ------------------------------------ */
.invoice-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.invoice-head h1 {
    font-size: 1.875rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.invoice-head .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.invoice-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
}
@media (max-width: 960px) {
    .invoice-grid { grid-template-columns: 1fr; }
}

.kv-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px 16px;
    font-size: 0.9rem;
}
.kv-list dt { color: var(--text-muted); font-weight: 500; }
.kv-list dd { margin: 0; color: var(--text); }

.vin-specs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 24px;
    font-size: 0.8125rem;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.vin-specs .spec-label { color: var(--text-muted); }
.vin-specs .spec-value { color: var(--text); font-family: var(--font-mono); }

.action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ---------- Invoice form line items -------------------------------- */
.line-items-card .card-head {
    background: var(--surface-2);
}

.line-items-table {
    display: grid;
    gap: 8px;
}
.line-items-header {
    display: none;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    padding: 4px 12px;
}
@media (min-width: 900px) {
    .line-items-header { display: grid; }
}

.line-item-group {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 12px;
    position: relative;
    transition: border-color 120ms ease, background 120ms ease;
}
.line-item-group:focus-within {
    border-color: var(--accent-ring);
    background: var(--surface-2);
}
.line-item-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
@media (min-width: 900px) {
    .line-item-row {
        display: grid;
        grid-template-columns:
            90px              /* Type */
            minmax(130px, 1fr)  /* Service */
            minmax(160px, 1.6fr)  /* Description */
            80px              /* Hours (labor-only) */
            80px              /* Cost (parts-only) */
            60px              /* Qty */
            100px             /* Price */
            120px;            /* Actions */
        gap: 8px;
        align-items: center;
    }
}
.line-item-row > div { min-width: 0; }
.line-item-row .col-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}
@media (min-width: 900px) {
    .line-item-row .col-label { display: none; }
}

.line-item-row .actions {
    display: inline-flex;
    gap: 2px;
    align-items: center;
    justify-content: flex-end;
}
.line-item-row .actions .btn { width: 30px; height: 30px; padding: 0; }

.time-tracking-fields {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.time-tracking-fields.is-open { display: grid; }
@media (max-width: 899px) {
    .time-tracking-fields { grid-template-columns: 1fr; }
}
.time-tracking-fields .field { margin: 0; }

.line-items-add {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

/* Top of invoice form: customer + vehicle side by side */
.form-top-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 760px) {
    .form-top-grid { grid-template-columns: 1fr; }
}

/* ---------- Detail page header pattern ---------------------------- */
.detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.detail-head h1 {
    font-size: 1.75rem;
    letter-spacing: -0.02em;
    margin: 0 0 4px;
}
.detail-head .meta {
    color: var(--text-muted);
    font-size: 0.875rem;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.detail-head .meta strong { color: var(--text); font-weight: 600; }
.detail-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.section + .section { margin-top: 32px; }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-tight { display: flex; align-items: center; gap: 6px; }
.row-spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

.hide-mobile { display: none; }
@media (min-width: 600px) { .hide-mobile { display: initial; } }

.show-mobile { display: initial; }
@media (min-width: 600px) { .show-mobile { display: none; } }

/* ---------- Login page --------------------------------------------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    z-index: 1;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 8px;
    color: var(--accent);
}
.login-brand .brand-name {
    color: var(--text);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
}
.login-headline {
    text-align: center;
    margin-bottom: 24px;
}
.login-headline h1 {
    font-size: 1.375rem;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}
.login-headline p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* ---------- SMTP help collapsible (settings) -------------------- */
.smtp-help {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface-2);
    overflow: hidden;
}
/* Hide the default disclosure triangle across browsers */
.smtp-help > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--accent);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 120ms ease, color 120ms ease;
}
.smtp-help > summary::-webkit-details-marker { display: none; }
.smtp-help > summary::marker { display: none; content: ''; }
.smtp-help > summary::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") center/contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") center/contain no-repeat;
    flex-shrink: 0;
    transition: transform 160ms ease;
}
.smtp-help > summary:hover { background: rgba(245, 158, 11, 0.06); color: var(--accent-hover); }
.smtp-help[open] > summary { border-bottom: 1px solid var(--border); }
.smtp-help[open] > summary::before { transform: rotate(180deg); }
.smtp-help-body { padding: 6px 16px 16px; }
.smtp-provider {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.smtp-provider:last-child { border-bottom: 0; padding-bottom: 4px; }
.smtp-provider strong {
    display: block;
    margin-bottom: 2px;
    color: var(--text);
    font-size: 0.875rem;
}
.smtp-provider p { margin: 0 0 6px; font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.smtp-provider ol {
    margin: 8px 0 0;
    padding-left: 20px;
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.6;
}
.smtp-provider ol li { margin-bottom: 4px; }
.smtp-provider ol li::marker { color: var(--text-subtle); }
.smtp-provider code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--surface-1);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--accent-text);
    border: 1px solid var(--border);
}
.smtp-provider a { color: var(--accent); }
.smtp-provider a:hover { color: var(--accent-hover); }
.smtp-provider table.compact { font-size: 0.8rem; margin-top: 8px; }
.smtp-provider table.compact th { font-size: 0.65rem; }

/* ---------- Print stylesheet (browser-native print) --------------- */
@media print {
    :root {
        --bg: #fff; --surface-1: #fff; --surface-2: #fff;
        --text: #000; --text-muted: #555; --text-subtle: #888;
        --border: #ccc; --border-strong: #999;
    }
    body { background: #fff; color: #000; }
    body::before { display: none; }
    .app-header, .mobile-menu, .flash-stack, .action-bar, .btn, .navbar, .nav { display: none !important; }
    .card, .table-wrap { border-color: #ddd; box-shadow: none; background: #fff; }
    .badge { border: 1px solid #ccc; background: #fff; color: #000; }
    a { color: #000; }
    .app-main { padding: 0; }
    .app-container { max-width: none; padding: 0; }
}
