/* === Сброс === */
*, *::before, *::after { box-sizing: border-box; }

/* === Светлая тема (по умолчанию) === */
:root,
html[data-applied-theme="light"] {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --surface-2: #f1efe8;
    --border: rgba(0,0,0,0.08);
    --border-strong: rgba(0,0,0,0.14);
    --text: #1a1a1a;
    --text-2: #5f5e5a;
    --text-3: #888780;

    --brand: #185fa5;
    --brand-2: #0c447c;
    --brand-bg: #e6f1fb;

    --success: #0f6e56;
    --success-bg: #e1f5ee;
    --danger: #a32d2d;
    --danger-bg: #fceaea;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 0 0 0.5px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.06);
}

/* === Тёмная тема === */
html[data-applied-theme="dark"] {
    --bg: #0e0f12;
    --surface: #1a1c20;
    --surface-2: #232529;
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.16);
    --text: #f0f0f0;
    --text-2: #b0b0b0;
    --text-3: #808080;

    --brand: #4a9eff;
    --brand-2: #6cb2ff;
    --brand-bg: rgba(74,158,255,0.12);

    --success: #4ade80;
    --success-bg: rgba(74,222,128,0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,0.12);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 0.5px rgba(255,255,255,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(255,255,255,0.08);
}

:root {
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    transition: background 0.2s, color 0.2s;
}

a { color: inherit; text-decoration: none; }

/* === Верхняя панель === */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--brand-bg);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--text-2); }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-2);
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }

.nav-link-button {
    background: transparent;
    border: 0;
    font: inherit;
}

.nav-link-primary {
    background: var(--brand);
    color: white;
}
.nav-link-primary:hover {
    background: var(--brand-2);
    color: white;
}

.nav-text { display: inline; }
@@media (max-width: 900px) {
    .nav-text { display: none; }
}

.logout-form { margin: 0; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 4px 12px;
    background: var(--surface-2);
    border-radius: 999px;
}
.user-name { font-size: 13px; color: var(--text-2); }
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--brand-bg);
    color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

/* === Dropdown === */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    padding: 4px;
    display: none;
    z-index: 100;
}
.dropdown.open .dropdown-menu { display: block; animation: fadeIn 0.15s ease; }
.dropdown-form { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.1s;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.active { background: var(--brand-bg); color: var(--brand); }
.lang-flag { font-size: 18px; line-height: 1; }
.lang-code { font-size: 12px; font-weight: 600; color: var(--text-2); }

@@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Контейнер === */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
}

/* === Hero === */
.hero { margin-bottom: 32px; }
.hero-greeting {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.hero-sub { margin: 0; color: var(--text-2); font-size: 15px; }

/* === Категории и плитки === */
.category { margin-bottom: 36px; }
.category-title {
    margin: 0 0 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    cursor: pointer;
}
.tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.tile-head { display: flex; justify-content: space-between; align-items: center; }
.tile-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.tile-ext { color: var(--text-3); font-size: 14px; }
.tile-body { flex: 1; }
.tile-title { margin: 0 0 2px; font-weight: 600; font-size: 15px; }
.tile-desc { margin: 0; font-size: 13px; color: var(--text-2); }
.tile-foot { display: flex; align-items: center; }
.tile-status {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--success);
    background: var(--success-bg);
    padding: 3px 10px;
    border-radius: 999px;
}
.status-dot {
    width: 6px; height: 6px;
    background: var(--success);
    border-radius: 50%;
}

/* === Цвета плиток (работают в обеих темах через прозрачность) === */
.color-blue   .tile-icon, .td-icon.color-blue   { background:#e6f1fb; color:#0c447c; }
.color-teal   .tile-icon, .td-icon.color-teal   { background:#e1f5ee; color:#085041; }
.color-purple .tile-icon, .td-icon.color-purple { background:#eeedfe; color:#3c3489; }
.color-coral  .tile-icon, .td-icon.color-coral  { background:#faece7; color:#712b13; }
.color-amber  .tile-icon, .td-icon.color-amber  { background:#faeeda; color:#633806; }
.color-pink   .tile-icon, .td-icon.color-pink   { background:#fbeaf0; color:#72243e; }
.color-green  .tile-icon, .td-icon.color-green  { background:#eaf3de; color:#27500a; }
.color-gray   .tile-icon, .td-icon.color-gray   { background:#f1efe8; color:#444441; }

html[data-applied-theme="dark"] .color-blue   .tile-icon, html[data-applied-theme="dark"] .td-icon.color-blue   { background:rgba(74,158,255,0.16); color:#7ab8ff; }
html[data-applied-theme="dark"] .color-teal   .tile-icon, html[data-applied-theme="dark"] .td-icon.color-teal   { background:rgba(45,212,191,0.16); color:#5eead4; }
html[data-applied-theme="dark"] .color-purple .tile-icon, html[data-applied-theme="dark"] .td-icon.color-purple { background:rgba(139,92,246,0.16); color:#a78bfa; }
html[data-applied-theme="dark"] .color-coral  .tile-icon, html[data-applied-theme="dark"] .td-icon.color-coral  { background:rgba(251,113,80,0.16); color:#fb923c; }
html[data-applied-theme="dark"] .color-amber  .tile-icon, html[data-applied-theme="dark"] .td-icon.color-amber  { background:rgba(251,191,36,0.16); color:#fcd34d; }
html[data-applied-theme="dark"] .color-pink   .tile-icon, html[data-applied-theme="dark"] .td-icon.color-pink   { background:rgba(244,114,182,0.16); color:#f9a8d4; }
html[data-applied-theme="dark"] .color-green  .tile-icon, html[data-applied-theme="dark"] .td-icon.color-green  { background:rgba(132,204,22,0.16); color:#bef264; }
html[data-applied-theme="dark"] .color-gray   .tile-icon, html[data-applied-theme="dark"] .td-icon.color-gray   { background:rgba(160,160,160,0.16); color:#d4d4d4; }

/* === Пусто === */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-2);
}
.empty-icon { font-size: 48px; color: var(--text-3); margin-bottom: 12px; display: block; }

/* === Формы === */
.form-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-label > span:first-child {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}
.form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-bg);
}
.form-hint { color: var(--text-3); font-size: 12px; }
.form-error { color: var(--danger); font-size: 12px; display: block; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-2);
    cursor: pointer;
}
.form-check.pad { padding-top: 26px; }
.form-check input { width: 16px; height: 16px; }

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 800px;
}
.form-row {
    display: grid;
    gap: 16px;
}
.form-row.two { grid-template-columns: 1fr 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
@@media (max-width: 700px) {
    .form-row.two, .form-row.three { grid-template-columns: 1fr; }
}
.form-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
}

/* === Кнопки === */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--brand);
    color: white;
    border: 0;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--brand-2); }
.btn-primary:active { transform: scale(0.98); }
.btn-block { width: 100%; justify-content: center; }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: var(--surface-2);
    color: var(--text-2);
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.btn-sm:hover { background: var(--border); color: var(--text); }
.btn-sm.btn-danger { color: var(--danger); }
.btn-sm.btn-danger:hover { background: var(--danger-bg); }

/* === Админ === */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.page-sub { margin: 0; color: var(--text-2); font-size: 14px; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert.success {
    background: var(--success-bg);
    color: var(--success);
}

/* === Таблицы === */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead { background: var(--surface-2); }
.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }

.td-title { display: flex; align-items: center; gap: 12px; }
.td-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.td-main { margin: 0; font-weight: 500; }
.td-sub { margin: 0; font-size: 12px; color: var(--text-3); }
.td-url {
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 12px;
    color: var(--text-2);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.td-actions { text-align: right; white-space: nowrap; }
.inline-form { display: inline; margin: 0; margin-left: 4px; }

code {
    background: var(--surface-2);
    color: var(--text);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 13px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--surface-2);
    color: var(--text-2);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: var(--surface-2); color: var(--text-3); }
.badge-admin { background: var(--brand-bg); color: var(--brand); }

/* === Страница блокировки IP === */
.blocked-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}
.blocked-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    max-width: 440px;
    box-shadow: var(--shadow-md);
}
.blocked-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--danger-bg);
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin-bottom: 20px;
}
.blocked-card h1 { margin: 0 0 8px; font-size: 22px; }
.blocked-card p { margin: 0 0 24px; color: var(--text-2); }
.blocked-ip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    font-size: 13px;
}
.blocked-ip-label { color: var(--text-3); }
