@font-face {
    font-family: 'Reef';
    src: url('../fonts/Reef.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap; /* показывает системный шрифт, пока грузится кастомный */
}

:root {
    --accent: #9634eb;
    --bg: #f5f5f8;
    --card: #ffffff;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.08); /* мягкая тень */
    --text: #1b1b1f;
    --muted: #8a8a98;
    --chip-bg: #f0e7ff;
    --chip-active-bg: #ede3ff;
    --border: #ececf2;
    /*--shadow: 0 8px 24px rgba(0, 0, 0, 0.08);*/
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 12px;
    --past: #f2f2f6;
    --locked: #f7efff;
    --error: #d63939;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
}

.hide {
    display: none;
}

/* ===== Основная обёртка ===== */
.wrap {
    max-width: 420px;
    margin: 0 auto;
    padding: 16px;
}

.back-btn svg {
    width: 24px;   /* желаемая ширина */
    height: 24px;  /* желаемая высота */
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
}

.back-btn svg:hover {
    color: var(--accent, #6c4be3);
}

/* ===== Шапка ===== */
header {
    position: sticky;
    top: 0;
    /*background: var(--bg);*/
    z-index: 5;
    padding-bottom: 8px;
    background: transparent;
}

.title {
    font-family: Reef, sans-serif;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.2px;
    text-align: center;
    background: transparent;
}

.subtitle {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
    text-align: center;
}

.controls {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}

/* ===== Кнопки ===== */
button.primary {
    flex: 1;
    background: linear-gradient(135deg, #9634eb, #bf5fff, #e67aff);
    color: #fff;
    border: none;
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    font-weight: 700;
    box-shadow: var(--shadow);
    font-size: 15px;
    transition: background 0.3s ease;
}

button.primary:hover {
    background: linear-gradient(135deg, #bf5fff, #e67aff, #9634eb);
}

button.outline {
    flex: 1;
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    font-weight: 700;
    font-size: 15px;
}

button.danger {
    flex: 1;
    background: #fff;
    color: #d63939;
    border: 1px solid #d63939;
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    font-weight: 700;
    font-size: 15px;
}

.sheet {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
}


/* ===== Формы и надписи ===== */
form.card {
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}


.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.label {
    font-size: 12px;
    color: var(--muted);
}

.input {
    width: 100%;
    padding: 12px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 14px;
    outline: none;
    background-color: #ececf2;
}

.input:focus {
    border-color: var(--accent, #6c4be3);
    box-shadow: 0 0 0 3px rgba(108, 75, 227, .12);
}

.help {
    font-size: 11px;
    color: var(--muted);
}

.error {
    font-size: 12px;
    color: #d63939;
    display: none;
}

.error.show {
    display: block;
}

.controls {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.primary[disabled] {
    opacity: .6;
    pointer-events: none;
}

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    border-top-color: var(--accent, #6c4be3);
    animation: spin .8s linear infinite;
}

.spinner.show {
    display: inline-block;
}

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

/* ===== Низ страницы ===== */
footer {
    text-align: center;
    padding: 20px 10px;
    color: var(--muted);
    font-size: 13px;
}

.hint {
    margin: 10px 6px 0;
    color: var(--muted);
    font-size: 12px;
}

/* ===== Адаптивность ===== */
@media (max-width: 600px) {
    .grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }

    .cell {
        min-height: 55px;
        padding: 4px;
    }

    .chip {
        font-size: 9px;
        padding: 2px 4px;
    }

    .month {
        font-size: 16px;
    }

    button.primary,
    button.outline {
        font-size: 14px;
        padding: 10px 12px;
    }
}

/* overlay */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(1px);
  opacity: 0; transition: opacity .18s ease-out;
}

/* окно */
.modal-box {
  width: min(420px, calc(100vw - 24px));
  height: min(420px, calc(100vh - 24px));
  background: #fff; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  transform: translateY(12px) scale(.98);
  transition: transform .18s ease-out, opacity .18s ease-out;
  opacity: 0; overflow: hidden; position: relative;
}

/* header с кнопкой закрытия (опционально) */
.modal-close {
  position: absolute; right: 8px; top: 8px; border: 0; background: transparent; cursor: pointer;
  width: 36px; height: 36px; border-radius: 10px; font-size: 20px; line-height: 36px;
}
.modal-close:hover { background: rgba(0,0,0,.06); }

/* iframe */
.modal-frame {
  width: 100%; height: 100%; border: 0; display: block;
}

/* активные состояния */
.modal-overlay.show { display: flex; }
.modal-overlay.show .modal-box { opacity: 1; transform: translateY(0) scale(1); }
.modal-overlay.show { opacity: 1; }

.modal-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px; /* расстояние между текстом и кнопками */
}