:root {
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: var(--background);
    font-synthesis: none;
    --primary: #003163;
    --primary-hover: #0a4a8c;
    --primary-soft: #d6e7fa;
    --text: #14263b;
    --background: #f4f6f9;
    --surface: #fff;
    --surface-soft: #f5f7fa;
    --sidebar: #e9eef4;
    --muted: #566476;
    --line: #d9e1ea;
    --input-border: #7f8ea1;
    --link: #0b4f8f;
    --focus: #1f6fbf;
    --red: #a83a2d;
    --error: #a3301f;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
}

[hidden] {
    display: none !important;
}

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

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

:focus-visible {
    outline: 2px solid var(--focus);
}

/* Buttons and button-styled links */
button,
.button {
    display: inline-block;
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 11px 17px;
    background: var(--surface);
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    line-height: normal;
}

button:hover,
.button:hover {
    background: #e8eef6;
}

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

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

button.primary:hover,
.button.primary:hover {
    background: var(--primary-hover);
}

button.danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

button.danger:hover {
    background: #8f2f24;
}

button.small,
.button.small {
    padding: 7px 10px;
    font-size: 13px;
}

button.link,
a.link {
    display: inline-block;
    border: 0;
    background: none;
    padding: 8px 0;
    text-align: left;
    color: var(--link);
    font-weight: 600;
    text-decoration: none;
}

button.link:hover,
a.link:hover {
    background: none;
    text-decoration: underline;
}

a {
    color: var(--primary);
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 32px;
    letter-spacing: -1px;
    font-weight: 650;
}

h2 {
    font-size: 20px;
    letter-spacing: -.3px;
}

h3 {
    font-size: 16px;
}

p {
    line-height: 1.55;
}

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

.small {
    font-size: 13px;
}

.eyebrow {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--muted);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 200;
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
}

.skip-link:focus {
    top: 16px;
}

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

.mark {
    width: 34px;
    height: 34px;
    border: 2px solid currentColor;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
}

.mark::before {
    content: "↗";
}

/* Status pills */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 20px;
    background: #e6edf5;
    color: #2c4a6b;
    padding: 5px 9px;
    font-size: 11px;
    white-space: nowrap;
}

.pill.auto {
    background: #fff1d8;
    color: #84540f;
}

.pill.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.pill.paid {
    background: #e3f1e7;
    color: #2b6640;
}

/* Application layout */
.sidebar {
    width: 238px;
    position: fixed;
    inset: 0 auto 0 0;
    background: var(--sidebar);
    padding: 32px 22px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
}

.sidebar .brand {
    margin-bottom: 12px;
    color: var(--primary);
}

.nav {
    display: grid;
    gap: 7px;
    margin-top: 39px;
}

.nav a {
    border-radius: 9px;
    text-align: left;
    padding: 13px 15px;
    color: #4b596a;
    font-weight: 500;
    text-decoration: none;
}

.nav a:hover {
    background: #d9e3ef;
}

.nav a.selected,
.nav a.selected:hover {
    background: var(--primary);
    color: #fff;
}

.nav .icon {
    display: inline-block;
    width: 27px;
    opacity: .8;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
}

.account {
    border-top: 1px solid var(--line);
    padding-top: 20px;
    margin-bottom: 10px;
    line-height: 1.5;
}

.main {
    margin-left: 238px;
    padding: 32px 42px 50px;
    max-width: 1600px;
}

#content:focus {
    outline: none;
}

.topline {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    align-items: center;
    margin-bottom: 38px;
    font-size: 13px;
    color: var(--muted);
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
}

.title-row p {
    margin-top: 9px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    align-items: center;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 25px;
    margin-bottom: 22px;
}

.card-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 22px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 17px;
    margin-bottom: 26px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 23px;
}

.stat:first-child {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.stat .label {
    font-size: 13px;
    opacity: .85;
}

.stat .value {
    font-size: 31px;
    letter-spacing: -1px;
    margin: 15px 0 4px;
}

.stat .hint {
    font-size: 12px;
    opacity: .75;
}

.grid-two {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 22px;
}

.grid-two > .card {
    min-width: 0;
}

/* Forms */
label {
    font-weight: 600;
}

.field,
.filters label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.field {
    margin-bottom: 16px;
}

.field-check {
    margin-bottom: 16px;
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--surface);
    color: #1d2c3d;
    min-height: 43px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

input:disabled {
    background: var(--surface-soft);
    color: var(--muted);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--error);
}

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

input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    accent-color: var(--primary);
}

input[type="number"] {
    font-variant-numeric: tabular-nums;
}

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

.help {
    font-size: 12px;
    color: var(--muted);
    margin: -5px 0 18px;
    line-height: 1.5;
    font-weight: 400;
}

.field .help,
.field-check .help {
    margin: 0;
}

.field-check .help {
    margin-top: 8px;
}

.field-error {
    color: var(--error);
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

.error {
    color: var(--error);
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.5;
    min-height: 0;
}

.error:empty {
    margin: 0;
}

.error-line {
    display: block;
}

.checkline {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}

.filters label {
    margin: 0;
    min-width: 145px;
    flex: 1;
}

.filters .check {
    flex-direction: row;
    align-items: center;
    flex: 0 0 auto;
    height: 43px;
    min-width: 0;
}

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

/* Tables */
.table-wrap {
    overflow: auto;
}

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

th {
    text-align: left;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-soft);
    padding: 13px 12px;
    white-space: nowrap;
}

td {
    padding: 15px 12px;
    border-bottom: 1px solid #e7ecf2;
    vertical-align: middle;
    line-height: 1.5;
}

tr:last-child td {
    border-bottom: 0;
}

.num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.name {
    font-weight: 600;
}

.sub {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

.subtotal td {
    background: #f6f8fb;
    font-weight: 650;
}

.total td {
    background: #e8eef6;
    font-weight: 750;
}

.empty {
    text-align: center;
    padding: 38px 20px;
    color: var(--muted);
    line-height: 1.7;
}

.empty strong {
    color: var(--primary);
    display: block;
}

/* Work timer */
.timer {
    text-align: center;
    padding: 25px 0;
}

.timer-digits {
    font-size: 55px;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    margin: 18px 0;
}

.timer .pill {
    margin-top: 12px;
}

.wide {
    width: 100%;
}

.start-button {
    margin-top: 4px;
    font-size: 16px;
    padding: 16px;
}

.rate-row {
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    gap: 15px;
}

.rate-row:last-child {
    border: 0;
}

.notice {
    padding: 13px 16px;
    border-radius: 8px;
    background: #eef3f9;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.list-item {
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}

.list-item:last-child {
    border: 0;
}

.list-item p {
    margin-top: 8px;
    overflow-wrap: anywhere;
}

details summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--muted);
    margin-top: 8px;
}

pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 11px;
    background: #f3f6f9;
    padding: 10px;
    border-radius: 7px;
}

/* Sign-in pages */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.auth-story {
    background: var(--primary);
    padding: 56px 12%;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-story .eyebrow {
    color: #a9c1dc;
}

.auth-story h1 {
    font-size: 52px;
    line-height: 1.12;
    margin: 22px 0;
    max-width: 430px;
}

.auth-story p {
    color: #c6d5e6;
    max-width: 390px;
}

.story-steps {
    display: flex;
    gap: 12px;
    margin-top: 40px;
}

.story-steps span {
    padding: 12px 17px;
    border: 1px solid #4d6f95;
    border-radius: 30px;
    font-size: 13px;
}

.auth-form-wrap {
    padding: 45px 12%;
    display: flex;
    justify-content: center;
    flex-direction: column;
}

.auth-form {
    width: 100%;
    max-width: 430px;
    margin: auto;
}

.auth-form h2 {
    font-size: 28px;
    margin-bottom: 10px;
}

.auth-form > p {
    margin-bottom: 28px;
    color: var(--muted);
}

.auth-foot {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 15px;
}

.auth-footer {
    font-size: 12px;
    color: var(--muted);
    margin-top: 24px;
}

.local-note {
    font-size: 12px;
    color: #c6d5e6;
    margin-top: 35px;
}

.error-page {
    max-width: 560px;
    margin: 10vh auto;
    padding: 0 16px;
}

.error-page .brand {
    color: var(--primary);
}

/* Toast and dialogs */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 5px 25px #0002;
    padding: 15px 22px;
    border-radius: 10px;
    z-index: 100;
    max-width: 90vw;
}

.toast.error-toast {
    background: #a3301f;
}

dialog {
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 28px;
    max-width: 540px;
    width: calc(100% - 32px);
    max-height: 90vh;
    color: var(--text);
}

dialog::backdrop {
    background: #0a1b2e66;
}

dialog h2 {
    margin-bottom: 22px;
    color: var(--primary);
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.spaced {
    margin-top: 22px;
}

.mobile-brand {
    display: none;
}

@media (min-width: 1500px) {
    .main {
        padding-left: 60px;
        padding-right: 60px;
    }
}

@media (max-width: 1100px) {
    .main {
        padding: 28px 24px;
        margin-left: 208px;
    }

    .sidebar {
        width: 208px;
        padding: 28px 17px;
    }

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

    .auth-story {
        padding: 45px 10%;
    }

    .auth-story h1 {
        font-size: 42px;
    }

    .auth-form-wrap {
        padding: 35px 9%;
    }

    .title-row {
        align-items: flex-start;
    }

    .stats {
        gap: 10px;
    }

    .stat {
        padding: 18px;
    }
}

@media (max-width: 740px) {
    .sidebar {
        position: static;
        width: 100%;
        padding: 18px 16px 10px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar .brand {
        margin-bottom: 8px;
    }

    .nav {
        display: flex;
        overflow: auto;
        margin-top: 18px;
        gap: 4px;
        padding-bottom: 6px;
    }

    .nav a {
        white-space: nowrap;
        font-size: 12px;
        padding: 10px;
    }

    .nav .icon {
        display: none;
    }

    .sidebar-footer {
        display: none;
    }

    .main {
        margin-left: 0;
        padding: 22px 16px;
    }

    .topline {
        margin-bottom: 25px;
    }

    .mobile-brand {
        display: block;
    }

    .title-row {
        flex-direction: column;
        gap: 14px;
        margin-bottom: 22px;
    }

    h1 {
        font-size: 28px;
    }

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

    .stat:last-child {
        grid-column: 1 / -1;
    }

    .stat .value {
        font-size: 27px;
        margin: 10px 0 0;
    }

    .card {
        padding: 19px 15px;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-story {
        padding: 24px;
    }

    .auth-story > div:nth-child(2),
    .auth-story > .local-note {
        display: none;
    }

    .auth-form-wrap {
        padding: 32px 16px;
    }

    .auth-form {
        max-width: 450px;
    }

    .filters label {
        min-width: 120px;
    }

    .grid-two {
        gap: 0;
    }

    .timer-digits {
        font-size: 48px;
    }

    .form-row {
        gap: 10px;
    }

    .card-title {
        align-items: flex-start;
    }

    td,
    th {
        padding: 12px 9px;
    }

    .story-steps {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
    }
}
