/* Atlas Gateway panel — Apple-minimal: typography-first, near-monochrome,
   one accent, hairline dividers, generous whitespace. Dark default. */

:root {
  --bg: #0a0a0b;
  --surface: #131315;
  --surface-2: #1b1b1e;
  --text: #f5f5f7;
  --text-2: #98989d;
  --hairline: rgba(255, 255, 255, 0.09);
  --accent: #0a84ff;
  --danger: #ff453a;
  --ok: #30d158;
  --warn: #ffd60a;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafa; --surface: #ffffff; --surface-2: #f2f2f4;
    --text: #1d1d1f; --text-2: #6e6e73; --hairline: rgba(0, 0, 0, 0.09);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--text-2); }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
::placeholder { color: color-mix(in srgb, var(--text-2) 72%, transparent); }

/* Selects: native chrome off, hairline chevron on */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2398989d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
select:hover { border-color: color-mix(in srgb, var(--text-2) 40%, transparent); }

/* Brand */
.brand {
  font-size: 13px; font-weight: 700; letter-spacing: 0.22em;
}
.brand span { font-weight: 300; color: var(--text-2); margin-left: 2px; }
.brand.small { font-size: 12px; }

/* Login */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 32px;
}
.login-card {
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 0;
}
.login-card .brand { margin-bottom: 40px; }
.login-card h1 {
  font-size: 44px; font-weight: 700; letter-spacing: -0.035em;
  line-height: 1.05; margin-bottom: 14px;
}
.login-card .muted { font-size: 15px; line-height: 1.5; margin-bottom: 36px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card form input { padding: 14px 16px; font-size: 16px; border-radius: 12px; }
.login-card form .primary { padding: 14px 18px; font-size: 15.5px; border-radius: 12px; margin-top: 4px; }
.login-card form .ghost { margin-top: 6px; align-self: center; }
.login-card .msg { font-size: 13px; color: var(--text-2); min-height: 18px; margin-top: 20px; }
.login-card .msg.err { color: var(--danger); }
#login-pin { font-size: 30px; letter-spacing: 0.42em; text-align: center; font-family: var(--mono); padding: 16px; }
#login-pin::placeholder { font-size: 15px; letter-spacing: normal; font-family: var(--font); }

/* Buttons */
.primary {
  background: var(--accent); color: #fff;
  border-radius: 10px; padding: 11px 18px; font-weight: 600;
  transition: opacity 0.2s, transform 0.1s;
}
.primary:hover { opacity: 0.88; }
.primary:active { transform: scale(0.985); }
.ghost {
  color: var(--text-2); padding: 8px 12px; border-radius: 8px;
  transition: color 0.2s, background 0.2s; font-size: 13px;
}
.ghost:hover { color: var(--text); background: var(--surface-2); }
.danger-ghost { color: var(--danger); opacity: 0.75; }
.danger-ghost:hover { opacity: 1; background: rgba(255, 69, 58, 0.1); }
.icon-btn {
  font-size: 13px; padding: 0 12px; border-radius: 8px;
  height: 30px; display: inline-flex; align-items: center;
  white-space: nowrap; flex: 0 0 auto;
}
a.icon-btn { text-decoration: none; line-height: 1; }

/* Shell */
header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
nav { display: flex; gap: 4px; flex: 1; }
nav button {
  padding: 7px 14px; border-radius: 999px; font-size: 13.5px;
  color: var(--text-2); transition: all 0.2s;
}
nav button:hover { color: var(--text); }
nav button.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.head-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }

main { max-width: 1060px; margin: 0 auto; padding: 44px 28px 120px; }

/* Page primitives */
.page-title { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 6px; }
.page-sub { color: var(--text-2); margin-bottom: 34px; font-size: 14.5px; }
.section-h {
  font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-2); margin: 44px 0 16px;
}
.section-h a { line-height: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--hairline);
  transition: background 0.2s ease;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; margin-right: 8px; }
.row .name {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 600; font-size: 14.5px; line-height: 1.35;
}
.row .sub {
  margin-top: 4px;
  font-size: 12.5px; color: var(--text-2); font-family: var(--mono);
  word-break: break-all; line-height: 1.5;
}
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--hairline);
  white-space: nowrap; line-height: 1.5;
}
.badge.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* Forms — micro-labels sit crisp above their fields */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 14px; padding: 22px; }
.form-grid .full { grid-column: 1 / -1; }
label {
  display: block;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 8px;
  -webkit-font-smoothing: subpixel-antialiased;
}
.inline-form { display: flex; gap: 14px; padding: 22px; flex-wrap: wrap; align-items: flex-end; }
.inline-form > div { flex: 1; min-width: 160px; }
.inline-form button { flex: 0 0 auto; height: 43px; }
.inline-form .primary, .form-grid .primary { padding: 11px 22px; }

/* Key reveal */
.key-reveal {
  font-family: var(--mono); font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 14px; word-break: break-all;
  margin: 12px 0; cursor: pointer;
}
.key-reveal:hover { border-color: var(--accent); }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 24px;
}
.modal-card {
  width: 100%; max-width: 480px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 18px; padding: 26px;
  animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-card h3 { font-size: 20px; letter-spacing: -0.02em; margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 10px 22px; font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  z-index: 60; animation: pop 0.2s ease;
}
.toast.err { color: var(--danger); }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 20px;
}
.tile .v { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.tile .k { font-size: 12px; color: var(--text-2); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 4px; }

.mono { font-family: var(--mono); }
.switch { appearance: none; width: 40px; height: 24px; min-width: 40px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--hairline); position: relative; cursor: pointer; transition: background 0.2s; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: all 0.2s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { left: 19px; background: #fff; }

/* Overview hero: credit ring beside stat tiles */
.overview-hero {
  display: flex; gap: 14px; align-items: stretch;
  margin-bottom: 8px;
}
.overview-hero .hero-tiles {
  flex: 1; margin-bottom: 0;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-content: stretch;
}
.ring-wrap {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px 26px 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-width: 208px;
}
.ring-svg { position: relative; width: 128px; height: 128px; }
.ring-svg svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 9; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-v { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.ring-k { font-size: 10px; color: var(--text-2); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px; }
.ring-sub { font-size: 12px; color: var(--text-2); text-align: center; }
@media (max-width: 720px) {
  .overview-hero { flex-direction: column; }
  .ring-wrap { min-width: 0; }
}

/* Live indicator */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); flex: 0 0 auto;
  animation: live-pulse 2.4s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); }
  50% { opacity: 0.75; box-shadow: 0 0 0 5px transparent; }
}

/* Alias inspector modal */
.modal-card.wide { max-width: 640px; max-height: 86vh; overflow-y: auto; }
.inspect .inspect-h {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-2); margin: 22px 0 12px;
}
.inspect .inspect-h:first-child { margin-top: 4px; }
.inspect-kv {
  display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 12px;
  padding: 7px 0; font-size: 13.5px;
}
.inspect-kv > span:first-child {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2);
}
.inspect-kv input, .inspect-kv select { padding: 9px 12px; }
.inspect-kv .small { font-size: 12.5px; }
.inspect .check {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; text-transform: none; letter-spacing: normal;
  color: var(--text); font-weight: 400; margin: 0 0 10px;
  cursor: pointer;
}
.inspect .check input { width: auto; accent-color: var(--accent); margin: 0; }

/* Composition editor + brain browser */
.edit-area {
  width: 100%; min-height: 320px; resize: vertical;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--hairline); border-radius: 10px;
  padding: 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
}
.edit-area:focus { outline: none; border-color: var(--accent); }
.preview-pre {
  max-height: 55vh; overflow: auto; white-space: pre-wrap;
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
}
.brain-browser { border-top: 1px solid var(--hairline); margin-top: 4px; padding-top: 14px; }
.brain-browser.hidden { display: none; }

@media (max-width: 720px) {
  header { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  main { padding: 28px 16px 90px; }
  .page-title { font-size: 27px; }
}
