:root {
  --c-primary: #2d4a7c;
  --c-primary-hover: #243d66;
  --c-primary-soft: #e8eef7;
  --c-accent: #0d9488;
  --c-accent-soft: #ccfbf1;
  --c-danger: #dc2626;
  --c-warning: #d97706;
  --c-text: #1a1f2e;
  --c-muted: #64748b;
  --c-border: #e2e8f0;
  --c-bg: #f1f5f9;
  --c-surface: #ffffff;
  --sidebar-w: 220px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body.console-body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.console-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--c-text);
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.console-shell {
  display: flex;
  min-height: 100vh;
}

.console-sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #94a3b8;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
}

.console-sidebar .brand {
  padding: 16px;
  border-bottom: 1px solid #1e293b;
  color: #f1f5f9;
  font-size: 13px;
}

.console-sidebar .brand small {
  display: block;
  color: #64748b;
  font-weight: 400;
  margin-top: 4px;
}

.console-nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.console-nav a {
  display: block;
  padding: 10px 16px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
}

.console-nav a:hover { background: #1e293b; color: #e2e8f0; }

.console-nav a.active {
  background: #1e293b;
  color: #fff;
  border-left-color: var(--c-accent);
}

.console-nav .nav-group {
  padding: 12px 16px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}

.console-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.console-topbar {
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left h1 { font-size: 18px; font-weight: 600; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tenant-select {
  padding: 6px 10px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--c-surface);
}

.btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  font-size: 13px;
  cursor: pointer;
  color: var(--c-text);
}

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

.btn-primary:hover { background: var(--c-primary-hover); }

.btn-ghost {
  border: none;
  background: transparent;
  color: var(--c-primary);
}

.console-content {
  padding: 24px;
  flex: 1;
}

.page { display: none; }
.page.active { display: block; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 16px;
}

.stat-card .label { font-size: 12px; color: var(--c-muted); }
.stat-card .value { font-size: 22px; font-weight: 700; margin-top: 6px; }
.stat-card .delta { font-size: 12px; color: var(--c-accent); margin-top: 4px; }

.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-body { padding: 18px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}

.data-table th {
  background: #f8fafc;
  color: var(--c-muted);
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.badge-ok { background: var(--c-accent-soft); color: #0f766e; }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: var(--c-danger); }
.badge-muted { background: #f1f5f9; color: var(--c-muted); }

.form-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.form-row label { color: var(--c-muted); font-size: 13px; }

.form-row input,
.form-row select {
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  max-width: 400px;
}

.hint {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 8px;
}

.flow-diagram {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--c-muted);
  margin: 12px 0;
}

.flow-diagram span {
  background: var(--c-primary-soft);
  color: var(--c-primary);
  padding: 6px 10px;
  border-radius: 6px;
}

.flow-diagram .arrow { background: none; color: var(--c-muted); padding: 0; }

.proto-link-bar {
  padding: 10px 16px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  font-size: 12px;
  color: #92400e;
}

.proto-link-bar a { color: var(--c-primary); margin-left: 8px; }

.role-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.role-tabs button {
  padding: 8px 16px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.role-tabs button.active {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 12px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-primary);
  background: var(--c-primary-soft);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.page-back:hover {
  background: #dce6f5;
}

.stat-card-click {
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.stat-card-click:hover {
  box-shadow: 0 4px 12px rgba(45, 74, 124, 0.12);
}

.data-table .link-action {
  color: var(--c-primary);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
}

.data-table .link-action:hover {
  text-decoration: underline;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  overflow-x: auto;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .console-sidebar { display: none; }
  .console-main { margin-left: 0; }
}
