/* ==========================================================================
   ❤️ RULITE

   Спокойная нейтральная база и один акцент — тот же красный, что в названии.
   Плотность интерфейса подобрана под длинные списки доменов: данные набраны
   моноширинным шрифтом с табличными цифрами, чтобы колонки не плясали.

   Макет строится от ширины экрана: на телефоне одна колонка, на ноутбуке
   и шире — рабочая область рядом с постоянно видимой панелью управления.
   ========================================================================== */

:root {
    color-scheme: light;

    --accent: #c8322f;
    --accent-hover: #ab2724;
    --accent-weak: rgba(200, 50, 47, 0.08);
    --accent-ring: rgba(200, 50, 47, 0.22);
    --on-accent: #ffffff;

    --ok: #0f7b4f;
    --ok-weak: rgba(15, 123, 79, 0.1);
    --warn: #8a5a00;
    --warn-weak: rgba(196, 133, 15, 0.12);
    --bad: #b32318;
    --bad-weak: rgba(179, 35, 24, 0.08);

    --page: #f6f6f7;
    --surface: #ffffff;
    --surface-sunk: #fafafa;
    --surface-raised: #ffffff;
    --line: #e6e6e8;
    --line-strong: #d4d4d8;

    --ink: #18181b;
    --ink-2: #52525b;
    --ink-3: #8e8e96;

    --veil: rgba(24, 24, 27, 0.32);
    --lift-1: 0 1px 2px rgba(24, 24, 27, 0.05);
    --lift-2: 0 2px 8px -2px rgba(24, 24, 27, 0.08),
              0 6px 20px -6px rgba(24, 24, 27, 0.06);
    --lift-3: 0 12px 28px -8px rgba(24, 24, 27, 0.18),
              0 32px 64px -24px rgba(24, 24, 27, 0.24);

    --r-sm: 8px;
    --r: 12px;
    --r-lg: 18px;

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
            "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono",
            Menlo, Consolas, monospace;
}

.dark {
    color-scheme: dark;

    --accent: #f1635f;
    --accent-hover: #ff7c78;
    --accent-weak: rgba(241, 99, 95, 0.12);
    --accent-ring: rgba(241, 99, 95, 0.3);
    --on-accent: #2a0f0e;

    --ok: #4ec98d;
    --ok-weak: rgba(78, 201, 141, 0.12);
    --warn: #e0a33f;
    --warn-weak: rgba(224, 163, 63, 0.12);
    --bad: #ff8078;
    --bad-weak: rgba(255, 128, 120, 0.1);

    --page: #0d0d0f;
    --surface: #17171a;
    --surface-sunk: #131315;
    --surface-raised: #1e1e22;
    --line: #27272b;
    --line-strong: #3a3a40;

    --ink: #f4f4f5;
    --ink-2: #a9a9b2;
    --ink-3: #7c7c85;

    --veil: rgba(0, 0, 0, 0.66);
    --lift-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --lift-2: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
    --lift-3: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

.hidden {
    display: none !important;
}

code {
    font-family: var(--mono);
    font-size: 0.9em;
    background: var(--surface-sunk);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0.05em 0.35em;
}

/* ==========================================================  шапка  ===== */

.header {
    position: sticky;
    top: 0;
    z-index: 80;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2.5rem);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.brand-mark {
    font-size: 1.5rem;
    line-height: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ==========================================================  макет  ===== */

.layout {
    max-width: 1680px;
    margin: 0 auto;
    padding: clamp(1rem, 2.5vw, 2rem) clamp(1rem, 3vw, 2.5rem)
             clamp(3rem, 6vw, 5rem);
    display: grid;
    gap: clamp(0.85rem, 1.6vw, 1.4rem);
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

@media (min-width: 1080px) {
    .layout {
        grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    }

    .rail {
        position: sticky;
        top: 84px;
    }
}

.rail,
.content {
    display: flex;
    flex-direction: column;
    gap: clamp(0.85rem, 1.6vw, 1.4rem);
    min-width: 0;
}

/* ==========================================================  карточки  == */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--lift-1);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.85rem;
    padding: clamp(1rem, 2vw, 1.35rem) clamp(1rem, 2vw, 1.5rem);
    border-bottom: 1px solid var(--line);
}

.card-head h2 {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.card-body {
    padding: clamp(1rem, 2vw, 1.5rem);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-width: 0;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-note {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--ink-2);
}

.action-card .card-body {
    gap: 0.6rem;
}

.action-card .card-note {
    margin-bottom: 0.25rem;
}

.card-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem clamp(1rem, 2vw, 1.5rem);
    border-top: 1px solid var(--line);
    background: var(--surface-sunk);
}

.foot-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-right: auto;
}

.foot-links {
    display: flex;
    gap: 0.4rem;
}

/* ==========================================================  кнопки  ==== */

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface-raised);
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--lift-1);
    transition: background-color 0.14s, border-color 0.14s, color 0.14s,
                box-shadow 0.14s, transform 0.1s;
}

.button:hover:not(:disabled) {
    background: var(--surface-sunk);
    border-color: var(--line-strong);
}

.button:active:not(:disabled) {
    transform: translateY(0.5px);
    box-shadow: none;
}

.button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.button-primary {
    background: var(--accent);
    border-color: transparent;
    color: var(--on-accent);
    font-weight: 600;
}

.button-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: transparent;
}

.button-quiet {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--ink-2);
}

.button-quiet:hover:not(:disabled) {
    background: var(--surface-sunk);
    color: var(--ink);
}

.button-danger {
    color: var(--bad);
    border-color: var(--line-strong);
}

.button-danger:hover:not(:disabled) {
    background: var(--bad-weak);
    border-color: var(--bad);
}

.button-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
}

.button-block {
    width: 100%;
}

.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    transition: background-color 0.14s, color 0.14s, opacity 0.14s;
}

.icon-action:hover:not(:disabled) {
    background: var(--surface-sunk);
    color: var(--ink);
}

.icon-action:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.icon-action.tiny {
    width: 24px;
    height: 24px;
}

.link {
    align-self: flex-start;
    background: none;
    border: none;
    padding: 0.25rem 0;
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
}

.link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.sun-icon { display: none; }
.moon-icon { display: block; }
.dark .sun-icon { display: block; }
.dark .moon-icon { display: none; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.14s, color 0.14s;
}

.pill:hover:not(.disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.pill.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ==========================================================  сводка  ==== */

.facts {
    gap: 1.05rem;
}

.fact-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 0.25rem;
}

.fact-value {
    font-size: 0.9375rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    word-break: break-word;
}

.fact-meta {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--ink-3);
}

.fact-meta a {
    color: var(--accent);
    text-decoration: none;
}

.fact-meta a:hover {
    text-decoration: underline;
}

/* ==========================================================  задача  ==== */

.job-panel {
    border-color: var(--line);
}

.job-panel .card-body {
    gap: 0.6rem;
}

.job-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.job-head-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.job-panel.job-done .job-head { color: var(--ok); }
.job-panel.job-failed .job-head { color: var(--bad); }

.progress-track {
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.job-panel.job-done .progress-bar { background: var(--ok); }
.job-panel.job-failed .progress-bar { background: var(--bad); }

.job-log {
    max-height: 180px;
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 0.6875rem;
    line-height: 1.7;
    color: var(--ink-3);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ==========================================================  метрики  === */

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    border-bottom: 1px solid var(--line);
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: clamp(0.85rem, 1.6vw, 1.15rem) clamp(1rem, 2vw, 1.5rem);
    border-right: 1px solid var(--line);
}

.metric:last-child {
    border-right: none;
}

.metric-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.metric-value {
    font-size: clamp(1.25rem, 2.4vw, 1.6rem);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.metric-accent .metric-value {
    color: var(--accent);
}

.metric-meta {
    font-size: 0.75rem;
    color: var(--ink-3);
}

/* ==========================================================  панель  ==== */

.panel {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-sunk);
    padding: 0.9rem 1rem;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.panel-head h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.panel-head p {
    font-size: 0.8125rem;
    color: var(--ink-3);
    max-width: 54ch;
    margin-top: 0.1rem;
}

/* ==========================================================  элементы  == */

.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-sunk);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.segmented label {
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: block;
    padding: 0.32rem 0.85rem;
    border-radius: 7px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-2);
    transition: background-color 0.14s, color 0.14s, box-shadow 0.14s;
}

.segmented input:checked + span {
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--lift-1);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.search {
    position: relative;
    flex: 1 1 220px;
    min-width: 0;
}

.search input {
    width: 100%;
    padding: 0.55rem 0.9rem 0.55rem 2.35rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface-sunk);
    font-size: 0.875rem;
    transition: border-color 0.14s, box-shadow 0.14s, background-color 0.14s;
}

.search input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.search-icon {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-3);
    pointer-events: none;
}

.toolbar select {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface-sunk);
    font-size: 0.8125rem;
    cursor: pointer;
}

.pager {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pager-info {
    min-width: 104px;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.pager-bottom {
    justify-content: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.bulk-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    padding-bottom: 0.2rem;
}

.bulk-actions button {
    background: none;
    border: none;
    padding: 0;
    color: var(--ink-2);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.14s;
}

.bulk-actions button:hover {
    color: var(--accent);
}

.divider {
    width: 1px;
    height: 14px;
    background: var(--line-strong);
}

/* ==========================================================  категории  = */

.category-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.category-item {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    overflow: hidden;
    transition: border-color 0.14s, box-shadow 0.14s;
}

.category-item:hover {
    border-color: var(--line-strong);
    box-shadow: var(--lift-1);
}

.category-item.category-new {
    border-color: var(--warn);
    background: linear-gradient(90deg, var(--warn-weak), transparent 38%),
                var(--surface);
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.62rem 0.85rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.14s;
}

.category-header:hover {
    background: var(--surface-sunk);
}

.category-code {
    font-family: var(--mono);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    word-break: break-all;
}

.category-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.badge-new {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.1rem 0.4rem;
    border-radius: 5px;
    background: var(--warn-weak);
    color: var(--warn);
    border: 1px solid var(--warn);
}

.chevron {
    flex-shrink: 0;
    color: var(--ink-3);
    transition: transform 0.2s ease;
}

.category-checkbox,
.entry-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.entry-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.35;
}

.category-content {
    border-top: 1px solid var(--line);
    background: var(--surface-sunk);
    max-height: min(48vh, 400px);
    overflow-y: auto;
}

.entry-list {
    list-style: none;
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.entry-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.28rem 0.45rem;
    border-radius: 6px;
    transition: background-color 0.12s;
}

.entry-item:hover {
    background: var(--surface);
}

.entry-type {
    flex-shrink: 0;
    min-width: 72px;
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.08rem 0.35rem;
    border-radius: 5px;
    border: 1px solid transparent;
}

.entry-type.plain {
    background: rgba(37, 99, 235, 0.09);
    color: #2258cf;
    border-color: rgba(37, 99, 235, 0.22);
}

.entry-type.regex {
    background: rgba(124, 58, 237, 0.09);
    color: #6d33cc;
    border-color: rgba(124, 58, 237, 0.22);
}

.entry-type.root {
    background: var(--ok-weak);
    color: var(--ok);
    border-color: var(--ok);
}

.entry-type.full {
    background: var(--warn-weak);
    color: var(--warn);
    border-color: var(--warn);
}

.dark .entry-type.plain {
    background: rgba(96, 165, 250, 0.13);
    color: #8fbcfb;
    border-color: rgba(96, 165, 250, 0.28);
}

.dark .entry-type.regex {
    background: rgba(192, 132, 252, 0.13);
    color: #d0aefb;
    border-color: rgba(192, 132, 252, 0.28);
}

.entry-value {
    font-family: var(--mono);
    font-size: 0.78125rem;
    color: var(--ink-2);
    word-break: break-all;
}

.highlight {
    background: var(--accent-weak);
    color: var(--accent);
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 600;
}

.entry-placeholder,
.list-placeholder,
.entry-notice {
    padding: 0.8rem;
    font-size: 0.8125rem;
    color: var(--ink-3);
    text-align: center;
}

.list-placeholder {
    padding: 3rem 1rem;
}

.load-more {
    display: block;
    width: calc(100% - 0.7rem);
    margin: 0.15rem 0.35rem 0.35rem;
    padding: 0.5rem;
    background: none;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.14s, color 0.14s;
}

.load-more:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ==========================================================  свои  ====== */

.custom-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.custom-list:not(:empty) {
    margin-top: 0.8rem;
}

.custom-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    transition: border-color 0.14s, opacity 0.14s;
}

.custom-row:hover {
    border-color: var(--line-strong);
}

.custom-row.custom-off {
    opacity: 0.45;
}

.custom-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.custom-code {
    font-family: var(--mono);
    font-size: 0.8125rem;
    font-weight: 600;
    word-break: break-all;
}

.custom-meta {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.custom-edit {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    color: var(--accent);
    font-size: 0.8125rem;
    cursor: pointer;
}

.custom-edit:hover {
    background: var(--accent-weak);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.chips:empty {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.3rem 0.18rem 0.55rem;
    border-radius: 999px;
    background: var(--accent-weak);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.75rem;
}

.chip button {
    background: none;
    border: none;
    padding: 0 0.15rem;
    color: inherit;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.65;
}

.chip button:hover {
    opacity: 1;
}

/* ==========================================================  сообщения  = */

.notice {
    padding: 0.7rem 0.9rem;
    border-radius: var(--r-sm);
    border: 1px solid;
    font-size: 0.8125rem;
    line-height: 1.55;
}

.notice-error {
    background: var(--bad-weak);
    border-color: var(--bad);
    color: var(--bad);
}

.notice-ok {
    background: var(--ok-weak);
    border-color: var(--ok);
    color: var(--ok);
}

/* ==========================================================  окна  ====== */

.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.5rem, 3vw, 2rem);
    background: var(--veil);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: veil-in 0.16s ease;
}

@keyframes veil-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.sheet {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    max-height: min(92vh, 860px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--lift-3);
    overflow: hidden;
    animation: sheet-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet-wide {
    max-width: 880px;
}

@keyframes sheet-in {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1.15rem;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.sheet-head h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sheet-main {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sheet-body {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: clamp(1rem, 2.2vw, 1.5rem);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.sheet-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.85rem 1.15rem;
    border-top: 1px solid var(--line);
    background: var(--surface-sunk);
    flex-shrink: 0;
}

.sheet-foot .button-danger {
    margin-right: auto;
}

/* Вкладки: сбоку на широком экране, сверху на узком */

.tabs {
    display: flex;
    flex-shrink: 0;
}

.tab {
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-2);
    transition: background-color 0.14s, color 0.14s;
}

.tab:hover {
    color: var(--ink);
}

.tab.active {
    color: var(--accent);
    font-weight: 600;
}

@media (min-width: 720px) {
    .tabs {
        flex-direction: column;
        gap: 2px;
        width: 188px;
        padding: 0.75rem 0.6rem;
        border-right: 1px solid var(--line);
        background: var(--surface-sunk);
        overflow-y: auto;
    }

    .tab {
        text-align: left;
        padding: 0.5rem 0.7rem;
        border-radius: var(--r-sm);
    }

    .tab:hover {
        background: var(--surface);
    }

    .tab.active {
        background: var(--surface);
        box-shadow: var(--lift-1);
    }
}

@media (max-width: 719px) {
    .sheet-main {
        flex-direction: column;
    }

    .tabs {
        gap: 0.1rem;
        padding: 0 0.6rem;
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        position: relative;
        padding: 0.65rem 0.6rem;
    }

    .tab.active::after {
        content: "";
        position: absolute;
        left: 0.45rem;
        right: 0.45rem;
        bottom: 0;
        height: 2px;
        border-radius: 2px;
        background: var(--accent);
    }
}

.tab-panel {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

/* ==========================================================  поля  ====== */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.field > span {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-2);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface-sunk);
    font-size: 0.875rem;
    transition: border-color 0.14s, box-shadow 0.14s, background-color 0.14s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--ink-3);
}

.field textarea {
    min-height: 190px;
    resize: vertical;
    font-family: var(--mono);
    font-size: 0.78125rem;
    line-height: 1.65;
    tab-size: 2;
}

.field-row-inline {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.field-row-inline input {
    flex: 1;
    min-width: 0;
}

.field-pair {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 560px) {
    .field-pair {
        grid-template-columns: 1fr 1fr;
    }
}

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

.hint {
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--ink-3);
}

.hint pre {
    font-family: var(--mono);
    font-size: 0.71875rem;
    line-height: 1.65;
    white-space: pre-wrap;
    margin-top: 0.3rem;
}

.hint-ok { color: var(--ok); }
.hint-bad { color: var(--bad); }

.check {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--ink-2);
    cursor: pointer;
}

.check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-top: 0.1rem;
    flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.5rem 1.25rem;
}

/* ==========================================================  списки  ==== */

.target-list,
.note-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.target-row,
.note-row {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.85rem;
    background: var(--surface-sunk);
    border: 1px solid var(--line);
    border-radius: var(--r);
    transition: opacity 0.14s;
}

.target-row.target-off,
.note-row.note-off {
    opacity: 0.5;
}

.target-head,
.note-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.target-head input[type="checkbox"],
.note-head input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.target-head select,
.note-head input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 0.8125rem;
}

.note-head input[type="text"] {
    font-weight: 600;
}

.note-row textarea {
    width: 100%;
    min-height: 150px;
    resize: vertical;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1.65;
}

.note-row textarea:focus,
.target-head select:focus,
.note-head input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.note-footer {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

/* ==========================================================  прочее  ==== */

.foldout {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-sunk);
    padding: 0.6rem 0.85rem;
}

.foldout summary {
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-2);
}

.foldout summary:hover {
    color: var(--accent);
}

.variable-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.3rem 1.25rem;
    margin-top: 0.7rem;
    font-size: 0.75rem;
    color: var(--ink-3);
}

.variable-list code {
    color: var(--accent);
    background: var(--accent-weak);
    border-color: transparent;
    cursor: pointer;
}

.preview {
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--surface-sunk);
    overflow: hidden;
}

.preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.5rem 0.4rem 0.85rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.preview pre {
    max-height: 340px;
    overflow: auto;
    padding: 0.85rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1.65;
    color: var(--ink-2);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ==========================================================  вход  ====== */

.auth-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(900px 400px at 50% -12%, var(--accent-weak), transparent 70%),
        var(--page);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: clamp(1.5rem, 5vw, 2.25rem);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--lift-2);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: center;
}

.auth-subtitle {
    text-align: center;
    font-size: 0.875rem;
    color: var(--ink-2);
    margin-bottom: 0.3rem;
}

.auth-hint {
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--ink-3);
    text-align: center;
}

.auth-card .button-primary {
    padding: 0.62rem 1rem;
    margin-top: 0.3rem;
}

/* ==========================================================  скроллы  === */

.category-content::-webkit-scrollbar,
.job-log::-webkit-scrollbar,
.sheet-body::-webkit-scrollbar,
.preview pre::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.category-content::-webkit-scrollbar-thumb,
.job-log::-webkit-scrollbar-thumb,
.sheet-body::-webkit-scrollbar-thumb,
.preview pre::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.category-content::-webkit-scrollbar-track,
.job-log::-webkit-scrollbar-track,
.sheet-body::-webkit-scrollbar-track,
.preview pre::-webkit-scrollbar-track {
    background: transparent;
}

/* ==========================================================  телефон  === */

@media (max-width: 620px) {
    body {
        font-size: 14px;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .button-quiet span {
        display: none;
    }

    #logoutButton {
        display: none;
    }

    .card,
    .sheet {
        border-radius: var(--r);
    }

    .metrics {
        grid-template-columns: 1fr 1fr;
    }

    .metric:nth-child(2) {
        border-right: none;
    }

    .metric-accent {
        grid-column: 1 / -1;
        border-top: 1px solid var(--line);
        border-right: none;
    }

    .toolbar {
        gap: 0.45rem;
    }

    .search {
        flex-basis: 100%;
    }

    .pager {
        margin-left: auto;
    }

    .pager-info {
        min-width: 88px;
        font-size: 0.75rem;
    }

    .entry-type {
        min-width: 58px;
    }

    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .sheet {
        max-width: none;
        max-height: 94dvh;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        border-bottom: none;
    }

    .panel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-head .button {
        align-self: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Обёртка чекбокса категории: клик по ней не должен сворачивать список */
.category-toggle {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}
