:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface-hover: #243044;
    --border: #2d3a4f;
    --text: #e8edf4;
    --text-muted: #8b9cb3;
    --accent: #4a9eff;
    --available-bg: #1e3d2f;
    --available-border: #2d6b4a;
    --available-hover: #265a3f;
    --available-label: #7dcea0;
    --unavailable-bg: #3d1a1a;
    --unavailable-border: #6b2d2d;
    --unavailable-text: #a07070;
    --unavailable-stripe: rgba(0, 0, 0, 0.15);
    --today: #2a4a3a;
    --today-border: #3d8b6e;
    --hour-min-width: 5.5rem;
    --hour-height: 4rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 1rem 1.5rem;
    background: rgba(15, 20, 25, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-status {
    font-size: 0.8rem;
    color: var(--available-label);
}

.customer-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.customer-stat {
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    white-space: nowrap;
}

.customer-stat strong {
    color: var(--text);
    font-weight: 600;
}

.customer-stat--month {
    border-color: #3d5a7a;
    color: #9ec5ef;
    font-weight: 600;
}

.customer-stat--kv {
    border-color: #b85a8a;
    color: #ffb8d8;
}

.customer-stat--nt {
    border-color: #4a7ec4;
    color: #9ec5ff;
}

.customer-stat--ja {
    border-color: #d08040;
    color: #ffc898;
}

.btn {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
}

.btn-primary {
    background: #245a40;
    border-color: #2d6b4a;
    color: #dff7ea;
}

.btn-secondary {
    background: var(--surface);
}

.btn-danger {
    background: #4a2020;
    border-color: #7a3030;
    color: #f5d0d0;
}

.dialog {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    background: #151d29;
    color: var(--text);
    width: min(92vw, 26rem);
}

.dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.dialog-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.25rem;
}

.dialog-form h2 {
    font-size: 1.1rem;
}

.dialog-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-field__label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.choice-btn {
    flex: 1 1 auto;
    min-width: 2.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    background: #0f1419;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.choice-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.choice-btn.is-selected {
    background: #245a40;
    border-color: #2d6b4a;
    color: #dff7ea;
}

.dialog-form input,
.dialog-form textarea {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    background: #0f1419;
    color: var(--text);
    font: inherit;
}

.dialog-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.dialog-actions__right {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.form-error {
    color: #e07070;
    font-size: 0.85rem;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.subtitle {
    margin-top: 0.15rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.calendar {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 1rem 4rem;
    max-width: 100%;
}

.day-block {
    border-bottom: 1px solid var(--border);
    padding: 1rem 0 1.25rem;
}

.month-separator {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
    padding: 0.5rem 0 1rem;
}

.month-separator__label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.month-separator__line {
    width: 1px;
    height: 1.1rem;
    background: linear-gradient(
        to bottom,
        var(--border),
        rgba(45, 58, 79, 0.15)
    );
}

.day-block.is-today {
    background: linear-gradient(90deg, var(--today) 0%, transparent 100%);
    border-left: 3px solid var(--today-border);
    padding-left: 0.75rem;
    margin-left: -0.75rem;
}

.day-block.is-weekend {
    padding: 0.3rem 0 0.35rem;
    background: linear-gradient(
        90deg,
        rgba(45, 58, 79, 0.14) 0%,
        transparent 55%
    );
    border-bottom-style: dashed;
    border-bottom-color: rgba(45, 58, 79, 0.45);
}

.day-block.is-weekend.is-today {
    background: linear-gradient(
        90deg,
        rgba(45, 58, 79, 0.18) 0%,
        var(--today) 35%,
        transparent 70%
    );
    border-left-color: rgba(45, 58, 79, 0.55);
}

.day-block.is-weekend .day-label,
.day-block.is-weekend .day-date {
    color: var(--unavailable-text);
    font-size: 0.82rem;
    font-weight: 500;
}

.day-block.is-weekend .day-header {
    margin-bottom: 0.15rem;
    gap: 0.45rem;
}

.day-weekend-note {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--unavailable-text);
    opacity: 0.85;
}

.day-weekend-events {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--unavailable-text);
    border: 1px dashed rgba(122, 138, 158, 0.55);
    border-radius: 999px;
    padding: 0.05rem 0.35rem;
}

.day-weekend-strip {
    height: 2px;
    margin: 0 0.25rem;
    border-radius: 999px;
    background: repeating-linear-gradient(
        90deg,
        rgba(122, 138, 158, 0.45) 0,
        rgba(122, 138, 158, 0.45) 6px,
        transparent 6px,
        transparent 12px
    );
    opacity: 0.7;
}

.day-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0 0.25rem;
}

.day-label {
    font-size: 1rem;
    font-weight: 600;
}

.day-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.day-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--today-border);
    background: rgba(61, 139, 110, 0.15);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.hours-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    position: relative;
}

.now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: #f05d5e;
    box-shadow: 0 0 0 1px rgba(240, 93, 94, 0.35);
    z-index: 5;
    pointer-events: none;
}

.now-line::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f05d5e;
    box-shadow: 0 0 0 2px rgba(240, 93, 94, 0.25);
}

.hours-row::-webkit-scrollbar {
    height: 6px;
}

.hours-row::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.hour-cell {
    flex: 0 0 var(--hour-min-width);
    min-height: var(--hour-height);
    background: var(--available-bg);
    border: 1px solid var(--available-border);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
}

.hour-cell:not(.hour-cell--unavailable):hover {
    background: var(--available-hover);
    border-color: #3d8b6e;
}

.hour-cell--unavailable {
    background-color: var(--unavailable-bg);
    background-image: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 6px,
        var(--unavailable-stripe) 6px,
        var(--unavailable-stripe) 7px
    );
    border: 1px dashed var(--unavailable-border);
    cursor: not-allowed;
}

.hour-cell--unavailable .hour-label {
    color: var(--unavailable-text);
    font-weight: 500;
}

.hour-cell--unavailable .hour-content {
    min-height: 1.5rem;
}

.hour-cell--occupied {
    border-style: solid;
}

.hour-cell--occupied.hour-cell--floating {
    border-style: dashed;
}

.hour-cell--customer-kv {
    --customer-bg: rgba(120, 36, 78, 0.42);
    --customer-border: #c45a8a;
    --customer-text: #ffe0ef;
    --customer-muted: #f0b0c8;
    --customer-badge: #ffc8e0;
}

.hour-cell--customer-nt {
    --customer-bg: rgba(28, 58, 118, 0.42);
    --customer-border: #4a7ec4;
    --customer-text: #d8e8ff;
    --customer-muted: #a8c0e8;
    --customer-badge: #b8d4ff;
}

.hour-cell--customer-ja {
    --customer-bg: rgba(118, 58, 18, 0.42);
    --customer-border: #d08040;
    --customer-text: #ffe8c8;
    --customer-muted: #e8c098;
    --customer-badge: #ffd4a8;
}

.hour-cell--occupied.hour-cell--customer-kv,
.hour-cell--occupied.hour-cell--customer-nt,
.hour-cell--occupied.hour-cell--customer-ja {
    background: var(--customer-bg);
    border-color: var(--customer-border);
}

.hour-cell--occupied.hour-cell--customer-kv .hour-label,
.hour-cell--occupied.hour-cell--customer-nt .hour-label,
.hour-cell--occupied.hour-cell--customer-ja .hour-label,
.hour-cell--occupied .event-chip__title {
    color: var(--customer-text);
}

.hour-cell--occupied .event-chip__meta,
.hour-cell--occupied .event-chip__content {
    color: var(--customer-muted);
}

.hour-cell--occupied .event-chip__customer {
    color: var(--customer-badge);
    background: rgba(255, 255, 255, 0.1);
}

.hour-cell--done {
    --customer-bg: rgba(48, 48, 56, 0.55);
    --customer-border: #5a5a66;
    --customer-text: #d8dae2;
    --customer-muted: #a8abb8;
    --customer-badge: #b8bcc6;
    opacity: 0.82;
}

.hour-cell--full-day .event-chip {
    min-height: 2.35rem;
}

.hour-cell--drop-target {
    outline: 2px solid #7dcea0;
    outline-offset: 2px;
}

.hour-cell--magnet-target {
    background-image: linear-gradient(
        135deg,
        rgba(125, 206, 160, 0.22) 0%,
        rgba(125, 206, 160, 0.08) 100%
    );
    box-shadow: inset 0 0 0 2px rgba(125, 206, 160, 0.75);
}

.hour-cell--occupied.hour-cell--magnet-target {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.hour-cell--magnet-subslot::after {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    width: calc((100% - 0.75rem) / var(--magnet-slot-count, 1));
    left: calc(0.375rem + (100% - 0.75rem) / var(--magnet-slot-count, 1) * var(--magnet-slot-index, 0));
    border: 2px solid rgba(125, 206, 160, 0.95);
    border-radius: 6px;
    pointer-events: none;
    box-sizing: border-box;
}

.hour-cell--draggable {
    cursor: grab;
}

.hour-cell--dragging {
    opacity: 0.72;
    cursor: grabbing;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.checkbox-label input {
    width: auto;
}

.hour-add-btn {
    width: 100%;
    min-height: 2rem;
    border: 1px dashed var(--available-border);
    border-radius: 6px;
    background: transparent;
    color: var(--available-label);
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.hour-add-btn--insert {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    z-index: 2;
    width: 1.55rem;
    min-height: 1.55rem;
    padding: 0;
    font-size: 0.95rem;
    line-height: 1;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    opacity: 0;
}

.hour-cell:hover .hour-add-btn,
.hour-cell:focus-within .hour-add-btn {
    opacity: 1;
}

.hour-cell--occupied .hour-add-btn--insert {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
}

.event-chip {
    border-radius: 4px;
    padding: 0;
    background: transparent;
    border: none;
}

.event-chip--fixed {
    cursor: inherit;
}

.event-chip--editable {
    cursor: pointer;
}

.event-chip--floating {
    cursor: inherit;
}

.event-chip--dragging {
    opacity: 0.55;
    cursor: grabbing;
}

.event-chip__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.35rem;
}

.event-chip__badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
}

.event-chip__customer {
    flex: 0 0 auto;
    font-size: 0.58rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
}

.event-chip__pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--customer-text, #fff);
    cursor: help;
}

.event-chip__pin .pin-icon {
    display: block;
}

.hour-label__pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    opacity: 0.92;
    cursor: help;
}

.hour-cell--pinned .hour-label__pin {
    color: var(--customer-text, #fff);
}

.hour-cell--pinned .hour-label {
    font-weight: 600;
}

.hour-label {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--available-label);
    margin-bottom: 0.35rem;
}

.event-done-btn {
    margin-top: 0.35rem;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.12);
    color: var(--customer-text, #cfe3fb);
    font-size: 0.68rem;
    padding: 0.25rem 0.35rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.hour-cell--occupied .event-done-btn {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.12);
    color: var(--customer-text);
}

.event-done-btn__icon {
    font-size: 0.75rem;
    line-height: 1;
}

.event-done-btn.is-done {
    border-color: #5a5a66;
    color: #b8bcc6;
}

.event-chip__title {
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.25;
}

.event-chip__meta {
    margin-top: 0.15rem;
    font-size: 0.68rem;
    line-height: 1.2;
}

.hour-cell--occupied .hour-content {
    min-height: 2.5rem;
}

.hour-cell--occupied .event-chip {
    height: 100%;
}

.event-chip__content {
    margin-top: 0.2rem;
    font-size: 0.72rem;
    line-height: 1.25;
}

.hour-content {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-height: 1.5rem;
}

.loader {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.move-loader {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 18, 0.42);
    backdrop-filter: blur(2px);
}

.move-loader:not([hidden]) {
    display: flex;
}

.move-loader__panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    min-width: 11rem;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    background: var(--surface, #1a2332);
    border: 1px solid var(--border, #2d3a4d);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.move-loader__spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(125, 206, 160, 0.22);
    border-top-color: #7dcea0;
    border-radius: 50%;
    animation: move-loader-spin 0.75s linear infinite;
}

.move-loader__text {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

@keyframes move-loader-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 600px) {
    :root {
        --hour-min-width: 4.75rem;
        --hour-height: 3.75rem;
    }

    .header {
        padding: 0.75rem 1rem;
    }

    .header-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .calendar {
        padding: 0 0.75rem 3rem;
    }
}
