:root {
  --bg: #edf2f9;
  --panel: #ffffff;
  --line: #d7deea;
  --ink: #17243a;
  --muted: #60708a;
  --green: #178a49;
  --red: #c33f35;
  --amber: #b57100;
  --brand: #2588e8;
  --brand-dark: #101a2d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Avenir Next", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 560px at 8% -12%, #f8fbff 0%, transparent 60%),
    linear-gradient(180deg, #f7faff 0%, #ecf2fa 100%);
}

a { color: inherit; text-decoration: none; }

.terminal-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 58px 1fr;
}

.side {
  background: linear-gradient(180deg, #162136 0%, #0f1728 100%);
  color: #dbe7f6;
  border-right: 1px solid #20304c;
  padding: 10px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rail-brand {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(160deg, #49a5ff 0%, #257ce2 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  margin-bottom: 4px;
  box-shadow: 0 6px 16px rgba(27, 115, 223, 0.38);
}

.nav-link {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid #2b3e59;
  border-radius: 10px;
  background: #162238;
  color: #d3dded;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link::after {
  content: attr(data-name);
  position: absolute;
  z-index: 60;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  border-radius: 6px;
  background: #0f1520;
  border: 1px solid #2a374c;
  color: #ecf2fb;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.nav-link.active {
  border-color: #4eb1ff;
  color: #fff;
  background: #23354e;
  box-shadow:
    inset 0 0 0 1px rgba(78, 177, 255, 0.45),
    0 6px 12px rgba(9, 19, 35, 0.26);
}

.nav-link:hover::after,
.nav-link:focus-visible::after {
  opacity: 1;
}

.main {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top {
  background: var(--brand-dark);
  color: #ecf3ff;
  border: 1px solid #21324f;
  border-radius: 14px;
  padding: 13px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 24px rgba(11, 20, 35, 0.22);
}

.top h1 {
  margin: 0;
  font-size: 20px;
}

.meta {
  margin-top: 4px;
  font-size: 12px;
  color: #b9c9e0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 5px 16px rgba(50, 70, 98, 0.08);
}

.panel-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f5f8fb;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 12px;
  color: #36465f;
}

.panel-body { padding: 10px 12px; }

.kpis {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(100px, 1fr));
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.kpi .value { margin-top: 6px; font-size: 20px; font-weight: 700; }
.kpi .sub { margin-top: 4px; font-size: 12px; color: var(--muted); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 12px;
}

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

.table th,
.table td {
  border-bottom: 1px solid #e6ecf2;
  padding: 8px 6px;
  text-align: left;
}

.table th { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.table th.sortable { white-space: nowrap; }

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-transform: inherit;
  font-size: inherit;
  font-weight: 700;
}

.sort-btn:hover {
  color: #3b6f9d;
}

.sort-icon {
  font-size: 11px;
  opacity: 0.9;
}

.pos { color: var(--green); font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }
.neutral { color: var(--muted); }

.stack {
  display: grid;
  gap: 10px;
}

.signal {
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
}

.signal[data-priority="high"] { border-left-color: var(--red); }
.signal[data-priority="medium"] { border-left-color: #d98b15; }
.signal-title { font-size: 13px; font-weight: 700; }
.signal-meta { margin-top: 3px; font-size: 12px; color: var(--muted); }

.controls {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

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

input,
select,
button,
textarea {
  font: inherit;
  border: 1px solid #c4d0df;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  padding: 0 10px;
}

button {
  cursor: pointer;
  background: #f5f8fc;
  font-weight: 600;
}

button.primary {
  background: linear-gradient(140deg, #49a5ff 0%, #2588e8 100%);
  color: #fff;
  border-color: #237ddb;
}

textarea {
  min-height: 88px;
  padding: 8px 10px;
  resize: vertical;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  border: 1px solid #cfe0f2;
  background: #f3f8ff;
  color: #234d79;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
}

.pro-wrap {
  border: 1px dashed #b7cbe4;
  border-radius: 12px;
  background: #f7fbff;
  padding: 12px;
}

.pro-wrap.hidden {
  display: none;
}

.pro-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pro-title {
  font-size: 13px;
  font-weight: 700;
  color: #274e79;
}

.pro-note {
  font-size: 12px;
  color: #4f6480;
}

.ops-dim-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
}

.ops-dim-list-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid #e1e8f1;
  border-radius: 10px;
}

.ops-dim-table thead th {
  position: sticky;
  top: 0;
  background: #f5f8fb;
  z-index: 2;
}

.ops-dim-table tr {
  cursor: pointer;
}

.ops-row-active td {
  background: #edf5ff;
}

.ops-dim-editor {
  border: 1px solid #e1e8f1;
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
}

.ops-dim-title {
  font-size: 13px;
  font-weight: 700;
  color: #274e79;
}

.ops-form-grid {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.hidden {
  display: none;
}

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .ops-dim-grid { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
  .terminal-shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 10px; }
  .top { flex-direction: column; align-items: flex-start; }
  .kpis { grid-template-columns: repeat(2, minmax(110px, 1fr)); }
}
