:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #eef2f5;
  --border: #d9e0e7;
  --text: #18202a;
  --muted: #687384;
  --accent: #176b87;
  --accent-strong: #0f5268;
  --success: #14764f;
  --warning: #9a6200;
  --danger: #b42318;
  --shadow: 0 14px 40px rgba(25, 42, 62, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 16px;
  background: #10232c;
  color: #f5f8fa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e3f5fb;
  color: #10232c;
  font-weight: 800;
  font-size: 20px;
}

.brand-text {
  font-weight: 800;
  font-size: 18px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c9d4dc;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.11);
  font-size: 12px;
  font-weight: 800;
}

.sidebar-status {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-status strong,
.sidebar-status span {
  display: block;
}

.sidebar-status span:not(.status-dot) {
  margin-top: 2px;
  color: #afbec8;
  font-size: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--warning);
}

.status-dot.ok {
  background: var(--success);
}

.status-dot.fail {
  background: var(--danger);
}

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

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

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

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

.icon-button,
.ghost-button,
.text-button,
.primary-button,
.secondary-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.icon-button {
  width: 38px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  text-decoration: none;
}

.text-button {
  background: transparent;
  color: var(--accent);
  padding: 0 4px;
}

.primary-button {
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  padding: 0 16px;
  background: var(--surface-muted);
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 128px;
  padding: 18px;
}

.metric-label,
.metric-card small,
.panel-head p,
label span {
  color: var(--muted);
}

.metric-label,
label span {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 30px;
  line-height: 1;
}

.metric-card small {
  font-size: 13px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.8fr);
  gap: 18px;
}

.catalog-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.panel {
  padding: 18px;
}

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

.panel-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.toolbar,
.split-form,
.inline-form,
.form-stack {
  display: grid;
  gap: 12px;
}

.toolbar {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.split-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 16px;
}

.form-stack {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 11px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(23, 107, 135, 0.18);
  border-color: var(--accent);
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.pill.ok {
  background: #dcf5e8;
  color: var(--success);
}

.pill.warn {
  background: #fff1d6;
  color: var(--warning);
}

.pill.bad {
  background: #ffe4df;
  color: var(--danger);
}

.stack-list,
.compact-list,
.service-grid,
.membership-grid {
  display: grid;
  gap: 10px;
}

.service-grid,
.membership-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.list-row,
.service-card,
.membership-card,
.client-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
}

.list-row strong,
.service-card strong,
.membership-card strong {
  display: block;
  margin-bottom: 4px;
}

.list-row span,
.service-card span,
.membership-card span {
  color: var(--muted);
  font-size: 13px;
}

.service-card,
.membership-card {
  padding: 14px;
}

.client-card,
.client-card-empty {
  min-height: 256px;
}

.client-card {
  padding: 16px;
}

.client-card-empty,
.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
}

.client-name {
  margin: 0 0 6px;
  font-size: 22px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.kv {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.kv span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.kv strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 50;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #10232c;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .brand-text,
  .nav-item span:last-child,
  .sidebar-status div {
    display: none;
  }

  .sidebar {
    align-items: center;
  }

  .metric-grid,
  .content-grid,
  .catalog-grid {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px;
  }

  .brand {
    flex: 0 0 auto;
  }

  .nav-list {
    display: flex;
    min-width: max-content;
  }

  .nav-item {
    width: auto;
  }

  .sidebar-status {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .metric-grid,
  .content-grid,
  .catalog-grid,
  .toolbar,
  .split-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

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

  .topbar-actions {
    flex-shrink: 0;
  }
}
