:root {
    --bg: #1F1F1F; /* Глубокий темный */
    --card: #f5f7ff12; /* Карточки */
    --border: #f5f7ff15;
    --text: #E4E5EB;
    --text-dim: #989898;
    --accent: #157EFF; /* Синий Mos.ru стиль */
    --green: #80CC40;
    --red: #D63D54;
    --yellow: #F7C863;
    --radius: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Дополнительные токены для отступов и типографики */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 20px;
    --space-xl: 30px;

    /* Цветовой алиас для приглушённого текста (совместимость с admin.html) */
    --dim: var(--text-dim);

    --font-xs: 0.7rem;
    --font-sm: 0.8rem;
    --font-md: 1rem;
    --font-lg: 1.25rem;
    --font-xl: 1.5rem;
}

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

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

a { color: var(--accent); text-decoration: none; transition: 0.2s; }
a:hover { opacity: 0.8; }

.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.admin-container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* --- HEADER --- */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.25rem; letter-spacing: -0.025em; }
.brand img { width: 36px; height: 36px; border-radius: 8px; }

/* --- CARDS & FORMS --- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
.p-4 { padding: 20px; }

.form-grid { display: grid; gap: 15px; }
.input-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 1rem; color: var(--text-dim); font-weight: 400; }
.inp { background: var(--bg); border: 1px solid var(--border); color: white; padding: 12px; border-radius: 8px; font-weight: 400; font-size: 1rem; width: 100%; transition: 0.2s; }
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }

/* --- BUTTONS --- */
.btn { background: var(--accent); color: white; border: none; padding: 12px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-size: 0.95rem; }
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

/* --- STATS GRID --- */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-box { background: var(--card); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius); text-align: center; }
.stat-val { font-size: 1.75rem; font-weight: 700; display: block; line-height: 1.1; }
.stat-lbl { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; font-weight: 600; margin-top: 5px; }

/* --- LISTS & DETAILS --- */
.list-header { background: rgba(255,255,255,0.03); padding: 10px 20px; font-size: 0.75rem; text-transform: uppercase; color: var(--text-dim); font-weight: 700; border-bottom: 1px solid var(--border); }
.res-item { border-bottom: 1px solid var(--border); }
.res-item:last-child { border-bottom: none; }
.res-summary { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; user-select: none; }
.res-summary::-webkit-details-marker { display: none; }
.res-name { font-weight: 500; font-size: 1rem; }
.res-details { padding: 0 20px 20px; color: var(--text-dim); font-size: 0.9rem; animation: slideDown 0.2s ease; }
@keyframes slideDown { from { opacity:0; transform:translateY(-5px); } to { opacity:1; transform:translateY(0); } }

/* --- BADGES --- */
.badge { font-size: 0.7rem; padding: 4px 10px; border-radius: 99px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.bg-wait { background: #334155; color: #94a3b8; }
.bg-ok { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.bg-block { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.bg-down { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }

/* --- TABLES (ADMIN) --- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 15px; color: var(--text-dim); border-bottom: 1px solid var(--border); font-size: 0.75rem; text-transform: uppercase; font-weight: 700; }
td { padding: 12px 15px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(255,255,255,0.02); }

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 600px) {
    .container { padding: 15px; }
    .header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .header > div:last-child { align-self: flex-end; }
    .stats-grid { gap: 8px; }
    .stat-val { font-size: 1.4rem; }
    .btn { width: 100%; }
    .admin-container { padding: 10px; }
    /* В админке таблицы делаем скроллируемыми */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* --- UTILITY CLASSES (TOKENS-BASED) --- */
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-xs { font-size: var(--font-xs); }
.text-sm { font-size: var(--font-sm); }
.text-md { font-size: var(--font-md); }
.text-lg { font-size: var(--font-lg); }
.font-regular { font-weight: 400; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.ml-sm { margin-left: var(--space-sm); }
.ml-md { margin-left: var(--space-md); }
.px-md { padding-inline: var(--space-md); }
.py-sm { padding-block: var(--space-sm); }
.py-md { padding-block: var(--space-md); }
.py-lg { padding-block: var(--space-lg); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.border-top { border-top: 1px solid var(--border); }
.border-top-dashed { border-top: 1px dashed var(--border); }
.border-bottom { border-bottom: 1px solid var(--border); }

.bg-muted { background: rgba(0,0,0,0.2); }
.bg-success-soft { background: rgba(16, 185, 129, 0.05); }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.grid { display: grid; }

/* --- PAGE CONTEXT TOKENS --- */
body.page-admin {
    padding: var(--space-lg);
}

body.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-lg);
}

body.page-report {
    padding: var(--space-lg);
}

.page-admin .container {
    max-width: 1400px;
    margin: 0 auto;
}

.page-login .login-box {
    width: 100%;
    max-width: 360px;
}

.page-report .container {
    max-width: 900px;
    margin: 0 auto;
}

.logo-area {
    text-align: center;
    margin-bottom: 25px;
}

.logo-area img {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    margin-bottom: 15px;
}

.h1 {
    margin: 0;
    font-size: var(--font-lg);
}

.error-text {
    color: var(--red);
    text-align: center;
    margin-top: 15px;
    font-size: var(--font-sm);
}

.header-meta {
    text-align: right;
    font-size: var(--font-sm);
    color: var(--text-dim);
}

/* --- ADMIN: TABS & LAYOUT --- */
.tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    overflow-x: auto;
    padding-bottom: var(--space-xs);
}

.tab {
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-dim);
    font-weight: 600;
    white-space: nowrap;
    transition: 0.2s;
    font-size: 0.9rem;
}

.tab.active {
    background: #fff;
    color: #000;
    border: 1px solid var(--border);
}

.page-admin .header {
    margin-bottom: 20px;
    padding-bottom: 15px;
}

.page-admin .brand img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.form-grid {
    display: grid;
    gap: 10px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
    align-items: flex-end;
}

.inp:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sub-text {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 3px;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
}

.btn-icon:hover {
    color: var(--text);
    border-color: var(--text);
}

.btn-del:hover {
    border-color: var(--red);
    color: var(--red);
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    margin-left: 5px;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 10px; 
    margin-bottom: 20px; 
}

.metric-card {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-title {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0px;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 900;
    line-height: 1.2;
}

.metric-sub {
    font-size: 0.85rem;
    color: var(--accent);
    margin-top: 10px;
}

.res-sum-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.res-sum-row:hover {
    background: rgba(255,255,255,0.02);
}

.res-sum-row b {
    font-weight: 600;
}

.set-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
}

.set-label {
    font-weight: 600;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    .res-sum-row {
        grid-template-columns: 1fr 1fr;
    }
    .res-sum-row div:nth-child(3),
    .res-sum-row div:nth-child(4) {
        display: none;
    }
}

/* --- REPORT PAGE (META + TECH ROWS) --- */
.page-report .meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.page-report .meta-box {
    background: rgba(255,255,255,0.03);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.page-report .meta-label {
    color: var(--text-dim);
    font-size: var(--font-xs);
    text-transform: uppercase;
    display: block;
    margin-bottom: 5px;
}

.page-report .meta-val {
    font-weight: 600;
    font-size: var(--font-md);
}

.page-report .tech-row {
    display: flex;
    justify-content: space-between;
    font-family: monospace;
    font-size: 0.85rem;
    padding: 5px 0;
    border-bottom: 1px dashed var(--border);
}

@media (max-width: 600px) {
    .page-report .meta-grid {
        grid-template-columns: 1fr;
    }
}