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

:root {
  --bg: #f8f9ff;
  --surface: #ffffff;
  --surface-low: #eff4ff;
  --surface-mid: #e5eeff;
  --surface-high: #dce9ff;
  --ink: #0b1c30;
  --muted: #45474c;
  --faint: #69707d;
  --line: #c5c6cd;
  --line-soft: #dde5f2;
  --primary: #091426;
  --primary-soft: #1e293b;
  --on-primary: #ffffff;
  --accent: #006c4a;
  --accent-soft: #dffbea;
  --warn: #d97705;
  --warn-soft: #fff4e5;
  --danger: #ba1a1a;
  --danger-soft: #ffdad6;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 1px 2px rgba(9, 20, 38, 0.08), 0 6px 16px rgba(9, 20, 38, 0.04);
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(229, 238, 255, 0.72) 0, rgba(229, 238, 255, 0.72) 1px, transparent 1px) 0 0 / 88px 88px,
    var(--bg);
}

.app-body {
  background:
    linear-gradient(90deg, rgba(229, 238, 255, 0.72) 0, rgba(229, 238, 255, 0.72) 1px, transparent 1px) 0 0 / 88px 88px,
    var(--bg);
}

.app-shell {
  min-height: 100vh;
}

.side-rail {
  display: none;
}

.workspace {
  min-width: 0;
}

.workspace-inner {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.commandbar-title {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.commandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.commandbar h1 {
  margin: 0;
  color: var(--primary);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.1;
}

.commandbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.command-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: min(360px, 36vw);
  max-width: 420px;
  margin: 0;
}

.command-search input {
  width: 100%;
  min-height: 48px;
  padding-left: 48px;
  background: var(--surface-mid);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid var(--primary);
  border-radius: 999px;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 7px;
  height: 2px;
  background: var(--primary);
  transform: rotate(45deg);
  transform-origin: center;
}

.command-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.icon-button::before,
.icon-button::after {
  content: "";
  position: absolute;
}

.icon-status::before {
  left: 9px;
  bottom: 10px;
  width: 16px;
  height: 10px;
  border-left: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
}

.icon-status::after {
  left: 12px;
  top: 11px;
  width: 13px;
  height: 9px;
  border-top: 2px solid var(--primary);
  border-right: 2px solid var(--primary);
  transform: skew(-28deg);
}

.icon-user::before {
  left: 12px;
  top: 8px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--primary);
  border-radius: 999px;
}

.icon-user::after {
  left: 10px;
  bottom: 8px;
  width: 14px;
  height: 8px;
  border: 2px solid var(--primary);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom: 0;
}

.icon-exit::before {
  left: 10px;
  top: 10px;
  width: 8px;
  height: 14px;
  border: 2px solid var(--primary);
  border-right: 0;
}

.icon-exit::after {
  right: 8px;
  top: 17px;
  width: 11px;
  height: 2px;
  background: var(--primary);
  box-shadow: 5px -4px 0 -1px var(--primary), 5px 4px 0 -1px var(--primary);
}

@media (min-width: 1180px) {
  .app-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .side-rail {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    border-right: 1px solid var(--line);
    background: #f3f6ff;
    padding: 30px 20px;
  }

  .rail-brand {
    display: grid;
    gap: 4px;
    margin-bottom: 36px;
  }

  .rail-brand strong {
    color: var(--primary);
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: 0;
  }

  .rail-brand span {
    color: var(--primary);
    font-family: var(--mono);
    font-size: 0.84rem;
  }

  .rail-nav {
    display: grid;
    gap: 8px;
  }

  .rail-bottom {
    margin-top: auto;
  }

  .rail-link {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 50px;
    border-radius: var(--radius);
    color: var(--primary);
    padding: 0 14px;
    font-family: var(--mono);
    font-size: 0.88rem;
    text-decoration: none;
  }

  .rail-link span {
    display: inline-block;
    width: 26px;
    height: 26px;
  }

  .nav-icon {
    position: relative;
    border: 1px solid currentColor;
    border-radius: var(--radius);
  }

  .nav-icon::before,
  .nav-icon::after {
    content: "";
    position: absolute;
  }

  .nav-grid::before {
    top: 5px;
    left: 5px;
    width: 5px;
    height: 5px;
    border: 2px solid currentColor;
    box-shadow: 9px 0 0 -2px currentColor, 0 9px 0 -2px currentColor, 9px 9px 0 -2px currentColor;
  }

  .nav-laptop::before {
    left: 5px;
    top: 6px;
    width: 14px;
    height: 9px;
    border: 2px solid currentColor;
    border-bottom-width: 1px;
  }

  .nav-laptop::after {
    left: 4px;
    bottom: 5px;
    width: 16px;
    height: 2px;
    background: currentColor;
  }

  .nav-display::before {
    left: 5px;
    top: 5px;
    width: 14px;
    height: 10px;
    border: 2px solid currentColor;
  }

  .nav-display::after {
    left: 10px;
    bottom: 5px;
    width: 4px;
    height: 4px;
    border-left: 2px solid currentColor;
    border-right: 2px solid currentColor;
  }

  .nav-bars::before {
    left: 6px;
    top: 5px;
    width: 12px;
    height: 14px;
    border: 2px solid currentColor;
  }

  .nav-bars::after {
    left: 9px;
    top: 8px;
    width: 2px;
    height: 8px;
    background: currentColor;
    box-shadow: 4px -2px 0 0 currentColor, 8px 2px 0 0 currentColor;
  }

  .nav-lock::before {
    left: 7px;
    top: 10px;
    width: 12px;
    height: 9px;
    border: 2px solid currentColor;
  }

  .nav-lock::after {
    left: 9px;
    top: 5px;
    width: 8px;
    height: 7px;
    border: 2px solid currentColor;
    border-bottom: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
  }

  .nav-exit::before {
    left: 6px;
    top: 6px;
    width: 8px;
    height: 12px;
    border: 2px solid currentColor;
    border-right: 0;
  }

  .nav-exit::after {
    right: 5px;
    top: 12px;
    width: 9px;
    height: 2px;
    background: currentColor;
    box-shadow: 4px -3px 0 -1px currentColor, 4px 3px 0 -1px currentColor;
  }

  .rail-link:hover,
  .rail-link.active {
    background: var(--surface-high);
  }

  .commandbar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding-left: 32px;
    padding-right: 32px;
  }
}

a {
  color: var(--primary);
  text-underline-offset: 3px;
}

button,
input,
select {
  font: inherit;
}

code,
pre,
.code,
.price,
th,
.meta,
.chip,
.stat span,
label {
  font-family: var(--mono);
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 44px;
}

.topbar,
.panel,
.deal-panel,
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand strong {
  color: var(--primary);
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.15;
}

.brand span,
.meta,
.muted {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.meta {
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.button.primary,
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.button:hover,
button:hover {
  border-color: var(--primary);
  background: var(--surface-low);
}

.button.primary:hover,
button.primary:hover {
  background: var(--primary-soft);
  color: var(--on-primary);
}

.button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.status-grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.hero-band {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy h2 {
  margin: 0;
  color: var(--primary);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.2;
}

.hero-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.hero-actions,
.hero-action {
  flex-shrink: 0;
}

.hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.dashboard-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.status-card strong {
  text-transform: capitalize;
}

.metric-card span {
  display: block;
  color: var(--primary);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 18px;
  color: var(--primary);
  font-size: 2.45rem;
  font-weight: 800;
  line-height: 1;
}

.metric-card .metric-text {
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.35;
  word-break: break-word;
}

.metric-card em {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
}

.stat {
  min-height: 116px;
  padding: 18px 20px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 18px;
  color: var(--primary);
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.filters,
.filterbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.45fr) repeat(3, minmax(150px, 0.8fr)) auto auto minmax(150px, auto);
  gap: 14px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.notebook-filterbar {
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.25;
  text-transform: uppercase;
}

input,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  padding: 8px 10px;
  box-shadow: inset 0 1px 0 rgba(9, 20, 38, 0.03);
}

input::placeholder {
  color: #6b7280;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 24px 0 10px;
}

.section-title h2 {
  margin: 0;
  color: var(--primary);
  font-size: 1.55rem;
  font-weight: 750;
  line-height: 1.2;
}

.section-title-flush {
  margin-top: 0;
}

.panel-pad {
  padding: 16px;
}

.setup-warning {
  margin-bottom: 16px;
  padding: 18px;
}

.setup-warning h1 {
  margin: 0 0 8px;
}

.setup-warning p {
  margin: 0;
}

.notebook-grid {
  display: grid;
  gap: 14px;
}

@media (min-width: 1280px) {
  .notebook-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .notebook-grid .deal-panel {
    max-height: 72vh;
    overflow: auto;
  }

  .notebook-grid table {
    min-width: 700px;
    table-layout: fixed;
  }

  .notebook-grid th,
  .notebook-grid td {
    padding: 9px 8px;
  }

  .notebook-grid th:nth-child(1),
  .notebook-grid td:nth-child(1),
  .notebook-grid th:nth-child(3),
  .notebook-grid td:nth-child(3),
  .notebook-grid th:nth-child(7),
  .notebook-grid td:nth-child(7),
  .notebook-grid th:nth-child(8),
  .notebook-grid td:nth-child(8) {
    display: none;
  }

  .notebook-grid th:nth-child(2),
  .notebook-grid td:nth-child(2) {
    width: 28%;
  }

  .notebook-grid th:nth-child(6),
  .notebook-grid td:nth-child(6) {
    width: 13%;
  }

  .notebook-grid th:nth-child(9),
  .notebook-grid td:nth-child(9) {
    width: 16%;
  }

  .notebook-grid th:nth-child(10),
  .notebook-grid td:nth-child(10) {
    width: 10%;
  }

  .notebook-grid th:nth-child(11),
  .notebook-grid td:nth-child(11) {
    width: 12%;
  }
}

.deal-panel {
  overflow: hidden;
}

.deal-panel header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-high);
}

.deal-panel header h3 {
  margin: 0;
  color: var(--primary);
  font-size: 1.18rem;
  font-weight: 750;
  line-height: 1.2;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line-soft);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-mid);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  line-height: 1.25;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: rgba(239, 244, 255, 0.45);
}

tbody tr:hover {
  background: #f1f5f9;
}

.model {
  color: var(--ink);
  display: -webkit-box;
  font-weight: 700;
  line-height: 1.35;
  max-width: 34ch;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.code {
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.price {
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.empty {
  padding: 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

.health-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.health-item {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.health-item strong {
  display: block;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  padding: 34px 40px;
  border-color: var(--line-soft);
}

.login-card h1 {
  margin: 0 0 18px;
  color: var(--primary);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.login-card button.primary {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  font-size: 0.9rem;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.remember-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.95rem;
  letter-spacing: 0;
  line-height: 1.4;
  text-transform: none;
}

.remember-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: auto;
  padding: 0;
}

.notice {
  border: 1px solid var(--line-soft);
  background: var(--surface-low);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
}

.notice.error {
  border-color: var(--danger-soft);
  background: #fff7f6;
  color: var(--danger);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.rule-panel {
  background: #101a2a;
  color: #eaf1ff;
}

.rule-panel .section-title h2,
.rule-panel .meta,
.rule-panel p,
.rule-panel .muted,
.rule-panel code,
.rule-panel strong {
  color: #eaf1ff;
}

.rule-panel pre {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #eaf1ff;
}

.rule-note {
  margin: 14px 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  padding: 14px;
}

.rule-note strong {
  display: block;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rule-list {
  margin: 0;
  padding-left: 18px;
}

.rule-list li + li {
  margin-top: 8px;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.source-row:last-child {
  border-bottom: 0;
}

pre {
  overflow-x: auto;
  margin: 8px 0 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-low);
  padding: 12px;
  color: var(--primary);
  font-size: 0.82rem;
  line-height: 1.55;
}

p {
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .status-grid,
  .metric-grid,
  .health-list,
  .admin-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filters,
  .filterbar {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace-inner {
    width: min(100% - 20px, 1440px);
    padding-top: 12px;
  }

  .commandbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    padding: 14px 10px;
  }

  .commandbar-title,
  .hero-band,
  .hero-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .command-search {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .commandbar h1 {
    font-size: 1.45rem;
  }

  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 12px;
  }

  .topbar,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-grid,
  .metric-grid,
  .health-list,
  .admin-grid,
  .filters,
  .filterbar {
    grid-template-columns: 1fr;
  }

  .stat {
    min-height: 96px;
  }

  .metric-card {
    min-height: 104px;
  }

  .stat strong,
  .metric-card strong {
    font-size: 1.8rem;
  }

  .login-card {
    padding: 26px 22px;
  }

  table {
    min-width: 900px;
  }
}
