:root {
  --sm-bg: #f1f5f9;
  --sm-shell: #0f172a;
  --sm-surface: #ffffff;
  --sm-surface-soft: #f8fafc;
  --sm-line: #dbe2ea;
  --sm-line-dark: #c2cfdd;
  --sm-ink: #0f172a;
  --sm-muted: #475569;
  --sm-brand: #1d4ed8;
  --sm-brand-soft: #dbeafe;
  --sm-ok: #166534;
  --sm-danger: #b91c1c;
  --sm-radius: 12px;
  --sm-shadow: 0 18px 36px rgba(15, 23, 42, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--sm-bg);
  color: var(--sm-ink);
  font-family: "Avenir Next", "Segoe UI", Arial, sans-serif;
}

a { color: var(--sm-brand); }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111f3f 100%);
  color: #fff;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.09);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--sm-radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.brand h1 {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.moduleNav {
  display: grid;
  gap: 8px;
}

.moduleLink {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #e2e8f0;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: 0.9rem;
}

.moduleLink:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.moduleLink.active {
  background: #1d4ed8;
  border-color: #60a5fa;
  color: #fff;
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex: 0 0 18px;
}

.icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.siteSwitch h2 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #bfdbfe;
}

.siteSwitchList {
  display: grid;
  gap: 7px;
}

.siteSwitchLink {
  text-decoration: none;
  color: #dbeafe;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
}

.siteSwitchLink b {
  display: block;
  font-size: 0.87rem;
  color: #fff;
  margin-bottom: 2px;
}

.siteSwitchLink small {
  color: #bfdbfe;
  font-size: 0.72rem;
}

.siteSwitchLink.active {
  border-color: #60a5fa;
  background: rgba(37, 99, 235, 0.24);
}

.main {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  padding: 18px;
}

.topbar {
  background: var(--sm-surface);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-radius);
  box-shadow: var(--sm-shadow);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.crumbs {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--sm-muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.crumbs a {
  color: var(--sm-brand);
  text-decoration: none;
}

.crumbs .current { color: var(--sm-ink); }

.panel {
  background: var(--sm-surface);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-radius);
  box-shadow: var(--sm-shadow);
  padding: 14px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  padding: 9px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn.primary {
  background: var(--sm-brand);
  color: #fff;
}

.btn.ghost {
  background: #fff;
  color: var(--sm-ink);
  border-color: var(--sm-line-dark);
}

.btn.danger {
  border-color: #fecaca;
  background: #fff;
  color: var(--sm-danger);
}

.actionRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

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

.field label {
  display: block;
  font-size: 0.74rem;
  color: var(--sm-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
}

.field input,
.field textarea,
.field select,
input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--sm-line);
  border-radius: 8px;
  padding: 8px 9px;
  font: inherit;
  background: #fff;
  color: var(--sm-ink);
}

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

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
  border: 1px solid transparent;
}

.alert.notice {
  color: var(--sm-ok);
  border-color: #86efac;
  background: #f0fdf4;
}

.alert.error {
  color: var(--sm-danger);
  border-color: #fecaca;
  background: #fef2f2;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  border: 1px solid var(--sm-line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.table th {
  background: #e2e8f0;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--sm-line);
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fff;
}

.pill.off {
  color: #92400e;
  border-color: #fdba74;
  background: #fff7ed;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.modal.open { display: block; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal-card {
  position: relative;
  width: min(680px, calc(100vw - 24px));
  margin: 4vh auto;
  background: #fff;
  border: 1px solid var(--sm-line);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35);
  max-height: 90vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.modal-head,
.modal-foot {
  padding: 12px 14px;
  border-bottom: 1px solid var(--sm-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-foot {
  border-bottom: 0;
  border-top: 1px solid var(--sm-line);
}

.modal-head h3 {
  margin: 0;
  font-size: 1.02rem;
}

.modal-body {
  padding: 12px 14px;
  overflow: auto;
}

.sm-loading body,
.sm-loading {
  cursor: progress;
}

.sm-loading [data-sm-main] {
  opacity: 0.62;
  transition: opacity 0.16s ease;
  pointer-events: none;
}

[data-sm-main] {
  transition: opacity 0.16s ease;
}

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

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
}
