:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #eef4f3;
    --ink: #16202a;
    --muted: #647383;
    --line: #dbe3ea;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #c026d3;
    --warning: #b45309;
    --danger: #b91c1c;
    --shadow: 0 18px 40px rgba(22, 32, 42, 0.08);
}

* {
    box-sizing: border-box;
}

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

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-height: 64px;
    padding: 12px 24px;
}

.topnav {
    align-items: center;
    display: flex;
    flex: 1;
    gap: 6px;
    justify-content: center;
    min-width: 0;
}

.nav-button {
    background: transparent;
    border: 0;
    border-radius: 7px;
    color: var(--muted);
    min-height: 36px;
    padding: 8px 10px;
}

.nav-button.active {
    background: var(--surface-soft);
    color: var(--ink);
    font-weight: 750;
}

.brand {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    align-items: center;
    background: var(--primary);
    border-radius: 8px;
    color: #ffffff;
    display: inline-flex;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.brand-text {
    font-size: 19px;
    font-weight: 750;
}

.workspace {
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.auth-layout {
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) 420px;
    min-height: calc(100vh - 64px);
}

.intro {
    align-self: center;
    padding: 24px 0;
}

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

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

h1 {
    font-size: 40px;
    line-height: 1.08;
    margin-bottom: 14px;
}

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

h3 {
    font-size: 17px;
    margin-bottom: 6px;
}

.intro p,
.muted {
    color: var(--muted);
    line-height: 1.55;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.auth-panel {
    align-self: center;
}

.tabs {
    background: var(--surface-soft);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 18px;
    padding: 4px;
}

.tab-button {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    min-height: 38px;
}

.tab-button.active {
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
}

.form {
    display: grid;
    gap: 14px;
}

.form-row {
    display: grid;
    gap: 6px;
}

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

label {
    color: #324152;
    font-size: 14px;
    font-weight: 650;
}

input,
select {
    background: #ffffff;
    border: 1px solid #cfd9e2;
    border-radius: 7px;
    color: var(--ink);
    min-height: 44px;
    padding: 10px 12px;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
    outline: none;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.button-row {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

.button {
    align-items: center;
    border: 0;
    border-radius: 7px;
    display: inline-flex;
    font-weight: 750;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
}

.button.primary {
    background: var(--primary);
    color: #ffffff;
}

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

.button.secondary {
    background: #e6edf1;
    color: #263645;
}

.status {
    border-radius: 7px;
    display: none;
    font-size: 14px;
    line-height: 1.45;
    margin-top: 14px;
    padding: 10px 12px;
}

.status.show {
    display: block;
}

.status.error {
    background: #fee2e2;
    color: var(--danger);
}

.status.success {
    background: #dcfce7;
    color: #166534;
}

.dashboard-head {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-head {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 20px;
}

.dashboard-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: 290px minmax(0, 1fr);
}

.management-panel {
    margin-bottom: 18px;
}

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

.management-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.management-grid.single-management {
    grid-template-columns: 1fr;
}

.management-grid.single-management .management-card {
    max-width: none;
}

.settings-panel {
    max-width: 960px;
}

.management-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    min-width: 0;
    padding: 14px;
}

.compact-form {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 76px auto;
}

.service-form {
    grid-template-columns: minmax(0, 1.4fr) 86px 86px minmax(0, 1fr) auto;
}

.compact-form input,
.compact-form select {
    min-height: 38px;
}

.item-list {
    display: grid;
    gap: 8px;
}

.list-item {
    background: #f9fbfc;
    border: 1px solid #edf1f4;
    border-radius: 8px;
    display: grid;
    gap: 3px;
    padding: 10px;
}

.list-item strong {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 0;
}

.list-item-head {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.small-button {
    font-size: 13px;
    min-height: 32px;
    padding: 6px 10px;
}

.danger-button {
    background: #fee2e2;
    color: var(--danger);
}

.list-item span,
.step-list small {
    color: var(--muted);
    font-size: 13px;
}

.service-item {
    align-content: start;
}

.step-list {
    display: grid;
    gap: 3px;
    margin-top: 4px;
}

.metric-list {
    display: grid;
    gap: 12px;
    margin: 16px 0 20px;
}

.metric {
    background: var(--surface-soft);
    border-radius: 8px;
    padding: 12px;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 13px;
}

.metric strong {
    display: block;
    font-size: 20px;
    margin-top: 2px;
}

.calendar-toolbar {
    align-items: end;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.calendar-actions {
    align-items: center;
    display: flex;
    gap: 12px;
}

.view-toggle {
    background: var(--surface-soft);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    grid-template-columns: 1fr 1fr;
    min-width: 170px;
    padding: 4px;
}

.resource-calendar {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
}

.resource-header {
    background: #f9fbfc;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 72px repeat(var(--resource-count), minmax(180px, 1fr));
    min-width: calc(72px + var(--resource-count) * 180px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.time-corner,
.resource-title {
    min-height: 58px;
    padding: 10px;
}

.time-corner {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 13px;
    font-weight: 750;
}

.resource-title {
    border-left: 1px solid var(--line);
    display: grid;
    gap: 2px;
    grid-template-columns: auto minmax(0, 1fr);
}

.resource-title strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-title span:last-child {
    color: var(--muted);
    font-size: 13px;
    grid-column: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-dot {
    border-radius: 999px;
    height: 10px;
    margin-top: 6px;
    width: 10px;
}

.resource-body {
    display: grid;
    grid-template-columns: 72px repeat(var(--resource-count), minmax(180px, 1fr));
    min-width: calc(72px + var(--resource-count) * 180px);
}

.time-axis,
.resource-column {
    min-height: var(--calendar-height);
    position: relative;
}

.time-axis {
    background: #fbfcfd;
}

.time-label {
    color: var(--muted);
    font-size: 12px;
    padding-right: 8px;
    position: absolute;
    right: 0;
    transform: translateY(-8px);
}

.resource-column {
    background: #ffffff;
    border-left: 1px solid var(--line);
}

.grid-line {
    border-top: 1px solid #edf1f4;
    left: 0;
    position: absolute;
    right: 0;
}

.availability-block {
    background: rgba(15, 118, 110, 0.06);
    border-left: 2px solid rgba(15, 118, 110, 0.26);
    left: 4px;
    position: absolute;
    right: 4px;
}

.absence-block,
.calendar-event {
    border-radius: 7px;
    left: 8px;
    overflow: hidden;
    position: absolute;
    right: 8px;
}

.absence-block {
    background: rgba(180, 83, 9, 0.12);
    border: 1px dashed rgba(180, 83, 9, 0.45);
    color: var(--warning);
    display: grid;
    font-size: 12px;
    gap: 2px;
    padding: 7px;
    z-index: 2;
}

.calendar-event {
    background: #ffffff;
    border: 1px solid rgba(22, 32, 42, 0.14);
    border-left: 5px solid var(--event-color);
    box-shadow: 0 10px 18px rgba(22, 32, 42, 0.12);
    display: grid;
    gap: 2px;
    padding: 8px;
    z-index: 3;
}

.calendar-event strong,
.calendar-event span,
.calendar-event small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event strong {
    font-size: 14px;
    white-space: nowrap;
}

.calendar-event span {
    color: #354657;
    font-size: 13px;
    white-space: nowrap;
}

.calendar-event small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.3;
}

.calendar-event-time {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.calendar-empty {
    margin-top: 14px;
}

.pill {
    background: #fef3c7;
    border-radius: 999px;
    color: var(--warning);
    font-size: 12px;
    font-weight: 750;
    padding: 4px 8px;
}

.segments {
    color: var(--muted);
    display: grid;
    gap: 4px;
    font-size: 14px;
    margin-top: 10px;
}

.loading-view {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.shop-edit-form {
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.modal-backdrop {
    align-items: center;
    background: rgba(15, 23, 42, 0.38);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 20px;
    position: fixed;
    z-index: 40;
}

.modal {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(22, 32, 42, 0.24);
    max-height: calc(100vh - 40px);
    max-width: 720px;
    overflow: auto;
    padding: 22px;
    width: min(720px, 100%);
}

.wide-modal {
    max-width: 1120px;
    width: min(1120px, 100%);
}

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

.step-editor {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 14px;
    padding-top: 18px;
}

.editable-step-list {
    display: grid;
    gap: 10px;
}

.step-edit-form {
    background: #f9fbfc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    grid-template-columns: 70px minmax(180px, 1.4fr) 90px minmax(150px, 1fr) auto auto auto;
    padding: 10px;
}

.step-form {
    grid-template-columns: minmax(0, 1.2fr) 80px minmax(0, 1fr) auto auto auto;
}

.check-row {
    align-items: center;
    color: #324152;
    display: flex;
    font-size: 14px;
    font-weight: 650;
    gap: 8px;
}

.check-row input {
    min-height: auto;
    width: auto;
}

.compact-check {
    background: #f9fbfc;
    border: 1px solid var(--line);
    border-radius: 7px;
    min-height: 38px;
    padding: 8px 10px;
}

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

.icon-button {
    align-items: center;
    background: #edf2f5;
    border: 0;
    border-radius: 7px;
    color: var(--ink);
    display: inline-flex;
    font-size: 24px;
    height: 38px;
    justify-content: center;
    line-height: 1;
    width: 38px;
}

.slot-suggestions {
    background: var(--surface-soft);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    padding: 10px;
}

.slot-suggestions > span:first-child {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.slot-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.slot-button {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 750;
    min-height: 32px;
    padding: 6px 10px;
}

.slot-button:hover {
    border-color: var(--primary);
}

.slot-warning {
    color: var(--danger);
    font-size: 13px;
    line-height: 1.4;
}

@media (max-width: 860px) {
    .auth-layout,
    .dashboard-grid,
    .form-grid,
    .management-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 32px;
    }

    .topbar,
    .dashboard-head,
    .page-head,
    .calendar-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .topnav {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .calendar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .section-head {
        flex-direction: column;
    }

    .view-toggle {
        width: 100%;
    }

    .compact-form,
    .service-form,
    .step-form,
    .step-edit-form,
    .service-editor {
        grid-template-columns: 1fr;
    }

    .step-editor {
        border-top: 1px solid var(--line);
    }
}
