/* ── RESET & BASE ─────────────────────────────────────────────────────── */
:root {
  --sw: 236px; --sw-c: 56px; --hh: 52px;
  --c0:#0d1117; --c1:#161b22; --c2:#1c2333; --c3:#21262d; --c4:#30363d;
  --c5:#6e7681; --c6:#8b949e; --c7:#c9d1d9; --c8:#e6edf3; --c9:#f6f8fa;
  --acc:#1f6feb; --acc2:#388bfd; --grn:#2ea043; --red:#da3633;
  --amb:#d29922; --pur:#8957e5; --teal:#3fb950;
  --radius:5px; --shadow:0 1px 3px rgba(0,0,0,0.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5; color: #1c2333; font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d7de; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b8c0; }

/* ── SIDEBAR ──────────────────────────────────────────────────────────── */
#sb {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sw);
  background: linear-gradient(180deg, #0d1117 0%, #0f1724 100%);
  z-index: 300;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.1);
  transition: width 0.25s cubic-bezier(0.4,0,0.2,1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
#sb::-webkit-scrollbar { width: 3px; }
#sb::-webkit-scrollbar-track { background: transparent; }
#sb::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* ── SIDEBAR EXPANDED — main offset ──────────────────────────────────── */
#sb ~ #main { margin-left: var(--sw); transition: margin-left 0.25s cubic-bezier(0.4,0,0.2,1); }

/* ── SIDEBAR COLLAPSED (icon-rail, 56px wide) ─────────────────────────── */
#sb.collapsed { width: var(--sw-c); overflow: visible; }
#sb.collapsed ~ #main { margin-left: var(--sw-c); }

/* In collapsed mode: hide text, labels, badges */
#sb.collapsed .sb-appname,
#sb.collapsed .sb-tagline,
#sb.collapsed .sb-link-text,
#sb.collapsed .sb-badge { display: none !important; }

/* Collapsed header — show only logo + toggle btn */
#sb.collapsed .sb-head { justify-content: center; padding: 12px 0; gap: 0; }
#sb.collapsed .sb-head .sb-text-wrap { display: none !important; }

/* Section group headers: hide text row but keep divider */
#sb.collapsed .sb-sec-label {
  display: none !important;
}
#sb.collapsed .sb-sec-divider {
  display: block !important;
  height: 1px; background: rgba(255,255,255,0.08);
  margin: 6px 8px;
}

/* In collapsed mode ALL section bodies must always be visible */
#sb.collapsed .sb-sec-body {
  max-height: none !important;
  opacity: 1 !important;
  overflow: visible !important;
  padding: 0 !important;
  border: none !important;
}
/* Even if a body was individually collapsed by user, show in rail mode */
#sb.collapsed .sb-sec-body.collapsed-sec {
  max-height: none !important;
  opacity: 1 !important;
}

/* Collapsed links — centred icon + tooltip */
#sb.collapsed .sb-link {
  justify-content: center;
  padding: 10px 0;
  border-left: none;
  border-right: 3px solid transparent;
  position: relative;
}
#sb.collapsed .sb-link.active {
  border-left: none;
  border-right-color: var(--acc2);
  background: rgba(56,139,253,0.18);
}
#sb.collapsed .sb-link .ic {
  width: 22px; font-size: 15px; text-align: center;
  color: #adbac7;
}
#sb.collapsed .sb-link:hover .ic { color: #e6edf3; }
#sb.collapsed .sb-link.active .ic { color: #79c0ff; }

/* Tooltip on hover when collapsed */
#sb.collapsed .sb-link::after {
  content: attr(data-label);
  position: absolute; left: calc(var(--sw-c) + 6px); top: 50%;
  transform: translateY(-50%);
  background: #1c2333; color: #e6edf3;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 5px 11px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  pointer-events: none; opacity: 0;
  transition: opacity 0.14s;
  z-index: 500;
}
#sb.collapsed .sb-link:hover::after { opacity: 1; }

/* ── SIDEBAR TOGGLE BUTTON (always visible at top-right of rail) ─────── */
#sb-toggle-btn {
  position: absolute; top: 14px; right: -12px;
  width: 24px; height: 24px;
  background: #1c2333;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 310;
  color: #8b949e;
  font-size: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: background 0.15s, color 0.15s, transform 0.25s;
}
#sb-toggle-btn:hover { background: #30363d; color: #e6edf3; }
#sb.collapsed #sb-toggle-btn { transform: rotate(180deg); }

/* ── SIDEBAR OVERLAY (mobile) ─────────────────────────────────────────── */
#sb-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 299; backdrop-filter: blur(2px);
}

/* ── SIDEBAR HEADER ───────────────────────────────────────────────────── */
.sb-head {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
  min-height: 54px;
  user-select: none;
  position: relative;
}
.sb-logo {
  width: 32px; height: 32px; flex-shrink: 0;
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(31,111,235,0.35);
}
.sb-text-wrap { min-width: 0; flex: 1; }
.sb-appname { font-size: 13.5px; font-weight: 800; color: #e6edf3; letter-spacing: -0.1px; }
.sb-tagline { font-size: 10px; color: #6e7681; margin-top: 1px; }

/* ── SECTION STRUCTURE ────────────────────────────────────────────────── */
.sb-sec-group { flex-shrink: 0; }

/* Visible section label row (click to expand/collapse) */
.sb-sec-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 4px;
  font-size: 10px; font-weight: 700;
  color: #8b949e; text-transform: uppercase; letter-spacing: 1.2px;
  cursor: pointer; user-select: none;
  transition: color 0.14s;
}
.sb-sec-label:hover { color: #b0bec5; }
.sb-sec-label-text { display: flex; align-items: center; gap: 6px; }
.sb-sec-arrow {
  font-size: 9px; color: #6e7681;
  transition: transform 0.22s ease; flex-shrink: 0;
}

/* Thin horizontal divider shown in collapsed (icon-rail) mode */
.sb-sec-divider { display: none; }

.sb-sec-body {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.28s ease, opacity 0.2s ease;
  opacity: 1;
}
.sb-sec-body.collapsed-sec {
  max-height: 0 !important;
  opacity: 0;
}

/* ── NAV LINKS ────────────────────────────────────────────────────────── */
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 8px 16px;
  color: #adbac7;
  font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.14s ease;
  text-decoration: none; white-space: nowrap;
  cursor: pointer;
}
.sb-link:hover {
  color: #f0f6fc;
  background: rgba(255,255,255,0.08);
  border-left-color: rgba(255,255,255,0.2);
}
.sb-link.active {
  color: #ffffff;
  background: rgba(31,111,235,0.22);
  border-left-color: #79c0ff;
  font-weight: 600;
}
.sb-link .ic {
  width: 18px; text-align: center;
  font-size: 13px; flex-shrink: 0;
  color: #8b949e;
  transition: color 0.14s;
}
.sb-link:hover .ic { color: #c9d1d9; }
.sb-link.active .ic { color: #79c0ff; }
.sb-badge {
  margin-left: auto; background: #da3633; color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 10px;
  font-weight: 700; min-width: 18px; text-align: center; flex-shrink: 0;
  line-height: 1.6;
}

/* ── MAIN LAYOUT ──────────────────────────────────────────────────────── */
#main { min-height: 100vh; }
.topbar {
  background: #fff; border-bottom: 1px solid #e1e4e8;
  height: var(--hh); padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 200;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); gap: 10px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tb-title { font-size: 15px; font-weight: 700; color: #0d1117; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sub { font-size: 11px; color: #6e7681; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── PAGE CONTAINER ───────────────────────────────────────────────────── */
.pg { display: none; padding: 16px; }
.pg.active { display: block; animation: pgIn 0.12s ease; }
@keyframes pgIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

/* ── CARD ─────────────────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid #e1e4e8; padding: 14px 16px;
  box-shadow: var(--shadow);
}

/* ── KPI TILES ────────────────────────────────────────────────────────── */
.kpi { border-radius: var(--radius); padding: 14px 16px; color: #fff; position: relative; overflow: hidden; }
.kpi::after {
  content: ''; position: absolute; right: -10px; top: -10px;
  width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,0.08);
}
.kpi.blue  { background: linear-gradient(120deg,#0c2d6b,#1f6feb); }
.kpi.grn   { background: linear-gradient(120deg,#0d4a1f,#2ea043); }
.kpi.red   { background: linear-gradient(120deg,#5a1111,#da3633); }
.kpi.amb   { background: linear-gradient(120deg,#5a3a00,#d29922); }
.kpi.pur   { background: linear-gradient(120deg,#2d1a6b,#8957e5); }
.kpi.slate { background: linear-gradient(120deg,#1c2333,#30363d); }
.kpi.teal  { background: linear-gradient(120deg,#0d3a2f,#3fb950); }
.kpi.orng  { background: linear-gradient(120deg,#5a2800,#f05000); }
.kpi-lbl { font-size: 11px; font-weight: 600; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-val { font-size: 22px; font-weight: 700; margin: 5px 0 3px; line-height: 1.1; }
.kpi-sub { font-size: 12px; opacity: 0.65; }
.kpi-ic  { position: absolute; right: 12px; bottom: 10px; font-size: 22px; opacity: 0.12; }

/* ── TABLE ────────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 500px; }

/* ── COLLAPSIBLE TABLE SECTIONS ─────────────────────────────────────── */
.tbl-body-wrap {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease;
  opacity: 0;
}
.tbl-body-wrap.expanded {
  max-height: 5000px;
  opacity: 1;
}
.sh { cursor: pointer; user-select: none; }
.sh:hover { background: rgba(255,255,255,0.04); }
.tbl-toggle-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 4px; border: 1px solid #d0d7de;
  background: #f6f8fa; color: #57606a; cursor: pointer; transition: all 0.2s;
  flex-shrink: 0;
}
.tbl-toggle-btn:hover { background: #e1e4e8; color: #1c2333; }
.tbl-toggle-btn .chevron { transition: transform 0.3s ease; display: inline-block; }
.tbl-toggle-btn.collapsed .chevron { transform: rotate(-90deg); }
.tbl-row-count {
  font-size: 11px; font-weight: 600; color: #8b949e;
  background: #f0f2f5; border-radius: 10px; padding: 1px 7px;
  margin-left: 6px; white-space: nowrap;
}
/* Conversion ratio widget */
.conv-ratio-card {
  margin-top: 11px; padding: 14px 16px;
  background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
  border: 1px solid #30363d; border-radius: 6px;
}
.conv-ratio-title {
  font-size: 12px; font-weight: 700; color: #8b949e;
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 7px;
}
.conv-ratio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.conv-ratio-item {
  background: #21262d; border: 1px solid #30363d; border-radius: 5px;
  padding: 10px 12px; text-align: center;
}
.conv-ratio-item .cr-val { font-size: 22px; font-weight: 700; color: #e6edf3; }
.conv-ratio-item .cr-lbl { font-size: 11px; color: #8b949e; margin-top: 3px; }
.conv-ratio-item.cr-highlight .cr-val { color: #3fb950; }
.conv-ratio-item.cr-warn .cr-val { color: #d29922; }
.conv-ratio-bar { margin-top: 12px; }
.conv-ratio-bar-track {
  height: 8px; background: #30363d; border-radius: 4px; overflow: hidden; margin-top: 4px;
}
.conv-ratio-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #1f6feb, #3fb950);
  transition: width 0.6s ease;
}
.conv-ratio-bar-label { display: flex; justify-content: space-between; font-size: 11px; color: #8b949e; margin-top: 4px; }
.tbl th {
  padding: 9px 11px; text-align: left; font-size: 11.5px; font-weight: 700;
  color: #6e7681; text-transform: uppercase; letter-spacing: 0.4px;
  background: #f6f8fa; border-bottom: 2px solid #e1e4e8; white-space: nowrap;
}
.tbl td { padding: 9px 11px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: #f8fafc; }
.tbl-num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-tot td { background: #f6f8fa !important; font-weight: 700; border-top: 2px solid #e1e4e8; }

/* ── BADGE ────────────────────────────────────────────────────────────── */
.bg { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.bg-grn   { background: #dafbe1; color: #1a4731; }
.bg-red   { background: #ffdcd7; color: #5a1111; }
.bg-amb   { background: #fff8c5; color: #5a3a00; }
.bg-blue  { background: #ddf4ff; color: #0c2d6b; }
.bg-pur   { background: #f0eeff; color: #3b2884; }
.bg-slate { background: #f0f2f5; color: #30363d; }
.bg-teal  { background: #d2f4ea; color: #0d3a2f; }
.bg-orng  { background: #fff1e5; color: #7d3800; }

/* ── BUTTON ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all 0.15s;
  white-space: nowrap; line-height: 1.4;
}
.btn:active { transform: scale(0.98); }
.btn-prim  { background: var(--acc);  color: #fff; border-color: var(--acc);  } .btn-prim:hover  { background: var(--acc2); border-color: var(--acc2); }
.btn-grn   { background: var(--grn);  color: #fff; border-color: var(--grn);  } .btn-grn:hover   { background: #3fb950; }
.btn-red   { background: var(--red);  color: #fff; border-color: var(--red);  } .btn-red:hover   { background: #f85149; }
.btn-amb   { background: var(--amb);  color: #fff; border-color: var(--amb);  } .btn-amb:hover   { background: #e3b341; }
.btn-pur   { background: var(--pur);  color: #fff; border-color: var(--pur);  } .btn-pur:hover   { background: #a371f7; }
.btn-out   { background: transparent; color: #24292f; border-color: #d0d7de;  } .btn-out:hover   { background: #f6f8fa; border-color: #c9d1d9; }
.btn-ghost { background: transparent; color: #6e7681; border-color: transparent; } .btn-ghost:hover { background: #f0f2f5; }
.btn-xs  { padding: 3px 9px;  font-size: 11.5px; }
.btn-sm  { padding: 5px 11px; font-size: 12.5px; }
.btn-lg  { padding: 9px 18px; font-size: 14px; }

/* ── FORM ─────────────────────────────────────────────────────────────── */
.fg  { margin-bottom: 12px; }
.fl  { display: block; font-size: 12px; font-weight: 600; color: #24292f; margin-bottom: 4px; }
.fi  { width: 100%; padding: 8px 10px; border: 1px solid #d0d7de; border-radius: var(--radius); font-size: 13px; color: #1c2333; outline: none; background: #fff; transition: border-color 0.15s, box-shadow 0.15s; }
.fi:focus  { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(31,111,235,0.12); }
.fi::placeholder { color: #9ca3af; }
.fsel {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236e7681'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 13px; padding-right: 28px;
}

/* ── MODAL ────────────────────────────────────────────────────────────── */
.mo {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  z-index: 500; display: flex; align-items: flex-start;
  justify-content: center; padding: 20px; overflow-y: auto;
}
.mb {
  background: #fff; border-radius: 6px;
  width: 580px; max-width: calc(100vw - 32px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  margin: auto; position: relative; flex-shrink: 0;
}
.mb-lg { width: 760px; }
.mb-xl { width: 920px; }
.mh {
  padding: 14px 16px; border-bottom: 1px solid #e1e4e8;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: #fff; z-index: 1;
  border-radius: 6px 6px 0 0;
}
.mh-title { font-size: 14px; font-weight: 700; color: #0d1117; display: flex; align-items: center; gap: 8px; }
.mh-close { background: none; border: none; cursor: pointer; color: #6e7681; font-size: 16px; padding: 2px 4px; border-radius: 3px; line-height: 1; }
.mh-close:hover { background: #f0f2f5; color: #0d1117; }
.mbdy { padding: 16px; overflow-x: hidden; }
.mf {
  padding: 12px 16px; border-top: 1px solid #e1e4e8;
  display: flex; gap: 8px; justify-content: flex-end;
  background: #f6f8fa; border-radius: 0 0 6px 6px;
}

/* ── TABS ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid #e1e4e8; margin-bottom: 14px; overflow-x: auto; }
.tab  {
  padding: 9px 15px; font-size: 13px; font-weight: 600; color: #6e7681;
  cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.15s; white-space: nowrap; flex-shrink: 0;
}
.tab.active { color: var(--acc); border-bottom-color: var(--acc); }
.tab:hover:not(.active) { color: #30363d; background: #f6f8fa; }

/* ── ALERT ────────────────────────────────────────────────────────────── */
.al { padding: 10px 13px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid; }
.al-info  { background: #ddf4ff; border-color: #79c0ff; color: #0c2d6b; }
.al-warn  { background: #fff8c5; border-color: #e3b341; color: #5a3a00; }
.al-ok    { background: #dafbe1; border-color: #56d364; color: #1a4731; }
.al-err   { background: #ffdcd7; border-color: #ff7b72; color: #5a1111; }

/* ── PROGRESS ─────────────────────────────────────────────────────────── */
.pbar  { height: 5px; background: #e1e4e8; border-radius: 3px; overflow: hidden; }
.pfill { height: 100%; border-radius: 3px; transition: width 0.4s; }

/* ── DIVIDER / SECTION ────────────────────────────────────────────────── */
.dv { border: none; border-top: 1px solid #e1e4e8; margin: 14px 0; }
.sh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.sh-title { font-size: 14px; font-weight: 700; color: #0d1117; }

/* ── FX COLORS ────────────────────────────────────────────────────────── */
.fx-pos { color: var(--grn); font-weight: 600; }
.fx-neg { color: var(--red); font-weight: 600; }

/* ── GRID HELPERS ─────────────────────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.g5 { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; }
.g6 { display: grid; grid-template-columns: repeat(6,1fr); gap: 12px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }

/* ── STATUS DOT ───────────────────────────────────────────────────────── */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; }
.dot-grn { background: var(--grn); } .dot-amb { background: var(--amb); } .dot-red { background: var(--red); } .dot-blue { background: var(--acc); }

/* ── MINI STAT ────────────────────────────────────────────────────────── */
.mstat { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.mstat:last-child { border-bottom: none; }

/* ── LABELS ───────────────────────────────────────────────────────────── */
.sec-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: #6e7681; margin-bottom: 7px; }
.card-tbl  { font-size: 13px; width: 100%; }
.card-tbl td { padding: 5px 0; vertical-align: top; }

/* ── GLOBAL SEARCH ────────────────────────────────────────────────────── */
#gsearch-wrap { position: relative; }
#gsearch {
  border: 1px solid #d0d7de; border-radius: 20px;
  padding: 6px 12px 6px 32px; font-size: 13px; outline: none;
  background: #f6f8fa; width: 200px; transition: all 0.2s;
}
#gsearch:focus { width: 250px; background: #fff; border-color: var(--acc); box-shadow: 0 0 0 3px rgba(31,111,235,0.1); }
#gsearch-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #6e7681; font-size: 12px; pointer-events: none; }
#gsearch-results {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: #fff; border: 1px solid #e1e4e8; border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.14); width: 340px;
  max-height: 380px; overflow-y: auto; z-index: 999; display: none;
}
.gsr-item { padding: 9px 13px; cursor: pointer; border-bottom: 1px solid #f0f2f5; transition: background 0.1s; }
.gsr-item:hover { background: #f6f8fa; }
.gsr-item:last-child { border-bottom: none; }
.gsr-title { font-size: 13px; font-weight: 600; color: #0d1117; }
.gsr-sub   { font-size: 12px; color: #6e7681; margin-top: 2px; }

/* ── BURN / PROGRESS COLORS ───────────────────────────────────────────── */
.burn-good { background: var(--grn); }
.burn-warn { background: var(--amb); }
.burn-over { background: var(--red); }

/* ── EMPTY STATE ──────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: #6e7681; }
.empty-state i { font-size: 36px; margin-bottom: 12px; opacity: 0.35; display: block; }
.empty-state p { font-size: 13px; }

/* ── IMPORT ZONE ──────────────────────────────────────────────────────── */
.import-zone { border: 2px dashed #d0d7de; border-radius: 6px; padding: 24px; text-align: center; cursor: pointer; transition: all 0.2s; }
.import-zone:hover, .import-zone.drag-over { border-color: var(--acc); background: #f0f7ff; }

/* ── TOAST ────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: none; background: #fff; border: 1px solid #e1e4e8;
  border-radius: 6px; padding: 10px 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.14);
  align-items: center; gap: 9px; min-width: 220px; max-width: 340px;
}

/* ── MOBILE TOPBAR HAMBURGER ──────────────────────────────────────────── */
#menu-btn { display: none; }

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════ */

/* ── LARGE DESKTOP (≥1280px) ──────────────────────────────────────────── */
@media (min-width: 1280px) {
  .pg { padding: 18px 22px; }
  .kpi-val { font-size: 24px; }
}

/* ── TABLET MEDIUM (901px – 1100px) ──────────────────────────────────── */
@media (max-width: 1100px) {
  :root { --sw: 216px; }
  .g6 { grid-template-columns: repeat(3,1fr); }
  .g5 { grid-template-columns: repeat(3,1fr); }
  #gsearch { width: 150px; }
  #gsearch:focus { width: 190px; }
}

/* ── TABLET (769px – 900px): auto-collapse sidebar to icon rail ───────── */
@media (max-width: 900px) and (min-width: 769px) {
  #sb { width: var(--sw-c) !important; overflow: visible; }
  #sb ~ #main { margin-left: var(--sw-c) !important; }
  #sb.collapsed { width: var(--sw-c) !important; }
  /* Apply same icon-rail styles as desktop collapsed */
  #sb .sb-appname, #sb .sb-tagline,
  #sb .sb-link-text, #sb .sb-badge { display: none !important; }
  #sb .sb-head { justify-content: center; padding: 12px 0; gap: 0; }
  #sb .sb-text-wrap { display: none !important; }
  #sb .sb-sec-label { display: none !important; }
  #sb .sb-sec-divider { display: block !important; height: 1px; background: rgba(255,255,255,0.08); margin: 6px 8px; }
  #sb .sb-sec-body {
    max-height: none !important; opacity: 1 !important; overflow: visible !important; padding: 0 !important;
  }
  #sb .sb-sec-body.collapsed-sec { max-height: none !important; opacity: 1 !important; }
  #sb .sb-link {
    justify-content: center; padding: 10px 0;
    border-left: none; border-right: 3px solid transparent; position: relative;
  }
  #sb .sb-link.active { border-left: none; border-right-color: var(--acc2); background: rgba(56,139,253,0.18); }
  #sb .sb-link .ic { width: 22px; font-size: 15px; text-align: center; color: #adbac7; }
  #sb .sb-link:hover .ic { color: #e6edf3; }
  #sb .sb-link.active .ic { color: #79c0ff; }
  #sb .sb-link::after {
    content: attr(data-label);
    position: absolute; left: calc(var(--sw-c) + 6px); top: 50%; transform: translateY(-50%);
    background: #1c2333; color: #e6edf3; font-size: 12px; font-weight: 600; white-space: nowrap;
    padding: 5px 11px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.14);
    box-shadow: 0 4px 18px rgba(0,0,0,0.5); pointer-events: none; opacity: 0;
    transition: opacity 0.14s; z-index: 500;
  }
  #sb .sb-link:hover::after { opacity: 1; }
  #sb-toggle-btn { display: none; }
}

/* ── SMALL TABLET / LARGE MOBILE (≤768px) ────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar slides off-screen; opens as full-width overlay */
  #sb {
    transform: translateX(-100%);
    width: var(--sw) !important;
    overflow-y: auto; overflow-x: hidden;
  }
  #sb.open { transform: translateX(0); }
  #sb.open ~ #sb-overlay { display: block; }
  /* Reset any collapsed styles on mobile */
  #sb.collapsed {
    width: var(--sw) !important;
    overflow-y: auto; overflow-x: hidden;
  }
  #sb ~ #main,
  #sb.collapsed ~ #main { margin-left: 0 !important; }

  /* Restore all text in mobile slide-out */
  #sb .sb-appname, #sb .sb-tagline,
  #sb .sb-link-text, #sb .sb-badge { display: block !important; }
  #sb .sb-head { justify-content: flex-start; padding: 12px 14px; gap: 10px; }
  #sb .sb-text-wrap { display: block !important; }
  #sb .sb-sec-label { display: flex !important; }
  #sb .sb-sec-divider { display: none !important; }
  #sb .sb-sec-body { max-height: 500px; overflow: hidden; opacity: 1; }
  #sb .sb-sec-body.collapsed-sec { max-height: 0 !important; opacity: 0; }
  #sb .sb-link { justify-content: flex-start; padding: 8px 14px 8px 16px; border-left: 3px solid transparent; border-right: none; }
  #sb .sb-link.active { border-left-color: #79c0ff; border-right: none; }
  #sb .sb-link::after { display: none; }
  #sb-toggle-btn { display: none; }

  /* Show hamburger */
  #menu-btn { display: inline-flex !important; }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 6px; }
  .tb-sub { display: none; }
  #gsearch { width: 120px; }
  #gsearch:focus { width: 160px; }
  #cur-date { display: none; }

  /* Grids collapse to 2 columns */
  .g6, .g5, .g4 { grid-template-columns: repeat(2,1fr); }
  .g3 { grid-template-columns: 1fr 1fr; }
  .span3 { grid-column: span 2; }

  /* Page padding */
  .pg { padding: 12px; }

  /* Modal full width */
  .mb, .mb-lg, .mb-xl { max-width: calc(100vw - 16px); width: 100% !important; }
  .mo { padding: 8px; }

  /* KPI font smaller */
  .kpi-val { font-size: 18px; }
  .kpi { padding: 12px; }
}

/* ── MOBILE (≤600px) ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* All grids go single column */
  .g2, .g3, .g4, .g5, .g6 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: span 1; }

  /* Topbar minimal */
  .topbar { height: auto; min-height: var(--hh); flex-wrap: nowrap; padding: 0 10px; }
  .topbar-right { gap: 5px; }
  #gsearch-wrap { display: none; }

  /* Pages */
  .pg { padding: 10px; }

  /* Cards */
  .card { padding: 12px; }

  /* KPI single column */
  .kpi-val { font-size: 20px; }

  /* Tables: allow horizontal scroll */
  .card { overflow-x: auto; }

  /* Modal */
  .mb, .mb-lg, .mb-xl { max-width: 100vw; width: 100% !important; border-radius: 8px 8px 0 0; }
  .mo { padding: 0; align-items: flex-end; }

  /* Section header wraps */
  .sh { flex-direction: column; align-items: flex-start; }

  /* Buttons: smaller on mobile */
  .btn { padding: 5px 10px; font-size: 12px; }
  .btn-lg { padding: 8px 14px; font-size: 13px; }

  /* Hide less important topbar elements */
  #base-currency { display: none; }
  label[for="base-currency"] { display: none; }
}

/* ── DASHBOARD SPECIFIC RESPONSIVE ───────────────────────────────────── */
@media (max-width: 1024px) {
  .dash-grid-top { grid-template-columns: 1fr 1fr !important; }
  .dash-grid-top > .card:first-child { grid-column: span 2; }
  .dash-grid-mid { grid-template-columns: 1fr 1fr !important; }
  .dash-grid-mid > .card:last-child { grid-column: span 2; }
}
@media (max-width: 768px) {
  .dash-grid-top,
  .dash-grid-mid { grid-template-columns: 1fr !important; }
  .dash-grid-top > .card:first-child,
  .dash-grid-mid > .card:last-child { grid-column: span 1; }
}

/* ── ADDITIONAL MOBILE FIXES ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .topbar-right .btn-post-text { display: none; }
  .mstat { font-size: 12px; }
  .kpi-lbl { font-size: 10px; }
  .card-tbl { font-size: 12px; }
  .sh-title { font-size: 13px; }
}

/* ── PRINT ────────────────────────────────────────────────────────────── */
@media print {
  #sb, .topbar, .mf { display: none !important; }
  #main { margin-left: 0 !important; }
  .pg { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── UTILITY CLASSES (replaces inline styles in HTML) ────────────────── */

/* Toast notification */
#toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 999;
  display: none; background: #fff; border: 1px solid #e1e4e8;
  border-radius: 4px; padding: 9px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  align-items: center; gap: 8px; min-width: 200px;
}
#toast-ic { font-size: 14px; }
#toast-ic.ok  { color: #2ea043; }
#toast-ic.err { color: #da3633; }
#toast-msg { font-size: 12px; font-weight: 600; color: #0d1117; }

/* User avatar */
#user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #1f6feb, #8957e5);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
}

/* App loading state */
.app-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; gap: 16px; color: #6e7681;
}
.app-loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid #e1e4e8; border-top-color: #1f6feb;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Sidebar icon (logo box) */
.sb-logo-box {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Icon colour helpers used throughout app */
.ic-white { color: #fff; }
.ic-blue  { color: #1f6feb; }
.ic-green { color: #2ea043; }
.ic-red   { color: #da3633; }
.ic-amber { color: #d29922; }
.ic-pur   { color: #8957e5; }
.ic-teal  { color: #3fb950; }
.ic-muted { color: #6e7681; }
.ic-sm    { font-size: 14px; }
.ic-xs    { font-size: 12px; }

/* KPI value font override for detail panel */
.kpi-val-sm { font-size: 16px !important; }

/* Positive / negative variance colouring */
.val-pos { color: #2ea043; font-weight: 700; }
.val-neg { color: #da3633; font-weight: 700; }

/* Overflow helpers used in project table */
.cell-name {
  font-weight: 600; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell-id { font-size: 12px; font-weight: 700; color: #1f6feb; }
.cell-ref { font-size: 12px; color: #6e7681; }

/* Section label used in project detail */
.sec-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #6e7681; margin-bottom: 6px;
}

/* Burn-rate progress pill  */
.burn-pill { font-weight: 700; }
.burn-ok   { color: #2ea043; }
.burn-warn { color: #d29922; }
.burn-over { color: #da3633; }

/* Ghost padding override for compact icon-only buttons */
.btn-icon-only { padding: 6px 8px; }

/* Resource-role list item sub-label */
.role-type-badge { font-size: 12px; }

/* Inline muted text */
.txt-muted { font-size: 12px; color: #6e7681; }
.txt-bold  { font-weight: 700; }
.txt-sm    { font-size: 12px; }
.txt-xs    { font-size: 11px; }

/* Markup / profit percentage colour */
.pct-pos { color: #2ea043; }

/* Row variance colours */
.var-pos { font-weight: 700; color: #2ea043; }
.var-neg { font-weight: 700; color: #da3633; }

/* Sidebar section divider */
.sb-nav-icon { color: #fff; font-size: 14px; }

/* ── USER MENU (replaces remaining inline styles) ────────────────────── */
#user-menu-wrap { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; padding: 3px 6px;
  border-radius: 5px; transition: background 0.15s;
}
.user-menu-btn:hover { background: #f0f2f5; }
#user-display-name {
  font-size: 12px; color: #24292f; font-weight: 600;
  max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chevron { font-size: 9px; color: #6e7681; }

#user-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: #fff; border: 1px solid #e1e4e8; border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.14); min-width: 190px;
  z-index: 9999; padding: 4px 0;
}
.dd-header {
  padding: 10px 14px; border-bottom: 1px solid #e1e4e8;
}
#dd-username { font-size: 13px; font-weight: 700; color: #0d1117; }
#dd-role { font-size: 11px; color: #6e7681; }
.dd-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; font-size: 13px; color: #24292f; cursor: pointer;
}
.dd-item:hover { background: #f6f8fa; }
.dd-icon { color: #6e7681; width: 15px; }
.dd-divider { border-top: 1px solid #f0f2f5; margin: 3px 0; }
.dd-item-danger { color: #da3633; }
.dd-item-danger .dd-icon { color: #da3633; }

/* Topbar compound elements */
.topbar-date { font-size: 11px; color: #6e7681; border-right: 1px solid #e1e4e8; padding-right: 8px; white-space: nowrap; }
.topbar-label { font-size: 12px; color: #6e7681; white-space: nowrap; }
.topbar-ccy { width: 76px; padding: 4px 24px 4px 8px; font-size: 12px; }
.topbar-title { min-width: 0; }
.topbar-gap { height: 16px; flex-shrink: 0; }

/* Menu button */
#menu-btn { padding: 6px 8px; }
#menu-btn i { font-size: 15px; }

/* tbl-actions cell */
.tbl-actions { white-space: nowrap; }
