:root {
    --bg: #0c1016;
    --bg-elev: #121821;
    --panel: #161d27;
    --panel-2: #1c2530;
    --line: #2a3544;
    --text: #e7edf4;
    --muted: #8b98a8;
    --accent: #5b8fb9;
    --accent-2: #3d6f94;
    --ok: #3d9a6a;
    --warn: #c4923a;
    --danger: #c45c5c;
    --hud: #4f8fbf;
    --radius: 12px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100vh;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(900px 420px at 12% -8%, #1b2734 0%, transparent 58%),
        var(--bg);
    color: var(--text);
    line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #7aa9cc; }

.site-header {
    border-bottom: 1px solid var(--line);
    background: rgba(12, 16, 22, 0.92);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.site-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.site-brand {
    color: var(--text);
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.92em;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.site-nav a {
    color: var(--muted);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.92em;
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--text);
    background: var(--panel-2);
}

.site-nav .nav-logout {
    margin-left: 8px;
    border: 1px solid var(--line);
}

.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 24px 48px;
}

.page-title {
    margin: 0 0 6px;
    font-size: 1.7em;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.page-sub {
    margin: 0 0 24px;
    color: var(--muted);
}

.flash-banner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 24px 0;
}

.flash-banner-inner {
    background: #3a2a18;
    border: 1px solid #6a4e28;
    color: #f0d19a;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.98em;
}

.flash-banner-inner strong {
    color: #ffd27a;
    letter-spacing: 0.06em;
    margin-right: 6px;
}

.flash-page {
    padding: 20px;
}

.flash-card {
    padding: 4px 0 16px;
}

.flash-card h2 {
    margin: 0 0 6px;
    font-size: 1.25em;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--line);
}

.controls button, .targets button { width: 100%; }

.control-group { display: flex; flex-direction: column; }

label {
    display: block;
    font-size: 0.72em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
    font-weight: 600;
}

input, select, button, .btn {
    font: inherit;
}

input, select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #0f151c;
    color: var(--text);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

button:hover, .btn:hover { filter: brightness(1.08); color: #fff; }

.btn-secondary, .refresh-btn {
    background: var(--panel-2);
    border-color: var(--line);
    color: var(--text);
}

.btn-danger, .clear-btn {
    background: #6e2f32;
    border-color: #8a3d41;
}

.stats-summary, .cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    padding: 20px;
}

.stat-card, .card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.stat-value, .card strong {
    display: block;
    font-size: 1.7em;
    color: var(--accent);
    margin-bottom: 4px;
}

.stat-label, .muted {
    color: var(--muted);
    font-size: 0.85em;
}

.results, .pad { padding: 20px; }

.item-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fav-btn {
    width: auto;
    min-width: 36px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 1.05em;
    line-height: 1;
}

.fav-btn.on {
    color: #e0b56a;
    border-color: #6a4e28;
    background: #3a2a18;
}

tr.fav-row { background: rgba(224, 181, 106, 0.07); }
tr.fav-row:hover { background: rgba(224, 181, 106, 0.12); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 980px; }
.table-scroll small { color: var(--muted); font-size: 0.78em; }

.stat-bots { display: grid; gap: 14px; }

.stat-bot {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
}

.stat-bot-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: baseline;
    margin-bottom: 12px;
}

.stat-bot-head strong { font-size: 1.05em; }

.derived-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.skill.derived { border-color: #3d5a78; }

.skill-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.skill {
    background: #0f151c;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
}

.skill span {
    display: block;
    font-size: 0.68em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 650;
}

.skill b {
    display: block;
    font-size: 1.25em;
    color: var(--accent);
    margin: 2px 0;
}

.skill small { color: var(--muted); font-size: 0.78em; }

.rate-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px 8px;
    margin-top: 8px;
    font-size: 0.82em;
    color: var(--muted);
}

@media (max-width: 720px) {
    .skill-grid, .rate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.pad h3 {
    margin: 0 0 12px;
    font-size: 1.05em;
    font-weight: 600;
}

#latestTable > .muted {
    text-align: center;
    padding: 24px 0;
}

table .btn {
    display: inline-flex;
    padding: 6px 12px;
    font-size: 0.82em;
}

.panel table { margin: 0; }
.panel table th:first-child, .panel table td:first-child { padding-left: 16px; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

th {
    font-size: 0.75em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 650;
}

tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: ' \2195'; opacity: 0.4; }
th.sort-asc::after { content: ' \2191'; opacity: 1; }
th.sort-desc::after { content: ' \2193'; opacity: 1; }

.user-name { font-weight: 600; }
.timestamp { color: var(--muted); font-size: 0.88em; }

.btn-hud { background: var(--hud); }
.btn-echest { background: var(--danger); }
.btn.disabled, .btn-hud.disabled, .btn-echest.disabled {
    background: #2a323c;
    color: var(--muted);
    cursor: not-allowed;
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}
.status-fresh { background: var(--ok); }
.status-old { background: var(--warn); }
.status-unavailable { background: #5a6570; }

.no-links, .no-data, .loading {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}

.error {
    background: #3a1f24;
    color: #f3c1c6;
    padding: 12px 14px;
    border-radius: 8px;
    border-left: 3px solid var(--danger);
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: var(--shadow);
}

.auth-card h1 { margin: 0 0 8px; font-weight: 600; letter-spacing: 0.04em; }
.auth-card button, .auth-card .btn { width: 100%; }
.auth-card input { margin-bottom: 16px; }
.auth-card .error { margin-bottom: 16px; }
.tagline { margin: 0 0 28px; color: var(--muted); }
.tools { display: grid; gap: 12px; margin-bottom: 16px; max-width: 640px; }
.tool {
    display: block;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    background: #12181f;
}
.tool:hover { border-color: var(--accent); color: var(--text); }
.tool strong { display: block; margin-bottom: 4px; }
.tool span { color: var(--muted); font-size: 0.9em; }
.logout {
    width: 100%;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
}
.auth-foot { margin-top: 24px; text-align: center; color: var(--muted); font-size: 0.8em; }

.targets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    align-items: end;
    padding: 0 20px 20px;
}

.section-title {
    margin: 28px 0 12px;
    font-size: 0.8em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 650;
}

.hosts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.host-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
}

.host-card.online { border-color: #2e5c45; }
.host-name { font-weight: 650; margin-bottom: 4px; }

.pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.78em;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: #2a323c;
    color: var(--muted);
}
.pill-in-world, .pill-online, .pill-running { background: #1d3b2d; color: #8fd4ad; }
.pill-combat { background: #3a2a18; color: #e0b56a; }
.pill-boxing { background: #2a3340; color: #9bb7d4; }
.pill-starting { background: #2a3340; color: #9bb7d4; }
.pill-captcha { background: #3a2418; color: #e0a06a; }
.pill-conflict { background: #3a1f24; color: #f3c1c6; }
.pill-offline { background: #2a323c; color: var(--muted); }

.row-actions {
    white-space: nowrap;
}
.row-actions button {
    width: auto;
    padding: 6px 10px;
    font-size: 0.82em;
    margin-right: 4px;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 30;
}
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(460px, 100%);
    height: 100vh;
    background: var(--panel);
    border-left: 1px solid var(--line);
    z-index: 31;
    display: flex;
    flex-direction: column;
}
.drawer[hidden],
.drawer-backdrop[hidden] {
    display: none !important;
}
.drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}
.line-log {
    flex: 1;
    overflow: auto;
    padding: 14px 18px 24px;
    font-family: Consolas, "Segoe UI Mono", monospace;
    font-size: 0.82em;
}
.line { margin-bottom: 6px; }
.line.chat { color: var(--text); }
.line.log { color: var(--muted); }

.speed-panel { padding: 20px; }
.speed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 20px 0 8px;
}
.speed-status { margin: 8px 0 0; }
.speed-verdict {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
}
.speed-verdict.good { background: #1d3b2d; border-color: #2e5c45; }
.speed-verdict.ok { background: #3a2a18; border-color: #6a4e28; }
.speed-verdict.bad { background: #3a1f24; border-color: #6e2f32; }

@media (max-width: 720px) {
    .site-header-inner { flex-direction: column; align-items: flex-start; }
    .page { padding: 18px 14px 36px; }
}

.speed-gauge-wrap {
    position: relative;
    max-width: 420px;
    margin: 0 auto 8px;
}
.speed-gauge { width: 100%; height: auto; display: block; }
.gauge-track {
    stroke: var(--line);
    stroke-width: 14;
    stroke-linecap: round;
}
.gauge-fill {
    stroke: url(#gaugeArc);
    stroke-width: 14;
    stroke-linecap: round;
}
.gauge-tick { stroke: var(--muted); stroke-width: 2; }
.gauge-tick-label {
    fill: var(--muted);
    font-size: 11px;
    text-anchor: middle;
    dominant-baseline: middle;
}
.gauge-needle {
    stroke: var(--text);
    stroke-width: 3;
    stroke-linecap: round;
    transform-origin: 160px 170px;
    transition: transform 80ms linear;
}
.gauge-hub { fill: var(--accent); stroke: var(--text); stroke-width: 2; }
.gauge-readout {
    position: absolute;
    left: 0;
    right: 0;
    top: 58%;
    text-align: center;
    pointer-events: none;
}
.gauge-value {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
    letter-spacing: -0.03em;
}
.gauge-unit {
    color: var(--accent);
    font-size: 0.95rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 2px;
}
.gauge-phase {
    margin-top: 10px;
    font-weight: 650;
    color: var(--text);
}
.gauge-sub { margin-top: 2px; font-size: 0.85em; }
.speed-panel .toolbar { justify-content: center; margin-top: 8px; }
