:root {
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #d7d0c2;
    --paper: #fbf7ef;
    --paper-dark: #f1eadb;
    --accent: #0f766e;
    --danger: #b91c1c;
    --soft: #eef2f7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: #f4f0e8;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

a {
    color: var(--accent);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
}

.topbar nav {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 24px auto;
}

.container.wide {
    width: min(1480px, calc(100% - 32px));
}

.panel {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

.date-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.date-nav form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.button,
button {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    padding: 10px 14px;
    text-decoration: none;
    font-weight: 700;
}

.button.secondary {
    background: #374151;
}

.button.light {
    background: #e5e7eb;
    color: var(--ink);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 10px;
    font: inherit;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-actions {
    margin-top: 16px;
}

.book {
    position: relative;
    display: grid;
    grid-template-columns: 86px 1fr;
    min-height: 780px;
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
}

.book-panel {
    padding: 16px;
    background: #fffdf8;
}

.book-spread {
    display: grid;
    grid-template-columns: 82px repeat(3, minmax(280px, 1fr));
    min-height: calc(var(--book-min-height) + 46px);
    overflow-x: auto;
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45), 0 12px 30px rgba(31, 41, 55, 0.08);
}

.hour-band.even-hour,
.hour-bg.even-hour {
    background: rgba(251, 247, 239, 0.92);
}

.hour-band.odd-hour,
.hour-bg.odd-hour {
    background: rgba(241, 234, 219, 0.92);
}

.book-times,
.book-day {
    min-width: 0;
    border-right: 1px solid var(--line);
}

.book-times {
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--paper-dark);
}

.book-day-title {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 46px;
    border-bottom: 2px solid #c9bfae;
    background: #efe4d0;
    color: #3f3528;
}

.dimmed-day {
    background: #d8d1c4;
}

.dimmed-day .book-day-title {
    background: #c9bca9;
    color: #2f2a24;
}

.dimmed-day .hour-bg.even-hour {
    background: rgba(202, 194, 180, 0.88);
}

.dimmed-day .hour-bg.odd-hour {
    background: rgba(187, 178, 163, 0.88);
}

.dimmed-day .empty-note,
.dimmed-day .closed-overlay {
    color: #3f3528;
}

.book-day-title strong {
    font-size: 18px;
}

.book-day-title span,
.muted-title {
    color: var(--muted);
    font-size: 13px;
}

.admin-day-column {
    min-height: var(--book-min-height);
}

.hour-bg {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 0;
    height: var(--hour-height, 60px);
    border-bottom: 1px solid var(--line);
    pointer-events: none;
}

.book-hour-add {
    position: absolute;
    right: 10px;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-top: 8px;
    border: 1px solid rgba(15, 118, 110, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--accent);
    text-decoration: none;
    font-size: 22px;
    font-weight: 700;
    transition: 0.15s ease;
}

.book-hour-add:hover {
    background: var(--accent);
    color: #ffffff;
    transform: scale(1.04);
}

.time-column {
    background: var(--paper-dark);
    border-right: 1px solid var(--line);
}

.time-slot {
    height: var(--hour-height, 60px);
    padding: 8px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
}

.schedule-column {
    position: relative;
}

.block {
    position: absolute;
    left: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 34px;
    border-radius: 6px;
    padding: 8px 10px;
    color: #ffffff;
    background: #64748b;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.block.shade-0 {
    filter: saturate(1.35) brightness(0.96);
}

.block.shade-1 {
    filter: saturate(1.5) brightness(1.16);
}

.block.shade-2 {
    filter: saturate(1.45) brightness(0.82);
}

.block.shade-3 {
    filter: saturate(1.15) brightness(1.34);
}

.block.has-overlap {
    background-color: #b91c1c !important;
    border: 2px solid #fff7ed;
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.25), 0 5px 12px rgba(127, 29, 29, 0.25);
    filter: none;
}

.block strong {
    font-size: 14px;
    line-height: 1.1;
}

.block span {
    font-size: 12px;
    line-height: 1.15;
    opacity: 0.9;
}

.block em {
    display: block;
    margin-top: 3px;
    color: #fff7ed;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
    text-transform: uppercase;
}

.admin-block {
    left: 8px;
    right: 8px;
}

.block-link {
    color: #ffffff;
    text-decoration: none;
}

.block-link:hover {
    filter: brightness(0.96);
}

.draggable-appointment {
    cursor: grab;
}

.draggable-appointment.dragging {
    cursor: grabbing;
    opacity: 0.58;
}

.drop-day.drag-over {
    outline: 3px dashed var(--accent);
    outline-offset: -6px;
    background: #ecfdf5;
}

.drop-day.drag-over .book-day-title {
    background: #ccfbf1;
}

.next-client {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px 18px;
    border: 1px solid #bfdbfe;
    border-left: 6px solid #2563eb;
    border-radius: 8px;
    background: #eff6ff;
}

.next-client span {
    display: block;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.next-client strong {
    display: block;
    margin-top: 2px;
    font-size: 24px;
}

.next-client small {
    display: block;
    color: #334155;
    font-size: 14px;
}

.empty-note {
    padding: 18px;
    color: var(--muted);
}

.login-card {
    max-width: 420px;
    margin: 64px auto;
}

.alert {
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 14px;
}

.alert.error {
    color: var(--danger);
    background: #fee2e2;
}

.alert.success {
    color: #166534;
    background: #dcfce7;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
    gap: 16px;
    align-items: start;
}

.client-layout {
    display: grid;
    grid-template-columns: minmax(340px, 0.9fr) minmax(460px, 1.1fr);
    gap: 16px;
    align-items: start;
}

.stacked-panels {
    display: grid;
    gap: 16px;
}

.history-panel {
    margin-top: 16px;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-item {
    border: 1px solid #e5e7eb;
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    padding: 14px;
    background: #ffffff;
}

.history-item div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.history-item span,
.muted-text {
    color: var(--muted);
}

.history-item p {
    margin: 8px 0 0;
}

.settings-layout {
    display: grid;
    grid-template-columns: minmax(360px, 0.9fr) minmax(480px, 1.1fr);
    gap: 16px;
    align-items: start;
}

.services-settings {
    margin-bottom: 16px;
}

.service-settings-list {
    display: grid;
    gap: 10px;
}

.service-settings-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) 110px;
    align-items: end;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.service-active {
    align-self: center;
    margin-top: 22px;
}

.add-service-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
    align-items: end;
    gap: 12px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 2px solid #e5e7eb;
}

.hours-list,
.holiday-list {
    display: grid;
    gap: 10px;
}

.hours-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 120px 120px;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.holiday-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-weight: 400;
}

.holiday-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.holiday-toggle input {
    width: auto;
}

.year-form {
    display: grid;
    grid-template-columns: 100px auto;
    gap: 8px;
}

.inline-form {
    margin: 12px 0 16px;
}

.closed-day {
    display: grid;
    gap: 6px;
    padding: 46px 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    text-align: center;
}

.closed-day strong {
    font-size: 24px;
}

.closed-day span {
    color: var(--muted);
}

.public-spread .admin-day-column {
    background: rgba(226, 232, 240, 0.35);
}

.public-work-window {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 1;
    background: rgba(255, 255, 255, 0.52);
    border-top: 1px dashed rgba(15, 118, 110, 0.55);
    border-bottom: 1px dashed rgba(15, 118, 110, 0.55);
    pointer-events: none;
}

.public-closed-window {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    min-height: 28px;
    padding: 12px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #1f2937;
    text-align: center;
    pointer-events: none;
}

.public-closed-window strong {
    font-size: 15px;
    line-height: 1.3;
}

.public-closed-before {
    border-top: 0;
}

.public-closed-after {
    border-bottom: 0;
}

.public-block {
    z-index: 3;
}

.closed-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-content: center;
    gap: 4px;
    padding: 16px;
    background: rgba(107, 114, 128, 0.14);
    text-align: center;
}

.closed-overlay strong {
    font-size: 20px;
}

.closed-overlay span {
    color: var(--muted);
}

.sms-intro {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.sms-intro h2 {
    margin-top: 0;
}

.sms-template-form textarea {
    width: 100%;
    resize: vertical;
}

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    background: #e5e7eb;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-sent {
    background: #dcfce7;
    color: #166534;
}

.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.status-skipped {
    background: #e5e7eb;
    color: #374151;
}

.full-field {
    margin-top: 14px;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-head h2 {
    margin: 0;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 8px;
}

.mode-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    border-bottom: 1px solid #e5e7eb;
}

.mode-tabs a {
    padding: 10px 12px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
    border-bottom: 3px solid transparent;
}

.mode-tabs a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.spaced-grid {
    margin-top: 14px;
}

.client-picker-field {
    display: grid;
    align-content: start;
    gap: 8px;
}

.quick-client-open {
    justify-self: start;
}

.quick-client-dialog {
    width: min(620px, calc(100% - 24px));
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 20px;
    color: var(--ink);
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(31, 41, 55, 0.28);
}

.quick-client-dialog::backdrop {
    background: rgba(31, 41, 55, 0.48);
}

.quick-client-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.quick-client-dialog-head h2,
.quick-client-dialog-head p {
    margin: 0;
}

.quick-client-dialog-head p {
    margin-top: 4px;
    color: var(--muted);
}

.dialog-close {
    width: auto;
}

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

.quick-client-error {
    margin-top: 14px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    font-weight: 700;
}

.check-row input {
    width: auto;
}

.danger-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.danger-button {
    background: var(--danger);
}

button:disabled,
.button.disabled {
    cursor: wait;
    opacity: 0.62;
}

.duration-hint {
    color: var(--muted);
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.data-table small {
    display: block;
    color: var(--muted);
}

.stat {
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
}

.stat strong {
    display: block;
    font-size: 28px;
}

@media (max-width: 760px) {
    .topbar,
    .date-nav {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-grid,
    .dashboard-grid,
    .split-layout,
    .client-layout,
    .settings-layout,
    .service-settings-row,
    .add-service-form {
        grid-template-columns: 1fr;
    }

    .hours-row,
    .holiday-row {
        grid-template-columns: 1fr;
        align-items: stretch;
        flex-direction: column;
    }

    .container {
        width: min(100% - 20px, 1120px);
        margin: 16px auto;
    }

    .book {
        grid-template-columns: 68px 1fr;
    }

    .book-spread {
        display: block;
        overflow-x: visible;
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .book-times {
        display: none;
    }

    .book-day {
        margin-bottom: 18px;
        border: 1px solid var(--line);
        background: var(--paper);
        box-shadow: 0 8px 18px rgba(31, 41, 55, 0.08);
    }

    .book-day-title {
        position: sticky;
        top: 0;
        z-index: 6;
    }

    .admin-day-column {
        min-height: var(--book-min-height);
    }

    .next-client {
        align-items: flex-start;
        flex-direction: column;
    }

    .sms-intro {
        align-items: flex-start;
        flex-direction: column;
    }

    .time-slot {
        font-size: 12px;
    }
}
