/* Fluxraum Insights -- same palette/shapes as the FLX Application Hosting
   UI (poc-flx-application-hosting-service/control-plane/web): warm off-white
   background, near-black ink, the two fluxraum greens as accent glow. */
:root {
  color-scheme: light;
  --bg: #FFFEF9;
  --ink: #111815;
  --ink-soft: #4b5952;
  --ink-faint: #8a948f;
  --green: #42EAAB;
  --green-bright: #34FFD0;
  --green-soft: #e4fbf1;
  --green-ink: #0d7a54;
  --border: #e7e4da;
  --card: #fff;
  --warn-soft: #fff4e0;
  --warn-ink: #a15c00;
  --bad-soft: #fdecea;
  --bad-ink: #c0392b;
  --shadow: 0 1px 2px rgba(17,24,21,.04), 0 8px 24px rgba(17,24,21,.05);
  --shadow-hover: 0 4px 8px rgba(17,24,21,.06), 0 16px 32px rgba(17,24,21,.08);
  --radius: 18px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
a { color: inherit; }
.glow {
  position: fixed; top: -260px; right: -200px; width: 620px; height: 620px;
  background: radial-gradient(closest-side, var(--green-bright), var(--green) 55%, transparent 75%);
  filter: blur(70px); opacity: 0.5; z-index: 0; pointer-events: none;
}

/* --- header ----------------------------------------------------------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  padding: 14px 32px; background: var(--ink); color: var(--bg);
  display: flex; align-items: center; gap: 24px;
}
header.top .brand {
  font-size: 15px; margin: 0; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  text-decoration: none; display: flex; align-items: center; gap: 10px; white-space: nowrap;
}
.brand .hex { width: 22px; height: 22px; }
header.top .spacer { flex: 1; }
.env-switch { display: flex; background: rgba(255,254,249,.08); border-radius: 999px; padding: 3px; gap: 2px; }
.env-switch button {
  background: transparent; color: var(--bg); opacity: .7; padding: 6px 14px; font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase; border-radius: 999px;
}
.env-switch button:hover { opacity: 1; }
.env-switch button.active { background: var(--green); color: var(--ink); opacity: 1; }
.env-switch button.active.env-prod { background: var(--green); }
.env-switch button.active.env-dev { background: #ffd27a; }
.env-switch button:disabled { opacity: .3; cursor: not-allowed; }
.user { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.user button { background: transparent; color: var(--bg); border: 1px solid rgba(255,254,249,.25); padding: 5px 12px; font-size: 12px; }

/* --- layout ----------------------------------------------------------- */
main { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 28px 32px 64px; }
.crumbs { font-size: 12px; color: var(--ink-soft); margin: 0 0 18px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs a { text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-soft); font-weight: 700; margin: 0 0 6px; }
.hero-title { font-size: 36px; font-weight: 500; margin: 0 0 10px; letter-spacing: -0.015em; line-height: 1.15; }
.hero-sub { font-size: 15px; color: var(--ink-soft); margin: 0 0 8px; max-width: 680px; line-height: 1.55; }
h2.section { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); font-weight: 700; margin: 36px 0 14px; }

/* --- tiles ------------------------------------------------------------ */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; min-height: 200px;
  box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative; overflow: hidden;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: #d6eee3; }
.tile:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.tile .icon {
  width: 44px; height: 44px; border-radius: 14px; background: var(--green-soft); color: var(--green-ink);
  display: grid; place-items: center;
}
.tile .icon svg { width: 24px; height: 24px; }
.tile.folder .icon { background: var(--ink); color: var(--green); }
.tile.folder::after {
  content: ""; position: absolute; right: -40px; bottom: -40px; width: 140px; height: 140px;
  background: radial-gradient(closest-side, var(--green-bright), transparent); opacity: .25; pointer-events: none;
}
.tile h3 { margin: 4px 0 0; font-size: 17px; font-weight: 700; }
.tile .subtitle { font-size: 13px; color: var(--ink); font-weight: 500; margin: 0; }
.tile p { margin: 0; font-size: 13px; color: var(--ink-soft); flex: 1; }
.tile .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--ink-faint); }
.badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: var(--green-soft); color: var(--green-ink); padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.badge.dark { background: var(--ink); color: var(--green); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.new { background: var(--green); color: var(--ink); }
.empty-state {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 40px; text-align: center;
  color: var(--ink-soft); background: rgba(255,255,255,.5);
}

/* --- buttons & forms -------------------------------------------------- */
button {
  font: inherit; font-weight: 600; border: none; border-radius: 44px; padding: 9px 18px;
  background: var(--ink); color: var(--bg); cursor: pointer; transition: opacity .12s;
}
button:hover { opacity: .88; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--green-soft); color: var(--ink); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
button.danger { background: var(--bad-soft); color: var(--bad-ink); }
button.small { padding: 5px 12px; font-size: 12px; }
input, select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
  color: var(--ink); width: 100%; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
input[type=number] { font-variant-numeric: tabular-nums; text-align: right; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green-ink); }

/* --- app view --------------------------------------------------------- */
.app-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 20px; }
.app-head .hero-title { font-size: 30px; }
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow);
}
.toolbar .scenario-name { font-size: 13px; font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar .scenario-name .dirty { color: var(--warn-ink); font-weight: 700; }
.toolbar .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); font-weight: 700; }
.app-grid { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 1000px) { .app-grid { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.inputs { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
@media (max-width: 1000px) { .inputs { position: static; max-height: none; } }
.inputs details { border-bottom: 1px solid var(--border); }
.inputs details:last-child { border-bottom: none; }
.inputs summary {
  list-style: none; cursor: pointer; padding: 14px 18px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); display: flex; justify-content: space-between;
}
.inputs summary::-webkit-details-marker { display: none; }
.inputs summary::after { content: "+"; font-size: 16px; line-height: 1; color: var(--ink-faint); }
.inputs details[open] summary::after { content: "–"; }
.fields { padding: 0 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.field { display: grid; grid-template-columns: 1fr 130px; gap: 10px; align-items: center; }
.field label { font-size: 13px; font-weight: 500; }
.field .unit { display: block; font-size: 11px; color: var(--ink-faint); font-weight: 400; }
.field.changed label { color: var(--green-ink); }
.field.changed input { border-color: var(--green); }
.field.bool { grid-template-columns: 1fr auto; }
.matrix-wrap { padding: 0 10px 14px; overflow-x: auto; }
table.matrix { border-collapse: separate; border-spacing: 4px; width: 100%; }
table.matrix th { font-size: 11px; color: var(--ink-soft); font-weight: 700; text-align: right; padding: 2px 4px; }
table.matrix th:first-child { text-align: left; }
table.matrix td.rowlabel { font-size: 12px; font-weight: 500; padding-right: 4px; min-width: 110px; }
table.matrix td.rowlabel .unit { display: block; font-size: 10px; color: var(--ink-faint); font-weight: 400; }
table.matrix input { padding: 5px 7px; font-size: 12px; min-width: 70px; }
table.matrix td.changed input { border-color: var(--green); }
.colorchip { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; vertical-align: 1px; }
[title] { cursor: help; }
button[title], a[title] { cursor: pointer; }

.results { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.results.loading { opacity: .55; transition: opacity .2s; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 700; }
.kpi .k-value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi .k-value small { font-size: 13px; color: var(--ink-soft); font-weight: 500; margin-left: 3px; }
.kpi .k-hint { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.kpi.good { border-color: #bdf0da; background: linear-gradient(180deg, #f3fdf8, #fff); }
.kpi.good .k-value { color: var(--green-ink); }
.kpi.bad .k-value { color: var(--bad-ink); }
.chart-card { padding: 18px 18px 10px; }
.chart-card h4, .table-card h4 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--ink-faint); font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: #efece3; }
.chart .axis-title { font-size: 11px; fill: var(--ink-soft); font-weight: 600; }
.chart .marker line { stroke: var(--ink-soft); stroke-dasharray: 3 4; }
.chart .marker text { font-size: 10px; fill: var(--ink-soft); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); margin: 4px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow-hover); white-space: nowrap; z-index: 5;
  font-variant-numeric: tabular-nums;
}
.tooltip .t-title { font-weight: 700; margin-bottom: 4px; opacity: .8; }
.tooltip .t-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tooltip .t-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.table-card { padding: 18px; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--ink-soft); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }
table.data td { font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: none; }
.notes { font-size: 12px; color: var(--ink-soft); padding: 14px 18px; }
.notes ul { margin: 0; padding-left: 18px; }
.notes li { margin: 3px 0; }

/* --- drawer / dialog -------------------------------------------------- */
dialog { border: none; border-radius: 20px; padding: 0; width: min(460px, 92vw); box-shadow: 0 24px 64px rgba(17,24,21,.25); color: var(--ink); }
dialog.wide { width: min(640px, 94vw); }
dialog::backdrop { background: rgba(17,24,21,.45); }
.dialog-body { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dialog-body h3 { margin: 0; font-size: 17px; }
.dialog-body label { font-size: 13px; color: var(--ink-soft); font-weight: 600; display: flex; flex-direction: column; gap: 5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.scenario-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.scenario-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px;
}
.scenario-item.current { border-color: var(--green); background: #f6fdf9; }
.scenario-item .s-main { flex: 1; min-width: 0; }
.scenario-item .s-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenario-item .s-meta { font-size: 11px; color: var(--ink-faint); }

/* --- banners / toasts ------------------------------------------------- */
.banner { padding: 10px 14px; border-radius: 12px; font-size: 13px; margin-bottom: 16px; }
.banner.error { background: var(--bad-soft); color: var(--bad-ink); }
.banner.info { background: var(--warn-soft); color: var(--warn-ink); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 50; box-shadow: var(--shadow-hover);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.spinner { width: 28px; height: 28px; border: 3px solid var(--green-soft); border-top-color: var(--green-ink); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
footer.foot { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 0 32px 32px; font-size: 11px; color: var(--ink-faint); display: flex; gap: 12px; flex-wrap: wrap; }

@media (max-width: 640px) {
  header.top { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  header.top .user span { display: none; }
  main { padding: 20px 16px 48px; }
  .hero-title { font-size: 28px; }
  .field { grid-template-columns: 1fr 110px; }
  footer.foot { padding: 0 16px 24px; }
}
