:root {
  --bg: #060d14; --bg2: #0b1622; --card: #0f1d2b; --card2: #13263a; --line: #1d3550;
  --text: #e3eef7; --muted: #8aa3b8; --accent: #4fd8ff; --accent2: #2a9fd6; --ok: #3ddc97; --warn: #ffc857; --bad: #ff6b6b;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #eef3f8; --bg2: #e3ebf3; --card: #ffffff; --card2: #f3f7fb; --line: #d3dfeb; --text: #0e2233; --muted: #557089; --accent: #0b8fc4; --accent2: #0a6f99; --shadow: 0 6px 20px rgba(14,34,51,.08); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: .4em 0 0; }
.small { font-size: 13px; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.25; }
h2 { font-size: 22px; } h3 { font-size: 16px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
label.check input { width: auto; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card2); border-radius: 10px; padding: 9px 14px; }
button:hover { border-color: var(--accent); }
button.primary { background: linear-gradient(135deg, var(--accent2), var(--accent)); border: 0; color: #031018; font-weight: 600; }
button.danger { color: var(--bad); }
button.link { background: none; border: 0; color: var(--muted); padding: 8px 12px; text-align: left; }
button:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; font-size: 20px; padding: 6px 10px; }

.orb { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px; background: radial-gradient(circle at 50% 42%, #e6fbff 0, var(--accent) 35%, #0a3d5c 75%); box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 60%, transparent); animation: pulse 3s ease-in-out infinite; }
.orb.small { width: 64px; height: 64px; } .orb.tiny { width: 22px; height: 22px; margin: 0; animation: none; box-shadow: 0 0 10px var(--accent); }
@keyframes pulse { 50% { box-shadow: 0 0 50px color-mix(in srgb, var(--accent) 85%, transparent); transform: scale(1.03); } }
@media (prefers-reduced-motion: reduce) { .orb { animation: none; } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; text-align: center; box-shadow: var(--shadow); }
.login-card form { display: grid; gap: 10px; margin-top: 12px; text-align: left; }

.shell { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg2); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; letter-spacing: .5px; }
.top-status { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; font-size: 12px; }
#menu-btn { display: none; }
.nav { border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; background: var(--bg2); }
.nav a { padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
.nav a.active { background: var(--card2); color: var(--accent); }
.main { padding: 22px; max-width: 1100px; width: 100%; min-width: 0; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { display: flex; gap: 8px; align-items: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.stack > * + * { margin-top: 12px; }
.section { margin-bottom: 26px; }
.stat { font-size: 28px; font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); background: var(--card2); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.imp { width: 8px; align-self: stretch; border-radius: 4px; background: var(--line); flex: 0 0 8px; }
.imp-2 { background: var(--warn); } .imp-3 { background: var(--bad); } .imp-1 { background: var(--accent2); }
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow: auto; padding: 4px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent2); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--card2); border: 1px solid var(--line); }
.qr { background: #fff; padding: 10px; border-radius: 12px; width: 220px; max-width: 100%; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--bg2); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { position: relative; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px 18px; box-shadow: var(--shadow); }
.modal-x { position: absolute; top: 8px; right: 8px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 16px; z-index: 30; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.help { background: var(--bg2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  #menu-btn { display: inline-block; }
  .nav { position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; z-index: 10; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  .nav.open { transform: none; }
  .main { padding: 16px; }
  .top-status .pill:not(.keep) { display: none; }
}
