/* ITWorks brand variables (shared with the marketing site) */
:root {
    --itw-navy: #0E1B3D;
    --itw-navy-700: #15264F;
    --itw-cyan: #1FA9E1;
    --itw-cyan-600: #0F8DC2;
    --itw-light: #F5F7FA;
    --itw-muted: #6B7280;
}

html, body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

/* App bar */
.app-bar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.app-bar-brand { display: flex; align-items: center; gap: .6rem; }
.app-bar-logo { height: 22px; width: auto; }
.app-bar-title { font-weight: 700; letter-spacing: .02em; color: var(--mud-palette-appbar-text); }

/* Drawer */
.app-drawer .mud-drawer-content { display: flex; flex-direction: column; }

.drawer-brand {
    padding: 18px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.drawer-logo-card {
    display: block;
    background: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    line-height: 0;
}

.drawer-logo-card img { width: 100%; height: auto; }

.drawer-brand-text {
    color: var(--itw-cyan);
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    font-size: .72rem;
    padding-left: 2px;
}

.app-nav { padding: 4px 8px 16px; }

.app-nav .nav-section {
    color: rgba(199, 208, 224, .55);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    padding: 16px 12px 4px;
}

.app-nav .mud-nav-link { color: var(--mud-palette-drawer-text); border-radius: 8px; margin: 1px 0; }
.app-nav .mud-nav-link .mud-nav-link-icon { color: var(--mud-palette-drawer-icon); }
.app-nav .mud-nav-link:hover { background: rgba(255, 255, 255, .06); }
.app-nav .mud-nav-link.active { background: rgba(31, 169, 225, .18); color: #fff; }
.app-nav .mud-nav-link.active .mud-nav-link-icon { color: var(--itw-cyan); }
.app-nav .nav-count { height: 20px; margin: 0; }

/* Page */
.page-heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-heading h1 { margin: 0; }
.page-heading .subtitle { color: var(--mud-palette-text-secondary); margin-top: 2px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.stat-tile { height: 100%; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.stat-tile .stat-label { font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--mud-palette-text-secondary); }
.stat-tile .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-tile .stat-caption { font-size: .8rem; color: var(--mud-palette-text-secondary); }
.stat-tile .stat-icon { position: absolute; right: 14px; top: 14px; opacity: .18; }
.stat-tile.clickable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.stat-tile.clickable:hover { transform: translateY(-2px); box-shadow: var(--mud-elevation-4); }

.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.negative { color: var(--mud-palette-error); }
.text-right { text-align: right; }
.mud-table-cell.text-right, th.text-right { text-align: right !important; }
.cursor-pointer { cursor: pointer; }
.row-link tbody tr { cursor: pointer; }

/* Suggestion cards */
.suggestion-card { border-left: 4px solid var(--itw-cyan); }
.suggestion-card.kind-Payment { border-left-color: var(--mud-palette-success); }
.suggestion-card.kind-Invoice { border-left-color: var(--mud-palette-warning); }
.suggestion-card.kind-Customer, .suggestion-card.kind-Project { border-left-color: var(--itw-navy); }
.suggestion-card .rationale { background: var(--mud-palette-background-gray); border-radius: 6px; padding: 8px 12px; font-size: .875rem; }

/* Assistant */
.assistant-fab { position: fixed; right: 24px; bottom: 24px; z-index: 1200; }
/* Room to scroll the last row's action icons out from under the floating assistant button. */
.app-main > .mud-container { padding-bottom: 112px !important; }

.assistant-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 440px;
    max-width: calc(100vw - 32px);
    height: min(640px, calc(100vh - 120px));
    z-index: 1200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-thread { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 12px; flex: 1; }
.chat-bubble { max-width: 85%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; font-size: .9rem; line-height: 1.45; }
.chat-bubble.user { align-self: flex-end; background: var(--itw-cyan-600); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; background: var(--mud-palette-background-gray); border-bottom-left-radius: 4px; }
.chat-tools { display: flex; flex-wrap: wrap; gap: 4px; align-self: flex-start; }
.chat-composer { border-top: 1px solid var(--mud-palette-lines-default); padding: 8px 12px; display: flex; gap: 8px; align-items: flex-end; }
.chat-page .chat-thread { min-height: 50vh; max-height: calc(100vh - 300px); }

/* Upload drop zone */
.drop-zone { border: 2px dashed var(--mud-palette-lines-inputs); border-radius: 10px; padding: 28px 16px; text-align: center; transition: border-color .15s ease, background .15s ease; }
.drop-zone.dragging { border-color: var(--itw-cyan); background: rgba(31, 169, 225, .06); }

/* Auth pages (Bootstrap, static SSR) */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--itw-navy) 0%, var(--itw-navy-700) 100%); padding: 24px; }
.auth-card { background: #fff; border-radius: 12px; padding: 32px; width: 100%; max-width: 920px; box-shadow: 0 24px 50px rgba(0, 0, 0, .35); }
.auth-card h1 { color: var(--itw-navy); font-weight: 700; }
.auth-logo { display: block; width: 240px; margin: 0 auto 24px; }
.auth-logo img { width: 100%; height: auto; }
.auth-footer { color: #c7d0e0; font-size: .8rem; margin-top: 16px; }
.auth-card .btn-primary { background-color: var(--itw-cyan-600); border-color: var(--itw-cyan-600); }
.auth-card .btn-primary:hover { background-color: var(--itw-navy); border-color: var(--itw-navy); }
.auth-card a { color: var(--itw-cyan-600); }

/* Printable invoice */
.print-page { background: #fff; color: #111; font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; max-width: 860px; margin: 0 auto; padding: 40px 48px; }
.print-toolbar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 16px; }
.print-toolbar button, .print-toolbar a { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid #cfd5de; background: #fff; cursor: pointer; text-decoration: none; color: #111; }
.print-toolbar button.primary { background: var(--itw-cyan-600); border-color: var(--itw-cyan-600); color: #fff; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; border-bottom: 3px solid var(--itw-navy); padding-bottom: 20px; margin-bottom: 24px; }
.inv-head img { width: 220px; height: auto; }
.inv-title { font-size: 2rem; font-weight: 800; color: var(--itw-navy); letter-spacing: .04em; text-align: right; }
.inv-meta { text-align: right; font-size: .9rem; color: #444; }
.inv-meta div { margin-top: 2px; }
.inv-parties { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 24px; font-size: .92rem; }
.inv-parties h4 { margin: 0 0 6px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: #6B7280; }
.inv-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.inv-table th { text-align: left; background: var(--itw-light); color: var(--itw-navy); padding: 10px 8px; border-bottom: 2px solid #e0e4ea; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.inv-table td { padding: 10px 8px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.inv-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-totals { margin-left: auto; width: 320px; margin-top: 12px; font-size: .95rem; }
.inv-totals div { display: flex; justify-content: space-between; padding: 6px 8px; }
.inv-totals .grand { border-top: 2px solid var(--itw-navy); font-weight: 800; font-size: 1.1rem; color: var(--itw-navy); }
.inv-totals .due { background: var(--itw-light); border-radius: 6px; font-weight: 700; }
.inv-notes { margin-top: 28px; font-size: .9rem; color: #333; }
.inv-notes h4 { margin: 14px 0 4px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: #6B7280; }
.inv-footer { margin-top: 36px; text-align: center; color: #6B7280; font-size: .85rem; }
.inv-attachments { margin-top: 28px; padding-top: 16px; border-top: 1px solid #e5e7eb; font-size: .9rem; }
.inv-attachments h4 { margin: 0 0 6px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: #6B7280; }
.inv-attachments ul { margin: 0; padding-left: 18px; }
.inv-attachments li { margin: 4px 0; }
.inv-attachments a { color: var(--itw-cyan-600); }
.inv-attachments span { color: #6B7280; font-size: .8rem; margin-left: 6px; }
.shared-missing { text-align: center; padding: 64px 16px; color: #444; }
.shared-missing h1 { font-size: 1.4rem; color: var(--itw-navy); margin-bottom: 8px; }
.status-stamp { display: inline-block; border: 3px solid; border-radius: 6px; padding: 4px 12px; font-weight: 800; letter-spacing: .1em; transform: rotate(-6deg); }
.status-stamp.paid { color: #198754; border-color: #198754; }
.status-stamp.void { color: #dc3545; border-color: #dc3545; }
.status-stamp.draft { color: #6B7280; border-color: #6B7280; }

@media print {
    .print-toolbar { display: none; }
    .print-page { padding: 0; max-width: none; }
    body { background: #fff; }
}

/* Blazor */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem 1rem 1rem 3.7rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }
.darker-border-checkbox.form-check-input { border-color: #929292; }
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder { color: var(--bs-secondary-color); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { text-align: start; }

/* Login has its own layout so account management retains its existing shell. */
.login-shell { min-height: 100vh; min-height: 100dvh; background: #eef2f7; padding: 48px 24px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--itw-navy); }
.login-frame { display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 1080px; min-height: 680px; background: #fff; border: 1px solid #e0e6ef; border-radius: 24px; overflow: hidden; box-shadow: 0 20px 65px rgba(14, 27, 61, .09); }
.login-story { padding: 44px; display: flex; flex-direction: column; background: radial-gradient(ellipse at 100% 0%, #234d70, transparent 65%), var(--itw-navy); color: #fff; }
.login-brand { display: block; background: #fff; padding: 12px 18px; border-radius: 10px; width: 205px; }
.login-brand img { display: block; width: 100%; height: auto; }
.login-story-content { margin: 58px 0 40px; }
.login-eyebrow, .login-kicker { font-size: .7rem; font-weight: 700; letter-spacing: .17em; }
.login-eyebrow { color: #74d1f7; }
.login-story h2 { font-size: clamp(2rem, 3.5vw, 2.7rem); font-weight: 700; letter-spacing: -.045em; line-height: 1.15; margin: 16px 0 20px; }
.login-story-content > p { color: #c7d0e0; line-height: 1.7; font-size: .95rem; max-width: 360px; }
.login-features { display: grid; gap: 22px; margin-top: 36px; }
.login-features > div { display: flex; gap: 16px; }
.login-features > div > span { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border: 1px solid #42607c; border-radius: 9px; color: #74d1f7; font-size: .7rem; }
.login-features strong { font-size: .87rem; font-weight: 600; }
.login-features p { color: #c7d0e0; font-size: .8rem; line-height: 1.5; margin: 4px 0 0; }
.login-story-footer { margin-top: auto; font-size: .75rem; color: #c7d0e0; }
.login-panel { padding: 56px 48px; display: flex; align-items: center; }
.login-form-wrap { width: 100%; max-width: 360px; margin: auto; }
.login-kicker { color: #52657c; }
.login-panel h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.04em; margin: 12px 0; }
.login-intro { color: #617085; font-size: .9rem; margin-bottom: 32px; }
.login-field { margin-bottom: 20px; }
.login-field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 8px; }
.login-field .form-control { min-height: 50px; border: 1px solid #cbd4df; border-radius: 8px; font-size: .9rem; padding: 12px 14px; }
.login-field .form-control::placeholder { color: #768396; }
.login-field .form-control:focus { border-color: #0b6f99; box-shadow: 0 0 0 3px rgba(15, 141, 194, .15); }
.login-field .validation-message { font-size: .8rem; margin-top: 6px; }
.login-options { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-size: .78rem; margin: 4px 0 24px; }
.login-options label { display: flex; align-items: center; gap: 8px; color: #526176; }
.login-options .form-check-input { margin: 0; width: 16px; height: 16px; }
.login-panel a { color: #0b6f99; font-weight: 600; text-decoration: none; }
.login-panel a:hover { text-decoration: underline; }
.login-submit, .login-passkey { width: 100%; min-height: 50px; border-radius: 8px; font-size: .88rem; font-weight: 600; }
.login-submit { background: var(--itw-navy); color: #fff; display: flex; align-items: center; justify-content: center; gap: 16px; }
.login-submit:hover, .login-submit:active { background: #23436b; color: #fff; }
.login-divider { display: flex; align-items: center; gap: 14px; color: #617085; font-size: .75rem; margin: 24px 0; }
.login-divider::before, .login-divider::after { content: ''; height: 1px; flex: 1; background: #e0e6ef; }
.login-passkey { border: 1px solid #cbd4df; color: var(--itw-navy); background: #fff; }
.login-passkey:hover { border-color: #7c91aa; background: #f5f7fa; }
.login-shell a:focus-visible, .login-shell button:focus-visible, .login-shell input:focus-visible { outline: 3px solid #0b6f99; outline-offset: 3px; }
.login-help { border-top: 1px solid #e0e6ef; padding-top: 24px; margin: 32px 0 0; color: #617085; font-size: .78rem; line-height: 1.6; text-align: center; }
.login-footer { color: #617085; font-size: .75rem; margin-top: 24px; }
@media (max-width: 800px) {
    .login-shell { padding: 24px 16px; }
    .login-frame { grid-template-columns: 1fr; max-width: 480px; min-height: auto; border-radius: 16px; }
    .login-story { padding: 24px 28px; }
    .login-brand { width: 170px; }
    .login-story-content { margin: 24px 0 0; }
    .login-story h2 { font-size: 1.8rem; margin-bottom: 0; }
    .login-story-content > p, .login-features, .login-story-footer, .login-eyebrow { display: none; }
    .login-panel { padding: 36px 28px; }
}
@media (max-width: 380px) {
    .login-shell { padding: 12px; }
    .login-panel { padding: 28px 20px; }
}
