:root {
  --paper: #f5f7fb;
  --surface: #ffffff;
  --soft: #edf1f8;
  --ink: #111528;
  --ink-2: #1a2038;
  --muted: #687086;
  --line: #dce2ed;
  --cobalt: #515ff5;
  --cobalt-dark: #3440cf;
  --orange: #ff6a3d;
  --mint: #20bb8a;
  --amber: #e99221;
  --danger: #dc4261;
  --display: "Bricolage Grotesque", "Arial Black", sans-serif;
  --body: "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .75, .25, 1);
  --shadow: 0 24px 70px rgba(23, 30, 58, .11);
  --shadow-small: 0 10px 30px rgba(23, 30, 58, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(circle at center, rgba(81,95,245,.10) 1px, transparent 1.2px);
  background-size: 24px 24px;
  mask-image: linear-gradient(to bottom, #000, transparent 60%);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
::selection { color: #fff; background: var(--cobalt); }
:focus-visible { outline: 3px solid rgba(81,95,245,.45); outline-offset: 3px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.wrap { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }
.chamfer { border-radius: 16px; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 12px; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: var(--cobalt-dark); font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 24px; height: 2px; background: currentColor; }

/* Navigation */
.topbar { position: sticky; top: 0; z-index: 50; padding-top: 14px; pointer-events: none; }
.topbar-in { min-height: 64px; display: flex; align-items: center; gap: 26px; padding: 9px 10px 9px 15px; border: 1px solid rgba(214,220,233,.86); border-radius: 16px; background: rgba(255,255,255,.86); box-shadow: 0 8px 28px rgba(22,28,52,.08); backdrop-filter: blur(18px); pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; font-family: var(--display); font-size: 15px; font-weight: 760; letter-spacing: -.02em; }
.brand::before { content: "RI"; width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: var(--ink); border-radius: 9px 9px 3px 9px; font-family: var(--mono); font-size: 12px; transform: rotate(-4deg); }
.brand i { color: var(--cobalt); font-style: normal; }
.nav-links { display: flex; align-items: center; gap: 24px; margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 700; }
.nav-links a { transition: color .16s ease; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.nav-action { margin-left: 3px; }

.btn { min-height: 45px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 11px 18px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 800; line-height: 1; transition: transform .18s var(--ease), box-shadow .18s, border-color .18s, background .18s; }
.btn:hover { transform: translateY(-2px); border-color: #bbc3d3; box-shadow: var(--shadow-small); }
.btn-primary { color: #fff; border-color: var(--cobalt); background: var(--cobalt); }
.btn-primary:hover { border-color: var(--cobalt-dark); background: var(--cobalt-dark); }
.btn-violet { color: #fff; border-color: var(--ink); background: var(--ink); }
.btn-danger { color: var(--danger); border-color: rgba(220,66,97,.35); background: #fff8fa; }
.btn-small { min-height: 39px; padding: 9px 13px; font-size: 10px; }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }

/* Auth entry */
.auth-shell { min-height: calc(100vh - 80px); display: grid; grid-template-columns: minmax(0,.9fr) minmax(500px,1.1fr); gap: clamp(48px,8vw,104px); align-items: center; padding-block: 78px; }
.auth-copy h1, .page-heading h1, .guide-hero h1 { max-width: 760px; margin-top: 22px; font-family: var(--display); font-size: clamp(42px,6vw,80px); font-weight: 780; letter-spacing: -.065em; line-height: .9; }
.auth-copy h1 span, .guide-hero h1 span { color: var(--cobalt); }
.auth-copy > p:not(.eyebrow) { max-width: 610px; margin-top: 24px; color: var(--muted); font-size: 16px; }
.auth-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 32px; }
.trust-note { color: var(--muted); font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.trust-note b { color: #087754; font-weight: 600; }

/* Signature connection rail */
.connection-shell { position: relative; overflow: hidden; padding: 32px; color: #eef1ff; background: var(--ink); border: 1px solid #303852; border-radius: 22px 22px 22px 7px; box-shadow: 20px 24px 0 #dce2f1, var(--shadow); }
.connection-shell::before { content: ""; position: absolute; inset: 0; opacity: .15; background-image: linear-gradient(rgba(255,255,255,.09) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.09) 1px,transparent 1px); background-size: 32px 32px; }
.connection-shell > * { position: relative; z-index: 1; }
.rail-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 30px; }
.rail-title { color: #aeb6ff; font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.rail-ping { display: inline-flex; align-items: center; gap: 7px; color: #99f0d2; font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.rail-ping::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); animation: pulse 2s ease-in-out infinite; }
.connection-rail { display: grid; grid-template-columns: repeat(4,1fr); position: relative; gap: 8px; }
.connection-rail::before { content: ""; position: absolute; left: 10%; right: 10%; top: 20px; height: 2px; background: #3c4568; }
.rail-node { position: relative; z-index: 1; text-align: center; }
.node-mark { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 11px; color: #8290b2; background: #202641; border: 1px solid #3a4465; border-radius: 50%; font-family: var(--mono); font-size: 10px; transition: .22s var(--ease); }
.rail-node[data-state="connected"] .node-mark { color: #99f0d2; border-color: var(--mint); box-shadow: 0 0 0 5px rgba(32,187,138,.11); }
.rail-node[data-state="attention"] .node-mark { color: #ffd391; border-color: var(--amber); }
.rail-node[data-state="offline"] .node-mark { color: #ff9bb0; border-color: var(--danger); }
.node-label { display: block; font-size: 11px; font-weight: 800; }
.node-state { display: block; margin-top: 3px; color: #8792ae; font-size: 9px; }
.rail-log { display: grid; gap: 8px; margin-top: 28px; padding-top: 18px; color: #8d98b5; border-top: 1px solid #303852; font-family: var(--mono); font-size: 9px; }
.rail-log span::before { content: "✓"; margin-right: 9px; color: var(--mint); }

/* Dashboard */
.dashboard { padding-block: 54px 90px; }
.dashboard-head { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 30px; }
.page-heading h1 { margin-top: 10px; font-size: clamp(34px,4.5vw,55px); }
.user-block { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 11px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; object-fit: cover; color: #fff; background: var(--cobalt); border-radius: 10px; font-weight: 800; }
.server-picker { min-width: min(100%,340px); }
.server-picker label, .field label { display: block; margin-bottom: 8px; color: var(--muted); font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
select, input[type="number"], input[type="text"], input[type="search"] { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; transition: border-color .15s, box-shadow .15s; }
select:focus, input:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(81,95,245,.13); }
.connection-compact { margin-bottom: 20px; padding: 22px 26px; border-radius: 16px 16px 16px 5px; box-shadow: 10px 12px 0 #dce2f1; }
.connection-compact .rail-head { margin-bottom: 20px; }
.connection-compact .rail-log { display: none; }
.dashboard-grid { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 18px; align-items: start; }
.side-stack { position: sticky; top: 92px; display: grid; gap: 14px; }
.panel, .form-panel { background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 3px 0 rgba(23,30,58,.02); }
.panel { padding: 23px; }
.panel-title { margin-bottom: 17px; font-family: var(--display); font-size: 18px; letter-spacing: -.025em; }
.status-list { display: grid; gap: 12px; list-style: none; }
.status-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 11px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; }
.status-row:last-child { padding: 0; border: 0; }
.status-row b { color: var(--ink); font-family: var(--mono); font-size: 10px; font-weight: 500; text-align: right; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.status-dot.attention::before { background: var(--amber); }
.status-dot.offline::before { background: var(--danger); }
.side-actions { display: grid; gap: 8px; margin-top: 19px; }
.side-actions .btn { width: 100%; }
.metric-strip { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; overflow: hidden; margin-top: 18px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; }
.metric { padding: 12px 6px; text-align: center; background: var(--soft); }
.metric b { display: block; font-family: var(--display); font-size: 18px; }
.metric span { color: var(--muted); font-family: var(--mono); font-size: 7px; text-transform: uppercase; }
.settings-form { display: grid; gap: 14px; }
.form-panel { padding: 27px; }
.form-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 23px; }
.form-head h2 { font-family: var(--display); font-size: 21px; letter-spacing: -.03em; }
.form-head p { max-width: 610px; margin-top: 5px; color: var(--muted); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.field-hint { margin-top: 6px; color: var(--muted); font-size: 9px; }
.switch-line { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 15px 17px; background: var(--soft); border: 1px solid var(--line); border-radius: 11px; }
.switch-copy b { display: block; font-size: 12px; }
.switch-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.switch { position: relative; width: 48px; height: 27px; flex: none; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { position: absolute; inset: 0; background: #cbd2df; border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 19px; height: 19px; background: #fff; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.18); transition: .2s var(--ease); }
.switch input:checked + span { background: var(--cobalt); }
.switch input:checked + span::after { transform: translateX(21px); }
.switch input:focus-visible + span { outline: 3px solid rgba(81,95,245,.38); outline-offset: 3px; }
.routing-list { display: grid; border-top: 1px solid var(--line); }
.route-row { display: grid; grid-template-columns: minmax(180px,.85fr) minmax(220px,1.15fr) auto; gap: 18px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--line); }
.route-name b { display: block; font-size: 12px; }
.route-name span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.route-state { min-width: 56px; color: var(--muted); font-family: var(--mono); font-size: 8px; font-weight: 600; text-align: right; text-transform: uppercase; }
.route-state.on { color: #087754; }
.empty-state { padding: 62px 28px; text-align: center; background: rgba(255,255,255,.8); border: 1px dashed #bcc4d4; border-radius: 16px; }
.empty-state h2 { font-family: var(--display); font-size: 24px; letter-spacing: -.03em; }
.empty-state p { max-width: 560px; margin: 10px auto 20px; color: var(--muted); font-size: 12px; }
.save-bar { position: sticky; bottom: 16px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 14px 13px 18px; background: rgba(255,255,255,.9); border: 1px solid #cbd1ff; border-radius: 13px; box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.save-state { color: var(--muted); font-size: 10px; }

/* Guide */
.guide-main { padding-bottom: 100px; }
.guide-hero { display: grid; grid-template-columns: 1fr .72fr; gap: 70px; align-items: end; padding: 94px 0 60px; }
.guide-hero h1 { font-size: clamp(46px,6.5vw,82px); }
.guide-hero .intro { max-width: 680px; margin-top: 22px; color: var(--muted); font-size: 14px; }
.command-search { padding: 22px; background: var(--ink); border: 1px solid #303852; border-radius: 16px 16px 16px 5px; box-shadow: 13px 15px 0 #dce2f1; }
.search-label { display: block; margin-bottom: 9px; color: #aeb6ff; font-family: var(--mono); font-size: 9px; font-weight: 600; text-transform: uppercase; }
.search-wrap { position: relative; }
.search-wrap::before { content: "/"; position: absolute; left: 14px; top: 8px; z-index: 1; color: var(--orange); font-family: var(--display); font-size: 20px; }
.search-wrap input { padding-left: 35px; color: #fff; background: #202641; border-color: #384160; }
.search-wrap input::placeholder { color: #7f8aa7; }
.search-meta { display: flex; justify-content: space-between; margin-top: 10px; color: #8e99b5; font-family: var(--mono); font-size: 8px; }
.quickstart { padding: 48px 0; background: var(--soft); border-block: 1px solid var(--line); }
.quick-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 25px; }
.quick-step { min-height: 175px; padding: 21px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.quick-step .num { color: var(--cobalt); font-family: var(--mono); font-size: 9px; font-weight: 600; }
.quick-step h2 { margin: 27px 0 7px; font-family: var(--display); font-size: 18px; letter-spacing: -.02em; }
.quick-step p { color: var(--muted); font-size: 10px; }
.quick-step code, .inline-code { color: var(--cobalt-dark); font-family: var(--mono); }
.guide-tools { position: sticky; top: 80px; z-index: 30; padding: 14px 0; background: rgba(245,247,251,.91); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.filters { display: flex; gap: 8px; overflow: auto; scrollbar-width: none; }
.filter { padding: 7px 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-size: 10px; font-weight: 700; white-space: nowrap; }
.filter:hover, .filter.active { color: #fff; background: var(--cobalt); border-color: var(--cobalt); }
.command-section { padding-top: 55px; }
.command-count { margin-bottom: 18px; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.command-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
.command-card { padding: 23px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; transition: transform .18s var(--ease), box-shadow .18s, border-color .18s; }
.command-card:hover { transform: translateY(-3px); border-color: #c2c9d8; box-shadow: var(--shadow-small); }
.command-top { display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.command-name { color: var(--cobalt-dark); font-family: var(--mono); font-size: 14px; font-weight: 600; }
.access-badge { padding: 4px 7px; color: var(--muted); background: var(--soft); border: 1px solid var(--line); border-radius: 99px; font-family: var(--mono); font-size: 7px; font-weight: 600; text-transform: uppercase; }
.access-badge.admin { color: #a15a00; background: #fff6e4; border-color: #f1d49e; }
.command-summary { min-height: 39px; margin: 12px 0 17px; color: var(--muted); font-size: 11px; }
.command-detail { display: grid; gap: 10px; padding-top: 15px; border-top: 1px solid var(--line); }
.detail-row { display: grid; grid-template-columns: 68px 1fr; gap: 11px; font-size: 10px; }
.detail-row dt { color: #8a91a2; font-family: var(--mono); font-size: 8px; font-weight: 600; text-transform: uppercase; }
.detail-row dd { color: #4e566b; overflow-wrap: anywhere; }
.detail-row code { color: var(--cobalt-dark); }
.no-results { grid-column: 1/-1; padding: 68px 20px; color: var(--muted); text-align: center; background: var(--surface); border: 1px dashed #bbc3d3; border-radius: 14px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 1000; max-width: 420px; padding: 14px 17px; color: #075c44; background: #e0f8ef; border: 1px solid #9bdcc6; border-radius: 10px; box-shadow: var(--shadow); font-size: 11px; animation: toast-in .22s var(--ease); }
.toast.error { color: #92263e; background: #fff0f3; border-color: #efacba; }
.loading { opacity: .58; pointer-events: none; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.8); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1000px) {
  .auth-shell, .guide-hero { grid-template-columns: 1fr; gap: 46px; }
  .auth-shell { min-height: auto; padding-block: 72px; }
  .connection-shell { max-width: 680px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-stack { position: static; grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .command-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .wrap { width: min(100% - 28px,1180px); }
  .topbar-in { min-height: 58px; gap: 13px; }
  .brand { font-size: 13px; }
  .brand::before { width: 30px; height: 30px; }
  .nav-links a:not([aria-current="page"]) { display: none; }
  .nav-action { display: none; }
  .auth-copy h1 { font-size: 50px; }
  .connection-shell { padding: 24px 14px; box-shadow: 10px 12px 0 #dce2f1; }
  .connection-rail { grid-template-columns: repeat(2,1fr); row-gap: 28px; }
  .connection-rail::before { display: none; }
  .dashboard-head { display: grid; align-items: start; }
  .server-picker { min-width: 0; width: 100%; }
  .side-stack { grid-template-columns: 1fr; }
  .form-panel { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .route-row { grid-template-columns: 1fr; }
  .route-state { text-align: left; }
  .quick-grid { grid-template-columns: 1fr; }
  .guide-hero { padding-top: 65px; }
  .save-bar { bottom: 8px; }
  .save-state { display: none; }
  .user-block span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
