:root {
    color-scheme: dark;
    --ink: #e6edf7;
    --muted: #a5b2c6;
    --accent: #78b4ff;
    --accent-hover: #a3ccff;
    --on-accent: #101f35;
    --line: #354258;
    --bg: #10151e;
    --paper: #192230;
    --surface: #222e40;
    --surface-hover: #2d3c52;
    --input: #121b28;
    --good-bg: #203c2d;
    --good: #99e0ae;
    --warn-bg: #3b301e;
    --warn: #f2c888;
    --error-bg: #3d2525;
    --error: #ffb4ac;
    --error-line: #86514a;
    --focus: #a3ccff;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif
}

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

a:hover {
    text-decoration: underline
}

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

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 17px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap
}

button:hover, .button:hover {
    background: var(--surface-hover);
    text-decoration: none
}

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

.primary {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent)
}

.primary:hover {
    background: var(--accent-hover)
}

.quiet {
    border-color: transparent;
    background: transparent;
    padding: 7px 10px
}

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

.brand {
    font-size: 20px;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px
}

.brand strong {
    font-weight: 500;
    color: var(--muted)
}

.brand-mark {
    position: relative;
    margin-right: 7px;
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 800
}

.brand-mark span {
    color: var(--accent);
    font-size: 28px;
    position: absolute;
    right: 0;
    top: -9px
}

main {
    max-width: 1380px;
    padding: 46px 5vw 64px;
    margin: auto;
    min-height: calc(100vh - 155px)
}

h1 {
    font-size: clamp(30px, 3.3vw, 44px);
    font-weight: 580;
    letter-spacing: -1.6px;
    line-height: 1.15;
    margin: 13px 0
}

h2 {
    font-size: 19px;
    letter-spacing: -.4px;
    font-weight: 650;
    margin: 0 0 20px
}

p {
    margin: 10px 0 18px
}

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

.small, .hint {
    font-size: 12px
}

.eyebrow {
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 1.7px;
    color: var(--muted)
}

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

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

.actions form {
    margin: 0
}

.panel {
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 3px 12px #0000001a
}

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

.stats .panel {
    display: flex;
    flex-direction: column
}

.stats strong {
    font-size: 40px;
    font-weight: 550;
    letter-spacing: -1px;
    margin: 12px 0 4px
}

.stats .panel > span:last-child {
    font-size: 12px;
    color: var(--muted)
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 25px 28px
}

.section-heading h2 {
    margin: 0
}

.clients-panel {
    padding: 0;
    overflow: hidden
}

.table-scroll {
    overflow: auto
}

table {
    border-collapse: collapse;
    width: 100%;
    text-align: left
}

th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    font-weight: 650;
    background: var(--input)
}

td, th {
    padding: 19px 23px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap
}

tbody tr:last-child td {
    border: 0
}

.client-name {
    font-weight: 650;
    font-size: 15px;
    color: var(--ink)
}

.balance {
    font-size: 22px;
    font-weight: 550;
    letter-spacing: -.5px
}

.badge {
    display: inline-block;
    border-radius: 5px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 650
}

.good {
    background: var(--good-bg);
    color: var(--good)
}

.warn {
    background: var(--warn-bg);
    color: var(--warn)
}

.neutral {
    background: var(--surface);
    color: var(--muted)
}

.notice {
    padding: 15px 20px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 9px;
    margin-bottom: 22px;
    font-size: 13px;
    overflow-wrap: anywhere
}

.notice.error {
    background: var(--error-bg);
    border-color: var(--error-line);
    color: var(--error)
}

.notice form {
    margin-top: 10px
}

.empty {
    text-align: center;
    padding: 55px 20px 65px
}

.empty h2 {
    margin: 12px 0
}

.empty-symbol {
    font-size: 46px;
    color: var(--accent)
}

.empty p {
    margin-bottom: 24px
}

footer {
    display: flex;
    justify-content: space-between;
    padding: 20px 5vw;
    color: var(--muted);
    font-size: 11px;
    border-top: 1px solid var(--line)
}

.back {
    font-size: 12px;
    display: inline-block;
    margin-bottom: 22px
}

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

.step {
    float: right;
    color: var(--muted);
    font-size: 22px;
    font-weight: 350
}

.client-form h2 {
    margin-bottom: 27px
}

label {
    display: block;
    font-weight: 600;
    font-size: 12px;
    margin: 19px 0 0
}

input:not([type=checkbox]), textarea, select {
    display: block;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--input);
    padding: 11px 12px;
    margin-top: 7px;
    color: var(--ink);
    outline: none;
    font-size: 14px;
    min-height: 44px
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px #78b4ff29
}

input[type=checkbox] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    margin: 0
}

.check {
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 500;
    font-size: 13px
}

.hint {
    margin: 8px 0 12px;
    line-height: 1.6
}

fieldset {
    border: 0;
    margin: 23px 0 16px;
    padding: 0
}

legend {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px
}

.day-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.day {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    font-size: 11px
}

.inset {
    background: var(--surface);
    padding: 16px;
    border-radius: 9px;
    margin-top: 23px
}

.inset p {
    margin: 5px 0
}

.save-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin: 24px 0 34px
}

.history {
    padding: 25px 0 0;
    overflow: hidden;
    margin-top: 24px
}

.history h2 {
    padding: 0 28px
}

.danger {
    margin-top: 24px;
    background: transparent
}

.danger summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--error)
}

.danger p {
    font-size: 13px
}

.danger form {
    max-width: 420px
}

.danger-button {
    color: var(--error);
    border-color: var(--error-line);
    margin-top: 16px
}

.login {
    max-width: 450px;
    margin: 7vh auto;
    padding: 36px
}

.login h1 {
    font-size: 36px
}

.login .wide {
    width: 100%;
    margin-top: 27px
}

button:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px
}

@media (max-width: 800px) {
    .topbar {
        height: 70px;
        padding: 0 20px
    }

    .brand {
        font-size: 17px
    }

    main {
        padding: 30px 20px
    }

    .heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px
    }

    .stats {
        gap: 10px
    }

    .stats .panel {
        padding: 17px
    }

    .stats strong {
        font-size: 32px
    }

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

    .panel {
        border-radius: 10px
    }

    .section-heading {
        padding: 20px;
        align-items: flex-start;
        flex-direction: column;
        gap: 4px
    }

    .save-bar {
        gap: 18px
    }

    .save-bar span {
        max-width: 100px
    }

    footer {
        padding: 20px
    }

    .login {
        padding: 25px
    }

    .eyebrow {
        font-size: 9px
    }

    td, th {
        padding: 16px 18px
    }
}

@media (prefers-reduced-motion: no-preference) {
    button, .button {
        transition: background .15s
    }
}

.badge.error {
    background: var(--error-bg);
    color: var(--error)
}

.client-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 30px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line)
}

.client-nav a {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    font-weight: 600;
    font-size: 13px
}

.client-nav a[aria-selected=true] {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent)
}

.client-section[hidden] {
    display: none
}

#actions {
    margin-top: 32px
}

#actions h3 {
    font-size: 19px;
    letter-spacing: -.4px;
    font-weight: 650;
    margin: 0 0 20px
}

.client-section {
    margin-bottom: 32px;
    scroll-margin-top: 24px;
    min-width: 0
}

.client-form h3 {
    font-size: 19px;
    letter-spacing: -.4px;
    font-weight: 650;
    margin: 0 0 27px
}

.client-section .save-bar {
    margin-bottom: 0
}

.notification-logs {
    overflow-wrap: anywhere
}

.notification-logs details {
    margin: 18px 0;
    box-shadow: none
}

.notification-logs code {
    white-space: normal
}

.notification-history {
    list-style: none;
    margin: 0;
    padding: 0
}

.notification-history li {
    display: grid;
    gap: 4px;
    padding: 16px 0;
    border-top: 1px solid var(--line)
}

.notification-history time, .notification-history .muted {
    font-size: 12px
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0
}

.timezone-combobox {
    position: relative
}

[data-timezone-picker] > select[hidden] {
    display: none
}

.timezone-combobox input {
    padding-right: 42px
}

.timezone-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    min-height: 42px;
    width: 38px;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--muted)
}

.timezone-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 260px;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--input);
    box-shadow: 0 8px 24px #0005;
    padding: 4px;
    scrollbar-width: thin;
    font-size: 14px;
    font-weight: 400
}

.timezone-options[hidden] {
    display: none
}

.timezone-options > div {
    padding: 9px 10px;
    border-radius: 5px;
    overflow-wrap: anywhere
}

.timezone-options [role=option] {
    cursor: pointer
}

.timezone-options [role=option]:hover, .timezone-options .active {
    background: var(--surface-hover)
}

.timezone-options [aria-selected=true] {
    color: var(--accent)
}

input::placeholder, textarea::placeholder {
    color: var(--muted);
    opacity: 1
}

.threshold-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 12px
}

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

[data-timezone-search-label][hidden] {
    display: none
}

::selection {
    background: var(--accent);
    color: var(--on-accent)
}

html.overlay-scrollbar {
    scrollbar-width: none
}

html.overlay-scrollbar::-webkit-scrollbar {
    display: none
}

.page-scrollbar {
    position: fixed;
    top: 0;
    right: 0;
    width: 16px;
    z-index: 1100;
    touch-action: none;
    user-select: none;
    cursor: grab;
    outline: none
}

.page-scrollbar[hidden] {
    display: none
}

.page-scrollbar::before {
    content: "";
    position: absolute;
    inset: 0 4px 0 6px;
    border-radius: 99px;
    background: var(--muted);
    opacity: .35
}

.page-scrollbar:hover::before, .page-scrollbar:focus-visible::before, .page-scrollbar.dragging::before {
    opacity: .85
}

.page-scrollbar:focus-visible::before {
    outline: 2px solid var(--focus);
    outline-offset: 1px
}

.page-scrollbar.dragging {
    cursor: grabbing
}

@media (forced-colors: active) {
    html.overlay-scrollbar {
        scrollbar-width: auto
    }

    html.overlay-scrollbar::-webkit-scrollbar {
        display: block
    }

    .page-scrollbar {
        display: none
    }
}

.toasts {
    position: fixed;
    top: 96px;
    right: 24px;
    z-index: 1000;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 40px));
    pointer-events: none
}

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 12px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 8px 30px #0005;
    font-size: 13px;
    overflow-wrap: anywhere;
    pointer-events: auto
}

.toast.error {
    background: var(--error-bg);
    border-color: var(--error-line);
    color: var(--error)
}

.toast .quiet {
    flex-shrink: 0;
    min-width: 36px;
    min-height: 36px;
    padding: 4px;
    font-size: 20px;
    color: inherit
}

@media (max-width: 800px) {
    .toasts {
        top: 82px;
        right: 20px
    }
}
