* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
    font-size: 16px;
    color: #1f2937;
    background: #f9fafb;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

.app-shell {
    min-height: 100vh;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

.app-header {
    background: #111827;
    color: white;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
}

.app-header-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.header-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
}

.header-brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1;
}

.header-app-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    background: linear-gradient(135deg, #a8d977 0%, #8ec455 50%, #6ba33a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-company-name {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.header-tip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.06);
    padding: 6px 12px;
    border-radius: 20px;
    min-width: 0;
    flex: 1;
    max-width: 280px;
}

.tip-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.tip-text {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: fade-in-tip 0.5s ease-out;
}

@keyframes fade-in-tip {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 400px) {
    .header-tip {
        display: none;
    }
}

.app-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px;
}

.bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    z-index: 50;
}

.bottom-nav-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    min-width: 56px;
    text-decoration: none;
    color: #6b7280;
    font-size: 11px;
    transition: color 0.15s;
}

    .nav-item:hover {
        color: #374151;
    }

    .nav-item.active {
        color: #2563eb;
    }

.nav-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

    .page-header h2 {
        font-size: 24px;
        font-weight: 700;
        color: #111827;
    }

.page-header-with-back {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

    .page-header-with-back h2 {
        font-size: 24px;
        font-weight: 700;
        color: #111827;
    }

.back-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    font-size: 22px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

    .back-btn:hover {
        color: #111827;
    }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.12s, transform 0.12s, background 0.15s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

    .btn:active:not(:disabled) {
        transform: scale(0.97);
        opacity: 0.9;
    }

/* Small — chips, inline actions */
.btn-sm {
    padding: 9px 18px;
    font-size: 13px;
    border-radius: 10px;
    min-height: 36px;
}

/* Medium — secondary actions */
.btn-md {
    padding: 13px 24px;
    font-size: 15px;
    min-height: 46px;
}

/* Large — primary actions, full-width */
.btn-lg {
    width: 100%;
    padding: 17px 24px;
    font-size: 16px;
    letter-spacing: 0.01em;
    min-height: 54px;
    border-radius: 14px;
}

.btn-tall {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    min-height: 56px;
    border-radius: 14px;
}

/* Responsive: on wider screens buttons get a bit larger */
@media (min-width: 400px) {
    .btn-lg {
        min-height: 56px;
        font-size: 17px;
    }

    .btn-sm {
        padding: 10px 20px;
    }
}

.btn-primary {
    background: #2563eb;
    color: white;
}

    .btn-primary:hover {
        background: #1d4ed8;
    }

.btn-green {
    background: #166534;
    color: white;
}

    .btn-green:hover {
        background: #14532d;
    }

.btn-outline {
    background: none;
    border: 2px solid #e5e7eb;
    color: #374151;
}

    .btn-outline:hover {
        border-color: #d1d5db;
        background: #f9fafb;
    }

.btn-outline-primary {
    background: none;
    border: 2px solid #2563eb;
    color: #2563eb;
}

    .btn-outline-primary:hover {
        background: #eff6ff;
    }

.btn-outline-green {
    background: none;
    border: 2px solid #166534;
    color: #166534;
}

    .btn-outline-green:hover {
        background: #f0fdf4;
    }

.btn-outline-danger {
    background: none;
    border: 2px solid #fca5a5;
    color: #dc2626;
}

    .btn-outline-danger:hover {
        background: #fef2f2;
    }

.btn-dashed {
    background: none;
    border: 2px dashed #d1d5db;
    color: #2563eb;
    font-weight: 600;
}

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

.card {
    background: white;
    border: 1px solid #f0f0f0;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: box-shadow 0.15s;
}

.card-clickable {
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    will-change: transform;
}

    .card-clickable:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 14px rgba(0,0,0,0.09);
        border-color: #e9eaec;
    }

    .card-clickable:active {
        transform: scale(0.985);
        box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }

.card-bordered {
    border-width: 2px;
}

.card-muted {
    background: #f9fafb;
}

.search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 16px;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    font-size: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    outline: none;
    background: white;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

    .search-input:focus {
        border-color: #2563eb;
    }

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-label-sm {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.form-hint-text {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

.form-input {
    width: 100%;
    padding: 13px 16px;
    font-size: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    outline: none;
    background: white;
    box-sizing: border-box;
    transition: border-color 0.15s;
    height: 44px;
}

    .form-input:focus {
        border-color: var(--profile-color, #8ec455);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--profile-color, #8ec455) 15%, transparent);
    }

.form-select {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    outline: none;
    background: white;
    box-sizing: border-box;
    height: 48px;
    cursor: pointer;
}

    .form-select:focus {
        border-color: var(--profile-color, #8ec455);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--profile-color, #8ec455) 15%, transparent);
    }

.form-textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    outline: none;
    background: white;
    box-sizing: border-box;
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

    .form-textarea:focus {
        border-color: var(--profile-color, #8ec455);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--profile-color, #8ec455) 15%, transparent);
    }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: capitalize;
}

.badge-draft {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-sent {
    background: #dbeafe;
    color: #2563eb;
}

.badge-accepted {
    background: #dcfce7;
    color: #166534;
}

.badge-paid {
    background: #d1fae5;
    color: #065f46;
}

.badge-cancelled {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-rejected {
    background: #fef3c7;
    color: #92400e;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    border-radius: 12px;
    padding: 16px;
    border: 1px solid;
}

.stat-card-blue {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.stat-card-green {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.stat-icon {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #6b7280;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 12px;
}

.list-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.list-card-name {
    font-weight: 700;
    color: #111827;
}

.list-card-sub {
    font-size: 14px;
    color: #6b7280;
    margin-top: 2px;
}

.list-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.list-card-amount {
    color: #2563eb;
    font-size: 18px;
    font-weight: 700;
    color: #2563eb;
}

.list-card-amount-green {
    font-size: 18px;
    font-weight: 700;
    color: #166534;
}

.list-card-date {
    font-size: 12px;
    color: #9ca3af;
}

.line-card {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.line-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.line-num {
    font-size: 12px;
    font-weight: 700;
    color: #9ca3af;
}

.line-remove {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
}

.line-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.line-total {
    text-align: right;
    font-size: 17px;
    font-weight: 700;
    color: #2563eb;
    margin-top: 10px;
}

.add-line-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.totals-card {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.totals-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 14px;
    color: #6b7280;
}

.totals-row-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    margin-top: 8px;
    border-top: 2px solid #e5e7eb;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

    .totals-row-total .total-amount {
        color: #2563eb;
    }

.tax-input {
    width: 56px;
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}

.actions-primary {
    display: flex;
    gap: 10px;
    margin-top: 28px;
    align-items: stretch;
}

.actions-secondary {
    margin-top: 12px;
}

.actions-danger {
    margin-top: 16px;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #9ca3af;
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.empty-state-text {
    font-size: 15px;
}

.space-y > * + * {
    margin-top: 12px;
}

.space-y-lg > * + * {
    margin-top: 24px;
}

.flex-1 {
    flex: 1;
}

.text-center {
    text-align: center;
}

.preview-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.preview-frame-container {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background: white;
}

.preview-frame {
    width: 100%;
    height: 80vh;
    border: none;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    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: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

/* ── Document Info Labels ──────────────────── */
.doc-meta-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.doc-meta-item {
    display: flex;
    flex-direction: column;
}

.doc-meta-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    font-weight: 600;
}

.doc-meta-value {
    font-size: 13px;
    color: #334155;
    font-weight: 500;
}

/* ── Relative Time in Cards ───────────────── */
.list-card-time {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
}

/* ── Unsaved Changes Bar ──────────────────── */
.unsaved-bar {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #92400e;
    font-weight: 500;
}

.unsaved-text {
    flex: 1;
    font-size: 13px;
    color: #92400e;
    font-weight: 500;
}

.unsaved-save-btn {
    background: #f59e0b;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}

    .unsaved-save-btn:hover:not(:disabled) {
        background: #d97706;
    }

    .unsaved-save-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.unsaved-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    flex-shrink: 0;
}

/* ── Quote number format presets ──────────────────── */
.format-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.format-preset-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    transition: all 0.15s;
    min-width: 90px;
}

    .format-preset-btn:hover {
        border-color: #8ec455;
    }

    .format-preset-btn.active {
        border-color: #8ec455;
        background: #f0fdf4;
        color: #3a6e1a;
    }

.format-preview {
    font-size: 10px;
    font-weight: 400;
    color: #9ca3af;
    font-family: monospace;
}

.format-preset-btn.active .format-preview {
    color: #6ba33a;
}

.format-custom-input {
    font-family: monospace;
    font-size: 14px;
}
