* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a {
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a.btn,
a.brand,
a.cabinet-sidebar-brand,
.cabinet-sidebar-nav a {
    text-decoration: none;
}

a:hover {
    color: var(--color-muted);
}

a.cabinet-sidebar-brand:not(.brand-logo):hover,
.cabinet-sidebar-nav a:hover {
    color: var(--color-text);
}

h1, h2, h3 {
    margin: 0 0 0.75rem;
}

.page-title {
    font-size: 1.5rem;
}

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

.page-container {
    width: 100%;
}

.page-container--public {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}

.page-container--narrow {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.status-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
}

.status-badge--attention,
.status-badge--warning {
    background: var(--status-new-bg);
    color: var(--status-new-text);
    border: 1px solid rgba(146, 64, 14, 0.2);
}

.status-badge--neutral {
    background: var(--color-neutral-bg);
    color: var(--color-neutral-text);
    border: 1px solid var(--color-border);
}

.status-badge--new {
    background: var(--status-new-bg);
    color: var(--status-new-text);
    border: 1px solid rgba(146, 64, 14, 0.2);
}

.status-badge--confirmed {
    background: var(--status-confirmed-bg);
    color: var(--status-confirmed-text);
    border: 1px solid rgba(21, 128, 61, 0.2);
}

.status-badge--completed {
    background: var(--status-completed-bg);
    color: var(--status-completed-text);
    border: 1px solid rgba(22, 101, 52, 0.2);
}

.status-badge--cancelledbymaster,
.status-badge--cancelledbyclient {
    background: var(--status-cancelled-bg);
    color: var(--status-cancelled-text);
    border: 1px solid rgba(153, 27, 27, 0.2);
}

/* Public layout */
.public-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
}

.public-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.public-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.lang-switcher {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.875rem;
}

.lang-switcher:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.danger-zone {
    margin-top: 1.5rem;
}

.public-main {
    flex: 1;
    padding: 1.25rem;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.public-main:has(> .auth-card) {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.brand {
    font-size: 1.25rem;
    text-decoration: none;
}

.brand-logo {
    font-family: var(--font-brand);
    font-weight: 600;
    color: var(--color-brand);
}

a.brand-logo:hover,
a.cabinet-sidebar-brand.brand-logo:hover {
    color: var(--color-brand);
}

.public-nav a {
    text-decoration: none;
}

.public-nav a:hover {
    color: var(--color-muted);
}

/* Hero */
.hero {
    text-align: center;
    padding: 3rem 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin: 0 0 0.75rem;
}

.hero-sub {
    color: var(--color-muted);
    max-width: 28rem;
    margin: 0 auto 1.5rem;
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.features {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.features article,
.features .form-card {
    background: var(--color-surface);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0;
}

/* Cabinet layout (master + client) */
.cabinet-layout {
    min-height: 100vh;
}

.cabinet-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: 240px;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 0;
    overflow-y: auto;
}

.cabinet-sidebar-brand {
    display: block;
    padding: 0 1.25rem 1.5rem;
    font-size: 1.125rem;
    text-decoration: none;
}

.cabinet-sidebar-brand:hover {
    text-decoration: none;
}

.cabinet-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0 0.75rem;
    flex: 1;
}

.cabinet-sidebar-nav a {
    display: block;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--color-muted);
    text-decoration: none;
    font-size: 0.9375rem;
}

.cabinet-sidebar-nav a:hover {
    background: var(--color-neutral-bg);
    color: var(--color-text);
}

.cabinet-sidebar-nav a.active,
.cabinet-sidebar-nav a.active:hover {
    background: var(--color-nav-active-bg);
    color: var(--color-nav-active-text);
    font-weight: 600;
}

.cabinet-sidebar-footer {
    padding: 1rem 0.75rem 0;
    margin-top: auto;
    border-top: 1px solid var(--color-border);
}

.cabinet-sidebar .nav-logout {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.625rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--color-muted);
    font-size: 0.9375rem;
    cursor: pointer;
}

.cabinet-sidebar .nav-logout:hover {
    background: var(--color-neutral-bg);
    color: var(--color-text);
}

.cabinet-content {
    margin-left: 240px;
    min-height: 100vh;
    width: calc(100% - 240px);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cabinet-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 3rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.cabinet-main {
    flex: 1;
    padding: 2rem 3rem;
    width: 100%;
    max-width: none;
}

.cabinet-main .form-card,
.cabinet-main .list-card,
.cabinet-main .auth-card {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card.form-card {
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--color-border);
}

.stat-card--today {
    border-top-color: var(--color-action, #7BAE7F);
}

.stat-card--attention {
    border-top-color: var(--color-attention, #F4B183);
}

.stat-card--clients {
    border-top-color: var(--color-neutral-text, #475569);
}

.stat-card--revenue {
    border-top-color: var(--color-feedback-success-text, #67976B);
}

.stat-card-label {
    font-size: 0.875rem;
    color: var(--color-muted);
    line-height: 1.4;
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text);
}

.stat-card--attention .stat-card-value {
    color: var(--color-attention-text);
}

.master-email,
.client-email,
.session-email {
    font-size: 0.875rem;
    color: var(--color-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
}

/* Forms */
.auth-card {
    background: #FFFFFF;
    border-radius: var(--auth-card-radius, 20px);
    padding: 2rem 1.75rem;
    box-shadow: var(--auth-card-shadow, 0 10px 30px rgba(0, 0, 0, 0.06));
    margin-bottom: 1rem;
    max-width: 420px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.form-card,
.list-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.form-card,
.list-card {
    max-width: 100%;
}

.field {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-row {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.field label {
    font-size: 0.875rem;
    font-weight: 500;
}

.field input,
.field select,
.field textarea {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--color-surface);
    color: var(--color-text);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--color-text);
}

.field-error {
    color: var(--color-error-text);
    font-size: 0.8125rem;
}

.field-invalid label {
    color: var(--color-error-text);
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
    border-color: var(--color-error-text);
    background: var(--color-error-bg);
}

.hint {
    font-size: 0.8125rem;
    color: var(--color-muted);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    border: none;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.25;
    -webkit-appearance: none;
    appearance: none;
}

a.btn,
a.btn:visited {
    text-decoration: none;
}

.btn-primary {
    background: var(--color-action, #7BAE7F);
    color: var(--color-on-action, #FFFFFF);
}

a.btn-primary,
a.btn-primary:visited {
    color: var(--color-on-action, #FFFFFF);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-action-hover, #67976B);
    color: var(--color-on-action, #FFFFFF);
}

.btn-main {
    height: 44px;
    padding: 0 20px;
    font-weight: 600;
    font-size: 0.9375rem;
    gap: 0.375rem;
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

a.btn-secondary,
a.btn-secondary:visited {
    color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-attention {
    background: var(--color-attention, #F4B183);
    color: var(--color-on-attention, #FFFFFF);
}

a.btn-attention,
a.btn-attention:visited {
    color: var(--color-on-attention, #FFFFFF);
}

.btn-attention:hover:not(:disabled) {
    background: var(--color-attention-hover, #E89A67);
    color: var(--color-on-attention, #FFFFFF);
}

.btn-danger {
    background: var(--color-surface);
    color: var(--color-destructive-text);
    border: 1px solid var(--color-destructive-border);
}

a.btn-danger,
a.btn-danger:visited {
    color: var(--color-destructive-text);
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-destructive-bg);
    color: var(--color-destructive-hover);
    border-color: var(--color-destructive);
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

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

.alert-success {
    background: var(--color-feedback-success-bg);
    color: var(--color-feedback-success-text);
}

.alert-warning {
    background: var(--color-attention-bg);
    color: var(--color-attention-text);
    border: 1px solid var(--color-attention-border);
}

.profile-prompt {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
    background: var(--color-attention-bg);
    color: var(--color-attention-text);
    border: 1px solid var(--color-attention-border);
    font-size: 0.9375rem;
}

.profile-prompt p {
    margin: 0;
}

@media (min-width: 480px) {
    .profile-prompt {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.toast-banner {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    max-width: min(90vw, 420px);
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.9375rem;
    animation: toast-in 0.3s ease-out;
}

.toast-success {
    background: var(--color-feedback-success-bg);
    color: var(--color-feedback-success-text);
    border: 1px solid rgba(22, 101, 52, 0.15);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-0.5rem);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.auth-links {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* Lists */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
}

.list-item:last-child {
    border-bottom: none;
}

.schedule-days {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.schedule-day {
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.schedule-day--off {
    background: var(--color-bg);
}

.schedule-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.schedule-day-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.schedule-day-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-muted);
    cursor: pointer;
    margin: 0;
}

.schedule-day-hours {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.schedule-time-input {
    min-width: 7.5rem;
    height: 44px;
    padding: 0 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    font-size: 1rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    text-align: center;
    font-family: inherit;
}

.schedule-time-input:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--color-text);
}

.schedule-time-input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.schedule-time-separator {
    color: var(--color-muted);
    font-weight: 500;
}

/* Calendar */
.calendar-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.week-label {
    font-weight: 600;
    min-width: 10rem;
    text-align: center;
}

.day-group {
    margin-bottom: 1.25rem;
}

.day-group h2 {
    font-size: 1rem;
    color: var(--color-muted);
    text-transform: capitalize;
}

.appointment-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.appointment-card.in-exception {
    border-left: 3px solid var(--color-attention);
}

.appointment-card.status-new:not(.in-exception) {
    border-left: 3px solid var(--color-attention);
}

.appointment-card.status-confirmed:not(.in-exception) {
    border-left: 3px solid var(--color-action);
}

.appointment-card.status-completed {
    border-left: 3px solid var(--color-neutral-text);
}

.appointment-card.status-cancelledbymaster,
.appointment-card.status-cancelledbyclient {
    border-left: 3px solid var(--color-destructive);
}

.appointment-main {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.appointment-service {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.35;
}

.appointment-client {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.appointment-client-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--color-muted);
}

.appointment-client-name {
    font-size: 0.9375rem;
    color: var(--color-text);
}

.appointment-client-phone {
    font-size: 0.9375rem;
    color: var(--color-text);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

.appointment-client-phone:hover {
    color: var(--color-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.appointment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--color-overlay);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.25rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

@media (min-width: 640px) {
    .modal-backdrop {
        align-items: center;
    }

    .modal {
        border-radius: var(--radius-lg);
    }

    .calendar-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* Public master / booking */
.public-master {
    max-width: 640px;
    margin: 0 auto;
}

.master-public-header {
    margin-bottom: 1rem;
}

.master-description {
    color: var(--color-muted);
    margin-bottom: 1.25rem;
}

.rating-line {
    color: var(--color-muted);
    font-size: 0.9375rem;
}

.slot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.slot-btn {
    min-width: 4.5rem;
}

.booking-success {
    max-width: 480px;
    margin: 2rem auto;
}

.list-item .status-badge {
    margin-right: 0.5rem;
    vertical-align: middle;
}

.review-item {
    flex-direction: column;
    align-items: flex-start;
}
