:root {
    --bg: #121417;
    --bg-panel: #1a1d21;
    --bg-panel-soft: #21252b;
    --text: #e7eaee;
    --text-muted: #9ea7b3;
    --accent: #4fb0ff;
    --accent-dark: #2788d8;
    --border: #2b3138;
    --success: #57cc99;
    --error: #ff6b6b;
    --shadow: rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #111316 0%, #171b20 100%);
    color: var(--text);
    font-family: "Segoe UI", "Inter", Arial, sans-serif;
    min-height: 100vh;
}

.app-shell {
    max-width: 1380px;
    margin: 0 auto;
    padding: 28px 30px 34px;
}

.trial-banner {
    margin: -8px 0 18px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #3d4a5c;
    background: linear-gradient(135deg, #1e2630 0%, #1a222c 100%);
    box-shadow: 0 8px 24px var(--shadow);
}

.trial-banner-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.trial-banner-text {
    margin: 0;
    color: #d5dde8;
    font-size: 0.95rem;
    line-height: 1.45;
    flex: 1 1 280px;
}

.trial-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.trial-upgrade-btn {
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    color: #fff;
    border: none;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
}

.trial-upgrade-btn:hover {
    filter: brightness(1.06);
}

.trial-dismiss-btn {
    background: #2e3640;
    color: #dce2ea;
    border: 1px solid #444d59;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
}

.trial-dismiss-btn:hover {
    background: #394452;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.auth-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.welcome-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-nav-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

a.header-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
}

a.header-link:hover {
    background: rgba(79, 176, 255, 0.1);
    border-color: rgba(79, 176, 255, 0.25);
}

.settings-shell .settings-main {
    display: grid;
    gap: 16px;
    max-width: 720px;
}

.settings-panel h2 {
    font-size: 1.05rem;
    margin-bottom: 12px;
}

.settings-status {
    min-height: 22px;
}

.settings-lead {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.settings-help {
    margin: 0 0 8px;
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.settings-help.subtle {
    margin-top: 8px;
    margin-bottom: 0;
    font-size: 0.8rem;
    opacity: 0.9;
}

.settings-help code {
    font-size: 0.85em;
    color: #b8c5d6;
    background: #1e242c;
    padding: 2px 6px;
    border-radius: 4px;
}

.settings-row-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.settings-row-heading h2 {
    margin-bottom: 6px;
}

.settings-form {
    display: grid;
    gap: 12px;
    max-width: 420px;
}

.settings-primary-btn {
    justify-self: start;
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    color: #fff;
    border: none;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
}

.settings-primary-btn:hover:not(:disabled) {
    filter: brightness(1.06);
}

.settings-danger-zone h2 {
    color: #ff9a9a;
}

.settings-danger-btn {
    justify-self: start;
    background: rgba(255, 107, 107, 0.15);
    color: #ffb4b4;
    border: 1px solid rgba(255, 107, 107, 0.45);
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
}

.settings-danger-btn:hover:not(:disabled) {
    background: rgba(255, 107, 107, 0.25);
}

.input-readonly {
    opacity: 0.88;
    cursor: not-allowed;
    background: #15191e !important;
    color: var(--text-muted) !important;
}

.switch-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.switch-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-ui {
    width: 48px;
    height: 26px;
    border-radius: 999px;
    background: #2f3640;
    border: 1px solid #454d59;
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.switch-ui::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #c5ced9;
    top: 2px;
    left: 3px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.switch-input:checked + .switch-ui {
    background: rgba(79, 176, 255, 0.25);
    border-color: var(--accent);
}

.switch-input:checked + .switch-ui::after {
    transform: translateX(20px);
    background: var(--accent);
}

.switch-input:focus-visible + .switch-ui {
    box-shadow: 0 0 0 3px rgba(79, 176, 255, 0.2);
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, #3e464f, #252b31);
    border: 1px solid #3f4a56;
    font-weight: 700;
    letter-spacing: 0.06em;
}

h1, h2, p {
    margin: 0;
}

h1 {
    font-size: 1.45rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 2px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1.05fr 1.2fr;
    gap: 18px;
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 28px var(--shadow);
    padding: 20px;
}

.profile-section {
    margin-top: 16px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #181c21;
}

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

.rates-header {
    margin-top: 12px;
}

h3 {
    margin: 0;
    font-size: 0.98rem;
    letter-spacing: 0.02em;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
    margin-bottom: 12px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 0.87rem;
    color: var(--text-muted);
}

input, textarea, button {
    font: inherit;
}

input, textarea {
    width: 100%;
    border: 1px solid #39414a;
    background: var(--bg-panel-soft);
    color: var(--text);
    border-radius: 9px;
    padding: 11px 12px;
    outline: none;
}

input:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 176, 255, 0.15);
}

textarea[name="scopeOfWork"] {
    resize: vertical;
    min-height: 170px;
}

textarea[name="customRates"],
textarea[name="jobNotes"] {
    resize: vertical;
    min-height: 92px;
}

.actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}

button {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.18s ease;
    font-weight: 600;
}

#generateBtn {
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    color: white;
}

#generateBtn:hover:not(:disabled) {
    filter: brightness(1.06);
}

#copyBtn, #downloadBtn, #copyInvoiceBtn, #downloadInvoiceBtn, #convertInvoiceBtn, #emailQuoteBtn, #emailInvoiceBtn {
    background: #303741;
    color: #dce2ea;
    border-color: #444d59;
}

#saveProfileBtn {
    background: #2e3640;
    color: #dce2ea;
    border-color: #444d59;
}

#logoutBtn {
    background: #2e3640;
    color: #dce2ea;
    border-color: #444d59;
}

#logoutBtn:hover:not(:disabled) {
    background: #394452;
}

#saveProfileBtn:hover:not(:disabled) {
    background: #394452;
}

#copyBtn:hover:not(:disabled),
#downloadBtn:hover:not(:disabled),
#copyInvoiceBtn:hover:not(:disabled),
#downloadInvoiceBtn:hover:not(:disabled),
#convertInvoiceBtn:hover:not(:disabled),
#emailQuoteBtn:hover:not(:disabled),
#emailInvoiceBtn:hover:not(:disabled) {
    background: #3a4450;
}

button:disabled {
    opacity: 0.52;
    cursor: not-allowed;
}

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

.output-actions {
    display: flex;
    gap: 8px;
}

#quoteOutput {
    resize: vertical;
    min-height: 320px;
    line-height: 1.45;
}

.email-quote-row {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.email-quote-label {
    flex: 1 1 220px;
    min-width: 0;
    margin: 0;
}

.email-quote-row input {
    margin-top: 6px;
}

#emailQuoteBtn {
    flex: 0 0 auto;
    align-self: flex-end;
}

.invoice-client-email-row {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.invoice-client-email-label {
    flex: 1 1 220px;
    min-width: 0;
    margin: 0;
    font-size: 0.87rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.invoice-client-email-row input {
    margin-top: 6px;
}

#emailInvoiceBtn {
    flex: 0 0 auto;
    align-self: flex-end;
}

.invoice-convert-row {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.invoice-section {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

#invoiceOutput {
    resize: vertical;
    min-height: 230px;
    line-height: 1.45;
}

.history-section {
    margin-top: 14px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.history-header {
    align-items: baseline;
}

.history-help {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.history-list {
    margin-top: 10px;
    max-height: 280px;
    overflow-y: auto;
    display: grid;
    gap: 10px;
}

.history-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-card .history-item {
    width: 100%;
}

.history-card.active .history-item {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79, 176, 255, 0.16);
}

.invoice-paid-toggle {
    align-self: flex-end;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.invoice-paid-toggle:disabled {
    opacity: 0.55;
    cursor: wait;
}

.invoice-paid-toggle.is-unpaid {
    background: rgba(255, 107, 107, 0.12);
    color: #ff9a9a;
    border-color: rgba(255, 107, 107, 0.42);
}

.invoice-paid-toggle.is-unpaid:hover:not(:disabled) {
    background: rgba(255, 107, 107, 0.2);
}

.invoice-paid-toggle.is-paid {
    background: rgba(87, 204, 153, 0.12);
    color: #8ee4c0;
    border-color: rgba(87, 204, 153, 0.42);
}

.invoice-paid-toggle.is-paid:hover:not(:disabled) {
    background: rgba(87, 204, 153, 0.2);
}

.history-item {
    width: 100%;
    border: 1px solid #38414d;
    background: #20252d;
    color: var(--text);
    border-radius: 9px;
    padding: 10px 12px;
    text-align: left;
}

.history-item:hover {
    background: #2a313b;
}

.history-main {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 2px;
}

.history-title {
    font-weight: 600;
}

.history-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-empty {
    color: var(--text-muted);
    padding: 8px 0;
}

.status {
    margin-top: 10px;
    min-height: 20px;
    font-size: 0.9rem;
}

.status.success {
    color: var(--success);
}

.status.error {
    color: var(--error);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 28px var(--shadow);
    padding: 22px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.auth-form {
    display: grid;
    gap: 10px;
}

.auth-submit {
    margin-top: 8px;
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    color: #fff;
}

.auth-link {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 8px;
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.auth-verify-hint {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 6px 0 0;
    line-height: 1.45;
}

.auth-verify-hint a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-verify-hint a:hover {
    text-decoration: underline;
}

.check-email-card .check-email-lead {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.5;
}

.check-email-address {
    color: var(--accent);
    word-break: break-all;
}

.check-email-body {
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

.check-email-hint {
    margin: 0 0 18px;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.check-email-hint code {
    font-size: 0.82em;
    color: #c8d4e4;
    background: var(--bg-panel-soft);
    padding: 2px 6px;
    border-radius: 4px;
}

.check-email-actions {
    display: flex;
    justify-content: flex-start;
}

.check-email-resend-note {
    margin: 18px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.check-email-resend-note a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.check-email-resend-note a:hover {
    text-decoration: underline;
}

.unverified-account-actions {
    margin-top: 12px;
    padding: 14px 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-panel-soft);
}

.unverified-account-lead {
    margin: 0 0 10px;
    color: #c8d4e4;
    font-size: 0.9rem;
    line-height: 1.45;
}

.auth-resend-btn {
    width: 100%;
    margin: 0;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #3f4853;
    background: #2d343e;
    color: #dce2ea;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
}

.auth-resend-btn:hover:not(:disabled) {
    background: #394452;
}

.auth-resend-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.quote-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quote-field .field-error:empty {
    display: none;
}

.field-error {
    min-height: 1.15em;
    font-size: 0.82rem;
    color: var(--error);
    line-height: 1.35;
}

.scope-field-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 12px;
    margin-top: 2px;
}

.scope-field-footer .field-error {
    flex: 1 1 160px;
}

.char-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: auto;
}

.char-counter.is-short {
    color: #e8b86a;
}

.char-counter.is-ok {
    color: var(--success);
}

.landing-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 28px 44px;
}

.landing-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.landing-actions {
    display: flex;
    gap: 10px;
}

.landing-main {
    display: grid;
    gap: 20px;
}

.hero-panel {
    background: linear-gradient(145deg, #191d23 0%, #171b20 100%);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 30px;
    box-shadow: 0 10px 28px var(--shadow);
}

.hero-kicker {
    color: var(--accent);
    font-size: 0.9rem;
    margin-bottom: 10px;
    letter-spacing: 0.02em;
}

.hero-title {
    margin: 0;
    font-size: clamp(2rem, 4.5vw, 3.1rem);
    line-height: 1.08;
    max-width: 18ch;
}

.hero-subtitle {
    margin-top: 14px;
    color: #c2cad4;
    max-width: 62ch;
    font-size: 1.03rem;
    line-height: 1.5;
}

.hero-cta {
    margin-top: 22px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.hero-account-prompt {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hero-account-prompt a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.hero-account-prompt a:hover {
    text-decoration: underline;
}

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 16px;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.06);
}

.btn-secondary {
    background: #2d343e;
    border-color: #3f4853;
    color: #dce2ea;
}

.btn-secondary:hover {
    background: #394452;
}

.btn-large {
    padding: 12px 18px;
}

.landing-cta-panel {
    background: linear-gradient(145deg, #1a222c 0%, var(--bg-panel) 55%, #151a22 100%);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px 24px 26px;
    box-shadow: 0 12px 36px var(--shadow);
    text-align: center;
}

.landing-cta-heading {
    margin: 0 0 12px;
    font-size: clamp(1.35rem, 2.8vw, 1.85rem);
    letter-spacing: 0.01em;
    line-height: 1.25;
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
}

.landing-cta-lead {
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.55;
    max-width: 34rem;
    margin-left: auto;
    margin-right: auto;
}

.landing-cta-urgency {
    margin: 0 0 20px;
    color: #c8d4e4;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.landing-cta-buttons {
    justify-content: center;
}

.benefits-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.benefit-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.benefit-card h3 {
    font-size: 1.02rem;
    margin-bottom: 8px;
}

.benefit-card p {
    color: var(--text-muted);
    line-height: 1.5;
}

.benefit-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #252d38;
    border: 1px solid #39424f;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
}

.benefit-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #7cc5ff;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.landing-footer {
    margin-top: 22px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.footer-links {
    display: flex;
    gap: 12px;
}

.footer-links a {
    color: #b9c4d1;
    text-decoration: none;
}

.footer-links a:hover {
    color: #dce6f2;
}

@media (max-width: 1120px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .email-quote-row {
        flex-direction: column;
        align-items: stretch;
    }

    #emailQuoteBtn {
        align-self: stretch;
    }

    .invoice-client-email-row {
        flex-direction: column;
        align-items: stretch;
    }

    #emailInvoiceBtn {
        align-self: stretch;
    }

    .landing-topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .benefits-grid {
        grid-template-columns: 1fr;
    }

    .landing-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}
