:root {
    --ui-primary: #6d71f9;
    --ui-primary-hover: #5b60e8;
    --ui-primary-muted: rgba(109, 113, 249, 0.18);
    --ui-border: #d0d5dd;
    --ui-danger: #f87171;
    --ui-text: #111827;
    --ui-muted: #6b7280;

    /* Dark is the default palette (applies when data-theme is absent or "dark"). */
    --app-bg: #000000;
    --app-surface: #1a1a1b;
    --app-surface-raised: #242426;
    --app-chrome: #2b2b2b;
    --app-chrome-top: #2f2f2f;
    --app-text: #ffffff;
    --app-text-secondary: rgba(255, 255, 255, 0.78);
    --app-text-muted: rgba(255, 255, 255, 0.5);
    --app-border: rgba(255, 255, 255, 0.08);
    --app-radius: 12px;
    --app-radius-lg: 16px;
    --app-radius-xl: 20px;
    --app-max-content: 560px;
    --app-nav-height: 60px;
    --app-topbar-height: 56px;
    --app-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
    --app-bg: #f5f6f8;
    --app-surface: #ffffff;
    --app-surface-raised: #eef0f3;
    --app-chrome: #ffffff;
    --app-chrome-top: #ffffff;
    --app-text: #111827;
    --app-text-secondary: rgba(17, 24, 39, 0.75);
    --app-text-muted: rgba(17, 24, 39, 0.5);
    --app-border: rgba(17, 24, 39, 0.1);
}

/* ---- Page layout ---- */

.page {
    max-width: var(--app-max-content);
    margin: 0 auto;
    padding: 0 16px 24px;
}

.page-header {
    margin-bottom: 20px;
}

.page-title {
    margin: 0 0 6px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--app-text);
    letter-spacing: -0.02em;
}

.page-subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--app-text-muted);
    line-height: 1.45;
}

.page-status {
    margin: 0;
    font-size: 0.95rem;
    color: var(--app-text-secondary);
}

.page-status--error {
    color: var(--ui-danger);
}

.page-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    background: var(--app-surface);
    border-radius: var(--app-radius-lg);
    border: 1px solid var(--app-border);
}

.page-empty-icon {
    font-size: 2.5rem;
    color: var(--ui-primary);
    opacity: 0.85;
    margin-bottom: 16px;
}

.page-empty-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--app-text);
}

.page-empty-text {
    margin: 0;
    font-size: 0.9rem;
    color: var(--app-text-muted);
    line-height: 1.5;
    max-width: 280px;
}

.page-actions {
    margin-top: 20px;
    width: 100%;
    max-width: 280px;
}

/* ---- Job pool / My jobs (shared across pages, so kept global rather than CSS-isolated) ---- */

.job-pool-page {
    padding-top: 8px;
}

.job-pool-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.job-pool-tabs {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    border-bottom: 1px solid var(--app-border);
}

.job-pool-tab {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--app-text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.job-pool-tab.active {
    color: var(--app-text);
    border-bottom-color: var(--ui-primary);
}

/* ---- Auth shell (login / register) ---- */

.auth-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: #000000;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--app-surface);
    border-radius: var(--app-radius-xl);
    padding: 32px 24px;
    border: 1px solid var(--app-border);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.auth-logo {
    width: min(220px, 70vw);
    height: auto;
    object-fit: contain;
    margin-bottom: 8px;
}

.auth-title {
    margin: 0 0 20px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--app-text);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.auth-form .ui-field,
.auth-form .ui-button {
    width: 100%;
}

.auth-divider {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 20px 0 16px;
    color: var(--app-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--app-border);
}

.auth-divider span {
    padding: 0 12px;
}

.auth-biometric-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--app-border);
    border-radius: 50%;
    background: var(--app-surface-raised);
    color: var(--app-text-secondary);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.auth-biometric-icon-btn:hover:not(:disabled) {
    border-color: var(--ui-primary);
    color: var(--ui-primary);
}

.auth-biometric-icon-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.auth-biometric-icon-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.auth-biometric-icon-svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-link-row {
    margin: 16px 0 0;
    font-size: 0.9rem;
    color: var(--app-text-secondary);
}

.auth-link-row a {
    color: var(--ui-primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.auth-link-row a:hover {
    text-decoration: underline;
}

.auth-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.layout-empty {
    min-height: 100dvh;
    background: var(--app-bg);
}

/* ---- Form pages (profile, create job) ---- */

.form-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 32px;
}

.form-card {
    background: var(--app-surface);
    border-radius: var(--app-radius-lg);
    padding: 24px 20px;
    border: 1px solid var(--app-border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.form-card h2 {
    margin: 0 0 4px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--app-text);
}

.form-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ui-primary-muted);
    color: var(--ui-primary);
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 16px 0;
}

.form-grid .ui-field,
.form-grid .ui-button {
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 12px;
}

.form-actions .ui-button {
    flex: 1;
}

@media (max-width: 680px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Dark-theme validation summary inside form cards */
.form-card .validation-summary-errors,
.form-card .validation-message {
    color: var(--ui-danger);
}

.form-card ::deep(.validation-summary-errors) {
    color: var(--ui-danger);
    font-size: 0.9rem;
}

/* ---- Form controls ---- */

.ui-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ui-field--full {
    grid-column: 1 / -1;
}

.ui-field--checkbox {
    gap: 4px;
}

.ui-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: var(--app-text);
    cursor: pointer;
}

.ui-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--ui-primary);
    cursor: pointer;
}

.ui-label {
    font-size: 0.9rem;
    color: var(--app-text-secondary);
    font-weight: 500;
}

.ui-input {
    padding: 12px 14px;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    background: var(--app-surface-raised);
    color: var(--app-text);
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ui-input::placeholder {
    color: var(--app-text-muted);
}

.ui-input:focus {
    border-color: rgba(109, 113, 249, 0.6);
    box-shadow: 0 0 0 3px var(--ui-primary-muted);
}

select.ui-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.ui-button {
    width: 100%;
    padding: 13px 24px;
    border-radius: 10px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
    font-family: inherit;
}

.ui-button:active:not(:disabled) {
    transform: scale(0.98);
}

.ui-button--primary {
    background-color: var(--ui-primary);
    color: #fff;
}

.ui-button--primary:hover:not(:disabled) {
    background-color: var(--ui-primary-hover);
}

.ui-button--ghost {
    background: transparent;
    border: 1px solid var(--app-border);
    color: var(--app-text);
}

.ui-button--ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
}

.ui-button--secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--app-text);
}

.ui-button--secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
}

.ui-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ui-error {
    color: var(--ui-danger);
    margin: 8px 0 0;
    font-size: 0.9rem;
}

.validation-message {
    color: var(--ui-danger);
    font-size: 0.85rem;
}

.error-list {
    margin: 8px 0 0;
    padding-left: 20px;
    text-align: left;
    font-size: 0.9rem;
}

.error-list li {
    color: var(--ui-danger);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Invoicing (create/edit invoice, invoice detail) ---- */

.invoice-form-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.invoice-form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0;
}

.invoice-form-stack .form-card h2 {
    margin-bottom: 12px;
}

.invoice-form-stack .ui-field {
    margin-bottom: 12px;
}

.invoice-line-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.invoice-line-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--app-border);
}

.invoice-line-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.invoice-line-item-desc {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--app-text);
}

.invoice-line-item-meta {
    font-size: 0.8rem;
    color: var(--app-text-muted);
}

.invoice-line-item-amount {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--app-text);
    white-space: nowrap;
}

.invoice-line-item-remove {
    background: transparent;
    border: none;
    color: var(--app-text-muted);
    cursor: pointer;
    padding: 4px;
}

.invoice-line-item-remove:hover {
    color: var(--ui-danger);
}

.invoice-add-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--ui-primary);
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding: 4px 0;
}

.invoice-add-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--app-border);
}

.invoice-add-kind {
    display: flex;
    gap: 8px;
}

.invoice-kind-chip {
    flex: 1;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--app-border);
    background: transparent;
    color: var(--app-text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.invoice-kind-chip.active {
    background: var(--ui-primary-muted);
    border-color: var(--ui-primary);
    color: var(--ui-primary);
}

.invoice-totals-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    font-size: 0.92rem;
    color: var(--app-text-secondary);
}

.invoice-totals-row--total {
    border-top: 1px solid var(--app-border);
    margin-top: 6px;
    padding-top: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--app-text);
}

.invoice-totals-input {
    max-width: 120px;
    text-align: right;
}

.invoice-view-headline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.invoice-view-headline h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--app-text);
}

.invoice-view-meta {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: var(--app-text-muted);
}

.invoice-disclaimer {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--app-text-secondary);
    white-space: pre-wrap;
}

.invoice-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.invoice-status-pill--pending {
    background: rgba(245, 185, 66, 0.18);
    color: #f5b942;
}

.invoice-status-pill--accepted {
    background: rgba(109, 113, 249, 0.18);
    color: var(--ui-primary);
}

.invoice-status-pill--declinedrequestednew {
    background: rgba(245, 185, 66, 0.18);
    color: #f5b942;
}

.invoice-status-pill--paid {
    background: rgba(111, 214, 127, 0.18);
    color: #6fd67f;
}

.invoice-paid-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--app-radius);
    background: rgba(111, 214, 127, 0.12);
    color: #6fd67f;
    font-weight: 600;
}

/* ---- Post actions / comments (shared between Home feed and the post watch page) ---- */

.post-actions {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 16px;
}

.post-action {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--app-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding: 4px 0;
}

.post-action .bi {
    font-size: 1.15rem;
}

.post-action.active {
    color: var(--ui-primary);
}

.post-action--end {
    margin-left: auto;
}

.subscribe-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    margin-left: auto;
    border-radius: 999px;
    border: 1px solid var(--app-border);
    background: transparent;
    color: var(--app-text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}

.subscribe-pill .bi {
    font-size: 0.95rem;
}

.subscribe-pill.active {
    background: var(--ui-primary-muted);
    border-color: var(--ui-primary);
    color: var(--ui-primary);
}

.post-comments {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--app-border);
}

.post-comments-empty {
    margin: 0;
    font-size: 0.88rem;
    color: var(--app-text-muted);
}

.post-comment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.post-comment-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.88rem;
    line-height: 1.45;
    margin-bottom: 12px;
    color: var(--app-text-secondary);
}

.post-comment-item .post-comment-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--ui-primary-muted);
    color: var(--ui-primary);
    font-size: 0.78rem;
    font-weight: 700;
}

.post-comment-item img.post-comment-avatar {
    object-fit: cover;
}

.post-comment-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.post-comment-author {
    font-weight: 600;
    color: var(--app-text);
}

.post-comment-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.post-comment-compose {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.post-comment-input {
    width: 100%;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid var(--app-border);
    background: var(--app-surface-raised);
    color: var(--app-text);
    padding: 10px 12px;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 56px;
    font-family: inherit;
}

.post-comment-submit {
    align-self: flex-end;
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    background: var(--ui-primary);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.post-comment-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
