:root {
    --bg-dark: #050807;
    --bg-panel: #0a100d;
    --bg-card: #0f1812;
    --bg-card-hover: #142019;
    --border: rgba(34, 197, 94, 0.18);
    --green: #22c55e;
    --green-light: #4ade80;
    --green-dark: #15803d;
    --green-glow: rgba(34, 197, 94, 0.35);
    --text: #e8f5ec;
    --text-muted: #8fa899;
    --danger: #ef4444;
    --warning: #f59e0b;
    --sidebar-w: 260px;
    --radius: 14px;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

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

html, body {
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
}

body.app-body {
    background: linear-gradient(135deg, #030504 0%, #07110b 35%, #0a1a10 70%, #030806 100%);
    background-attachment: fixed;
}

a { color: var(--green-light); text-decoration: none; transition: color .2s; }
a:hover { color: #86efac; }

code {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.85em;
    color: var(--green-light);
    word-break: break-all;
}

/* LOGIN */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 20% 20%, rgba(34,197,94,.15), transparent 50%),
                radial-gradient(ellipse at 80% 80%, rgba(21,128,61,.2), transparent 50%),
                linear-gradient(160deg, #020403, #07120c 50%, #020504);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(145deg, rgba(15,24,18,.95), rgba(8,14,10,.98));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px;
    box-shadow: var(--shadow), 0 0 60px var(--green-glow);
}

.login-card.wide { max-width: 520px; }

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.login-brand .logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.4rem;
    color: #041208;
    box-shadow: 0 0 24px var(--green-glow);
}

.login-brand h1 { font-size: 1.5rem; font-weight: 700; }
.login-brand p { color: var(--text-muted); font-size: 0.9rem; }

/* APP SHELL */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: linear-gradient(180deg, #060b08 0%, #0a1510 50%, #060a08 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand h2 {
    font-size: 1.15rem;
    background: linear-gradient(90deg, var(--green-light), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand small {
    color: var(--text-muted);
    font-size: 0.75rem;
    display: block;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all .2s;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(34, 197, 94, 0.08);
    color: var(--text);
    border-color: var(--border);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(34,197,94,.2), rgba(34,197,94,.05));
    color: var(--green-light);
    border-color: rgba(34, 197, 94, 0.35);
    box-shadow: inset 3px 0 0 var(--green);
}

.nav-item .icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-footer a {
    display: block;
    padding: 10px;
    text-align: center;
    border-radius: 8px;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.sidebar-footer a:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

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

.top-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(5, 10, 7, 0.6);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-header h1 {
    font-size: 1.4rem;
    font-weight: 600;
}

.top-header .breadcrumb {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

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

.page-content {
    padding: 28px 32px 40px;
    flex: 1;
}

/* STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: linear-gradient(145deg, var(--bg-card), #0c1610);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--green-glow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    background: radial-gradient(circle, var(--green-glow), transparent 70%);
    opacity: 0.5;
}

.stat-card .stat-icon {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.stat-card .stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--green-light);
    line-height: 1;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 6px;
}

.stat-card .stat-trend {
    font-size: 0.75rem;
    color: var(--green);
    margin-top: 8px;
}

/* CARDS & GRID */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 24px;
}

.card {
    background: linear-gradient(160deg, rgba(15,24,18,.9), rgba(10,16,12,.95));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

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

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--green-light);
}

/* TABS */
.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: rgba(0,0,0,.3);
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--border);
    width: fit-content;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all .2s;
}

.tab-btn:hover { color: var(--text); background: rgba(34,197,94,.08); }

.tab-btn.active {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #041208;
    box-shadow: 0 4px 15px var(--green-glow);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* TABLE */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: rgba(34, 197, 94, 0.08);
    color: var(--green-light);
    font-weight: 600;
    text-align: left;
    padding: 14px 16px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    padding: 14px 16px;
    border-top: 1px solid rgba(34, 197, 94, 0.08);
    vertical-align: middle;
}

tr:hover td { background: rgba(34, 197, 94, 0.04); }

/* FORMS */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

input, select, textarea {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.35);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color .2s, box-shadow .2s;
}

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

textarea { min-height: 90px; resize: vertical; }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #041208;
    box-shadow: 0 4px 20px var(--green-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 28px var(--green-glow);
    color: #041208;
}

.btn-secondary {
    background: rgba(34, 197, 94, 0.1);
    color: var(--green-light);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: rgba(34, 197, 94, 0.2); color: var(--green-light); }

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.3); }

.btn-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-warning:hover { background: rgba(245, 158, 11, 0.3); }

.btn-sm { padding: 7px 12px; font-size: 0.8rem; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* BADGES */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-ok {
    background: rgba(34, 197, 94, 0.2);
    color: var(--green-light);
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge-off {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warn {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-info {
    background: rgba(34, 197, 94, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-m3u {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.badge-xc {
    background: rgba(34, 197, 94, 0.2);
    color: var(--green-light);
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.row-blocked { opacity: 0.65; }

.inline-form { display: inline; }

.filter-form select {
    min-width: 200px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.check-row {
    margin: 14px 0 18px;
    align-items: center;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    align-items: end;
}

.form-actions { grid-column: 1 / -1; }

.url-cell { max-width: 280px; display: inline-block; }

@media (max-width: 768px) {
    .form-row, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ALERTS */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    border: 1px solid;
}

.alert-ok {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
    color: var(--green-light);
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.hint { color: var(--text-muted); font-size: 0.85rem; line-height: 1.5; }

.info-list { list-style: none; }
.info-list li {
    padding: 10px 0;
    border-bottom: 1px solid rgba(34,197,94,.08);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.info-list li:last-child { border-bottom: none; }

.progress-bar {
    height: 6px;
    background: rgba(0,0,0,.4);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green-dark), var(--green-light));
    border-radius: 3px;
    transition: width .5s;
}

.activity-item {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(34,197,94,.06);
}

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    margin-top: 6px;
    box-shadow: 0 0 10px var(--green-glow);
    flex-shrink: 0;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--green-light);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: linear-gradient(160deg, #0f1812, #0a100d);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow), 0 0 40px var(--green-glow);
}

.modal h3 {
    color: var(--green-light);
    margin-bottom: 20px;
    font-size: 1.15rem;
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .page-content { padding: 20px 16px; }
    .top-header { padding: 16px; }
}
