:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef1ed;
  --line: #d8ded6;
  --ink: #1f2522;
  --muted: #66706b;
  --green: #198754;
  --green-ink: #0d5b37;
  --amber: #b26b00;
  --red: #b42318;
  --blue: #2864a6;
  --shadow: 0 10px 28px rgba(28, 35, 31, 0.08);
}

body.dark-mode {
  color-scheme: dark;
  --bg: #0e1110;
  --surface: #171c1a;
  --surface-2: #202722;
  --line: #2d3832;
  --ink: #edf3ef;
  --muted: #a0aba5;
  --green: #3bbf72;
  --green-ink: #88e0aa;
  --amber: #e3a336;
  --red: #ff6b5d;
  --blue: #6ba6e6;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

body.public-mode {
  background: #fbfcfa;
}

body.dark-mode.public-mode {
  background: #0e1110;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

button:hover {
  border-color: #b8c4bb;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.secondary {
  background: #f8faf8;
}

body.dark-mode .secondary {
  background: #202722;
}

.danger {
  border-color: #e4b8b3;
  color: var(--red);
}

.full {
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

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

.public-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  padding: 14px clamp(18px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 250, 0.94);
  position: sticky;
  top: 0;
  z-index: 4;
}

body.dark-mode .public-nav {
  background: rgba(14, 17, 16, 0.94);
}

.public-nav nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.public-nav a {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 0.8fr);
  gap: 28px;
  align-items: center;
  min-height: calc(100vh - 74px);
  padding: clamp(30px, 6vw, 72px) clamp(18px, 5vw, 64px);
}

.hero-copy h1 {
  margin: 0 0 12px;
  font-size: clamp(52px, 10vw, 118px);
  line-height: 0.88;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 680px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.hero-actions button {
  min-width: 142px;
}

.hero-board {
  display: grid;
  gap: 10px;
  min-height: 390px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1f2522;
  color: #fff;
  box-shadow: var(--shadow);
}

body.dark-mode .hero-board {
  background: #080a09;
}

.hero-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.hero-row span,
.hero-row em {
  color: #c8d5cd;
  font-style: normal;
}

.hero-chart {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 12px;
  min-height: 160px;
  margin-top: auto;
}

.hero-chart i {
  display: block;
  border-radius: 6px 6px 0 0;
  background: #8fd49d;
}

.hero-chart i:nth-child(1) { height: 36%; }
.hero-chart i:nth-child(2) { height: 58%; }
.hero-chart i:nth-child(3) { height: 44%; }
.hero-chart i:nth-child(4) { height: 78%; }
.hero-chart i:nth-child(5) { height: 62%; }

.public-band,
.pricing-section,
.faq-section {
  padding: 34px clamp(18px, 5vw, 64px);
}

.public-band,
.price-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.service-card-public,
.price-card {
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.service-card-public span,
.price-card span {
  color: var(--green-ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.service-card-public p,
.price-card p,
.faq-section p {
  color: var(--muted);
  line-height: 1.55;
}

.pricing-section {
  display: grid;
  grid-template-columns: 0.55fr 1fr;
  gap: 18px;
  align-items: start;
}

.price-card strong {
  display: block;
  margin: 14px 0 8px;
  font-size: 22px;
}

.faq-section {
  display: grid;
  gap: 10px;
  max-width: 980px;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
}

summary {
  cursor: pointer;
  font-weight: 800;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 22px;
  background: #eef1ed;
}

body.dark-mode .auth-shell {
  background: #0e1110;
}

.auth-panel {
  width: min(520px, 100%);
}

.auth-box {
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-box p {
  margin: 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.ghost-link {
  border: 0;
  background: transparent;
  color: var(--green-ink);
  font-weight: 800;
  padding-inline: 0;
}

.inline-link {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--green-ink);
  font-weight: 800;
  padding: 0;
  text-decoration: underline;
}

.confirm-hint {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #b7dfc8;
  border-radius: 8px;
  background: #e9f8ee;
  color: var(--green-ink);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.68);
}

.modal-panel {
  width: min(820px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.42);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.terms-notice {
  margin: 14px 18px 0;
  padding: 10px;
  border: 1px solid #efd5a5;
  border-radius: 8px;
  background: #fff7e6;
  color: var(--amber);
  font-weight: 700;
}

body.dark-mode .terms-notice {
  background: #2a2111;
}

.terms-content {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.terms-content section {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.terms-content h2 {
  font-size: 15px;
}

.terms-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

body.dark-mode .sidebar {
  background: #111513;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #1f2522;
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav-stack {
  display: grid;
  gap: 6px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  padding: 9px 11px;
  text-align: left;
  background: transparent;
}

.nav-item.active {
  border-color: #c4d9ca;
  background: #eaf4ed;
  color: var(--green-ink);
}

body.dark-mode .nav-item.active {
  border-color: #315b42;
  background: #16251d;
}

.slot-submenu {
  display: grid;
  gap: 5px;
  padding-left: 14px;
}

.slot-menu-item {
  min-height: 30px;
  padding: 6px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.slot-menu-item.active {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.connection-card {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  color: var(--ink);
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #111513;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #8fb29a;
  outline: 2px solid rgba(25, 135, 84, 0.14);
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.button-row,
.inline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button-row button {
  flex: 1 1 0;
}

.api-status {
  min-height: 24px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.api-status.ok {
  background: #e6f4ea;
  color: var(--green-ink);
}

.api-status.bad {
  background: #fff0ed;
  color: var(--red);
}

.signed-user {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.signed-user span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 16px;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segment {
  min-width: 72px;
  border-color: transparent;
  background: transparent;
}

.segment.active {
  background: #1f2522;
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.service-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.service-choice {
  display: grid;
  gap: 10px;
  min-height: 180px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.service-choice span {
  color: var(--green-ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.service-choice p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.choice-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.entitlement-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

body.dark-mode .entitlement-form {
  background: #111513;
}

.entitlement-form button {
  align-self: end;
}

.slot-detail {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.slot-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.detail-tile {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.detail-tile span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.kpi-grid.compact {
  margin: 12px 0;
}

.metric {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  font-size: 24px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #fbfcfa;
}

body.dark-mode th {
  background: #111513;
}

td {
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.running {
  border-color: #b7dfc8;
  background: #e9f8ee;
  color: var(--green-ink);
}

.status-pill.expired,
.status-pill.critical {
  border-color: #efc4be;
  background: #fff0ed;
  color: var(--red);
}

.status-pill.warning {
  border-color: #efd5a5;
  background: #fff7e6;
  color: var(--amber);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-width: 58px;
  padding-inline: 8px;
}

.alert-list,
.master-list {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
}

.empty {
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.alert-item,
.master-item {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

body.dark-mode .alert-item,
body.dark-mode .master-item {
  background: #111513;
}

.alert-item strong,
.master-item strong {
  font-size: 13px;
}

.alert-item span,
.master-item span {
  color: var(--muted);
  font-size: 12px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.form-grid .panel-head {
  grid-column: 1 / -1;
  margin: -14px -14px 2px;
}

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

.slot-editor {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--ink);
  font-size: 13px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.form-grid .full,
.form-grid.wide .full {
  grid-column: 1 / -1;
}

.log-output {
  min-height: 520px;
  max-height: 68vh;
  overflow: auto;
  margin: 0;
  padding: 14px;
  background: #151815;
  color: #dbe7dc;
  font: 12px/1.5 Consolas, Monaco, monospace;
}

.toast {
  padding: 10px 12px;
  border: 1px solid #c7dbc9;
  border-radius: 8px;
  background: #eff8f0;
  color: var(--green-ink);
}

.toast.error {
  border-color: #efc4be;
  background: #fff0ed;
  color: var(--red);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .kpi-grid,
  .split-grid,
  .hero-section,
  .pricing-section,
  .public-band,
  .price-grid,
  .service-choice-grid,
  .entitlement-form,
  .form-grid.wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-section,
  .pricing-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented,
  .top-actions,
  .inline-controls {
    width: 100%;
  }

  .segment,
  .top-actions .theme-toggle,
  .inline-controls select,
  .inline-controls button {
    flex: 1 1 0;
  }

  .kpi-grid,
  .split-grid,
  .public-band,
  .price-grid,
  .service-choice-grid,
  .entitlement-form,
  .slot-detail,
  .form-grid,
  .form-grid.wide {
    grid-template-columns: 1fr;
  }

  .public-nav,
  .public-nav nav,
  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .hero-copy h1 {
    font-size: 56px;
  }
}
