:root {
    --bg: #f6f5f3;
    --bg-deep: #eceae6;
    --paper: #fff;
    --ink: #1a1a1a;
    --muted: #6d6964;
    --line: #e6e3de;
    --green: #145c3e;
    --green-soft: #e7f3ec;
    --clay: #8e2f1c;
    --clay-soft: #f8ece8;
    --gold: #6d5318;
    --gold-soft: #f7f1e4;
    --shadow: none;
    --display: "Helvetica Neue", Helvetica, Arial, sans-serif;
    --sans: "Avenir Next", "Segoe UI", sans-serif;
    --nav-h: 3.5rem;
}

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

html {
    font-size: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 0.95rem;
    line-height: 1.45;
    color-scheme: light;
}

img,
svg,
input,
select,
textarea,
button {
    max-width: 100%;
}

h1, h2, h3, p {
    overflow-wrap: break-word;
}

h1, h2, h3 {
    font-family: var(--display);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

h1 {
    margin: 0;
    font-size: 1.65rem;
}

h2 {
    margin: 0;
    font-size: 1.15rem;
}

h3 {
    margin: 0;
    font-size: 1rem;
}

p {
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.text-link {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

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

button {
    cursor: pointer;
}

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

legend {
    padding: 0;
    font-weight: 650;
}

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

.skip {
    position: absolute;
    left: 1rem;
    top: -4rem;
    background: var(--ink);
    color: #f6f1ea;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    z-index: 5;
}

.skip:focus {
    top: 1rem;
}

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

.shell {
    min-height: 100vh;
}

.sidebar {
    display: none;
}

.main-col {
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: min(1080px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 0.75rem 0 0;
}

.topbar-studio,
.topbar-date {
    margin: 0;
}

.topbar-date {
    color: var(--muted);
    margin-right: auto;
}

.page {
    width: min(1080px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 0.6rem 0 1.75rem;
}

.tabbar {
    position: fixed;
    z-index: 4;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: #1c1915;
    color: #f6f1ea;
    padding-bottom: env(safe-area-inset-bottom);
    min-height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.tabbar .nav-link {
    color: #f6f1ea;
    justify-content: center;
    flex-direction: column;
    gap: 0.15rem;
    min-height: var(--nav-h);
    font-size: 0.72rem;
    border-radius: 0;
}

.tabbar .nav-link.is-active {
    color: #f3d2b0;
    background: transparent;
}

body {
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
    font-size: 0.82rem;
}

.brand-mark {
    width: 2.1rem;
    height: 2.1rem;
    border: 1.5px solid currentColor;
    border-radius: 999px;
    position: relative;
    flex: none;
}

.brand-mark::after {
    content: "";
    position: absolute;
    left: 0.42rem;
    right: 0.42rem;
    bottom: 0.5rem;
    height: 0.55rem;
    border-bottom: 1.5px solid currentColor;
    border-radius: 0 0 999px 999px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 36px;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
}

.icon {
    width: 1.2rem;
    height: 1.2rem;
    flex: none;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.kicker {
    margin: 0 0 0.15rem;
    color: var(--muted);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.lead {
    max-width: 40rem;
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stat,
.card,
.bill,
.form-card,
.lesson,
.guest-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: none;
}

.stat {
    padding: 0.7rem 0.8rem;
}

.stat span,
.stat p {
    color: var(--muted);
}

.stat b {
    display: block;
    margin-top: 0.2rem;
    font-family: var(--display);
    font-size: 1.35rem;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.stack {
    display: grid;
    gap: 0.5rem;
}

.client-lessons {
    gap: 0;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.client-lessons > h2 {
    padding: 0.65rem 0.8rem 0.15rem;
}

.client-lessons .lesson {
    background: transparent;
    border: 0;
    border-radius: 0;
    border-top: 1px solid var(--line);
}

.client-lessons .empty {
    margin: 0;
    padding: 0.55rem 0.8rem 0.75rem;
}

.status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 2.75rem;
}

.client-pay .bill {
    grid-template-columns: 1fr;
}

.client-pay .actions {
    justify-content: flex-start;
    max-width: none;
}

.amount-edit[open] {
    flex-basis: 100%;
}

.stack + .stack,
.stats + .stack,
.today-list + .stack {
    margin-top: 1.1rem;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
}

.bill {
    display: grid;
    gap: 0.55rem;
    padding: 0.75rem 0.85rem;
    min-width: 0;
}

.bill.is-owing {
    border-left: 2px solid var(--clay);
}

.bill.is-settled {
    border-left: 2px solid #ddd8d0;
}

.bill-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.bill h2 a,
.bill h3 a {
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 0.16em;
}

.bill h2 a:hover,
.bill h3 a:hover {
    text-decoration-color: currentColor;
}

.bill-amount {
    margin: 0;
    font-family: var(--display);
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.is-owing .bill-amount {
    color: var(--clay);
}

.bill-amount-quiet {
    color: var(--ink);
    font-size: 1.05rem;
}

.bill-meta,
.cluster,
.actions,
.filters,
.month-nav,
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.7rem;
}

.bill-meta,
.help {
    color: var(--muted);
    font-size: 0.95rem;
}

.note {
    color: var(--gold);
}

.warn {
    color: var(--clay);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.6rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
}

.badge-owe { background: var(--clay-soft); color: var(--clay); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-warn { background: var(--gold-soft); color: var(--gold); }
.badge-muted { background: var(--bg-deep); color: var(--muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    text-decoration: none;
    line-height: 1.2;
    touch-action: manipulation;
}

.btn-small {
    min-height: 32px;
    padding: 0.25rem 0.6rem;
    font-size: 0.88rem;
}

.btn-primary {
    background: var(--green);
    color: #f4fff8;
}

.btn-ink {
    background: var(--ink);
    color: #f6f1ea;
}

.btn-ghost {
    border-color: #d5cbbd;
    background: #fff;
}

.btn-danger {
    background: var(--clay);
    color: #fff;
}

.btn:disabled {
    opacity: 0.6;
}

.flash {
    margin: 0 0 1rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
}

.flash-ok {
    background: var(--green-soft);
    color: var(--green);
}

.flash-error {
    background: var(--clay-soft);
    color: var(--clay);
}

.empty {
    padding: 1rem 0;
    color: var(--muted);
}

.today-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.today-list li {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr);
    gap: 0.75rem;
    align-items: baseline;
    padding: 0.55rem 0.8rem;
    border-top: 1px solid var(--line);
}

.today-list li:first-child {
    border-top: 0;
}

.today-list a {
    color: inherit;
    text-decoration: none;
}

.pay-list {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.pay-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.55rem;
    padding: 0.4rem 0.7rem;
    border-top: 1px solid var(--line);
}

.pay-row:first-child {
    border-top: 0;
}

.totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.4rem;
    margin: 0 0 1.1rem;
    font-variant-numeric: tabular-nums;
}

.totals b {
    font-weight: 600;
}

.pay-row .name {
    flex: 1 1 8rem;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.pay-row .when,
.pay-row .amount {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pay-row .when.is-late {
    color: var(--clay);
}

.pay-row .price-edit {
    flex: 0 0 auto;
}

.pay-row .price-edit[open] {
    flex-basis: auto;
}

.pay-row .price-edit summary {
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-variant-numeric: tabular-nums;
    list-style: none;
    cursor: text;
}

.pay-row .price-edit summary::-webkit-details-marker {
    display: none;
}

.pay-row .price-edit[open] summary {
    display: none;
}

.pay-row .price-edit[open] form {
    display: block;
    margin: 0;
    max-width: none;
}

.pay-row .price-edit .input {
    width: 4.6rem;
    min-height: 28px;
    padding: 0 0.2rem;
    border: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.field {
    display: grid;
    gap: 0.35rem;
}

.field span {
    font-size: 0.92rem;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 40px;
    padding: 0.45rem 0.65rem;
    border: 1px solid #ddd8d1;
    border-radius: 8px;
    background: #fff;
    font-size: 16px;
}

input[type="date"].input,
input[type="time"].input {
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    padding: 0 0.65rem;
    line-height: 40px;
    -webkit-appearance: none;
    appearance: none;
}

.textarea {
    min-height: 9rem;
    resize: vertical;
    line-height: 1.45;
}

.field-error {
    color: var(--clay);
}

.form-card,
.card,
.clinical {
    padding: 1rem;
}

.form-card + .form-card,
.clinical + .card,
.card + .stack {
    margin-top: 1rem;
}

.plans {
    display: grid;
    gap: 0.75rem;
}

.plans legend {
    margin-bottom: 0.2rem;
}

.plan {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.plan:has(input:checked) {
    border-color: var(--green);
    background: var(--green-soft);
}

.plan span,
.plan strong {
    display: block;
}

.plan span span {
    color: var(--muted);
    font-size: 0.92rem;
}

.slot-row {
    display: grid;
    gap: 0.75rem;
    align-items: end;
}

.clinical {
    background: #f4efe4;
    border: 1px solid #e3d6bc;
    border-left: 2px solid var(--gold);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0.7rem 0.85rem;
}

.clinical.is-empty {
    border-left-color: var(--clay);
}

.clinical h2 {
    margin-bottom: 0.45rem;
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
}

.clinical.is-empty h2 {
    color: var(--clay);
}

.clinical-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.pips {
    display: flex;
    gap: 0.35rem;
}

.pip {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 999px;
    background: #d9d0c4;
}

.pip.is-used {
    background: var(--green);
}

.plain-list {
    margin: 0;
    padding-left: 1.1rem;
}

.lesson {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem 0.75rem;
    padding: 0.55rem 0.75rem;
    min-width: 0;
}

.lesson-time {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.amount-edit summary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    color: var(--muted);
}

.amount-edit:not([open]) form {
    display: none;
}

.amount-edit[open] form {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.4rem;
    max-width: 14rem;
}

.filters {
    margin-bottom: 0.8rem;
}

.filters .grow {
    flex: 1 1 12rem;
}

.page-head .filters {
    flex: 1 1 14rem;
    margin: 0;
}

.text-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.9rem;
    margin: 0 0 0.75rem;
}

.text-tabs a {
    color: var(--muted);
    text-decoration: none;
}

.text-tabs a.is-active {
    color: var(--ink);
}

.client-row .phone {
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.client-row form {
    display: inline-flex;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid #d5cbbd;
}

.chip.is-active {
    background: var(--ink);
    color: #f6f1ea;
    border-color: var(--ink);
}

.pager {
    gap: 0.2rem 0.85rem;
    margin-top: 0.85rem;
}

.pager a,
.pager span {
    color: var(--muted);
    text-decoration: none;
}

.pager [aria-current="page"] {
    color: var(--ink);
}

.schedule {
    display: grid;
    gap: 0.85rem;
}

.month-nav {
    margin-bottom: 0.65rem;
}

.month {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.dow {
    color: var(--muted);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    padding-bottom: 0.15rem;
}

.day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.16rem;
    min-height: 3.15rem;
    padding: 0.35rem 0.15rem 0.3rem;
    border-radius: 8px;
    color: inherit;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.day:has(.day-count):not(.is-selected):not(.is-closed) {
    background: var(--bg);
}

.day.is-empty {
    pointer-events: none;
}

.day.is-today {
    box-shadow: inset 0 0 0 1px var(--ink);
}

.day.is-selected {
    background: var(--green);
    color: #f4fff8;
}

.day.is-closed:not(.is-selected) {
    background: var(--clay-soft);
    color: var(--clay);
}

.day.is-range:not(.is-selected) {
    box-shadow: inset 0 0 0 2px var(--green);
}

.close-row,
.holiday-range {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.holiday-range .input {
    width: 10.2rem;
    flex: 0 0 auto;
}

.add-one summary {
    width: fit-content;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
}

.add-one summary::-webkit-details-marker {
    display: none;
}

.add-one:not([open]) form {
    display: none;
}

.add-one[open] form {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.55rem;
}

.add-one-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.add-one-row .input {
    width: 8.5rem;
    flex: 0 0 auto;
}

.client-pick {
    position: relative;
}

.pick-list {
    position: absolute;
    z-index: 3;
    top: calc(100% + 0.2rem);
    left: 0;
    right: 0;
    max-height: 11rem;
    margin: 0;
    padding: 0.2rem;
    overflow: auto;
    list-style: none;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.pick-list[hidden] {
    display: none;
}

.pick-list button {
    width: 100%;
    min-height: 36px;
    padding: 0.3rem 0.55rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.pick-list button:hover,
.pick-list button:focus {
    background: var(--bg-deep);
}

.close-days .btn,
.close-row > .btn {
    width: auto;
}

.btn.is-on {
    border-color: var(--green);
    background: var(--green-soft);
    color: var(--green);
}

.day-count {
    font-size: 0.68rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.day.is-selected .day-count,
.day.is-closed .day-count {
    color: inherit;
}

.day-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.85rem;
}

.day-head h2 {
    margin-right: auto;
}

.day-head .note {
    margin: 0;
}

.day-panel {
    min-width: 0;
}

.day-panel .holiday-range {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    width: fit-content;
    max-width: 100%;
}

.day-panel .holiday-range .input {
    width: 10.4rem;
    flex: 0 1 10.4rem;
    min-width: 0;
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    padding: 0 0.45rem;
    font-size: 0.85rem;
}

.day-scroll {
    min-width: 0;
}

.day-list {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
}

.day-lesson {
    display: grid;
    grid-template-columns: 3.2rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.2rem 0.75rem;
    margin: 0 -0.35rem;
    padding: 0.38rem 0.35rem;
    border-radius: 8px;
}

.day-lesson:hover {
    background: var(--bg);
}

.day-lesson .lesson-time {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.lesson-who {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    min-width: 0;
}

.day-lesson .name {
    min-width: 0;
    overflow: hidden;
    color: inherit;
    font-weight: 600;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.day-lesson .lesson-state {
    flex: none;
    color: var(--muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.day-lesson .actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.25rem;
    max-width: none;
}

.day-lesson .actions .btn {
    min-height: 28px;
    padding: 0.1rem 0.45rem;
    font-size: 0.78rem;
}

.guest-body {
    display: grid;
    place-items: center;
    padding: 1.25rem 1rem 2rem;
}

.guest-card {
    width: min(28rem, 100%);
    padding: 1.25rem;
}

.guest-card h1 {
    margin-top: 1rem;
}

.wrap {
    overflow-wrap: anywhere;
}

@media (min-width: 640px) {
    .stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .plans legend {
        grid-column: 1 / -1;
    }

    .slot-row {
        grid-template-columns: minmax(11rem, 16rem) 8.5rem auto;
        justify-content: start;
    }
}

@media (min-width: 800px) {
    .bill {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .actions {
        justify-content: end;
        max-width: 28rem;
    }
}

@media (min-width: 900px) {
    body {
        padding-bottom: 0;
    }

    .shell {
        display: grid;
        grid-template-columns: 16rem minmax(0, 1fr);
    }

    .sidebar {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        position: sticky;
        top: 0;
        height: 100vh;
        padding: 1.3rem 1rem;
        background: #1c1915;
        color: #f6f1ea;
    }

    .sidebar .brand small,
    .side-foot {
        color: #cfc4b6;
    }

    .side-nav {
        display: grid;
        gap: 0.25rem;
    }

    .sidebar .nav-link {
        color: #f6f1ea;
    }

    .sidebar .nav-link.is-active {
        background: #2c2824;
        color: #f3d2b0;
    }

    .side-foot {
        margin-top: auto;
        font-size: 0.92rem;
    }

    .tabbar {
        display: none;
    }

    .topbar-studio {
        display: none;
    }
}

@media (min-width: 960px) {
    .day {
        min-height: 3.35rem;
    }
}

@media (max-width: 520px) {
    .day-lesson {
        grid-template-columns: 3rem minmax(0, 1fr);
    }

    .day-lesson .actions {
        grid-column: 2;
        justify-content: flex-start;
    }

    .day-panel .holiday-range {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        width: 100%;
    }

    .day-panel .holiday-range .input {
        width: 100%;
        flex: 1 1 auto;
    }

    .day-panel .holiday-range .btn {
        grid-column: 1 / -1;
        justify-self: start;
    }
}

@media (max-width: 480px) {
    .actions .btn {
        flex: 1 1 auto;
    }
}
