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

:root {
    --bg:         #0d1117;
    --surface:    #161b22;
    --surface2:   #21262d;
    --border:     #30363d;
    --text:       #e6edf3;
    --muted:      #8b949e;
    --accent:     #ff6b35;
    --radius:     12px;
    --font:       'Inter', system-ui, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
}

/* ── Dashboard layout ── */
.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ── Topbar ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.topbar__icon { color: var(--accent); font-size: 1.3rem; }
.topbar__model { color: var(--accent); }

.topbar__clock {
    font-size: 1.4rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: #f85149;
    color: #f85149;
}

/* ── Stats bar ── */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.75rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex: 1;
    min-width: 130px;
}

.stat-item--wide {
    min-width: 220px;
    flex: 2;
}

.stat-item__icon {
    font-size: 1.3rem;
    color: var(--accent);
    opacity: 0.85;
    flex-shrink: 0;
}

.stat-item__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    margin-bottom: 0.15rem;
}

.stat-item__value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.stat-mem { flex: 1; }

.stat-mem__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.4rem;
}

.stat-mem__bar {
    height: 4px;
    background: var(--surface2);
    border-radius: 2px;
    overflow: hidden;
}

.stat-mem__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ffab6e);
    border-radius: 2px;
}

/* ── Service cards ── */
.services {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.service-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.service-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--card-color, var(--accent));
    opacity: 0;
    transition: opacity 0.2s;
}

.service-card:hover {
    border-color: var(--card-color, var(--accent));
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.service-card:hover::before { opacity: 0.08; }

.service-card__icon {
    font-size: 2.1rem;
    color: var(--card-color, var(--accent));
    position: relative;
    z-index: 1;
    transition: transform 0.2s;
}

.service-card:hover .service-card__icon { transform: scale(1.12); }

.service-card__name {
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    position: relative;
    z-index: 1;
}

/* ── Login page ── */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    font-family: var(--font);
}

.login {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2.5rem;
    border-radius: var(--radius);
    width: 340px;
    text-align: center;
}

.login__brand { margin-bottom: 1.8rem; }

.login__brand-icon {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.6rem;
}

.login__brand h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.05em;
}

.login__brand p {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.login input[type=password] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 0.9rem;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

.login input[type=password]:focus { border-color: var(--accent); }

.login input[type=password]::placeholder { color: var(--muted); }

.login button {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.login button:hover { background: #e55b28; }

.login .remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: 0.25rem;
}
.login .remember input[type=checkbox] { accent-color: var(--accent); }

.error {
    color: #f85149;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    padding: 0.6rem;
    background: rgba(248, 81, 73, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(248, 81, 73, 0.2);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: center;
}

/* ── Animations ── */

/* Keyframes */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes loadBar {
    0%   { transform: scaleX(0); opacity: 1; }
    80%  { transform: scaleX(1); opacity: 1; }
    100% { transform: scaleX(1); opacity: 0; }
}

@keyframes glow {
    0%, 100% { text-shadow: 0 0 0px transparent; }
    50%       { text-shadow: 0 0 12px rgba(255, 107, 53, 0.5); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.2; }
}

/* Loading bar */
.page-loader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 2px;
    background: linear-gradient(90deg, var(--accent), #ffab6e);
    transform-origin: left;
    transform: scaleX(0);
    animation: loadBar 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    z-index: 9999;
}

/* Topbar slide down */
.topbar {
    animation: slideDown 0.4s ease both;
}

/* Clock glow + blink separator */
.topbar__model {
    animation: glow 3s ease-in-out infinite;
}

.clock-sep {
    animation: blink 1s step-start infinite;
    display: inline-block;
}

/* Stats: fade up with stagger via nth-child */
.stat-item {
    animation: fadeUp 0.45s ease both;
}
.stat-item:nth-child(1) { animation-delay: 0.08s; }
.stat-item:nth-child(2) { animation-delay: 0.14s; }
.stat-item:nth-child(3) { animation-delay: 0.20s; }
.stat-item:nth-child(4) { animation-delay: 0.26s; }
.stat-item:nth-child(5) { animation-delay: 0.32s; }
.stat-item:nth-child(6) { animation-delay: 0.38s; }

/* Service cards: staggered fade-up via --i */
.service-card {
    animation: fadeUp 0.4s ease both;
    animation-delay: calc(0.3s + var(--i, 0) * 0.07s);
}

/* Hover glow ring */
.service-card:hover {
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.35),
        0 0 0 1px var(--card-color, var(--accent)),
        0 0 20px -4px var(--card-color, var(--accent));
}

/* ── Login animations ── */
body.login-page .login {
    animation: fadeUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

body.login-page .login__brand-icon {
    animation: glow 2.5s ease-in-out infinite;
}

/* Subtle shimmer on stat icons on hover */
.stat-item:hover .stat-item__icon {
    transition: color 0.2s, transform 0.2s;
    color: var(--accent);
    transform: scale(1.15);
}

/* ── Responsive & Touch ── */

/* Убираем задержку 300ms на тач-устройствах */
a, button, .service-card { touch-action: manipulation; }

@media (max-width: 768px) {
    .dashboard { padding: 0.75rem; }

    /* Шапка: 3 колонки → бренд | часы | кнопка */
    .topbar {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    .topbar__brand { font-size: 1rem; }
    .topbar__clock { font-size: 1rem; }

    /* Стат-карточки: 2 в ряд на планшете */
    .stats-bar { gap: 0.5rem; }
    .stat-item { min-width: calc(50% - 0.25rem); flex: 1 1 calc(50% - 0.25rem); }
    .stat-item--wide { min-width: 100%; flex: 1 1 100%; }

    /* Карточки сервисов: 3 в ряд на планшете */
    .services { grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
    .service-card { padding: 1.5rem 0.75rem; gap: 0.6rem; }
    .service-card__icon { font-size: 1.8rem; }
}

@media (max-width: 480px) {
    /* Шапка: прячем часы, оставляем только бренд + кнопку */
    .topbar__clock { display: none; }

    /* Стат-карточки: 2 в ряд */
    .stat-item { min-width: calc(50% - 0.25rem); }

    /* Карточки: 2 в ряд, крупные тач-цели */
    .services { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .service-card {
        padding: 1.6rem 0.5rem;
        /* Минимальная высота для удобного тапа */
        min-height: 100px;
    }
    .service-card__icon { font-size: 1.9rem; }
    .service-card__name { font-size: 0.72rem; }

    /* Кнопка выхода: только иконка */
    .btn-logout .btn-logout__text { display: none; }
    .btn-logout {
        padding: 0.5rem 0.7rem;
        min-width: 40px;
        min-height: 40px;
        justify-content: center;
    }
}

/* Увеличенные тач-цели для кнопок */
@media (pointer: coarse) {
    .btn-logout {
        min-height: 44px;
        padding: 0.5rem 1rem;
    }
    .service-card { min-height: 110px; }
    .login input[type=password] {
        min-height: 48px;
        font-size: 16px; /* предотвращает авто-зум в iOS */
    }
    .login button {
        min-height: 48px;
        font-size: 1rem;
    }
}

/* ── Sites section ── */
.sites-section {
    margin-top: 2rem;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i { color: var(--accent); }

.sites-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.site-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    animation: fadeUp 0.4s ease both;
    animation-delay: calc(0.3s + var(--i, 0) * 0.07s);
}

.site-card:hover {
    border-color: var(--accent);
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--accent), 0 0 16px -4px var(--accent);
}

.site-card__icon {
    font-size: 1.1rem;
    color: var(--accent);
    flex-shrink: 0;
    width: 1.4rem;
    text-align: center;
}

.site-card__name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.site-card__arrow {
    font-size: 0.75rem;
    color: var(--muted);
    transition: color 0.2s, transform 0.2s;
}

.site-card:hover .site-card__arrow {
    color: var(--accent);
    transform: translate(2px, -2px);
}
