/* MBJS Brandenburg dashboards — light Brandenburg-branded theme.
   Colour anchors: state red #E2231A, warm off-white background, warm-grey text. */

:root {
  color-scheme: light;            /* opt out of Chrome auto-dark */

  /* Brand */
  --brand: #E2231A;
  --brand-dark: #B91D17;
  --brand-soft: #FBEEED;
  --brand-tint: #FDF7F6;

  /* Surfaces */
  --bg: #FAFAF6;
  --surface: #FFFFFF;
  --surface-2: #F5F2EB;
  --surface-hover: #F0EBE0;

  /* Lines */
  --line: #E8E4D8;
  --line-strong: #D7D1C2;

  /* Text */
  --txt: #1A1815;
  --txt-soft: #3A352D;
  --muted: #6B6557;
  --muted-2: #9C9587;

  /* Status */
  --ok: #2B8F4D;
  --warn: #C97C1B;
  --down: #C7372D;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(26, 24, 21, .06);
  --shadow-md: 0 4px 12px rgba(26, 24, 21, .08);
  --shadow-lg: 0 12px 32px rgba(26, 24, 21, .12);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable", "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: .92em;
  border: 1px solid var(--line);
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px 120px; }

/* ---- topbar ---------------------------------------------------------------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  margin-bottom: 32px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.topbar .inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar a:has(img.brand-logo) { display: block; flex-shrink: 0; }
.topbar img.brand-logo {
  height: 44px;
  width: auto;
  display: block;
}
.topbar .wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  border-left: 1px solid var(--line);
  padding-left: 16px;
  min-width: 0;
}
.topbar .wordmark .l1 {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -.005em;
  color: var(--txt);
}
.topbar .wordmark .l2 {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .03em;
  margin-top: 2px;
}
.topbar .spacer { flex: 1; }
.topbar .navlink {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--r-sm);
}
.topbar .navlink:hover { color: var(--brand-dark); background: var(--brand-soft); text-decoration: none; }

/* ---- page header ----------------------------------------------------------- */

header.page {
  margin-bottom: 28px;
}
.eyebrow {
  color: var(--brand);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: 11.5px;
}
h1 {
  font-size: 34px;
  margin: 8px 0 6px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--txt);
  line-height: 1.15;
}
.sub {
  color: var(--muted);
  font-size: 15px;
  max-width: 760px;
  line-height: 1.55;
}

/* ---- KPI cards ------------------------------------------------------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 28px 0;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.kpi:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.kpi .lab {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.kpi .val {
  font-size: 26px;
  font-weight: 800;
  margin-top: 8px;
  letter-spacing: -.02em;
  color: var(--txt);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.kpi .chg {
  font-size: 12.5px;
  margin-top: 6px;
  font-weight: 600;
}
.up { color: var(--ok); }
.down { color: var(--down); }

/* ---- chart controls -------------------------------------------------------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.seg { flex-wrap: wrap; }
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
}
.seg button.active {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.seg button:hover:not(.active) { color: var(--txt); background: rgba(0, 0, 0, .03); }

.rangebox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.rangebox select {
  background: var(--surface);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 30px 7px 10px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%236B6557' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.rangebox select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

/* ---- chart card ------------------------------------------------------------ */

.chartcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 20px 12px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.chartwrap { position: relative; min-height: 460px; }

/* ---- heatmap (CSS grid) --------------------------------------------------- */
.heatmap-host { width: 100%; padding: 4px 0 8px; }
.hm-wrap { display: flex; flex-direction: column; gap: 12px; }
.hm {
  display: grid; gap: 2px;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  width: 100%; overflow-x: auto;
}
.hm-corner { background: transparent; }
.hm-col-h {
  padding: 6px 4px; text-align: center; color: var(--muted);
  font-weight: 700; font-size: 11px; letter-spacing: .02em;
  border-bottom: 1px solid var(--line);
}
.hm-row-h {
  padding: 0 12px; display: flex; align-items: center; gap: 8px;
  color: var(--txt); font-weight: 600; font-size: 12.5px;
  border-right: 1px solid var(--line);
}
.hm-row-h .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.hm-cell {
  padding: 10px 4px; text-align: center; border-radius: 4px;
  font-weight: 600; font-size: 11.5px;
  transition: transform .12s ease;
}
.hm-cell:hover { transform: scale(1.06); cursor: default; outline: 2px solid var(--brand); }
.hm-legend {
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.hm-ramp {
  flex: 1; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, rgb(255,247,220) 0%, rgb(226,35,26) 100%);
  border: 1px solid var(--line);
}
.hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 10px 0 4px;
}

/* ---- legend ---------------------------------------------------------------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
}
.lg {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s ease;
  user-select: none;
  color: var(--txt-soft);
}
.lg .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lg.off { opacity: .38; }
.lg.off .dot { background: var(--muted-2) !important; }
.lg:hover { border-color: var(--brand); color: var(--brand-dark); }

/* ---- footer ---------------------------------------------------------------- */

footer.page-footer {
  margin-top: 36px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
footer.page-footer b { color: var(--txt-soft); }

/* ---- inline analyst panel ------------------------------------------------ */

.analyst { margin: 0 0 28px; }
.ap-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.ap-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brand);
}

.ap-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.ap-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ap-meta { flex: 1; min-width: 0; }
.ap-name { font-weight: 700; font-size: 14px; color: var(--txt); letter-spacing: -.005em; }
.ap-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.ap-regen {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 11.5px; font-weight: 600; padding: 6px 10px; border-radius: 7px;
  cursor: pointer; font-family: inherit; transition: all .15s ease;
}
.ap-regen:hover { color: var(--brand-dark); border-color: var(--brand); background: var(--brand-soft); }

.ap-msgs {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px;
}
.ap-msg {
  font-size: 14.5px; line-height: 1.6;
  padding: 12px 14px; border-radius: var(--r-md);
  white-space: pre-wrap; word-wrap: break-word; max-width: 92%;
}
.ap-msg.assistant {
  background: var(--surface-2); color: var(--txt);
  align-self: flex-start; border-bottom-left-radius: 6px;
}
.ap-msg.assistant.ap-msg-intro {
  background: transparent;
  padding: 0 0 4px 0;
  font-size: 15.5px;
  color: var(--txt);
  max-width: 100%;
  border-radius: 0;
}
.ap-msg.user {
  background: var(--brand); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 6px;
  font-size: 14px;
}
.ap-msg.system {
  background: var(--brand-tint); color: var(--txt-soft);
  border: 1px solid rgba(226, 35, 26, .15); align-self: stretch; max-width: 100%;
  font-size: 13.5px;
}
.ap-msg.error {
  background: #F9E8E6; color: #7A211C; align-self: stretch; max-width: 100%;
  font-size: 13px;
}
.ap-msg code {
  background: rgba(26, 24, 21, .07); padding: 1px 6px; border-radius: 4px;
  font-size: .9em; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.ap-msg.user code { background: rgba(255, 255, 255, .2); color: #fff; }
.ap-msg strong { font-weight: 700; }
.ap-cursor {
  display: inline-block; color: var(--brand); animation: ap-blink 1s steps(1) infinite;
}
@keyframes ap-blink { 50% { opacity: 0; } }

.ap-table {
  border-collapse: collapse; margin: 8px 0; font-size: 12.5px; width: auto;
}
.ap-table th, .ap-table td {
  padding: 5px 9px; border: 1px solid var(--line); text-align: left;
}
.ap-table th { background: var(--surface-2); font-weight: 700; }

.ap-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.ap-chips button {
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  font-family: inherit; transition: all .15s ease;
}
.ap-chips button:hover {
  color: var(--brand-dark); border-color: var(--brand); background: var(--brand-soft);
}

.ap-form {
  display: flex; gap: 8px; align-items: stretch;
}
.ap-form input {
  flex: 1; padding: 10px 14px; font-size: 14px; font-family: inherit;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--txt);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.ap-form input:focus {
  outline: none; border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.ap-form button {
  background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 0 18px; font-weight: 700; font-size: 13.5px;
  cursor: pointer; font-family: inherit; transition: background .15s ease;
}
.ap-form button:hover:not(:disabled) { background: var(--brand-dark); }
.ap-form button:disabled { opacity: .5; cursor: not-allowed; }

/* ---- responsive ----------------------------------------------------------- */

@media (max-width: 760px) {
  .wrap { padding: 0 16px 80px; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi .val { font-size: 22px; }
  h1 { font-size: 26px; }
  .chartwrap { height: 360px; }
  .controls { padding: 10px 12px; }
  .topbar img.brand-logo { height: 32px; }
  .topbar .wordmark .l1 { font-size: 13px; }
  .topbar .wordmark .l2 { font-size: 10.5px; }
  .ap-card { padding: 16px 16px 14px; }
  .ap-msg.assistant.ap-msg-intro { font-size: 14.5px; }
  .ap-chips button { font-size: 11.5px; padding: 5px 10px; }
}
