@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
    --bg: #0d1117;
    --panel: #161b22;
    --panel-soft: #11161d;
    --border: #30363d;
    --text: #c9d1d9;
    --muted: #8b949e;
    --bright: #f0f6fc;
    --green: #3fb950;
    --blue: #58a6ff;
    --purple: #bc8cff;
    --orange: #d29922;
    --red: #f85149;
    --mono: 'JetBrains Mono', Consolas, monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    min-width: 320px;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
main { transition: opacity .12s ease; }
main:focus { outline: none; }
body.is-navigating main { opacity: .45; pointer-events: none; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }
[hidden] { display: none !important; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border);
    background: rgba(13, 17, 23, .94);
    backdrop-filter: blur(12px);
}
.nav-wrap {
    width: min(1180px, calc(100% - 40px));
    min-height: 68px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 28px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--bright);
    font-family: var(--mono);
    font-weight: 700;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; object-fit: contain; }
.brand-asn { color: var(--muted); font-size: .75rem; font-weight: 400; }
.main-nav { display: flex; align-items: stretch; align-self: stretch; gap: 4px; }
.main-nav a {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: .84rem;
}
.main-nav a:hover { color: var(--bright); text-decoration: none; }
.main-nav a[aria-current="page"] { color: var(--bright); }
.main-nav a[aria-current="page"]::after {
    content: '';
    position: absolute;
    right: 12px;
    bottom: -1px;
    left: 12px;
    height: 2px;
    background: var(--green);
}
.nav-meta { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: .75rem; white-space: nowrap; }
.nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
}
.nav-toggle span, .nav-toggle::before, .nav-toggle::after {
    content: '';
    display: block;
    width: 18px;
    height: 2px;
    margin: 4px auto;
    background: currentColor;
}

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 72px; }
.page-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 42px; align-items: start; }
.page-layout > *, .section, .card { min-width: 0; }
.side-nav { position: sticky; top: 96px; }
.side-label { margin: 0 0 10px; color: var(--muted); font-family: var(--mono); font-size: .72rem; text-transform: uppercase; }
.side-nav a {
    display: block;
    padding: 8px 12px;
    border-left: 2px solid var(--border);
    color: var(--muted);
    font-family: var(--mono);
    font-size: .82rem;
}
.side-nav a:hover, .side-nav a.is-active { border-left-color: var(--green); color: var(--bright); text-decoration: none; background: rgba(63, 185, 80, .05); }

.terminal-line {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: .9rem;
}
.prompt::before { content: 'guest@kio-os:~$ '; color: var(--green); }
.command { color: var(--bright); font-weight: 600; }
.clock { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.page-heading { max-width: 780px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-family: var(--mono); font-size: .75rem; text-transform: uppercase; }
h1 { margin: 0 0 10px; color: var(--bright); font-family: var(--mono); font-size: clamp(1.7rem, 4vw, 2.45rem); line-height: 1.2; letter-spacing: 0; }
.lead { margin: 0; color: var(--muted); font-size: 1rem; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.span-2 { grid-column: 1 / -1; }
.card { padding: 22px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.card-title { margin: 0 0 15px; color: var(--blue); font-family: var(--mono); font-size: 1rem; letter-spacing: 0; }
.card-title::before { content: '>> '; color: var(--purple); }
.card p:last-child { margin-bottom: 0; }
.info-list { margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: .85rem; }
.info-list li { display: grid; grid-template-columns: 125px minmax(0, 1fr); gap: 8px; padding: 4px 0; }
.key { color: var(--muted); }
.value { min-width: 0; overflow-wrap: anywhere; }
.highlight { color: var(--green); font-weight: 600; }
.prose { color: var(--muted); font-size: .93rem; }
.prose strong { color: var(--text); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.badge, .status-pill { display: inline-flex; align-items: center; border-radius: 4px; font-family: var(--mono); font-size: .72rem; }
.badge { padding: 3px 7px; background: rgba(88, 166, 255, .1); color: var(--blue); }
.status-pill { gap: 6px; padding: 3px 8px; border: 1px solid var(--border); color: var(--muted); }
.status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-pill.operational::before, .status-pill.established::before { background: var(--green); box-shadow: 0 0 7px rgba(63, 185, 80, .6); }
.status-pill.degraded::before { background: var(--orange); }
.status-pill.outage::before, .status-pill.down::before { background: var(--red); }

.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-soft); }
.stat { min-width: 0; padding: 17px 20px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: 0; }
.stat-value { display: block; overflow-wrap: anywhere; color: var(--bright); font-family: var(--mono); font-size: 1rem; font-weight: 600; }
.stat-label { display: block; margin-top: 3px; color: var(--muted); font-family: var(--mono); font-size: .68rem; text-transform: uppercase; }
.section { scroll-margin-top: 96px; margin-top: 34px; }
.section:first-of-type { margin-top: 0; }
.section-heading { margin: 0 0 15px; color: var(--bright); font-family: var(--mono); font-size: 1.15rem; letter-spacing: 0; }
.section-heading::before { content: '# '; color: var(--green); }
.ascii-diagram { max-width: 100%; margin: 0; padding: 18px; overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--green); font-family: var(--mono); font-size: .78rem; line-height: 1.55; white-space: pre; }

.record-list { display: grid; gap: 12px; }
.record { padding: 18px 20px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); }
.record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.record h3 { margin: 0; color: var(--bright); font-family: var(--mono); font-size: .95rem; letter-spacing: 0; }
.record p { margin: 9px 0 0; color: var(--muted); font-size: .88rem; white-space: pre-wrap; }
.record-meta { margin-top: 12px; color: var(--muted); font-family: var(--mono); font-size: .7rem; }
.empty-state { padding: 28px; border: 1px dashed var(--border); border-radius: 7px; color: var(--muted); text-align: center; font-family: var(--mono); font-size: .8rem; }
.skeleton { height: 84px; border: 1px solid var(--border); border-radius: 7px; background: linear-gradient(90deg, var(--panel) 25%, #1d242d 50%, var(--panel) 75%); background-size: 200% 100%; animation: loading 1.3s infinite; }
@keyframes loading { to { background-position: -200% 0; } }

.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 7px 13px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); font-family: var(--mono); font-size: .78rem; }
.button:hover { border-color: var(--blue); color: var(--bright); text-decoration: none; }
.button.primary { border-color: rgba(63, 185, 80, .55); background: rgba(63, 185, 80, .1); color: var(--green); }
.footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 20px 0 34px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-family: var(--mono); font-size: .72rem; }

.live-command { margin-bottom: 12px; overflow-wrap: anywhere; color: var(--text); font-family: var(--mono); font-size: .76rem; }
.live-command span { color: var(--green); }
.live-output { min-height: 150px; max-height: 420px; margin: 0; padding: 16px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--green); font-family: var(--mono); font-size: .78rem; line-height: 1.6; white-space: pre-wrap; }
.live-output.is-unavailable { color: var(--muted); }

.auth-layout { width: min(480px, 100%); margin: 46px auto 80px; }
.auth-form { display: grid; gap: 16px; padding: 24px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.auth-form .button { width: 100%; }
.auth-form label, .editor-form label { display: grid; gap: 6px; color: var(--muted); font-family: var(--mono); font-size: .74rem; }
.auth-form input, .editor-form input, .editor-form textarea, .editor-form select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    outline: none;
    background: var(--bg);
    color: var(--bright);
}
.editor-form textarea { resize: vertical; }
.auth-form input:focus, .editor-form input:focus, .editor-form textarea:focus, .editor-form select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(88, 166, 255, .12); }
.form-message { min-height: 1.4em; margin: 0; color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.form-message.error { color: var(--red); }
.form-message.success { color: var(--green); }
.oauth-options { margin-bottom: 14px; }
.oauth-buttons { display: grid; gap: 9px; }
.oauth-button { width: 100%; border-color: rgba(88, 166, 255, .55); color: var(--blue); }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; color: var(--muted); font-family: var(--mono); font-size: .68rem; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ''; height: 1px; flex: 1; background: var(--border); }
.admin-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.admin-bar h1 { font-size: 1.7rem; }
.admin-user { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.admin-tabs { display: flex; gap: 3px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.admin-tabs button { padding: 10px 16px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-family: var(--mono); font-size: .8rem; cursor: pointer; }
.admin-tabs button[aria-selected="true"] { border-bottom-color: var(--green); color: var(--bright); }
.admin-panel { min-width: 0; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0; color: var(--bright); font-family: var(--mono); font-size: 1.15rem; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.editor-form { margin-bottom: 22px; padding: 20px; border: 1px solid var(--blue); border-radius: 7px; background: var(--panel-soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.editor-form .check-label { display: flex; min-height: 40px; align-items: center; grid-template-columns: none; gap: 9px; }
.editor-form .check-label input { width: 16px; min-height: 16px; accent-color: var(--green); }
.form-actions { display: flex; gap: 9px; margin-top: 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 7px; }
.admin-table { width: 100%; min-width: 680px; border-collapse: collapse; background: var(--panel); font-size: .82rem; }
.admin-table th { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--muted); font-family: var(--mono); font-size: .68rem; text-align: left; text-transform: uppercase; }
.admin-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table strong { display: block; color: var(--bright); font-family: var(--mono); font-weight: 600; }
.admin-table small { display: block; max-width: 460px; margin-top: 3px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.table-empty { padding: 28px !important; color: var(--muted) !important; text-align: center; font-family: var(--mono); }
.row-actions { white-space: nowrap; }
.icon-text-button { margin-right: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: var(--blue); font-family: var(--mono); font-size: .7rem; cursor: pointer; }
.icon-text-button:hover { border-color: var(--blue); }
.icon-text-button.danger { color: var(--red); }
.icon-text-button.danger:hover { border-color: var(--red); }

@media (max-width: 860px) {
    .nav-wrap { flex-wrap: wrap; gap: 0; padding: 13px 0; }
    .nav-toggle { display: block; }
    .nav-meta { display: none; }
    .main-nav { display: none; width: 100%; height: auto; margin-top: 12px; border-top: 1px solid var(--border); flex-direction: column; }
    .main-nav.is-open { display: flex; }
    .main-nav a { min-height: 42px; padding: 0 8px; }
    .main-nav a[aria-current="page"]::after { top: 8px; right: auto; bottom: 8px; left: 0; width: 2px; height: auto; }
    .page-layout { grid-template-columns: 1fr; gap: 24px; }
    .side-nav { position: static; display: flex; gap: 5px; overflow-x: auto; padding-bottom: 4px; }
    .side-label { display: none; }
    .side-nav a { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 5px; padding: 6px 10px; }
    .side-nav a:hover, .side-nav a.is-active { border-color: var(--green); }
}

@media (max-width: 620px) {
    .nav-wrap, .page-shell, .footer { width: min(100% - 28px, 1180px); }
    .page-shell { padding-top: 24px; }
    .brand-asn { display: none; }
    .terminal-line { align-items: flex-start; flex-direction: column; gap: 5px; }
    .grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .stat-strip { grid-template-columns: repeat(2, 1fr); }
    .stat:nth-child(2) { border-right: 0; }
    .stat:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
    .info-list li { grid-template-columns: 105px minmax(0, 1fr); }
    .record-head { flex-direction: column; gap: 8px; }
    .footer { flex-direction: column; }
    .admin-bar, .panel-heading { align-items: stretch; flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    main { transition: none; }
    .skeleton { animation: none; }
}
