:root {
  --bg: #e8f2f7;
  --panel: #f5fbff;
  --card: #d7e2ee;
  --card-op: #d6ead7;
  --ink: #2a3542;
  --muted: #627080;
  --accent: #233f73;
  --positive: #16803c;
  --negative: #c01d1d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #e3eff5 0%, #edf4f8 70%, #f3f7fa 100%);
}

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

.side-nav {
  background: linear-gradient(180deg, #bfd3df, #b4ccd9);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #303944;
  display: grid;
  place-items: center;
  color: #fff;
}

.brand-badge svg { width: 24px; height: 24px; }

.nav-btn {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #314657;
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 10px 4px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.nav-btn svg { width: 16px; height: 16px; }
.nav-btn.active { background: rgba(255,255,255,0.65); color: #101820; }

.main-panel { padding: 18px 22px; }

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

h1 {
  margin: 4px 0 0;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 800;
}

.crumb { font-weight: 700; color: #38495f; }

.meta-wrap {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  line-height: 1.6;
  padding-top: 3px;
}

.controls-band {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
}

.time-toggle {
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(36, 63, 99, 0.15);
  border-radius: 20px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.time-chip {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #5a6778;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

.time-chip.active {
  background: #253f71;
  color: #fff;
}

.filter-wrap {
  display: flex;
  gap: 10px;
}

.filter-wrap label {
  background: rgba(255,255,255,0.66);
  border: 1px solid rgba(36, 63, 99, 0.15);
  border-radius: 20px;
  padding: 8px 12px;
  min-width: 190px;
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #4f5e70;
}

select {
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  color: #33465f;
  outline: none;
}

.dashboard-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 14px;
}

.screen { display: none; }
.screen.active { display: grid; }

.view-toggle {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.view-chip {
  border: 1px solid rgba(40,57,87,0.2);
  border-radius: 999px;
  background: rgba(255,255,255,0.65);
  color: #3c4f68;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
}

.view-chip.active {
  background: #253f71;
  color: #fff;
}

.panel {
  background: rgba(248, 252, 255, 0.68);
  border: 1px solid rgba(43, 69, 109, 0.15);
  border-radius: 18px;
  padding: 18px;
}

h2 {
  margin: -2px auto 14px;
  width: fit-content;
  padding: 9px 22px;
  border-radius: 999px;
  border: 1px solid rgba(40,57,87,0.2);
  background: #dbe7ee;
  font-size: 34px;
  letter-spacing: 0;
}

.chat-title {
  margin: 0;
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
}

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

.kpi-card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid rgba(47, 67, 100, 0.12);
  padding: 14px 16px;
}

.kpi-card.primary { background: #d0deee; }
.kpi-card.compact { padding: 12px; }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h3 {
  margin: 0;
  color: #5d6a7a;
  font-size: 14px;
  font-weight: 700;
}

.kpi-header svg {
  width: 18px;
  height: 18px;
  padding: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
}

.kpi-main {
  margin-top: 8px;
  display: flex;
  gap: 14px;
  align-items: baseline;
}

.value {
  font-size: 42px;
  font-weight: 800;
  color: #24385f;
  line-height: 1;
}

.delta {
  font-size: 17px;
  font-weight: 700;
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral { color: #647487; }

.split-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  color: #647385;
  font-size: 12px;
  font-weight: 600;
}

.split-value {
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.split-value span:first-child {
  font-size: 32px;
  font-weight: 800;
  color: #20355b;
}

.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.small-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.small-grid .split-value span:first-child { font-size: 28px; }
.small-grid .delta { font-size: 13px; }

.operations-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#chatScreen {
  margin-top: 14px;
}

.chat-panel {
  background: rgba(248, 252, 255, 0.72);
  border: 1px solid rgba(43, 69, 109, 0.15);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.chat-kicker {
  margin: 0;
  color: #5f6f84;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.chat-subtitle {
  margin: 4px 0 0;
  color: #5f6f84;
  font-size: 12px;
  max-width: 420px;
  text-align: right;
}

.chat-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr;
  gap: 8px;
}

.chat-toolbar label {
  background: rgba(255,255,255,0.56);
  border: 1px solid rgba(40,57,87,0.16);
  border-radius: 12px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}

.chat-toolbar input,
.chat-toolbar select {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  color: #33465f;
}

.chat-mode-toggle {
  display: flex;
  gap: 6px;
}

.chat-mode-chip {
  border: 1px solid rgba(40,57,87,0.2);
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  color: #3c4f68;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.chat-mode-chip.active {
  background: #253f71;
  color: #fff;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-chip {
  border: 1px solid rgba(40,57,87,0.2);
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  color: #3c4f68;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

.chat-messages {
  min-height: 280px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid rgba(40,57,87,0.14);
  border-radius: 12px;
  background: rgba(230, 241, 249, 0.5);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.chat-bubble {
  max-width: 86%;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.chat-bubble.user {
  margin-left: auto;
  background: #dbe7f7;
  border: 1px solid rgba(35,63,113,0.2);
}

.chat-bubble.assistant {
  margin-right: auto;
  background: #edf6ed;
  border: 1px solid rgba(29,93,52,0.18);
}

.chat-form {
  display: grid;
  gap: 8px;
}

.chat-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 80px;
  border: 1px solid rgba(40,57,87,0.18);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
}

.op-card {
  background: var(--card-op);
  border: 1px solid rgba(54, 94, 64, 0.12);
  border-radius: 12px;
  padding: 14px;
  min-height: 128px;
}

.op-card.wide {
  grid-column: 1 / -1;
  min-height: 150px;
}

.op-value {
  margin-top: 16px;
  font-size: 54px;
  font-weight: 800;
  color: #1d5d34;
  line-height: 1;
}

.alerts-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.alerts-grid > div {
  background: rgba(255,255,255,0.3);
  border-radius: 10px;
  padding: 8px 10px;
}

.alerts-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 34px;
  color: #1d5d34;
}

@media (max-width: 1400px) {
  h1 { font-size: 30px; }
  h2 { font-size: 30px; }
  .value { font-size: 36px; }
  .op-value { font-size: 46px; }
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-nav {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
  }
  .brand-badge { display: none; }
  .nav-btn { width: auto; padding: 8px 10px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .controls-band { grid-template-columns: 1fr; }
  .chat-toolbar { grid-template-columns: 1fr; }
  .chat-head { flex-direction: column; }
  .chat-subtitle { text-align: left; max-width: none; }
}
