:root {
  color-scheme: light;
  --bg: #f3f2ef;
  --panel: #ffffff;
  --ink: #191919;
  --muted: #666666;
  --line: #d8d6d2;
  --green: #0a66c2;
  --green-2: #004182;
  --gold: #915907;
  --aqua: #eef5fb;
  --rust: #56687a;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1113;
  --panel: #1b1f23;
  --ink: #f3f2ef;
  --muted: #b7b7b7;
  --line: #343a40;
  --green: #70b5f9;
  --green-2: #a8d8ff;
  --gold: #f5c75d;
  --aqua: #17324a;
  --rust: #9db3c7;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.rail {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, auto) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  height: auto;
  padding: 8px clamp(16px, 5vw, 46px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 0; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}
.brand small { display: block; color: var(--muted); margin-top: 2px; }

nav { display: flex; justify-content: flex-end; gap: 4px; }
.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 78px;
  min-height: 48px;
  padding: 5px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}
.nav-link[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
  background: transparent;
}
.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  text-align: center;
  font-size: .76rem;
}

main {
  width: min(1180px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 28px) 48px;
}
.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 420px) auto;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 1.8vw, 1.8rem); }
h2 { font-size: clamp(1.35rem, 2vw, 2rem); line-height: 1.15; margin-bottom: 10px; }
h3 { margin-bottom: 8px; }
p { color: var(--muted); line-height: 1.55; }
.eyebrow {
  margin-bottom: 7px;
  color: var(--gold);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.view { display: none; }
.active-view { display: block; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.topbar-actions, .button-row, .panel-head, .inline-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.primary-action, .secondary-action, .icon-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 38px;
  padding: 8px 16px;
  cursor: pointer;
  background: var(--panel);
  color: var(--ink);
}
.primary-action { background: var(--green); border-color: var(--green); color: white; font-weight: 800; }
.secondary-action { border-color: var(--green); color: var(--green); font-weight: 800; }
.icon-btn { width: 38px; padding: 0; font-size: 1rem; }
.global-search {
  position: relative;
  display: grid;
  gap: 0;
  color: var(--muted);
}
.global-search span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .78rem;
  font-weight: 800;
}
.global-search input {
  height: 40px;
  padding-left: 68px;
  border-radius: 6px;
  background: var(--aqua);
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(280px, .88fr);
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.hero-copy { padding: clamp(22px, 4vw, 42px); align-self: center; }
.hero-copy p { max-width: 56ch; }
.hero-band img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
}
.network-layout {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.profile-summary {
  position: sticky;
  top: 78px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}
.profile-cover {
  height: 58px;
  background: linear-gradient(135deg, var(--green), #9ecceb);
}
.profile-avatar {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  margin: -36px auto 10px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}
.profile-summary h3 { margin-bottom: 4px; padding: 0 14px; }
.profile-summary p { padding: 0 16px 12px; font-size: .9rem; }
.mini-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .88rem;
  text-align: left;
}
.mini-stat strong { color: var(--green); }

.metric-grid, .workflow-grid, .dashboard-grid, .expert-grid, .form-grid {
  display: grid;
  gap: 14px;
}
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 14px 0; }
.metric, .workflow-grid article, .panel, .filter-panel, .builder-form, .expert-card, .auth-panel, .signup-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.metric { padding: 18px; }
.metric strong { display: block; font-size: 1.45rem; color: var(--green-2); }
.section-band { padding: 28px 0; }
.section-title { margin: 16px 0; }
.workflow-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.workflow-grid article { padding: 16px; }
.workflow-grid span { color: var(--rust); font-weight: 900; }

.search-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; }
.filter-panel, .builder-form { padding: 18px; }
.auth-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(170px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
}
.signup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 18px;
  align-items: start;
}
.signup-copy {
  padding: clamp(22px, 4vw, 38px) 0;
}
.signup-form {
  display: grid;
  gap: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.compact-workflow {
  grid-template-columns: 1fr;
  margin-top: 18px;
}
label { display: grid; gap: 7px; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 96%, var(--bg));
  color: var(--ink);
  padding: 11px 12px;
}
textarea { resize: vertical; }
.filter-panel { align-self: start; display: grid; gap: 14px; position: sticky; top: 78px; }
.result-bar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; color: var(--muted); }
.expert-grid { grid-template-columns: 1fr; }
.expert-card { padding: 18px; display: grid; gap: 12px; }
.expert-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--aqua);
  color: var(--green-2);
  font-weight: 900;
}
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.status-pill, .tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--green) 20%, var(--line));
  border-radius: 999px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}
.status-pill { background: var(--aqua); color: var(--green-2); }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel { padding: 18px; }
.span-2 { grid-column: span 2; }
.usage-bars { display: grid; gap: 12px; }
.usage-bars span { justify-self: end; font-weight: 600; }
progress { width: 100%; height: 8px; accent-color: var(--green); }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.table-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 14px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: .82rem; text-transform: uppercase; }

.expert-application { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; }
.steps { margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); list-style-position: inside; }
.steps li { padding: 10px 0; color: var(--muted); border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.ops-layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; margin-top: 16px; }
.queue-item { display: grid; gap: 6px; padding: 14px 0; border-top: 1px solid var(--line); }
.queue-item:first-child { border-top: 0; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(120%);
  transition: transform .2s ease;
  background: var(--ink);
  color: var(--bg);
  padding: 12px 14px;
  border-radius: 8px;
  max-width: 320px;
}
.toast.show { transform: translateY(0); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  nav { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .nav-link { justify-content: center; }
  .nav-link span:last-child { display: none; }
  .hero-band, .search-layout, .expert-application, .ops-layout, .auth-panel, .signup-layout, .network-layout { grid-template-columns: 1fr; }
  .profile-summary { position: static; }
  .topbar { grid-template-columns: 1fr; }
  .metric-grid, .workflow-grid, .dashboard-grid, .expert-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-panel { position: static; }
}

@media (max-width: 640px) {
  main { padding: 18px 14px 32px; }
  .topbar, .inline-title, .topbar-actions { align-items: stretch; flex-direction: column; }
  nav { grid-template-columns: repeat(6, 1fr); }
  .metric-grid, .workflow-grid, .dashboard-grid, .expert-grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .hero-band img { min-height: 250px; }
  .card-actions, .button-row { grid-template-columns: 1fr; display: grid; }
}
