@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #06070c;
    --bg-elevated: #0c0e16;
    --bg-soft: #10131c;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-hover: rgba(255, 255, 255, 0.06);
    --text: #f0f2f8;
    --muted: #9aa3b8;
    --dim: #5a6278;
    --accent: #a8b4ff;
    --accent-soft: #c4b5fd;
    --accent-strong: #818cf8;
    --cyan: #67e8f9;
    --violet: #8b5cf6;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.12);
    --glow: rgba(168, 180, 255, 0.45);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.55);
    --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sidebar-w: 260px;
    --header-h: 64px;
}

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

html { height: 100%; }

body {
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ========== Background layers ========== */
.cosmic-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 80% 55% at 50% 0%, rgba(99, 102, 241, 0.16), transparent 55%),
        radial-gradient(ellipse 55% 45% at 85% 75%, rgba(139, 92, 246, 0.1), transparent 50%),
        radial-gradient(ellipse 45% 35% at 10% 85%, rgba(56, 189, 248, 0.07), transparent 45%);
}

.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.star {
    position: absolute;
    border-radius: 50%;
    background: #fff;
    opacity: 0.35;
    animation: twinkle var(--dur, 3s) ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.12; transform: scale(0.75); }
    50% { opacity: 0.85; transform: scale(1.15); }
}

/* ========== Typography ========== */
.kicker {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
}

.gradient-text {
    background: linear-gradient(135deg, #f0f2f8 0%, #c4b5fd 55%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.muted { color: var(--muted); }
.dim { color: var(--dim); }

/* ========== Glass / Cards ========== */
.glass {
    background: linear-gradient(145deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow), 0 0 0 1px rgba(168, 180, 255, 0.04);
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.card:hover {
    background: var(--surface-hover);
    border-color: var(--line-strong);
}

.card-interactive:hover {
    transform: translateY(-2px);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    color: #fff;
    box-shadow: 0 4px 20px -4px rgba(129, 140, 248, 0.55);
}

.btn-primary:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 28px -4px rgba(129, 140, 248, 0.65);
}

.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
}

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

.btn-soft {
    background: rgba(168, 180, 255, 0.12);
    color: var(--accent);
}

.btn-soft:hover {
    background: rgba(168, 180, 255, 0.2);
}

.btn-sm {
    height: 34px;
    padding: 0 12px;
    font-size: 12.5px;
    border-radius: 9px;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 11px;
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ========== Form controls ========== */
.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.input, .select, .textarea {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.textarea {
    height: auto;
    min-height: 100px;
    padding: 12px 14px;
    resize: vertical;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: rgba(168, 180, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(168, 180, 255, 0.12);
}

.input::placeholder, .textarea::placeholder {
    color: var(--dim);
}

.input-icon-wrap {
    position: relative;
}

.input-icon-wrap .input {
    padding-left: 42px;
}

.input-icon-wrap .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--dim);
    pointer-events: none;
}

/* ========== Status / Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.badge-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-success { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.badge-warning { background: rgba(251, 191, 36, 0.12); color: var(--warning); }
.badge-danger  { background: rgba(248, 113, 113, 0.12); color: var(--danger); }
.badge-info    { background: rgba(168, 180, 255, 0.12); color: var(--accent); }
.badge-neutral { background: rgba(255,255,255,0.06); color: var(--muted); }

/* ========== Loaders ========== */
.loader-orbit {
    width: 18px;
    height: 18px;
    position: relative;
    flex-shrink: 0;
}

.loader-orbit::before,
.loader-orbit::after {
    content: "";
    position: absolute;
    border-radius: 50%;
}

.loader-orbit::before {
    inset: 0;
    border: 1.5px solid rgba(168, 180, 255, 0.25);
}

.loader-orbit::after {
    width: 5px;
    height: 5px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--glow);
    top: -2.5px;
    left: 50%;
    margin-left: -2.5px;
    animation: orbit 1.35s linear infinite;
}

@keyframes orbit {
    from { transform: rotate(0deg) translateY(9px) rotate(0deg); }
    to   { transform: rotate(360deg) translateY(9px) rotate(-360deg); }
}

.loader-bars {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    height: 14px;
}

.loader-bars i {
    display: block;
    width: 2.5px;
    height: 100%;
    background: linear-gradient(to top, var(--accent), var(--cyan));
    border-radius: 2px;
    animation: bars 1.1s ease-in-out infinite;
}

.loader-bars i:nth-child(1) { animation-delay: 0s; }
.loader-bars i:nth-child(2) { animation-delay: 0.12s; }
.loader-bars i:nth-child(3) { animation-delay: 0.24s; }
.loader-bars i:nth-child(4) { animation-delay: 0.36s; }

@keyframes bars {
    0%, 100% { transform: scaleY(0.3); opacity: 0.35; }
    50%      { transform: scaleY(1); opacity: 1; }
}

.loader-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--glow);
    animation: pulse-dot 1.8s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.45; transform: scale(0.8); }
    50%      { opacity: 1; transform: scale(1.15); }
}

.loader-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(168, 180, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.loader-full {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 48px;
    color: var(--muted);
}

/* Button loading state */
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

/* ========== Toasts / Notifications ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    width: calc(100% - 40px);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(145deg, rgba(20, 22, 32, 0.95), rgba(12, 14, 22, 0.98));
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    box-shadow: 0 12px 40px -8px rgba(0,0,0,0.6), 0 0 0 1px rgba(168,180,255,0.06);
    backdrop-filter: blur(16px);
    animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.leaving {
    animation: toast-out 0.28s ease forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(24px) scale(0.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateX(20px) scale(0.95); }
}

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.toast-success .toast-icon { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.toast-error   .toast-icon { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.toast-info    .toast-icon { background: rgba(168, 180, 255, 0.15); color: var(--accent); }
.toast-warning .toast-icon { background: rgba(251, 191, 36, 0.15); color: var(--warning); }

.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13.5px; font-weight: 560; margin-bottom: 2px; }
.toast-msg   { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.toast-close {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dim);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.toast-close:hover {
    background: var(--surface);
    color: var(--text);
}

/* ========== Layout: App shell ========== */
.app {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(12,14,22,0.92), rgba(8,9,14,0.96));
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    backdrop-filter: blur(20px);
}

.sidebar-brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px;
    border-bottom: 1px solid var(--line);
}

.sidebar-brand .logo {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    box-shadow: 0 4px 16px -4px rgba(129, 140, 248, 0.5);
}

.sidebar-brand .name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sidebar-nav {
    flex: 1;
    padding: 18px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 22px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--dim);
    padding: 0 12px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 40px;
    padding: 0 12px;
    border-radius: 11px;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 450;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--surface);
    color: var(--text);
}

.nav-item.active {
    background: rgba(168, 180, 255, 0.12);
    color: var(--accent);
}

.nav-item .icon {
    width: 18px;
    height: 18px;
    opacity: 0.85;
    flex-shrink: 0;
}

.nav-item .badge-count {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(168, 180, 255, 0.15);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer {
    padding: 14px 12px 18px;
    border-top: 1px solid var(--line);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 12px;
    transition: background 0.15s;
}

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

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--dim); }

/* Main content area */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(6, 7, 12, 0.65);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 15px;
    font-weight: 560;
    letter-spacing: -0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.sidebar-toggle {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

.top-badges {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.alert-last-hint {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-box {
    position: relative;
    width: 220px;
}

.search-box .input {
    height: 36px;
    padding-left: 36px;
    font-size: 13px;
    border-radius: 10px;
}

.search-box .icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--dim);
}

.content {
    flex: 1;
    padding: 28px;
}

/* ========== Stats grid ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    top: -30px;
    right: -30px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(168, 180, 255, 0.12), transparent 70%);
    pointer-events: none;
}

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

.stat-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.stat-delta {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ========== Cards grid ========== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.project-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    transition: all 0.2s;
}

.project-card:hover {
    border-color: rgba(168, 180, 255, 0.25);
    background: var(--surface-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px -12px rgba(0,0,0,0.4);
}

.project-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.project-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: rgba(168, 180, 255, 0.12);
}

.project-title {
    font-size: 14.5px;
    font-weight: 560;
    margin-bottom: 4px;
}

.project-desc {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.avatar-stack {
    display: flex;
}

.avatar-stack span {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 2px solid var(--bg);
    margin-left: -8px;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.avatar-stack span:first-child { margin-left: 0; }

/* ========== Tables ========== */
.table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
}

th {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dim);
    background: rgba(0,0,0,0.2);
}

td { font-size: 13.5px; }

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255,255,255,0.02); }

/* ========== Section headers ========== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}

.section-title {
    font-size: 15px;
    font-weight: 560;
    letter-spacing: -0.01em;
}

/* ========== Tabs ========== */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0,0,0,0.25);
    border-radius: 12px;
    border: 1px solid var(--line);
    width: fit-content;
}

.tab {
    height: 32px;
    padding: 0 14px;
    border-radius: 9px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
    transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active {
    background: rgba(168, 180, 255, 0.15);
    color: var(--accent);
}

/* ========== Empty / placeholder ========== */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--muted);
}

.empty-state .icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 16px;
    background: rgba(168, 180, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* ========== Login page specific ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    position: relative;
    z-index: 1;
}

.login-card {
    width: min(420px, 100%);
    padding: 40px 36px 32px;
    position: relative;
}

.login-card .glow {
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    filter: blur(30px);
    pointer-events: none;
    z-index: -1;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    box-shadow: 0 8px 28px -6px rgba(129, 140, 248, 0.55);
}

.login-header h1 {
    font-size: 24px;
    font-weight: 560;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

.login-header p {
    font-size: 13.5px;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form .btn {
    width: 100%;
    height: 46px;
    margin-top: 6px;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 12.5px;
    color: var(--dim);
}

.login-footer a {
    color: var(--accent);
    font-weight: 500;
}

.login-footer a:hover { text-decoration: underline; }

.divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 8px 0;
    color: var(--dim);
    font-size: 11.5px;
}

.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* ========== Notification dropdown ========== */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: linear-gradient(160deg, rgba(16, 18, 28, 0.98), rgba(10, 12, 18, 0.98));
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    box-shadow: 0 20px 50px -12px rgba(0,0,0,0.65);
    backdrop-filter: blur(20px);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.98);
    transition: all 0.2s ease;
    z-index: 50;
}

.notif-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.notif-header h3 { font-size: 13.5px; font-weight: 560; }

.notif-list {
    max-height: 320px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    transition: background 0.15s;
    cursor: pointer;
}

.notif-item:hover { background: var(--surface); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: rgba(168, 180, 255, 0.04); }

.notif-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 5px;
    flex-shrink: 0;
    box-shadow: 0 0 8px var(--glow);
}

.notif-item .dot.read {
    background: transparent;
    box-shadow: none;
}

.notif-text { font-size: 13px; line-height: 1.4; }
.notif-time { font-size: 11.5px; color: var(--dim); margin-top: 3px; }

.notif-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    text-align: center;
}

.notif-footer a {
    font-size: 12.5px;
    color: var(--accent);
    font-weight: 500;
}

/* ========== Responsive ========== */
@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
    .sidebar-toggle { display: inline-flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: min(var(--sidebar-w), 86vw);
        box-shadow: 12px 0 40px -20px rgba(0, 0, 0, 0.65);
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 35;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(2px);
    }
    .sidebar-backdrop[hidden] { display: none !important; }

    body.sidebar-open { overflow: hidden; }

    .main { margin-left: 0; }
    .search-box { display: none; }

    .topbar {
        height: auto;
        min-height: var(--header-h);
        padding: 10px 16px;
        gap: 10px;
        flex-wrap: wrap;
        align-items: flex-start;
    }
    .topbar-left, .topbar-right { width: 100%; }
    .topbar-right { justify-content: flex-start; }
    .alert-last-hint { max-width: min(220px, 55vw); }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .script-editor {
        height: 22rem;
        max-height: 60vh;
    }
}

@media (max-width: 560px) {
    .content {
        padding: 14px;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }
    .stats-grid { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: 1fr; }
    .login-page {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        align-items: flex-start;
        padding-top: max(24px, env(safe-area-inset-top, 0px));
    }
    .login-card { padding: 24px 18px 20px; }
    .topbar {
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top, 0px));
    }

    /* iOS: avoid auto-zoom on focus */
    .input, .select, .textarea { font-size: 16px; }

    .btn, .nav-item { min-height: 44px; }
    .btn-sm { min-height: 40px; }
    .btn-icon { width: 44px; height: 44px; min-height: 44px; }

    th, td { padding: 12px 12px; }
    .page-title { font-size: 14px; }
}

@supports (padding: max(0px)) {
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* Telegram wizard QR login */
.wizard-qr-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px 0;
}
img.wizard-qr {
  width: 280px !important;
  height: 280px !important;
  max-width: min(280px, 85vw) !important;
  max-height: min(280px, 85vw) !important;
  object-fit: fill !important;
  image-rendering: pixelated;
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  box-sizing: border-box;
  flex-shrink: 0;
}
.wizard-phone-alt {
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
  padding-top: 12px;
}
.wizard-phone-alt > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.wizard-phone-alt > summary::-webkit-details-marker { display: none; }
.wizard-phone-alt > summary::before {
  content: '▸ ';
  opacity: .6;
}
.wizard-phone-alt[open] > summary::before { content: '▾ '; }
.wizard-phone-alt-body { margin-top: 12px; }

/* Utility */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.relative { position: relative; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-medium { font-weight: 500; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


/* SPA alerts */
.alert {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
}
.alert-error {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger, #f87171);
  border-color: rgba(248, 113, 113, 0.28);
}

/* Script constructor editor + highlight */
.script-editor {
  position: relative;
  min-height: calc(14 * 1.45em * 1.3 + 24px); /* ~30% taller than 14 rows */
  height: 28rem;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,.35);
  overflow: hidden;
}
.script-hl,
.script-input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 14px 16px;
  font-family: var(--mono), ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  box-sizing: border-box;
  border: 0;
  width: 100%;
  height: 100%;
}
.script-hl {
  color: var(--text);
  pointer-events: none;
  z-index: 1;
}
.script-input {
  z-index: 2;
  background: transparent;
  color: transparent;
  caret-color: var(--accent, #7aa2ff);
  resize: none;
}
.script-input:focus {
  outline: none;
}
.hl-timer { color: #5eead4; font-weight: 600; }
.hl-action { color: #fbbf24; font-weight: 600; }
.hl-assert { color: #fb7185; font-weight: 600; }
.hl-cmd { color: #a5b4fc; font-weight: 600; }
.hl-param { color: #93c5fd; }
.hl-num { color: #c4b5fd; }
.hl-comment { color: var(--muted); font-style: italic; }
