:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2330;
  --text-muted: #5b6472;
  --primary: #1f5f8b;
  --primary-soft: #e8f0f7;
  --ok: #2e7d4f;
  --ok-soft: #e8f5ee;
  --warn: #9a6b00;
  --warn-soft: #fdf3dd;
  --danger: #b03a3a;
  --danger-soft: #fbeaea;
  --info: #34556e;
  --info-soft: #e9f0f6;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06);
}

* { box-sizing: border-box; }
.credit-metrics { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:12px; margin:20px 0; }
.credit-metric { color:var(--text); background:var(--surface); border:1px solid var(--border); border-top:3px solid var(--primary); border-radius:6px; padding:16px; text-decoration:none; min-height:115px; }
.credit-metric:nth-child(n+4):nth-child(-n+6) { border-top-color:var(--danger); }
.credit-metric:nth-child(n+7) { border-top-color:var(--ok); }
.credit-metric span { display:block; font-size:14px; }
.credit-metric strong { display:block; font-size:26px; margin-top:8px; overflow-wrap:anywhere; }
.credit-table { max-width:100%; overflow:auto; margin:12px 0 24px; }
.credit-table table { min-width:620px; }
.credit-table th, .credit-table td { white-space:normal; min-width:90px; overflow-wrap:anywhere; }
.credit-tabs { display:flex; flex-wrap:wrap; gap:4px; border-bottom:1px solid var(--border); margin:18px 0; }
.credit-tabs button { background:transparent; color:var(--text-muted); border:0; border-bottom:3px solid transparent; padding:10px 12px; font:inherit; cursor:pointer; }
.credit-tabs button[aria-selected="true"] { color:var(--primary); border-bottom-color:var(--primary); }
.credit-360 { min-width:0; }
.credit-360 [role="tabpanel"] { min-height:200px; }
.brand-attribution { display:block; font-size:11px; font-weight:400; color:#cbd5e1; }
.nav details summary { padding:10px 12px; cursor:pointer; }
@media(max-width:600px) { .credit-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } .credit-metric { padding:12px; } .filters label { max-width:100%; } }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: #101826;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
}
.brand-name { color: #fff; font-weight: 600; }
.nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: block;
  padding: 9px 12px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-footer { margin-top: auto; padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.env-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fbbf24;
}

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.safety-banner {
  background: var(--danger-soft);
  color: var(--danger);
  border-bottom: 1px solid #f0c9c9;
  padding: 8px 18px;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.safety-banner strong { text-transform: uppercase; letter-spacing: 0.03em; }
.safety-banner span { color: #8a3b3b; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 16px;
}
.page-title { margin: 0; font-size: 18px; font-weight: 650; }
.ask-hint {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.ask-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

.content { padding: 20px; }

/* Cards */
.grid { display: grid; gap: 14px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.card .metric { font-size: 26px; font-weight: 700; }

/* Sections */
.section { margin-bottom: 24px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 0 0 12px; }

/* Tables / lists */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafbfc; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #eef0f3; color: var(--text-muted); }

.priority-HIGH { background: var(--danger-soft); color: var(--danger); }
.priority-MEDIUM { background: var(--warn-soft); color: var(--warn); }
.priority-LOW { background: var(--info-soft); color: var(--info); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* States */
.state { padding: 40px; text-align: center; color: var(--text-muted); }
.state-empty { border: 1px dashed var(--border); border-radius: 10px; background: var(--surface); }

/* Filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}

/* Search */
.search-input { width: 100%; max-width: 320px; }

/* Approval card */
.approval-card { margin-bottom: 14px; }
.approval-actions { display: flex; gap: 10px; margin-top: 12px; }
.approval-warning { font-size: 12px; color: var(--warn); margin-top: 8px; }

/* Detail panels */
.detail-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace; font-size: 13px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-block; }
  .content { padding: 14px; }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  table { display: block; overflow-x: auto; }
}

@media (max-width: 480px) {
  .card .metric { font-size: 22px; }
  .topbar { padding: 10px 12px; }
}
[hidden] { display: none !important; }
.topbar { order: -2; }
.safety-banner { order: -1; background: #edf2f1; color: #344b46; border-color: var(--border); }
.safety-banner span { color: inherit; }
.sidebar { width: 216px; }
.notice, .how-it-works { margin: 12px 20px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.notice { border-left: 4px solid var(--primary); }
.card + .section { margin-top: 18px; }
#logout-button { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 8px 12px; color: var(--text); }
.page-title { font-size: 15px; color: var(--text-muted); }
.approval-warning { padding: 12px; background: var(--warn-soft); font-size: 14px; font-weight: 600; }
:focus-visible { outline: 3px solid #287ab0; outline-offset: 3px; }
button, .btn, select, input { min-height: 44px; }
td, .card, .ask-hint { overflow-wrap: anywhere; }
.state-loading { background: linear-gradient(100deg, #edf0f2, #fafbfc, #edf0f2); border-radius: 8px; }
dialog { border: 1px solid var(--border); border-radius: 12px; width: min(480px, 92vw); padding: 24px; }
dialog::backdrop { background: #10182666; }
dialog label { display: grid; gap: 6px; margin: 14px 0; }
dialog input, dialog select { width: 100%; }
@media (max-width: 768px) {
  .topbar, .ask-hint { flex-wrap: wrap; }
  .ask-hint { margin-left: 0; }
  .sidebar.open { top: 100px; box-shadow: 8px 0 24px #10182633; }
  table, tbody, tr, td { display: block; width: 100%; }
  table { overflow: visible; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr { border-bottom: 2px solid var(--border); padding: 8px 0; }
  td { border: 0; padding: 6px 0; }
  td::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); }
  .filters > *, .approval-actions > * { flex: 1 1 140px; max-width: 100%; }
  .approval-actions { flex-wrap: wrap; }
}

/* Contextual help + guided tour */
.help-tip {
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--info-soft);
  color: var(--info);
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
}
.tour-sheet {
  position: fixed;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  width: min(480px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(20, 30, 45, 0.18);
  padding: 16px 18px;
  z-index: 100;
}
.tour-sheet strong { font-size: 14px; }
.tour-sheet p { margin: 6px 0 12px; }
