/* ==========================================================================
   url-shorts.com — дизайн-система
   Токены и компоненты перенесены из макетов Claude Design.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Токены
   Светлая палитра определена на голом :root, тёмная — переопределяется
   и в prefers-color-scheme (с guard на явный светлый выбор), и в
   [data-theme="dark"], чтобы переключатель работал в обе стороны.
   -------------------------------------------------------------------------- */
:root {
    --bg: #FCFCFD;
    --surface: #FFFFFF;
    --surface-2: #F6F6F8;
    --border: #E6E6EA;
    --border-strong: #D2D2DA;
    --text: #16161A;
    --text-2: #6B6B76;
    --text-3: #9A9AA4;
    --accent: #5B4BE8;
    --accent-hover: #4A3BD4;
    --accent-soft: #EFEDFD;
    --ok: #0E9F6E;
    --ok-soft: #E6F5EF;
    --warn: #D97706;
    --warn-soft: #FDF1E1;
    --bad: #DC2626;
    --bad-soft: #FCECEC;

    --shadow-sm: 0 4px 12px rgba(8, 8, 14, .06);
    --shadow-md: 0 12px 32px rgba(8, 8, 14, .14);
    --shadow-lg: 0 24px 48px rgba(8, 8, 14, .18);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --ease: cubic-bezier(.2, .8, .2, 1);

    --chart-1: #5B4BE8;
    --chart-2: #0EA5E9;
    --chart-3: #10B981;
    --chart-4: #F59E0B;
    --chart-5: #EC4899;
    --chart-6: #8B5CF6;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0B0B0F;
        --surface: #131318;
        --surface-2: #17171E;
        --border: #26262F;
        --border-strong: #35353F;
        --text: #F2F2F5;
        --text-2: #9C9CA8;
        --text-3: #6A6A76;
        --accent: #7B6CFF;
        --accent-hover: #8F82FF;
        --accent-soft: #1D1A33;
        --ok: #34D399;
        --ok-soft: #10261F;
        --warn: #F59E0B;
        --warn-soft: #2A1F0E;
        --bad: #F87171;
        --bad-soft: #2A1414;
        --shadow-sm: 0 4px 12px rgba(0, 0, 0, .3);
        --shadow-md: 0 12px 32px rgba(0, 0, 0, .45);
        --shadow-lg: 0 24px 48px rgba(0, 0, 0, .5);
    }
}

:root[data-theme="dark"] {
    --bg: #0B0B0F;
    --surface: #131318;
    --surface-2: #17171E;
    --border: #26262F;
    --border-strong: #35353F;
    --text: #F2F2F5;
    --text-2: #9C9CA8;
    --text-3: #6A6A76;
    --accent: #7B6CFF;
    --accent-hover: #8F82FF;
    --accent-soft: #1D1A33;
    --ok: #34D399;
    --ok-soft: #10261F;
    --warn: #F59E0B;
    --warn-soft: #2A1F0E;
    --bad: #F87171;
    --bad-soft: #2A1414;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, .3);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, .5);
}

/* --------------------------------------------------------------------------
   2. Сброс и база
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
p { margin: 0; }

a { color: var(--accent); text-decoration: none; transition: color .12s var(--ease); }
a:hover { color: var(--accent-hover); }

img, svg { max-width: 100%; height: auto; display: block; }

input, button, select, textarea { font-family: inherit; font-size: inherit; }

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

::selection { background: var(--accent-soft); color: var(--text); }

.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* Ссылка «пропустить к содержимому» для клавиатурной навигации */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    z-index: 100;
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; color: #fff; }

/* --------------------------------------------------------------------------
   3. Утилиты раскладки
   -------------------------------------------------------------------------- */
.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: 1440px; margin: 0 auto; padding: 0 24px; }

.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ml-auto { margin-left: auto; }

.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.gap-24 { gap: 24px; } .gap-32 { gap: 32px; }

.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; } .mt-48 { margin-top: 48px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-center { text-align: center; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.pretty { text-wrap: pretty; }
.balance { text-wrap: balance; }

.hidden { display: none !important; }

/* Любой широкий блок скроллится внутри себя — страница по горизонтали не едет */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------------------------
   4. Кнопки
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease), opacity .12s var(--ease);
    text-decoration: none;
}

.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-primary:active { filter: brightness(.92); }

.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(.92); color: #fff; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-block { display: flex; width: 100%; }

/* Загрузка: спиннер вместо текста, ширина не меняется */
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 14px; height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    color: #fff;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { color: var(--text-2); }

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

/* --------------------------------------------------------------------------
   5. Формы
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.field-hint { font-size: 12px; color: var(--text-2); line-height: 1.45; }
.field-hint.is-ok { color: var(--ok); }
.field-hint.is-error { color: var(--bad); }

.input, .select, .textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.5; resize: vertical; }

.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }

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

.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); opacity: .55; cursor: not-allowed; }
.input.is-error, .select.is-error { border-color: var(--bad); }

/* Поле с префиксом: url-shorts.com/[алиас] */
.input-group {
    display: flex;
    align-items: center;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    padding: 0 12px;
    gap: 8px;
    transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group.is-error { border-color: var(--bad); }
.input-group .prefix, .input-group .suffix {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
    flex: none;
}
.input-group input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    height: 100%;
}

/* Переключатель */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
    width: 34px; height: 20px;
    border-radius: var(--radius-full);
    background: var(--border);
    position: relative;
    flex: none;
    transition: background .16s var(--ease);
}
.toggle-track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: left .16s var(--ease);
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { left: 16px; }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle input:disabled + .toggle-track { opacity: .45; }

/* Чекбокс */
.checkbox { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox-box {
    width: 16px; height: 16px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 10px; line-height: 1;
    flex: none;
    transition: background .12s var(--ease), border-color .12s var(--ease);
}
.checkbox input:checked + .checkbox-box { background: var(--accent); border-color: var(--accent); }
.checkbox input:checked + .checkbox-box::after { content: "✓"; }
.checkbox input:indeterminate + .checkbox-box { background: var(--accent); border-color: var(--accent); }
.checkbox input:indeterminate + .checkbox-box::after { content: "–"; }
.checkbox input:focus-visible + .checkbox-box { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   6. Карточки и поверхности
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.card-lg { border-radius: var(--radius-lg); }
.card-pad { padding: 20px; }
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
}

.panel { background: var(--surface-2); border-radius: var(--radius-md); padding: 16px; }

.callout {
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    font-size: 14px;
}
.callout-ok { border-color: var(--ok); background: var(--ok-soft); }
.callout-warn { border-color: var(--warn); background: var(--warn-soft); }
.callout-bad { border-color: var(--bad); background: var(--bad-soft); }

/* --------------------------------------------------------------------------
   7. Бейджи
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    line-height: 1.5;
    white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 12px;
}

/* --------------------------------------------------------------------------
   8. KPI-плитки
   -------------------------------------------------------------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12px; color: var(--text-2); }
.kpi-value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.1; }
.kpi-delta { font-size: 12px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 4px; }
.kpi-delta.is-up { color: var(--ok); }
.kpi-delta.is-down { color: var(--bad); }
.kpi-delta.is-flat { color: var(--text-2); }

/* --------------------------------------------------------------------------
   9. Таблицы и списки
   -------------------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Строка ссылки */
.link-row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background .1s var(--ease);
}
.link-row:last-child { border-bottom: 0; }
.link-row:hover { background: var(--surface-2); }
.link-favicon {
    width: 20px; height: 20px;
    border-radius: 4px;
    flex: none;
    background: var(--surface-2);
}
.link-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.link-short {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    display: inline-flex; align-items: center; gap: 8px;
}
.link-short:hover { color: var(--accent); }
.link-target { font-size: 12px; color: var(--text-2); font-family: var(--font-mono); }
.link-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-clicks {
    font-size: 18px; font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    flex: none;
    min-width: 60px;
}
.link-clicks small { display: block; font-size: 11px; font-weight: 400; color: var(--text-2); }

/* Кнопка копирования появляется при наведении на строку */
.copy-btn {
    opacity: 0;
    transition: opacity .12s var(--ease);
    border: 0; background: transparent;
    color: var(--text-2); cursor: pointer;
    padding: 2px 4px; border-radius: 4px;
    font-size: 12px;
}
.link-row:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--accent); background: var(--surface-2); }
.copy-btn.is-copied { color: var(--ok); opacity: 1; }

/* --------------------------------------------------------------------------
   10. Разрезы аналитики
   -------------------------------------------------------------------------- */
.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.breakdown { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.breakdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px; font-weight: 500;
    display: flex; align-items: center; justify-content: space-between;
}
.breakdown-body { padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 2px; }

.bar-row {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    overflow: hidden;
}
.bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    z-index: 0;
    transition: width .3s var(--ease);
}
.bar-label, .bar-value, .bar-percent { position: relative; z-index: 1; }
.bar-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 500; }
.bar-percent { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* --------------------------------------------------------------------------
   11. Графики
   -------------------------------------------------------------------------- */
.chart { width: 100%; height: 240px; display: block; }
.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 240px; padding: 8px 0; }
.chart-bar {
    flex: 1;
    min-width: 2px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
    opacity: .85;
    transition: opacity .12s var(--ease);
    position: relative;
}
.chart-bar:hover { opacity: 1; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 6px; }

.sparkline { height: 32px; width: 100%; }

/* --------------------------------------------------------------------------
   12. Оверлеи
   -------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(8, 8, 14, .5);
    backdrop-filter: blur(2px);
    z-index: 90;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow: auto;
}
.modal-lg { max-width: 720px; }

.drawer-backdrop {
    position: fixed; inset: 0;
    background: rgba(8, 8, 14, .45);
    z-index: 90;
}
.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(560px, 100vw);
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -12px 0 32px rgba(8, 8, 14, .18);
    z-index: 91;
    display: flex; flex-direction: column;
    animation: slide-in .28s var(--ease);
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    flex: none;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
    flex: none;
}

/* Тосты */
.toasts {
    position: fixed;
    right: 20px; bottom: 20px;
    z-index: 95;
    display: flex; flex-direction: column; gap: 10px;
    max-width: 360px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 12px 14px;
    display: flex; gap: 10px; align-items: flex-start;
    animation: toast-in .24s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast-icon { font-size: 12px; margin-top: 3px; flex: none; }
.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toast-title { font-size: 13px; font-weight: 500; }
.toast-text { font-size: 12px; color: var(--text-2); }
.toast-close { border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; padding: 0 2px; }
.toast.is-success { border-color: var(--ok); }
.toast.is-success .toast-icon { color: var(--ok); }
.toast.is-warning { border-color: var(--warn); }
.toast.is-warning .toast-icon { color: var(--warn); }
.toast.is-error { border-color: var(--bad); }
.toast.is-error .toast-icon { color: var(--bad); }

/* Тултип */
.tip { position: relative; display: inline-flex; }
.tip-body {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s var(--ease);
    box-shadow: var(--shadow-md);
    z-index: 30;
    max-width: 240px;
}
.tip:hover .tip-body, .tip:focus-within .tip-body { opacity: 1; }

/* Дропдаун */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    right: 0; top: calc(100% + 4px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 4px;
    z-index: 40;
    display: none;
}
.dropdown.is-open .dropdown-menu { display: block; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    border: 0; background: transparent;
    width: 100%;
    text-align: left;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-item.is-danger { color: var(--bad); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* --------------------------------------------------------------------------
   13. Табы и пагинация
   -------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    height: 36px;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color .12s var(--ease), border-color .12s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.tab:disabled { opacity: .45; cursor: not-allowed; }

.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.page-link {
    min-width: 32px; height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    font-variant-numeric: tabular-nums;
}
.page-link:hover { border-color: var(--border-strong); color: var(--text); }
.page-link.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-link.is-disabled { opacity: .45; pointer-events: none; }

/* --------------------------------------------------------------------------
   14. Скелетоны и пустые состояния
   -------------------------------------------------------------------------- */
.skel {
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
    background-size: 320px 100%;
    animation: shimmer 1.4s linear infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: -320px 0; } 100% { background-position: 320px 0; } }

.empty {
    display: flex; flex-direction: column; align-items: center;
    text-align: center;
    padding: 64px 24px;
    gap: 12px;
}
.empty-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    margin-bottom: 4px;
}
.empty-title { font-size: 16px; font-weight: 600; }
.empty-text { font-size: 14px; color: var(--text-2); max-width: 380px; }

/* --------------------------------------------------------------------------
   15. Шапка публичной части
   -------------------------------------------------------------------------- */
.site-header {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.site-header-inner { height: 64px; display: flex; align-items: center; gap: 32px; }

.logo {
    display: inline-flex; align-items: center; gap: 9px;
    font-weight: 600; font-size: 15px; letter-spacing: -.01em;
    color: var(--text);
}
.logo:hover { color: var(--text); }
.logo-mark {
    width: 22px; height: 22px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    flex: none;
}

.site-nav { display: flex; gap: 24px; font-size: 14px; }
.site-nav a { color: var(--text-2); }
.site-nav a:hover { color: var(--text); }

.site-footer { margin-top: 112px; border-top: 1px solid var(--border); background: var(--surface); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; padding: 48px 0; }
.footer-col { display: flex; flex-direction: column; gap: 10px; }
.footer-col a { font-size: 13px; color: var(--text-2); }
.footer-col a:hover { color: var(--text); }
.footer-bottom {
    padding: 0 0 40px;
    font-size: 12px; color: var(--text-2);
    display: flex; gap: 20px; flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   16. Главная: форма сокращения
   -------------------------------------------------------------------------- */
.hero { padding: 96px 0 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.hero h1 {
    font-size: 60px;
    line-height: 1.05;
    letter-spacing: -.035em;
    max-width: 760px;
    text-wrap: balance;
}
.hero-sub {
    margin-top: 20px;
    font-size: 18px;
    line-height: 1.55;
    color: var(--text-2);
    max-width: 520px;
    text-wrap: pretty;
}

.shorten-form {
    margin-top: 40px;
    width: 100%;
    max-width: 660px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.shorten-input-wrap {
    width: 100%;
    display: flex; align-items: center; gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px;
    transition: border-color .12s var(--ease);
}
.shorten-input-wrap:focus-within { border-color: var(--accent); }
.shorten-input-wrap input {
    flex: 1; min-width: 0;
    border: 0; outline: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 15px;
    height: 48px;
    padding: 0 12px;
}
.shorten-input-wrap .btn { height: 48px; padding: 0 24px; border-radius: var(--radius-md); font-size: 15px; }

.trust-row {
    margin-top: 56px;
    display: flex; gap: 28px;
    font-size: 13px; color: var(--text-2);
    flex-wrap: wrap; justify-content: center;
    font-variant-numeric: tabular-nums;
}
.trust-sep { color: var(--border); }

.result-card { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; padding: 20px; }
.result-qr {
    width: 76px; height: 76px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-2);
    flex: none;
    padding: 6px;
}
.result-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.result-short { font-family: var(--font-mono); font-size: 17px; font-weight: 500; }

/* --------------------------------------------------------------------------
   17. Кабинет
   -------------------------------------------------------------------------- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex: none;
    border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex; flex-direction: column;
    position: sticky; top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-2);
    transition: background .1s var(--ease), color .1s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-item .icon { width: 16px; text-align: center; flex: none; font-size: 13px; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 0; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header {
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    background: var(--bg);
    position: sticky; top: 0; z-index: 15;
}
.app-content { padding: 24px; flex: 1; max-width: 1440px; width: 100%; }

/* Индикатор лимита тарифа */
.usage { display: flex; flex-direction: column; gap: 6px; }
.usage-bar { height: 5px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.usage-fill { height: 100%; background: var(--accent); border-radius: var(--radius-full); transition: width .3s var(--ease); }
.usage-fill.is-warn { background: var(--warn); }
.usage-fill.is-danger { background: var(--bad); }
.usage-text { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Переключатель воркспейса */
.ws-switch {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    text-align: left;
}
.ws-switch:hover { background: var(--surface-2); }
.ws-avatar {
    width: 22px; height: 22px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
    flex: none;
}

/* --------------------------------------------------------------------------
   18. Тарифы
   -------------------------------------------------------------------------- */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.plan {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 24px;
    display: flex; flex-direction: column; gap: 14px;
    position: relative;
}
.plan.is-featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.plan-price { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.plan-price small { font-size: 14px; font-weight: 400; color: var(--text-2); }
.plan-limits { font-size: 13px; line-height: 1.75; color: var(--text-2); }
.plan .btn { margin-top: auto; }

.billing-switch {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
}
.billing-switch button {
    height: 30px; padding: 0 14px;
    border: 0; background: transparent;
    border-radius: 4px;
    font-size: 13px; color: var(--text-2);
    cursor: pointer;
}
.billing-switch button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   19. Прочее
   -------------------------------------------------------------------------- */
.divider { height: 1px; background: var(--border); border: 0; margin: 24px 0; }

.section-title {
    font-size: 11px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 16px;
}

details.faq { border-bottom: 1px solid var(--border); }
details.faq summary {
    cursor: pointer;
    list-style: none;
    padding: 18px 0;
    font-size: 15px; font-weight: 500;
    display: flex; justify-content: space-between; gap: 16px; align-items: center;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; color: var(--text-2); font-size: 18px; font-weight: 400; }
details.faq[open] summary::after { content: "−"; }
details.faq .faq-body { padding: 0 0 18px; font-size: 14px; line-height: 1.6; color: var(--text-2); max-width: 640px; text-wrap: pretty; }

.theme-toggle {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

/* --------------------------------------------------------------------------
   20. Адаптив
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .sidebar { width: 68px; }
    .sidebar .nav-label, .sidebar-footer .usage-text, .ws-switch span:not(.ws-avatar) { display: none; }
    .nav-item { justify-content: center; padding: 0; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .hero { padding-top: 56px; }
    .hero h1 { font-size: 36px; line-height: 1.1; }
    .hero-sub { font-size: 16px; }
    .site-nav { display: none; }
    .shorten-input-wrap { flex-direction: column; align-items: stretch; padding: 10px; }
    .shorten-input-wrap input { width: 100%; }
    .shorten-input-wrap .btn { width: 100%; }
    .app-content { padding: 16px; }
    .container, .container-narrow, .container-wide { padding: 0 16px; }
    .footer-grid { grid-template-columns: 1fr; gap: 24px; }
    .breakdown-grid { grid-template-columns: 1fr; }
    .drawer { width: 100vw; }

    /* Сайдбар превращается в нижнюю навигацию */
    .app-layout { flex-direction: column; }
    .sidebar {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        top: auto;
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: 0;
        border-top: 1px solid var(--border);
        z-index: 30;
    }
    .sidebar-header, .sidebar-footer { display: none; }
    .sidebar-nav { flex-direction: row; justify-content: space-around; padding: 6px 4px; }
    .nav-item { flex-direction: column; height: auto; padding: 6px 0; gap: 3px; font-size: 10px; }
    .nav-item .nav-label { display: block; font-size: 10px; }
    .nav-divider { display: none; }
    .app-main { padding-bottom: 64px; }

    .link-row { flex-wrap: wrap; }
    .link-clicks { min-width: auto; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 30px; }
}

/* --------------------------------------------------------------------------
   21. Уважение к настройкам пользователя
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .sidebar, .app-header, .site-header, .site-footer, .toasts, .btn { display: none !important; }
    body { background: #fff; color: #000; }
    .card { border: 1px solid #ccc; break-inside: avoid; }
}
