:root {
  --bg: #0f141d;
  --surface: #171e2b;
  --surface-2: #1f293b;
  --border: #2c384f;
  --text: #e6edf7;
  --muted: #9aa7bd;
  --primary: #f97316;
  --primary-hover: #ea580c;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --merged: #a855f7;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

a {
  color: var(--info);
  text-decoration: none;
}

code, pre {
  font-family: Consolas, "Courier New", monospace;
}

/* Login Page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f97316, #dc2626);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 16px;
}

.login-brand h1 {
  margin: 0;
  font-size: 19px;
}

.login-brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.topbar-sub {
  font-size: 12px;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
}

/* Main Layout */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 64px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.tab-btn {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
  border-color: #445676;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.card-header h2, .card-header h3 {
  margin: 0;
  font-size: 16px;
}

.section-desc {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 13px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
}

.kpi-val {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
}

.kpi-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* Forms */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 170px;
  flex: 1;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  background: #0d121b;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 14px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-success {
  background: #16a34a;
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
}

.btn-warning {
  background: #d97706;
  color: #fff;
}

.btn-warning:hover:not(:disabled) {
  background: #b45309;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: #4f6282;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-open {
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge-scheduled {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-maintenance {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-merged {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.badge-ok {
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
}

.badge-warn {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.badge-err {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.direction-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(249, 115, 22, 0.16);
  border: 1px solid rgba(249, 115, 22, 0.45);
  color: #fdba74;
  font-weight: 800;
  font-size: 16px;
  padding: 6px 14px;
  border-radius: 8px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.02);
}

/* Alerts & Banners */
.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.alert-info {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fde68a;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.hidden {
  display: none !important;
}

.code-box {
  background: #0a0f17;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12px;
  color: #cbd5e1;
  margin: 8px 0;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}

.check-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.muted {
  color: var(--muted);
}

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.ml-8 { margin-left: 8px; }
.w-full { width: 100%; }
.max-w-360 { max-width: 360px; }
.max-w-290 { max-width: 290px; }
.text-11 { font-size: 11px; }
.text-115 { font-size: 11.5px; }
.text-12 { font-size: 12px; }
.text-13 { font-size: 13px; }
.text-14 { font-size: 14px; }
.mt-3 { margin-top: 3px; }
.mt-5 { margin-top: 5px; }
.card-nested { background: var(--surface-2); }
.list-compact { margin: 6px 0 0 18px; }
.list-steps { margin: 8px 0 0 18px; }
.list-steps li { margin-bottom: 6px; }
.detail-cell { font-size: 11px; max-width: 280px; word-break: break-word; }

/* Unified Console Extensions */
.container-wide {
  max-width: 1420px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.feature-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.feature-card-title {
  font-weight: 600;
  font-size: 13.5px;
}

.feature-card-desc {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.switch-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.switch-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.preset-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.preset-chip:hover {
  border-color: var(--primary);
  background: rgba(249, 115, 22, 0.14);
}

.cart-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #0d121b;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
}

.cart-row-qty {
  width: 120px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
}

.tower-slider-row {
  display: grid;
  grid-template-columns: 140px 1fr 90px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.tower-slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.tower-slider-row input[type="number"] {
  background: #0d121b;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
}

.rendered-code-banner {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.16), rgba(34, 197, 94, 0.12));
  border: 1px solid rgba(249, 115, 22, 0.55);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 12px;
}

.rendered-code-value {
  font-family: Consolas, "Courier New", monospace;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fdba74;
}

.split-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 16px;
}

.field-narrow {
  min-width: 110px;
  flex: 0 1 130px;
}

.field-xs {
  min-width: 85px;
  flex: 0 1 100px;
}

.search-results-box {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d121b;
  margin-top: 8px;
}

.search-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(44, 56, 79, 0.55);
  font-size: 12.5px;
}

.search-item-row:last-child {
  border-bottom: none;
}

.pill-exp {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.modal-card-wide {
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
}
