:root {
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #202c39;
    background: #f4f6f8;
    font-synthesis: none;
    --ink: #172c40;
    --muted: #657383;
    --line: #dfe5ea;
    --blue: #254dcd;
    --green: #06795d
}

* {
    box-sizing: border-box
}

.brand-image {
    display: block;
    width: 44px;
    height: 52px;
    object-fit: contain;
    flex-shrink: 0;
}

body {
    margin: 0;
    font-size: 16px
}

button,
input,
textarea,
select {
    font: inherit
}

button,
a,
input,
textarea,
select {
    outline-offset: 4px
}

button {
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    padding: 11px 17px;
    font-weight: 600;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    transition: background .15s, transform .15s
}

button:hover {
    background: #edf1f6
}

button:active {
    transform: translateY(1px)
}

button:disabled {
    opacity: .55;
    cursor: wait
}

.primary {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff
}

.primary:hover {
    background: #1b3da9
}

.dark {
    background: var(--ink);
    color: white;
    border-color: var(--ink)
}

.dark:hover {
    background: #294660
}

.ghost {
    background: transparent;
    border-color: transparent
}

.danger {
    color: #b52b38;
    background: #fff4f4;
    border-color: #f1d5d8
}

.small {
    padding: 8px 12px;
    font-size: 14px
}

.icon {
    font-size: 20px;
    line-height: 1
}

a {
    color: var(--blue);
    text-decoration: none
}

a:hover {
    text-decoration: underline
}

.brand {
    font-size: 23px;
    font-weight: 750;
    letter-spacing: -1px;
    display: flex;
    align-items: center;
    gap: 11px
}

.brand-mark {
    background: var(--ink);
    color: #fff;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 28px
}

.brand span:last-child {
    color: var(--blue)
}

.topbar {
    height: 88px;
    background: white;
    border-bottom: 1px solid var(--line);
    padding: 0 5vw;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px
}

.nav {
    display: flex;
    gap: 8px;
    align-items: center
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e8eefb;
    color: var(--blue);
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 750
}

.home-button {
    margin-left: 24px;
}

.brand-wrap {
    display: flex;
    align-items: center
}

main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 48px 32px 70px
}

.eyebrow {
    color: var(--blue);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    margin: 0 0 10px
}

h1 {
    font-size: 34px;
    line-height: 1.2;
    letter-spacing: -1.2px;
    margin: 0 0 10px;
    font-weight: 700
}

h2 {
    font-size: 19px;
    letter-spacing: -.3px;
    margin: 0
}

h3 {
    font-size: 17px;
    margin: 0 0 8px
}

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

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

.page-head p {
    margin: 8px 0 0;
    line-height: 1.5
}

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

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 14px #15263803
}

.panel-head {
    padding: 23px 26px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center
}

.count {
    font-size: 13px;
    color: var(--muted);
    background: #f0f3f6;
    border-radius: 6px;
    padding: 4px 9px;
    font-weight: 500;
    margin-left: 10px
}

.client-row {
    width: 100%;
    border: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
    padding: 24px 26px;
    justify-content: flex-start;
    text-align: left;
    gap: 18px
}

.client-row:last-child {
    border-bottom: 0
}

.client-icon {
    width: 48px;
    height: 48px;
    background: #edf1fa;
    color: var(--blue);
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 17px;
    font-weight: 700;
    flex-shrink: 0
}

.row-copy {
    flex: 1;
    min-width: 0
}

.row-copy strong {
    display: block;
    font-size: 17px;
    margin-bottom: 5px
}

.row-copy p {
    font-size: 14px;
    font-weight: 400;
    margin: 0;
    color: var(--muted);
    overflow-wrap: anywhere
}

.row-meta {
    font-size: 14px;
    color: var(--muted);
    font-weight: 400;
    margin-right: 24px
}

.arrow {
    color: #71839b;
    font-size: 24px
}

.empty {
    padding: 62px 24px;
    text-align: center
}

.empty-mark {
    margin: 0 auto 18px;
    width: 55px;
    height: 55px;
    border-radius: 14px;
    background: #edf1fa;
    color: var(--blue);
    display: grid;
    place-items: center;
    font-size: 28px
}

.empty p {
    color: var(--muted);
    max-width: 400px;
    margin: 10px auto 22px;
    line-height: 1.6
}

.footnote {
    font-size: 13px;
    color: var(--muted);
    margin-top: 22px;
    display: flex;
    justify-content: space-between;
    gap: 16px
}

.client-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 28px
}

.client-toolbar .back {
    margin-left: auto
}

.task-row {
    padding: 22px 26px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 18px
}

.task-row .row-copy {
    flex: 1
}

.task-detail {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 13px;
    color: var(--muted)
}

.task-time {
    font-variant-numeric: tabular-nums;
    text-align: right;
    min-width: 85px;
    font-weight: 650
}

.task-time span {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
    margin-top: 4px
}

.badge {
    display: inline-block;
    border-radius: 5px;
    background: #f0f2f5;
    color: #596879;
    font-size: 12px;
    padding: 5px 8px;
    font-weight: 600;
    white-space: nowrap
}

.badge.progress {
    color: #315bc5;
    background: #edf2ff
}

.badge.review {
    color: #8b5d0f;
    background: #fff5dc
}

.badge.done {
    color: #067255;
    background: #e7f5ef
}

.task-add {
    padding: 16px 20px
}

.section-gap {
    margin-top: 26px
}

.form-panel {
    padding: 30px;
    max-width: 820px
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px
}

.full {
    grid-column: 1/-1
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    font-weight: 600
}

input,
textarea,
select {
    border: 1px solid #ccd5df;
    background: #fff;
    color: var(--ink);
    padding: 11px 12px;
    border-radius: 7px;
    min-width: 0;
    width: 100%;
    font-weight: 400
}

textarea {
    resize: vertical;
    min-height: 84px
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue)
}

.hint {
    font-size: 13px;
    line-height: 1.5;
    font-weight: 400;
    color: var(--muted)
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--line)
}

.form-actions .danger {
    margin-right: auto
}

.error {
    padding: 12px;
    border-radius: 7px;
    background: #fff1f2;
    color: #a42130;
    font-size: 14px;
    margin: 16px 0;
    line-height: 1.5
}

.hidden {
    display: none !important
}

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

.stat {
    padding: 25px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px
}

.stat-number {
    font-size: 31px;
    font-weight: 650;
    letter-spacing: -.7px;
    font-variant-numeric: tabular-nums
}

.stat-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 7px
}

.rate-form {
    display: flex;
    align-items: end;
    gap: 10px
}

.rate-form input {
    width: 120px
}

.table-wrap {
    overflow-x: auto
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 14px
}

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .7px;
    text-align: left;
    color: var(--muted);
    padding: 16px 24px;
    background: #fafbfd;
    font-weight: 600
}

td {
    padding: 18px 24px;
    border-top: 1px solid var(--line);
    vertical-align: middle
}

td strong {
    display: block
}

td small {
    display: block;
    color: var(--muted);
    margin-top: 5px
}

.right {
    text-align: right
}

.inline-rate {
    display: flex;
    gap: 5px;
    justify-content: flex-end
}

.inline-rate input {
    width: 96px;
    padding: 7px
}

.invoice-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 26px;
    gap: 20px;
    border-top: 1px solid var(--line)
}

.invoice-action p {
    font-size: 13px;
    color: var(--muted);
    margin: 6px 0 0
}

.invoice-history a {
    font-weight: 600
}

dialog {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 32px;
    width: min(620px, calc(100% - 32px));
    max-height: 90vh;
    box-shadow: 0 25px 90px #0d1b3650;
    color: var(--ink)
}

dialog::backdrop {
    background: #0e1a2fd1;
    backdrop-filter: blur(5px)
}

dialog h2 {
    font-size: 24px;
    margin-bottom: 12px
}

dialog>p {
    line-height: 1.6;
    color: var(--muted)
}

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

.dialog-head h2 {
    margin: 0
}

.timer-modal {
    text-align: center;
    padding: 15px 0
}

.timer-modal .eyebrow {
    margin-bottom: 16px
}

.timer-modal h2 {
    font-size: 22px
}

.timer-client {
    color: var(--muted);
    font-size: 14px
}

.clock {
    font-size: 68px;
    font-weight: 600;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    margin: 28px 0 8px
}

.timer-breakdown {
    font-size: 14px;
    color: var(--muted);
    min-height: 24px
}

.timer-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 28px 0 18px
}

.recording {
    color: var(--green);
    font-size: 13px;
    font-weight: 600
}

.timer-confirm {
    border-top: 1px solid var(--line);
    margin-top: 22px;
    padding-top: 18px
}

.timer-confirm h3 {
    line-height: 1.5
}

.timer-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    background: #e8efff;
    padding: 10px;
    color: #264aa4;
    font-size: 14px
}

.login {
    max-width: 440px;
    margin: 9vh auto;
    padding: 32px
}

.login .brand {
    margin-bottom: 35px
}

.login h1 {
    font-size: 28px
}

.login p {
    line-height: 1.6
}

.login form {
    margin-top: 28px
}

.login label {
    margin-top: 18px
}

.login button {
    width: 100%;
    margin-top: 24px
}

.login-footer {
    margin-top: 24px;
    font-size: 12px;
    text-align: center;
    color: var(--muted)
}

.auth-links {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.auth-links button {
    margin-top: 0;
}

.auth-success {
    padding: 12px;
    border-radius: 8px;
    background: #e8f5ee;
    color: #226743;
}

.dev-mail {
    overflow-wrap: anywhere;
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
}

#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: white;
    padding: 13px 22px;
    border-radius: 9px;
    box-shadow: 0 6px 20px #0002;
    display: none;
    max-width: 90vw;
    z-index: 10;
    font-size: 14px
}

.loading {
    text-align: center;
    margin-top: 20vh
}

.profile-section {
    grid-column: 1/-1;
    border-bottom: 1px solid var(--line);
    padding: 12px 0
}

.section-title {
    margin: 30px 0 16px
}

.saved-label {
    color: var(--green);
    font-size: 13px
}

.account-email {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 24px
}

@media(max-width:760px) {
    .topbar {
        height: 75px;
        padding: 0 18px
    }

    .home-button {
        margin-left: 8px;
        padding: 8px;
        font-size: 13px;
    }

    .topbar .nav {
        gap: 0
    }

    .topbar .nav button {
        padding: 8px;
        font-size: 13px
    }

    .avatar {
        display: none
    }

    main {
        padding: 30px 18px
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 20px
    }

    h1 {
        font-size: 29px
    }

    .client-row {
        padding: 20px 16px
    }

    .row-meta {
        display: none
    }

    .task-row {
        flex-wrap: wrap;
        padding: 20px 16px
    }

    .task-row .row-copy {
        flex-basis: 65%
    }

    .task-row .task-time {
        margin-left: auto
    }

    .task-row .actions {
        width: 100%
    }

    .form-grid {
        grid-template-columns: 1fr
    }

    .form-panel {
        padding: 22px
    }

    .stats {
        grid-template-columns: 1fr
    }

    .stat {
        padding: 20px
    }

    .stat-number {
        font-size: 28px
    }

    .panel-head {
        padding: 20px;
        gap: 18px;
        flex-wrap: wrap
    }

    .invoice-action {
        flex-direction: column;
        align-items: flex-start
    }

    .footnote {
        flex-direction: column
    }

    .client-toolbar {
        flex-wrap: wrap
    }

    .clock {
        font-size: 54px
    }

    .login {
        margin: 5vh 18px
    }

    .timer-banner {
        flex-wrap: wrap
    }

    .brand {
        font-size: 20px
    }

    .brand-mark {
        width: 32px;
        height: 32px
    }

    .inline-rate {
        min-width: 150px
    }
}

/* Profile appearance controls. */
.appearance-panel { margin-bottom: 24px; }
.theme-setting { max-width: 420px; margin: 22px 0 30px; }
.logo-form { display: flex; align-items: center; flex-wrap: wrap; gap: 22px; margin: 18px 0; }
.logo-preview { width: 130px; height: 110px; background: #fff; border: 1px solid #dfe5ea; border-radius: 8px; padding: 12px; display: grid; place-items: center; }
.logo-preview img { max-width: 100%; max-height: 84px; object-fit: contain; }
.logo-fields { flex: 1; min-width: 210px; }
.logo-fields .actions { margin-top: 14px; }
.logo-form .error { flex-basis: 100%; }
/* Keep every working surface readable in dark mode; PDFs have independent styling. */
:root[data-theme="dark"] { color-scheme: dark; color: #e3eaf4; background: #101722; --ink: #e3eaf4; --muted: #a3b1c4; --line: #354359; --blue: #91adff; --green: #72d8b1; }
[data-theme="dark"] .topbar, [data-theme="dark"] .panel, [data-theme="dark"] .stat, [data-theme="dark"] dialog { background: #192333; }
[data-theme="dark"] button { background: #243248; }
[data-theme="dark"] button:hover { background: #31425b; }
[data-theme="dark"] .primary { background: #365bd5; border-color: #365bd5; color: white; }
[data-theme="dark"] .primary:hover { background: #456be8; }
[data-theme="dark"] .dark, [data-theme="dark"] .brand-mark, [data-theme="dark"] #toast { background: #314567; color: white; border-color: #455d83; }
[data-theme="dark"] .ghost, [data-theme="dark"] .client-row { background: transparent; }
[data-theme="dark"] .ghost:hover, [data-theme="dark"] .client-row:hover { background: #243248; }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: #111b29; border-color: #465770; color: #e3eaf4; }
[data-theme="dark"] .count, [data-theme="dark"] .badge { background: #2b394c; color: #c2cddd; }
[data-theme="dark"] .avatar, [data-theme="dark"] .client-icon, [data-theme="dark"] .empty-mark, [data-theme="dark"] .badge.progress, [data-theme="dark"] .timer-banner { background: #24385c; color: #aac0ff; }
[data-theme="dark"] .badge.review { background: #463b23; color: #f2ce81; }
[data-theme="dark"] .badge.done { background: #1d4139; color: #85dfbd; }
[data-theme="dark"] th { background: #152031; }
[data-theme="dark"] .danger, [data-theme="dark"] .error { color: #ffb1b7; background: #442730; border-color: #75434e; }
[data-theme="dark"] .arrow { color: #a3b1c4; }

/* Flag high-priority open tasks in both themes, retaining a text label. */
.task-row.high-priority { background: #fff1f2; box-shadow: inset 4px 0 #dc2626; }
.task-row.high-priority .row-copy > strong,
.task-row.high-priority .priority-label { color: #b91c1c; }
.task-row.high-priority .priority-label { font-weight: 700; }
[data-theme="dark"] .task-row.high-priority { background: #3a222c; box-shadow: inset 4px 0 #f87171; }
[data-theme="dark"] .task-row.high-priority .row-copy > strong,
[data-theme="dark"] .task-row.high-priority .priority-label { color: #ffb1b7; }

dialog:has(.invoice-review) { width: min(780px, calc(100vw - 32px)); }
.invoice-review > p { line-height: 1.6; }
.invoice-review table { margin: 16px 0; }
.invoice-review tfoot { border-top: 2px solid var(--line); }

dialog:has(.invoice-editor) { width: min(820px, calc(100vw - 32px)); }
.invoice-edit-line { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 16px 0; }
.invoice-editor h3 { margin-top: 28px; }

.custom-entry-form { padding: 20px 26px; }

.billing-badge { background: var(--surface-2); color: var(--muted); }
.kpi-value { display: inline-block; font-weight: 800; white-space: nowrap; }
.kpi-good { color: #20834f; }
.kpi-close { color: #a46900; }
.kpi-low { color: #c63737; }
.kpi-private-note {
    margin: 18px 0;
    padding: 12px 14px;
    border-left: 4px solid #20834f;
    background: color-mix(in srgb, #20834f 9%, var(--surface));
}
