/* ClickDesign Invoicing theme */
:root {
    --cd-navy: #0b1020;
    --cd-navy-2: #12182e;
    --cd-blue: #66b9e3;
    --cd-purple: #7b5cf0;
    --cd-grad: linear-gradient(90deg, #7b5cf0 0%, #38bdf8 100%);
    --cd-bg: #f4f6fb;
    --cd-card: #ffffff;
    --cd-text: #1c2333;
    --cd-muted: #6b7387;
    --cd-border: #e4e8f1;
    --cd-radius: 12px;
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--cd-bg);
    color: var(--cd-text);
}

h1, h2, h3 { font-weight: 700; }

a { color: var(--cd-purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Shell ---------- */
.cd-shell {
    display: flex;
    min-height: 100vh;
}

.cd-sidebar {
    width: 232px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--cd-navy) 0%, #171d3a 100%);
    color: #cdd4e6;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.cd-brand {
    display: block;
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cd-brand img { height: 34px; max-width: 100%; }

.cd-nav {
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    gap: 2px;
    flex-grow: 1;
}

.cd-nav-link {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: #cdd4e6;
    font-weight: 500;
    text-decoration: none;
}

.cd-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}

.cd-nav-link.active {
    background: var(--cd-grad);
    color: #fff;
}

.cd-user {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}

.cd-user-name { color: #fff; font-weight: 600; }
.cd-user-company { color: #8d96ad; margin-bottom: 8px; }

.cd-main {
    flex-grow: 1;
    padding: 28px 34px 48px;
    max-width: 1160px;
}

@media (max-width: 820px) {
    .cd-shell { flex-direction: column; }
    .cd-sidebar { width: 100%; height: auto; position: static; }
    .cd-nav { flex-direction: row; flex-wrap: wrap; }
    .cd-main { padding: 18px 16px 40px; }
}

/* ---------- Page furniture ---------- */
.cd-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.cd-page-head h1 { font-size: 1.45rem; margin: 0; }

.cd-card {
    background: var(--cd-card);
    border: 1px solid var(--cd-border);
    border-radius: var(--cd-radius);
    padding: 20px 22px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(16, 24, 64, 0.05);
}

.cd-card h2 {
    font-size: 1.02rem;
    margin: 0 0 14px;
    color: var(--cd-text);
}

.cd-muted { color: var(--cd-muted); }

/* ---------- Stat tiles ---------- */
.cd-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.cd-stat {
    background: var(--cd-card);
    border: 1px solid var(--cd-border);
    border-radius: var(--cd-radius);
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(16, 24, 64, 0.05);
}

.cd-stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cd-muted);
    margin-bottom: 6px;
}

.cd-stat-value { font-size: 1.5rem; font-weight: 700; }
.cd-stat-value.cd-danger { color: #d64545; }
.cd-stat-value.cd-success { color: #1e9e6a; }

/* ---------- Buttons ---------- */
.cd-btn {
    display: inline-block;
    background: var(--cd-grad);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-weight: 600;
    cursor: pointer;
}

.cd-btn:hover { filter: brightness(1.07); color: #fff; text-decoration: none; }
.cd-btn:disabled { opacity: 0.6; cursor: default; }

.cd-btn-outline {
    display: inline-block;
    background: transparent;
    color: var(--cd-purple);
    border: 1px solid var(--cd-purple);
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
}

.cd-btn-outline:hover { background: rgba(123, 92, 240, 0.08); text-decoration: none; }
.cd-btn-outline:disabled { opacity: 0.5; cursor: default; }

.cd-btn-danger {
    display: inline-block;
    background: transparent;
    color: #d64545;
    border: 1px solid #d64545;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
}

.cd-btn-danger:hover { background: rgba(214, 69, 69, 0.08); }

.cd-btn-ghost {
    background: transparent;
    color: #cdd4e6;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 7px;
    padding: 5px 12px;
    font-size: 0.82rem;
    cursor: pointer;
}

.cd-btn-ghost:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.cd-btn-sm { padding: 5px 12px; font-size: 0.85rem; }

/* ---------- Tables ---------- */
.cd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.cd-table th {
    text-align: left;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cd-muted);
    padding: 8px 10px;
    border-bottom: 2px solid var(--cd-border);
}

.cd-table td {
    padding: 10px;
    border-bottom: 1px solid var(--cd-border);
    vertical-align: middle;
}

.cd-table tr:last-child td { border-bottom: none; }
.cd-table tbody tr:hover { background: #f8faff; }
.cd-table .num { text-align: right; white-space: nowrap; }
.cd-table a { font-weight: 600; }

.cd-table-scroll { overflow-x: auto; }

/* ---------- Badges ---------- */
.cd-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
}

.cd-badge-draft { background: #eceff5; color: #5a6377; }
.cd-badge-sent { background: #e3f1fb; color: #1d7fc4; }
.cd-badge-partpaid { background: #fdf3dd; color: #b07d18; }
.cd-badge-paid { background: #e2f6ec; color: #17845a; }
.cd-badge-overdue { background: #fbe5e5; color: #c03434; }
.cd-badge-void { background: #e8e6ef; color: #6b6580; }
.cd-badge-converted { background: #ece7fd; color: #6a48e0; }

/* ---------- Forms ---------- */
.cd-field { margin-bottom: 14px; }

.cd-field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--cd-muted);
    margin-bottom: 4px;
}

.cd-input, .cd-select, .cd-textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid #cdd4e2;
    border-radius: 8px;
    background: #fff;
    color: var(--cd-text);
    font-size: 0.93rem;
}

.cd-input:focus, .cd-select:focus, .cd-textarea:focus {
    outline: none;
    border-color: var(--cd-purple);
    box-shadow: 0 0 0 3px rgba(123, 92, 240, 0.15);
}

.cd-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0 18px;
}

.cd-check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-weight: 500; }
.cd-check input { width: 17px; height: 17px; }

.cd-alert-error {
    background: #fbe5e5;
    color: #a12c2c;
    border: 1px solid #f3c2c2;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.cd-alert-success {
    background: #e2f6ec;
    color: #17845a;
    border: 1px solid #bfe8d4;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

/* ---------- Line-item editor ---------- */
.cd-items-table .cd-input, .cd-items-table .cd-select { min-width: 70px; }
.cd-items-table td { padding: 6px 5px; }

/* ---------- Totals ---------- */
.cd-totals {
    margin-left: auto;
    max-width: 320px;
    font-size: 0.95rem;
}

.cd-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.cd-totals-row.cd-totals-grand {
    border-top: 2px solid var(--cd-border);
    margin-top: 6px;
    padding-top: 8px;
    font-weight: 700;
    font-size: 1.05rem;
}

/* ---------- Auth screens ---------- */
.cd-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1000px 600px at 20% 0%, #1c2650 0%, var(--cd-navy) 55%);
    padding: 24px;
}

.cd-auth-card {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 34px 32px;
    color: #e8ecf6;
    backdrop-filter: blur(6px);
}

.cd-auth-logo { height: 40px; margin-bottom: 22px; }

.cd-auth-card h1 { font-size: 1.3rem; color: #fff; margin-bottom: 18px; }

.cd-auth-card .cd-field label { color: #9aa4c0; }

.cd-auth-card .cd-input {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.cd-auth-card .cd-input::placeholder { color: #6d7794; }

.cd-auth-alt { margin-top: 16px; font-size: 0.88rem; color: #9aa4c0; }
.cd-auth-alt a { color: var(--cd-blue); }

.cd-w100 { width: 100%; }

/* ---------- Settings: logo, templates, colour ---------- */
.cd-logo-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--cd-navy) 0%, #171d3a 100%);
    border-radius: 10px;
    padding: 10px 16px;
}

.cd-logo-chip img { max-height: 44px; max-width: 180px; }

.cd-tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.cd-tpl {
    border: 2px solid var(--cd-border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.12s ease;
}

.cd-tpl:hover { border-color: #b9a8f7; }
.cd-tpl.selected { border-color: var(--cd-purple); box-shadow: 0 0 0 3px rgba(123, 92, 240, 0.15); }

.cd-tpl-swatch {
    height: 44px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.cd-tpl-name { font-weight: 700; font-size: 0.92rem; }
.cd-tpl-desc { font-size: 0.78rem; color: var(--cd-muted); }

.cd-color {
    width: 46px;
    height: 34px;
    padding: 2px;
    border: 1px solid #cdd4e2;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.cd-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #cdd4e2;
    cursor: pointer;
}

/* ---------- Public site (landing, pricing, legal) ---------- */
.pub-shell { display: flex; flex-direction: column; min-height: 100vh; background: #fff; }

.pub-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 5vw;
    background: linear-gradient(90deg, var(--cd-navy) 0%, #171d3a 100%);
}

.pub-brand img { height: 32px; display: block; }

.pub-nav-links { display: flex; align-items: center; gap: 22px; }
.pub-nav-links a { color: #cdd4e6; font-weight: 500; text-decoration: none; }
.pub-nav-links a:hover { color: #fff; }
.pub-nav-links a.cd-btn { color: #fff; }

.pub-main { flex-grow: 1; }

.pub-hero {
    text-align: center;
    padding: 72px 5vw 64px;
    background: radial-gradient(1000px 600px at 50% -10%, #1c2650 0%, var(--cd-navy) 60%);
    color: #fff;
}

.pub-hero h1 { font-size: clamp(1.8rem, 4.5vw, 3rem); margin-bottom: 14px; }
.pub-hero p { color: #9aa4c0; max-width: 560px; margin: 0 auto 26px; font-size: 1.05rem; }
.pub-hero-alt { color: #cdd4e6; border-color: #cdd4e6; }
.pub-hero-alt:hover { background: rgba(255, 255, 255, 0.08); }

.pub-section { padding: 56px 5vw; max-width: 1100px; margin: 0 auto; }
.pub-section h2 { text-align: center; font-size: 1.6rem; margin-bottom: 30px; }
.pub-section-alt { max-width: none; background: var(--cd-bg); }
.pub-section-alt > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.pub-lead { text-align: center; color: var(--cd-muted); margin: -18px 0 26px; }

.pub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.pub-feature {
    border: 1px solid var(--cd-border);
    border-radius: var(--cd-radius);
    padding: 20px;
}

.pub-feature h3 { font-size: 1.02rem; margin-bottom: 6px; }
.pub-feature p { color: var(--cd-muted); font-size: 0.92rem; margin: 0; }

.pub-price-toggle { display: flex; justify-content: center; margin-bottom: 20px; }

.pub-price-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.pub-price-card {
    position: relative;
    background: #fff;
    border: 1px solid var(--cd-border);
    border-radius: var(--cd-radius);
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
}

.pub-price-card.featured { border: 2px solid var(--cd-purple); box-shadow: 0 6px 24px rgba(123, 92, 240, 0.15); }

.pub-price-flag {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--cd-grad);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

.pub-price-card h3 { font-size: 1.05rem; }
.pub-price { font-size: 1.9rem; font-weight: 800; margin-top: 6px; }
.pub-price-per { color: var(--cd-muted); font-size: 0.85rem; margin-bottom: 12px; }

.pub-price-card ul { list-style: none; padding: 0; margin: 0 0 18px; flex-grow: 1; }
.pub-price-card li { padding: 4px 0 4px 22px; position: relative; font-size: 0.9rem; }
.pub-price-card li::before { content: "✓"; position: absolute; left: 0; color: #1e9e6a; font-weight: 700; }

.pub-price-card .cd-btn, .pub-price-card .cd-btn-outline { text-align: center; }

.pub-price-note { text-align: center; color: var(--cd-muted); font-size: 0.85rem; margin-top: 22px; }

.pub-footer {
    background: var(--cd-navy);
    color: #8d96ad;
    padding: 30px 5vw 36px;
    font-size: 0.85rem;
    text-align: center;
}

.pub-footer-links { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.pub-footer-links a { color: #cdd4e6; text-decoration: none; }
.pub-footer-links a:hover { color: #fff; text-decoration: underline; }
.pub-footer a { color: #9db8d8; }

.pub-doc { max-width: 760px; margin: 0 auto; padding: 48px 5vw 64px; }
.pub-doc h1 { font-size: 1.7rem; }
.pub-doc-meta { color: var(--cd-muted); font-size: 0.85rem; margin-bottom: 26px; }
.pub-doc h2 { font-size: 1.05rem; margin: 26px 0 8px; }
.pub-doc p { color: #374151; line-height: 1.65; }

/* ---------- Blazor error bar (hidden until Blazor raises a real error) ---------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff3cd;
    color: #664d03;
    padding: 10px 20px;
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
    font-weight: 700;
}

/* ---------- Misc ---------- */
.cd-loading { color: var(--cd-muted); padding: 30px 0; }
.cd-empty { color: var(--cd-muted); padding: 24px 0; text-align: center; }
.cd-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cd-mt { margin-top: 16px; }
