/* ============ GCP Cost Anomaly Dashboard — Dark FinOps Theme ============ */
:root {
  --bg: #0b0f17;
  --bg-2: #101623;
  --panel: #131b2c;
  --panel-2: #182238;
  --border: #223049;
  --text: #e6ecf6;
  --text-dim: #8b9bb4;
  --text-faint: #5b6b85;
  --blue: #4f8ef7;
  --blue-2: #7db2ff;
  --green: #2ee6a8;
  --red: #ff5d73;
  --amber: #ffb02e;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --mono: "JetBrains Mono", monospace;
}

/* ============ Light theme — "warm daylight", easy on the eyes ============
   Deliberately NOT pure white: a soft blue-tinted parchment base with real
   depth (layered surfaces + coloured shadows) so the UI keeps its structure
   instead of flattening into a white sheet. */
html.light {
  --bg: #eef1f8;          /* page: soft blue-grey, never #fff */
  --bg-2: #e4e9f4;        /* recessed (inputs, tabs, tracks) */
  --panel: #fbfcfe;       /* raised card */
  --panel-2: #f1f4fa;     /* nested surface */
  --border: #cdd6e8;
  --text: #16202f;
  --text-dim: #4d5d7a;
  --text-faint: #7688a5;
  --blue: #2d6ae0;
  --blue-2: #17489f;
  --green: #058a63;
  --red: #cf2440;
  --amber: #a86800;
  /* layered, blue-tinted shadow = perceptible elevation on a light bg */
  --shadow: 0 1px 2px rgba(22, 32, 47, 0.05), 0 8px 24px rgba(45, 106, 224, 0.09);
}
html.light body {
  background:
    radial-gradient(1100px 560px at 82% -12%, rgba(45, 106, 224, 0.13), transparent 62%),
    radial-gradient(900px 520px at -12% 18%, rgba(5, 138, 99, 0.10), transparent 60%),
    radial-gradient(700px 700px at 50% 115%, rgba(132, 89, 245, 0.07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
html.light .topbar {
  background: rgba(251, 252, 254, 0.82);
  border-bottom-color: rgba(205, 214, 232, 0.9);
  box-shadow: 0 1px 12px rgba(45, 106, 224, 0.06);
}
html.light .modal-backdrop { background: rgba(28, 44, 74, 0.34); }
html.light .modal { box-shadow: 0 24px 70px rgba(22, 40, 75, 0.22); }
/* cards get a crisp top highlight + gentle gradient instead of flat white */
html.light .panel,
html.light .kpi-card {
  background: linear-gradient(168deg, #ffffff 0%, var(--panel-2) 100%);
  border-color: #d5dded;
}
html.light .watch-card { background: linear-gradient(168deg, #ffffff, var(--panel-2)); }
html.light .watch-card:hover { box-shadow: 0 10px 26px rgba(45, 106, 224, 0.16); }
html.light .watch-card.spike { background: linear-gradient(168deg, rgba(207,36,64,0.07), var(--panel)); }
html.light .watch-card.drop  { background: linear-gradient(168deg, rgba(5,138,99,0.07), var(--panel)); }
html.light tbody tr:hover { background: rgba(45, 106, 224, 0.06); }
html.light tbody td { border-bottom-color: rgba(205, 214, 232, 0.75); }
html.light .field input,
html.light .field select,
html.light .field-input,
html.light .chat-input-row input {
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(22, 32, 47, 0.06);
}
html.light .btn-ghost { background: #ffffff; }
html.light .btn-ghost:hover { background: #f4f7fd; }
html.light .theme-toggle { background: #dfe6f4; }
html.light .alert-item { background: #ffffff; }
html.light .toast { background: #ffffff; box-shadow: 0 12px 40px rgba(22, 40, 75, 0.22); }
html.light .chat-msg.bot .chat-bubble { background: #ffffff; }
html.light .chat-bubble code { background: #eef1f8; }
html.light ::-webkit-scrollbar-thumb { background: #c3cee2; }
html.light ::-webkit-scrollbar-thumb:hover { background: #a9b8d4; }
/* keep the accent pills readable on light surfaces */
html.light .watch-type.project { background: rgba(45,106,224,0.12); color: var(--blue-2); }
html.light .watch-type.sku { background: rgba(112,66,232,0.12); color: #5b30c0; }
html.light .chip { background: rgba(45,106,224,0.10); color: var(--blue-2); }
html.light .pill.ok { background: rgba(5,138,99,0.13); }
html.light .pill.chan { background: rgba(45,106,224,0.12); color: var(--blue-2); }

/* smooth the flip between themes */
body, .topbar, .panel, .kpi-card, .watch-card, .modal, .field input,
.field select, .field-input, .btn, .tab, .seg button, table, tbody td {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}


* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(79, 142, 247, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(46, 230, 168, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ============ Top Bar ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
  flex-wrap: wrap; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--blue), #8459f5);
  color: #fff; box-shadow: 0 4px 18px rgba(79, 142, 247, 0.4);
}
.brand h1 { font-size: 17px; font-weight: 800; letter-spacing: 0.2px; }
.brand-sub { font-size: 11.5px; color: var(--text-dim); letter-spacing: 1.2px; text-transform: uppercase; }

.topbar-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim); font-family: var(--mono);
}
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-blue { background: var(--blue); box-shadow: 0 0 8px var(--blue); }
.dot-green { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ============ Buttons ============ */
.btn {
  border: none; cursor: pointer; font-family: inherit;
  font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; border-radius: 10px;
  transition: all 0.18s ease;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue), #6a7ef7);
  color: #fff; box-shadow: 0 4px 14px rgba(79, 142, 247, 0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79, 142, 247, 0.5); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--blue); }
.btn-danger {
  background: transparent; color: var(--red);
  border: 1px solid rgba(255, 93, 115, 0.45);
}
.btn-danger:hover { background: rgba(255, 93, 115, 0.12); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.theme-toggle {
  width: 52px; height: 28px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-2); cursor: pointer; position: relative; flex-shrink: 0;
  transition: all 0.2s;
}
.theme-toggle::after {
  content: "🌙"; position: absolute; top: 2px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px;
  background: var(--panel); transition: all 0.25s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
html.light .theme-toggle::after { content: "☀️"; left: 26px; }
.sync-icon { display: inline-block; }
.btn.syncing .sync-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.tab {
  border: none; background: transparent; color: var(--text-dim);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 15px; border-radius: 9px; cursor: pointer; transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--blue); color: #fff; box-shadow: 0 2px 10px rgba(79, 142, 247, 0.4); }
.tabpane[hidden] { display: none; }

/* ============ Layout ============ */
.container { max-width: 1440px; margin: 0 auto; padding: 26px 28px 60px; }

.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px; margin-bottom: 22px;
}
.kpi-card {
  background: linear-gradient(160deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  opacity: 0.6;
}
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--text-dim); margin-bottom: 8px; }
.kpi-value { font-size: 30px; font-weight: 800; font-family: var(--mono); letter-spacing: -0.5px; }
.kpi-delta { margin-top: 6px; font-size: 13px; font-weight: 600; }
.kpi-delta.up { color: var(--red); }
.kpi-delta.down { color: var(--green); }
.kpi-delta.muted { color: var(--text-faint); font-weight: 500; }
.kpi-card.clickable { cursor: pointer; transition: all 0.18s; }
.kpi-card.clickable:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(79,142,247,0.2); }

/* ============ Panels ============ */
.panel {
  background: linear-gradient(160deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 18px; flex-wrap: wrap;
}
.panel-head h2 { font-size: 16px; font-weight: 700; }
.panel-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }
.hint { font-size: 12px; color: var(--text-faint); font-weight: 500; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* ============ Segmented control ============ */
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg.full { width: 100%; }
.seg.full button { flex: 1; }
.seg button {
  border: none; background: transparent; color: var(--text-dim);
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.seg button.active { background: var(--blue); color: #fff; box-shadow: 0 2px 10px rgba(79, 142, 247, 0.4); }

/* ============ Watchlist grid ============ */
.watch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.watch-card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; position: relative; transition: all 0.2s;
}
.watch-card:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.watch-card.spike { border-color: rgba(255, 93, 115, 0.55); background: linear-gradient(160deg, rgba(255,93,115,0.09), var(--panel-2)); }
.watch-card.drop  { border-color: rgba(46, 230, 168, 0.5); background: linear-gradient(160deg, rgba(46,230,168,0.08), var(--panel-2)); }

.watch-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.watch-name { font-weight: 700; font-size: 14px; word-break: break-all; cursor: pointer; }
.watch-name:hover { color: var(--blue-2); }
.watch-type {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  padding: 3px 8px; border-radius: 6px; font-weight: 700; white-space: nowrap;
}
.watch-type.project { background: rgba(79, 142, 247, 0.16); color: var(--blue-2); }
.watch-type.sku { background: rgba(132, 89, 245, 0.18); color: #b39bff; }

.watch-cost { margin: 12px 0 4px; display: flex; align-items: baseline; gap: 10px; }
.watch-cost .cur { font-size: 24px; font-weight: 800; font-family: var(--mono); }
.watch-badge {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  font-family: var(--mono);
}
.watch-badge.ok { background: rgba(139, 155, 180, 0.12); color: var(--text-dim); }
.watch-badge.spike { background: rgba(255, 93, 115, 0.16); color: var(--red); animation: pulse 2s infinite; }
.watch-badge.drop { background: rgba(46, 230, 168, 0.14); color: var(--green); }
.watch-badge.no-data { background: rgba(139,155,180,0.1); color: var(--text-faint); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.watch-base { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }
.watch-spark { margin-top: 10px; height: 42px; }
.watch-remove {
  position: absolute; top: 10px; right: 10px;
  background: transparent; border: none; color: var(--text-faint);
  cursor: pointer; font-size: 14px; padding: 4px; border-radius: 6px;
  opacity: 0; transition: all 0.15s;
}
.watch-card:hover .watch-remove { opacity: 1; }
.watch-remove:hover { color: var(--red); background: rgba(255, 93, 115, 0.12); }

/* ============ Charts ============ */
.chart-wrap { height: 300px; position: relative; }
.chart-wrap.tall { height: 380px; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-faint); padding: 8px 10px; border-bottom: 1px solid var(--border);
  font-weight: 600;
}
tbody td { padding: 10px; border-bottom: 1px solid rgba(34, 48, 73, 0.5); vertical-align: middle; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(79, 142, 247, 0.05); }
th.num, td.num { text-align: right; font-family: var(--mono); }
.cell-name { cursor: pointer; font-weight: 600; }
.cell-name:hover { color: var(--blue-2); }
.cell-sub { display: block; font-size: 11px; color: var(--text-faint); font-weight: 400; margin-top: 2px; }
.trend-up { color: var(--red); font-weight: 700; font-family: var(--mono); font-size: 12.5px; }
.trend-down { color: var(--green); font-weight: 700; font-family: var(--mono); font-size: 12.5px; }
.trend-flat { color: var(--text-faint); font-family: var(--mono); font-size: 12.5px; }
.watch-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
}
.watch-btn:hover { border-color: var(--amber); color: var(--amber); }
.watch-btn.watched { border-color: var(--amber); color: var(--amber); background: rgba(255,176,46,0.1); }

/* ============ Alert feed ============ */
.alert-feed { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.alert-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px;
}
.alert-item.spike { border-left: 3px solid var(--red); }
.alert-item.drop { border-left: 3px solid var(--green); }
.alert-ico { font-size: 20px; }
.alert-main { flex: 1; min-width: 0; }
.alert-title { font-weight: 700; font-size: 13.5px; }
.alert-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; font-family: var(--mono); }
.alert-pct { font-family: var(--mono); font-weight: 800; font-size: 16px; white-space: nowrap; }
.alert-pct.spike { color: var(--red); }
.alert-pct.drop { color: var(--green); }
.alert-slack { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

/* ============ Empty states ============ */
.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 40px 20px;
  color: var(--text-faint); font-size: 14px; line-height: 1.7;
}
.empty-state.small { padding: 20px; }
.empty-icon { font-size: 34px; margin-bottom: 10px; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 14, 0.72); backdrop-filter: blur(4px);
  display: grid; place-items: center;
  /* generous gutter so a tall modal never touches the viewport edges */
  padding: clamp(12px, 4vh, 40px) clamp(12px, 3vw, 32px);
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 520px;
  /* never exceed the space actually left by the backdrop padding */
  max-height: calc(100vh - clamp(24px, 8vh, 80px));
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.22s ease;
}
.modal.wide { max-width: 860px; }
.modal.xwide { max-width: min(1180px, 96vw); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border);
  flex: 0 0 auto;          /* header must never shrink or scroll away */
}
.modal-head h3 { font-size: 16px; line-height: 1.35; word-break: break-word; }
.modal-head > div { min-width: 0; }
.modal-close {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 15px; cursor: pointer; padding: 6px; border-radius: 8px; flex-shrink: 0;
}
.modal-close:hover { color: var(--text); background: var(--panel-2); }
/* the body is the ONLY scrolling region → rows can never spill over the
   header/footer or get clipped by the modal edge */
.modal-body {
  padding: 18px 22px; display: flex; flex-direction: column; gap: 14px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
}
.modal-body > .table-wrap { max-width: 100%; }
/* sticky header for long tables inside a popup */
.modal-body table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel); backdrop-filter: blur(6px);
}
.modal-body table td { word-break: break-word; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 14px 22px; border-top: 1px solid var(--border); flex: 0 0 auto;
}
@media (max-width: 640px) {
  .modal { max-width: 100%; border-radius: 12px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 14px; padding-right: 14px; }
}


.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.field input {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: inherit; font-size: 14px; padding: 10px 14px;
  outline: none; transition: border 0.15s;
}
.field input:focus { border-color: var(--blue); }
.field select {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: inherit; font-size: 13.5px; padding: 9px 12px;
  outline: none;
}
.field select[size] { padding: 4px; }
.field select option { padding: 7px 10px; background: var(--bg-2); }
.field select option:checked { background: var(--blue); color: #fff; }
.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.field.grow { flex: 1; min-width: 180px; }
.field-input {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: inherit; font-size: 14px; padding: 10px 14px; outline: none;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-dim); cursor: pointer; }
.check input { accent-color: var(--blue); width: 16px; height: 16px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(79,142,247,0.12); color: var(--blue-2);
  border: 1px solid rgba(79,142,247,0.3); border-radius: 999px;
  font-size: 12px; font-weight: 600; padding: 4px 12px; font-family: var(--mono);
}
.chip button { background: none; border: none; color: inherit; cursor: pointer; font-size: 11px; padding: 0; }

.picker-list {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2);
}
.picker-list.tall { max-height: 320px; }
.picker-check { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; border-bottom: 1px solid rgba(34,48,73,0.5); font-size: 13px; }
.picker-check:hover { background: rgba(79,142,247,0.07); }
.picker-check input { accent-color: var(--blue); flex-shrink: 0; }
.picker-check .pc-sub { color: var(--text-faint); font-size: 11px; font-family: var(--mono); margin-left: auto; white-space: nowrap; }
.picker-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid rgba(34,48,73,0.5);
  transition: background 0.12s;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover { background: rgba(79, 142, 247, 0.08); }
.picker-item.selected { background: rgba(79, 142, 247, 0.18); }
.picker-item .pi-name { font-size: 13px; font-weight: 600; word-break: break-all; }
.picker-item .pi-sub { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.picker-item .pi-cost { font-family: var(--mono); font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.picker-empty { padding: 22px; text-align: center; color: var(--text-faint); font-size: 13px; }
.picker-manual { border-top: 1px dashed var(--border); padding-top: 12px; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); font-size: 13.5px; font-weight: 600;
  padding: 12px 22px; border-radius: 12px; z-index: 200;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  animation: modalIn 0.2s ease;
}
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--green); }
.toast[hidden] { display: none; }

/* ============ Budget usage bar ============ */
.usage-bar { position: relative; width: 140px; height: 10px; background: var(--bg-2); border-radius: 6px; overflow: hidden; display: inline-block; vertical-align: middle; }
.usage-bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--green); }
.usage-bar.warn > i { background: var(--amber); }
.usage-bar.over > i { background: var(--red); }
.usage-pct { font-family: var(--mono); font-size: 12px; margin-left: 8px; }

/* ============ Status pills ============ */
.pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; font-family: var(--mono); }
.pill.ok { background: rgba(46,230,168,0.12); color: var(--green); }
.pill.spike { background: rgba(255,93,115,0.15); color: var(--red); }
.pill.drop { background: rgba(46,230,168,0.14); color: var(--green); }
.pill.no-data { background: rgba(139,155,180,0.1); color: var(--text-faint); }
.pill.chan { background: rgba(79,142,247,0.12); color: var(--blue-2); margin-right: 4px; }

/* ============ Chat ============ */
.chat-panel { display: flex; flex-direction: column; min-height: 70vh; }
.chat-box {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
  padding: 14px 6px; min-height: 45vh; max-height: 58vh;
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble {
  max-width: 78%; padding: 12px 16px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.65; word-wrap: break-word;
}
.chat-msg.bot .chat-bubble { background: var(--panel-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.chat-msg.user .chat-bubble { background: linear-gradient(135deg, var(--blue), #6a7ef7); color: #fff; border-top-right-radius: 4px; }
.chat-bubble table { border-collapse: collapse; margin: 8px 0; font-size: 12.5px; }
.chat-bubble th, .chat-bubble td { border: 1px solid var(--border); padding: 5px 9px; }
.chat-bubble code { background: var(--bg-2); padding: 1px 6px; border-radius: 5px; font-family: var(--mono); font-size: 12px; }
.chat-bubble ul, .chat-bubble ol { padding-left: 20px; margin: 6px 0; }
.chat-tools { font-size: 11px; color: var(--text-faint); font-family: var(--mono); margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 6px; }
.chat-input-row { display: flex; gap: 10px; margin-top: 14px; }
.chat-input-row input {
  flex: 1; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-family: inherit; font-size: 14px; padding: 13px 16px; outline: none;
}
.chat-input-row input:focus { border-color: var(--blue); }
.chat-typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.chat-typing i { width: 7px; height: 7px; background: var(--text-dim); border-radius: 50%; animation: bounce 1.2s infinite; }
.chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%,60%,100% { transform: none; opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ============ Excel-style data table ============ */
.data-table { table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.data-table thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--panel-2); padding: 0;
  border-bottom: 2px solid var(--border);
  text-transform: none; letter-spacing: 0; font-size: 11.5px;
}
html.light .data-table thead th { background: #eef2fa; }
.th-inner {
  display: flex; align-items: center; gap: 4px;
  padding: 9px 8px; cursor: pointer; user-select: none;
  border-right: 1px solid var(--border);
}
.data-table thead th:last-child .th-inner { border-right: none; }
.th-inner:hover { background: rgba(79, 142, 247, 0.10); }
.th-label {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px;
}
.th-inner.active .th-label { color: var(--blue); }
/* ONE arrow that flips direction; dimmed until the column is sorted */
.th-sort {
  font-size: 11px; line-height: 1; opacity: 0.28; flex-shrink: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.th-inner.sorted .th-sort { opacity: 1; color: var(--blue); }
.th-filter {
  font-size: 9px; flex-shrink: 0; opacity: 0.45;
  border: 1px solid transparent; border-radius: 4px; padding: 1px 3px;
}
.th-inner:hover .th-filter { opacity: 0.9; border-color: var(--border); }
.th-filter.on { opacity: 1; color: var(--blue); border-color: var(--blue); background: rgba(79,142,247,0.12); }
/* zebra striping + tidy cells */
.data-table tbody tr:nth-child(even) { background: rgba(127, 145, 180, 0.045); }
.data-table tbody tr:hover { background: rgba(79, 142, 247, 0.10); cursor: pointer; }
.data-table tbody tr.selected { background: rgba(79, 142, 247, 0.16); }
.data-table tbody td {
  padding: 9px 8px; vertical-align: top; font-size: 12.8px;
  border-bottom: 1px solid rgba(127, 145, 180, 0.18);
  overflow: hidden; text-overflow: ellipsis;
}
.data-table td.col-check, .data-table th.col-check { width: 34px; text-align: center; }
.data-table .col-project { width: 13%; }
.data-table .col-res     { width: 19%; }
.data-table .col-type    { width: 11%; }
.data-table .col-config  { width: 17%; }
.data-table .col-util    { width: 11%; }
.data-table .col-cost    { width: 11%; }
.data-table .col-recs    { width: 18%; }
.cell-wrap { white-space: normal; word-break: break-word; line-height: 1.45; }
.cell-mono { font-family: var(--mono); font-size: 11.5px; }
/* compact recommendation badge instead of a wall of text */
.rec-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255, 176, 46, 0.14); color: var(--amber);
  border: 1px solid rgba(255, 176, 46, 0.35); border-radius: 999px;
  font-size: 11px; font-weight: 700; padding: 2px 9px; white-space: nowrap;
}
.rec-preview {
  display: block; font-size: 11px; color: var(--text-faint); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.type-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; white-space: nowrap;
  padding: 2px 8px; border-radius: 6px;
  background: rgba(79, 142, 247, 0.14); color: var(--blue-2);
}
.type-badge.compute { background: rgba(79,142,247,0.16); color: var(--blue-2); }
.type-badge.disk    { background: rgba(132,89,245,0.16); color: #b39bff; }
.type-badge.sql     { background: rgba(255,176,46,0.16); color: var(--amber); }
.type-badge.storage { background: rgba(46,230,168,0.14); color: var(--green); }
.type-badge.other   { background: rgba(139,155,180,0.14); color: var(--text-dim); }
html.light .type-badge.disk { color: #5b30c0; }
html.light .type-badge.other { color: var(--text-dim); }

/* ============ Floating column menu (filter + sort) ============ */
.col-menu {
  position: absolute; z-index: 300; width: 268px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn 0.14s ease;
}
html.light .col-menu { box-shadow: 0 18px 44px rgba(22, 40, 75, 0.20); }
.col-menu[hidden] { display: none; }
.col-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.col-menu-sort { display: flex; flex-direction: column; border-bottom: 1px solid var(--border); }
.col-menu-sort button {
  background: transparent; border: none; color: var(--text);
  font-family: inherit; font-size: 12.5px; text-align: left;
  padding: 8px 12px; cursor: pointer;
}
.col-menu-sort button:hover { background: rgba(79, 142, 247, 0.12); }
.col-menu-sort button.active { color: var(--blue); font-weight: 700; background: rgba(79,142,247,0.10); }
.col-menu #colMenuSearch { margin: 10px 12px 6px; font-size: 12.5px; padding: 7px 10px; }
.col-menu-list { max-height: 210px; overflow-y: auto; padding: 2px 0; }
.col-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; font-size: 12.5px; cursor: pointer;
}
.col-menu-item:hover { background: rgba(79, 142, 247, 0.10); }
.col-menu-item input { accent-color: var(--blue); flex-shrink: 0; }
.col-menu-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-menu-item .cnt { color: var(--text-faint); font-family: var(--mono); font-size: 11px; }
.col-menu-foot {
  display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border);
}
.col-menu-foot .btn { flex: 1; justify-content: center; padding: 6px 8px; font-size: 12px; }
.col-menu-num { padding: 4px 12px 8px; }
.col-menu-num .hint { display: block; margin-bottom: 6px; }

/* ============ Resource detail modal ============ */
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.res-cell {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px;
}
.res-cell .k {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-dim); margin-bottom: 5px;
}
.res-cell .v { font-size: 13.5px; font-weight: 600; word-break: break-word; }
.res-cell .v.mono { font-family: var(--mono); font-size: 12.5px; }
.res-cell.wide { grid-column: 1 / -1; }
.res-rec {
  display: flex; gap: 9px; align-items: flex-start;
  background: rgba(255, 176, 46, 0.09); border: 1px solid rgba(255, 176, 46, 0.28);
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.55;
}

.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; font-size: 12px; color: var(--text-dim);
}
.filter-bar .spacer { flex: 1; }


/* ============ Optimization report ============ */
.rep-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 6px;
}
.rep-kpi {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.rep-kpi .lbl {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); margin-bottom: 6px;
}
.rep-kpi .val { font-size: 21px; font-weight: 800; font-family: var(--mono); }
.rep-kpi .sub { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.rep-kpi.good .val { color: var(--green); }
.rep-kpi.bad .val { color: var(--red); }
.rep-section-title {
  font-size: 13px; font-weight: 700; margin: 6px 0 2px;
  display: flex; align-items: center; gap: 8px;
}
.rep-note {
  font-size: 11.5px; color: var(--text-faint); line-height: 1.6;
  border-left: 2px solid var(--border); padding-left: 10px;
}
.rep-bar {
  display: inline-block; height: 6px; border-radius: 4px; min-width: 2px;
  background: var(--green); vertical-align: middle;
}
.rep-bar.up { background: var(--red); }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

