:root {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #edf2f7;
    background: #090c13;
    font-synthesis: none;
    --panel: #121722;
    --panel-soft: #0e131d;
    --border: rgba(148, 163, 184, 0.15);
    --muted: #8893a4;
    --accent: #64d9a5;
    --accent-strong: #39bd84;
    --danger: #ff7180;
    --warning: #f3bd58;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #090c13; }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(21px, 3vw, 26px); letter-spacing: -0.025em; }
h2 { margin-bottom: 16px; font-size: 15px; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0 44px; }
.panel { border: 1px solid var(--border); border-radius: 13px; background: var(--panel); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.brand-row { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 750; }
.brand-mark { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; color: #07130e; background: linear-gradient(135deg, var(--accent), #6a89ff); font-size: 13px; font-weight: 900; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 8px; font-size: 11px; }

.login-layout { min-height: calc(100vh - 64px); display: grid; place-items: center; }
.login-card { width: min(400px, 100%); padding: 28px; }
.login-card h1 { margin-top: 28px; }
.login-card > .muted { margin-bottom: 24px; font-size: 13px; }
.stack { display: grid; gap: 16px; }
.security-note { margin: 18px 0 0; color: #697487; font-size: 11px; line-height: 1.55; }
.form-error { min-height: 18px; margin: -4px 0 0; color: var(--danger); font-size: 12px; }

.topbar { min-height: 50px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; margin-bottom: 26px; }
.main-nav { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: #10151f; }
.nav-button { min-width: 70px; padding: 7px 12px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 13px; font-weight: 650; }
.nav-button:hover { color: #dfe6ef; }
.nav-button.active { color: #06130e; background: var(--accent); }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.connection, .user-chip, .status-pill, .revision { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 999px; color: var(--muted); background: rgba(148, 163, 184, 0.09); font-size: 11px; }
.connection::before { width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #747f90; content: ""; }
.connection.online::before { background: var(--accent); }
.icon-button { min-height: 32px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; background: transparent; cursor: pointer; font-size: 12px; }

.view { animation: reveal 140ms ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(3px); } }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.page-heading .muted { margin-bottom: 0; font-size: 13px; }
.status-pill { color: #d9e1eb; font-weight: 700; }
.status-pill.running { color: var(--accent); background: rgba(100, 217, 165, 0.1); }
.status-pill.error { color: var(--danger); background: rgba(255, 113, 128, 0.1); }
.status-pill.paused, .status-pill.waiting { color: var(--warning); background: rgba(243, 189, 88, 0.1); }

.runtime-card { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 20px; margin-bottom: 12px; }
.runtime-copy { min-width: 0; display: flex; align-items: center; gap: 13px; }
.runtime-copy strong { font-size: 15px; }
.runtime-copy p { margin: 4px 0 0; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #6f7989; }
.status-dot.running { background: var(--accent); box-shadow: 0 0 14px rgba(100, 217, 165, 0.45); }
.status-dot.error { background: var(--danger); }
.status-dot.paused, .status-dot.waiting { background: var(--warning); }
.control-actions { display: flex; flex: 0 0 auto; gap: 8px; }

.button { min-height: 36px; padding: 7px 13px; border: 1px solid rgba(148, 163, 184, 0.22); border-radius: 8px; background: #1a2230; cursor: pointer; font-size: 12px; font-weight: 700; }
.button:hover:not(:disabled) { border-color: rgba(148, 163, 184, 0.5); }
.button:disabled { cursor: not-allowed; opacity: 0.42; }
.button.primary { color: #06130e; border-color: transparent; background: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-strong); }
.button.danger { color: #ffdbe0; border-color: rgba(255, 113, 128, 0.25); background: rgba(255, 113, 128, 0.09); }
.button.ghost { background: transparent; }
.button.small { min-height: 32px; padding: 5px 10px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; }
.kpi span { color: var(--muted); font-size: 11px; }
.kpi strong { font-size: 21px; letter-spacing: -0.02em; }
.stats-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.overview-grid, .stats-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.detail-card { padding: 18px; }
.detail-list { display: grid; gap: 10px; margin: 0; }
.detail-list > div { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.detail-list dt { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; text-align: right; font-size: 12px; }
.detail-list.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-list.compact > div { padding: 10px; border-radius: 8px; background: var(--panel-soft); }

.notice { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 12px; }
.notice.warning { color: #ffe4ab; border-color: rgba(243, 189, 88, 0.25); background: rgba(243, 189, 88, 0.07); }
.notice.danger { color: #ffd1d7; border-color: rgba(255, 113, 128, 0.25); background: rgba(255, 113, 128, 0.07); }

.rarity-list { display: flex; flex-wrap: wrap; gap: 8px; }
.rarity-chip { display: inline-flex; gap: 7px; padding: 6px 9px; border-radius: 7px; color: #cad3df; background: var(--panel-soft); font-size: 11px; }
.rarity-chip strong { color: #f4f7fa; }
.history-card { padding: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }

.inline-field { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.inline-field select { width: 120px; }
.log-list { overflow: hidden; }
.log-entry { padding: 12px 15px; border-bottom: 1px solid rgba(148, 163, 184, 0.09); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; line-height: 1.5; }
.log-entry:last-child { border-bottom: 0; }
.log-meta { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 4px; color: #6f7b8c; }
.log-level { font-weight: 800; }
.log-entry.error .log-level { color: var(--danger); }
.log-entry.running .log-level { color: var(--accent); }
.log-entry.waiting .log-level, .log-entry.paused .log-level { color: var(--warning); }
.log-message { color: #c9d2de; overflow-wrap: anywhere; }
.empty-state { padding: 42px 20px; color: var(--muted); text-align: center; font-size: 12px; }

label { display: grid; gap: 7px; color: #c4cdda; font-size: 12px; }
input, select { width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid rgba(148, 163, 184, 0.2); border-radius: 8px; outline: none; color: #edf2f7; background: #0c111a; }
input:focus, select:focus { border-color: rgba(100, 217, 165, 0.65); box-shadow: 0 0 0 3px rgba(100, 217, 165, 0.08); }
input:disabled { color: #5b6675; background: #0a0e16; }
input[type="checkbox"] { position: relative; width: 38px; min-height: 21px; height: 21px; padding: 0; appearance: none; border-radius: 999px; cursor: pointer; }
input[type="checkbox"]::after { position: absolute; width: 15px; height: 15px; top: 2px; left: 3px; border-radius: 50%; background: #718096; content: ""; transition: 150ms; }
input[type="checkbox"]:checked { border-color: var(--accent-strong); background: rgba(57, 189, 132, 0.22); }
input[type="checkbox"]:checked::after { left: 18px; background: var(--accent); }
.toggle-row { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }

.settings-view { width: min(820px, 100%); margin: 0 auto; }
.settings-form { padding: 20px; }
.settings-section { margin-bottom: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
details { margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; }
summary { padding: 14px 15px; cursor: pointer; font-size: 13px; font-weight: 700; }
.details-content { padding: 3px 15px 16px; }
.save-bar { position: sticky; bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: rgba(12, 17, 26, 0.96); }
.save-bar .muted { font-size: 11px; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(380px, calc(100% - 32px)); padding: 11px 14px; border: 1px solid rgba(100, 217, 165, 0.3); border-radius: 9px; background: #14241f; box-shadow: 0 16px 46px rgba(0, 0, 0, 0.32); font-size: 12px; }
.toast.error { color: #ffd2d8; border-color: rgba(255, 113, 128, 0.35); background: #29171d; }

@media (max-width: 820px) {
    .topbar { grid-template-columns: auto 1fr; }
    .main-nav { grid-row: 2; grid-column: 1 / -1; justify-self: center; }
    .topbar-actions { justify-self: end; }
    .kpi-grid, .stats-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .shell { width: min(100% - 22px, 1180px); padding-top: 12px; }
    .topbar { gap: 12px; }
    .brand-row > span:last-child, .user-chip { display: none; }
    .runtime-card, .page-heading { align-items: stretch; flex-direction: column; }
    .runtime-copy p { white-space: normal; }
    .control-actions { width: 100%; }
    .control-actions .button { flex: 1; }
    .overview-grid, .stats-layout, .form-grid { grid-template-columns: 1fr; }
    .detail-list.compact { grid-template-columns: 1fr; }
    .settings-form, .login-card { padding: 17px; }
    .save-bar { align-items: stretch; flex-direction: column; }
}
