:root {
  --bg: #ffffff;
  --accent: #ff6900;
  --accent-soft: rgba(255, 105, 0, 0.08);
  --grey: #53565a;
  --grey-2: #8a8d91;
  --grey-3: #c9ccd0;
  --line: #ececee;
  --line-2: #e3e4e6;
  --danger: #c62828;
  --ok: #2e7d32;
  --warn: #b26a00;
  --sidebar-w: 280px;
  --sidebar-collapsed-w: 62px;
  --sidebar-transition: 280ms;
  --sidebar-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 8px;
  --shadow: 0 1px 3px rgba(83, 86, 90, 0.08);
  --shadow-lg: 0 8px 30px rgba(83, 86, 90, 0.14);
  --font: "Poppins", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--grey);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: width var(--sidebar-transition) var(--sidebar-ease), transform var(--sidebar-transition) var(--sidebar-ease), box-shadow var(--sidebar-transition) var(--sidebar-ease);
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
}
.app.authed .sidebar { width: var(--sidebar-collapsed-w); transform: translateX(0); overflow: visible; }
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.app.authed .sidebar.open { width: var(--sidebar-w); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  transition: padding var(--sidebar-transition) var(--sidebar-ease), gap var(--sidebar-transition) var(--sidebar-ease);
}
.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  object-fit: contain;
}
.brand-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--grey);
  letter-spacing: 0.2px;
  max-width: 210px;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transform: translateX(0);
  transition: max-width var(--sidebar-transition) var(--sidebar-ease), opacity 160ms var(--sidebar-ease) 80ms, transform var(--sidebar-transition) var(--sidebar-ease), visibility 0s;
}
.app.authed .sidebar:not(.open) .sidebar-brand { padding-left: 16px; padding-right: 16px; gap: 0; }
.app.authed .sidebar:not(.open) .brand-text {
  max-width: 0;
  opacity: 0;
  transform: translateX(-8px);
  visibility: hidden;
  transition: max-width var(--sidebar-transition) var(--sidebar-ease), opacity 120ms var(--sidebar-ease), transform var(--sidebar-transition) var(--sidebar-ease), visibility 0s var(--sidebar-transition);
}

.nav { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 10px 0; }
.nav-section {
  padding: 12px 18px 4px;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--grey-2);
  font-weight: 600;
  max-height: 32px;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transition: max-height var(--sidebar-transition) var(--sidebar-ease), padding var(--sidebar-transition) var(--sidebar-ease), opacity 160ms var(--sidebar-ease) 80ms, visibility 0s;
}
.app.authed .sidebar:not(.open) .nav-section {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  visibility: hidden;
  transition: max-height var(--sidebar-transition) var(--sidebar-ease), padding var(--sidebar-transition) var(--sidebar-ease), opacity 120ms var(--sidebar-ease), visibility 0s var(--sidebar-transition);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 18px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--grey);
  font-size: 14px;
  text-align: left;
  border-left: 3px solid transparent;
  position: relative;
  transition: padding var(--sidebar-transition) var(--sidebar-ease), gap var(--sidebar-transition) var(--sidebar-ease), background 150ms ease;
}
.nav-item span:not(.nav-icon) {
  max-width: 170px;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transform: translateX(0);
  transition: max-width var(--sidebar-transition) var(--sidebar-ease), opacity 160ms var(--sidebar-ease) 80ms, transform var(--sidebar-transition) var(--sidebar-ease), visibility 0s;
}
.app.authed .sidebar:not(.open) .nav-item { padding: 11px 19px; gap: 0; }
.app.authed .sidebar:not(.open) .nav-item span:not(.nav-icon) {
  max-width: 0;
  opacity: 0;
  transform: translateX(-8px);
  visibility: hidden;
  transition: max-width var(--sidebar-transition) var(--sidebar-ease), opacity 120ms var(--sidebar-ease), transform var(--sidebar-transition) var(--sidebar-ease), visibility 0s var(--sidebar-transition);
}
.app.authed .sidebar:not(.open) .nav-item::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--grey);
  color: #fff;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 80;
}
.app.authed .sidebar:not(.open) .nav-item:hover::after { opacity: 1; }
.nav-item:hover { background: var(--accent-soft); }
.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.nav-icon { display: inline-flex; width: 18px; height: 18px; }
.nav-icon svg { width: 18px; height: 18px; stroke: currentColor; }

.sidebar-footer { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 8px 0; background: var(--bg); }

/* ---------- Main / topbar ---------- */
.main { flex: 1; margin-left: 0; display: flex; flex-direction: column; min-width: 0; position: relative; transition: margin-left var(--sidebar-transition) var(--sidebar-ease); }
.main::before {
  content: '';
  position: fixed;
  inset: 58px 0 0;
  background: url('/logo/Watermark.png') center / auto 70vh no-repeat;
  opacity: 0.03;
  pointer-events: none;
  z-index: 2;
}
.app.authed .main { margin-left: var(--sidebar-collapsed-w); }
.app.authed .main.sidebar-open { margin-left: var(--sidebar-w); }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 58px;
  padding: 0 20px;
  border-bottom: 1px solid var(--accent);
  background: var(--accent);
  position: sticky;
  top: 0;
  z-index: 20;
}
.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}
.menu-btn:hover { background: rgba(255, 255, 255, 0.25); }
.menu-btn svg { width: 20px; height: 20px; stroke: currentColor; }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(83, 86, 90, 0.45);
  z-index: 39;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 0s 200ms;
}
.sidebar-backdrop.open { opacity: 1; visibility: visible; transition: opacity 200ms ease, visibility 0s; }
.page-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #fff;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.reminder-wrap { position: relative; }
.reminder-bell {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}
.reminder-bell:hover { background: rgba(255, 255, 255, 0.25); }
.reminder-bell svg { width: 19px; height: 19px; stroke: currentColor; }
.reminder-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.reminder-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: min(360px, calc(100vw - 28px));
  max-height: min(420px, calc(100vh - 88px));
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.reminder-panel-title { padding: 8px 10px; font-size: 13px; font-weight: 700; color: var(--grey); }
.reminder-empty { padding: 12px 10px; color: var(--grey-2); font-size: 13px; }
.reminder-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--grey);
  cursor: pointer;
  text-align: left;
}
.reminder-item:hover { background: var(--accent-soft); }
.reminder-item.read { opacity: 0.55; }
.reminder-item-title { font-size: 12.5px; font-weight: 700; }
.reminder-item-detail { font-size: 12px; color: var(--grey-2); }
.reminder-item.pending .reminder-item-title { color: var(--warn); }
.user-chip {
  font-size: 13px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  color: var(--grey);
}
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.content { position: relative; z-index: 1; width: 100%; max-width: none; padding: clamp(12px, 2vw, 32px); }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 14px; color: var(--grey); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}
.card-grid > .card { margin-bottom: 0; }

.detail-row { display: flex; flex-wrap: wrap; padding: 7px 0; border-bottom: 1px solid var(--line); gap: 4px 12px; }
.detail-row-label { flex: 1 1 140px; max-width: 180px; }
.detail-row > div:last-child { flex: 2 1 160px; min-width: 0; word-break: break-word; }
@media (max-width: 480px) {
  .detail-row { flex-direction: column; gap: 2px; }
  .detail-row-label,
  .detail-row > div:last-child { flex: 0 0 auto; max-width: none; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-value { font-size: 26px; font-weight: 700; color: var(--grey); line-height: 1.1; }
.stat-value.accent { color: var(--accent); }
.stat-label { font-size: 12px; color: var(--grey-2); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--grey-2);
  font-weight: 600;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:hover { background: #fafafa; }
tbody tr.clickable { cursor: pointer; }

.muted { color: var(--grey-2); }
.warn { background: #fff4e5; color: #b45309; padding: 9px 12px; border-radius: 7px; font-size: 13px; }
.small { font-size: 12px; }
.mono { font-family: var(--font); font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.badge.grey { background: #f1f2f3; color: var(--grey); }
.badge.green { background: #e8f5e9; color: var(--ok); }
.badge.red { background: #fdecea; color: var(--danger); }
.badge.amber { background: #fdf1e0; color: var(--warn); }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--grey); }
.field label .req { color: var(--accent); }
.input, select.input, textarea.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  font-size: 14px;
  color: var(--grey);
  background: #fff;
  font-family: inherit;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 74px; resize: vertical; }
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--grey);
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; }
.btn:hover { border-color: var(--grey-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #e25e00; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn.danger:hover { background: #fdecea; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  opacity: 0.85;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ---------- Filters bar ---------- */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}
.filters .input { width: auto; min-width: 150px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 18px; }
.tab {
  padding: 9px 16px;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--grey-2);
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-weight: 500;
}
.tab:hover { color: var(--grey); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 18px 22px;
  border-left: 1px solid var(--line-2);
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li.muted-item::before { background: var(--grey-3); }
.timeline .t-time { font-size: 11.5px; color: var(--grey-2); }
.timeline .t-title { font-weight: 600; margin: 2px 0; }
.timeline .t-body { color: var(--grey-2); font-size: 13px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(83, 86, 90, 0.35);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 540px;
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: #fff;
  margin: 18px -22px -22px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--grey);
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  max-width: 360px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--grey-2);
}
.empty svg { width: 40px; height: 40px; stroke: var(--grey-3); margin-bottom: 10px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: transparent;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 36px 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  margin-bottom: 18px;
}
.login-title { font-size: 19px; font-weight: 700; margin: 0 0 4px; }
.login-sub { font-size: 13px; color: var(--grey-2); margin-bottom: 24px; }
.login-error {
  background: #fdecea;
  color: var(--danger);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

/* ---------- Charts ---------- */
.chart-box { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, #ff9a4d, var(--accent));
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  position: relative;
}
.chart-bar.secondary { background: linear-gradient(180deg, #9b9ea1, var(--grey-2)); }
.chart-label { font-size: 10.5px; color: var(--grey-2); text-align: center; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-value { font-size: 11px; font-weight: 700; color: var(--grey); text-align: center; }
.funnel-step { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.funnel-track { flex: 1; height: 26px; background: #f4f4f5; border-radius: 4px; overflow: hidden; position: relative; }
.funnel-fill { height: 100%; background: linear-gradient(90deg, #ff9a4d, var(--accent)); border-radius: 4px; }
.funnel-fill.secondary { background: linear-gradient(90deg, #a9acaf, var(--grey-2)); }
.funnel-label { width: 170px; font-size: 12.5px; color: var(--grey); }
.funnel-num { width: 50px; text-align: right; font-weight: 700; color: var(--grey); font-size: 13px; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.pagination .btn { min-width: 34px; justify-content: center; }

/* ---------- Drill down / drill up ---------- */
.drillable { cursor: pointer; transition: opacity .15s, background .15s; }
.stat.drillable { transition: border-color .15s, box-shadow .15s, transform .15s; }
.stat.drillable:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 105, 0, .12); }
.stat.drillable:hover .stat-value { color: var(--accent); }
.chart-box .drillable:hover .chart-bar { filter: brightness(1.08); }
.chart-box .drillable:hover .chart-label { color: var(--accent); }
.funnel-step.drillable:hover .funnel-label { color: var(--accent); }
.funnel-step.drillable:hover .funnel-fill { filter: brightness(1.08); }

.drill-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: #fffaf5;
}
.drill-hint { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--grey-2); margin-right: 2px; }
.drill-hint svg { width: 14px; height: 14px; stroke: var(--accent); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: #fff0e2;
  border: 1px solid #ffd7b3;
  border-radius: 999px;
  padding: 4px 10px;
}
.chip-x {
  border: 0;
  background: none;
  color: var(--grey-2);
  font-size: 14px;
  line-height: 1;
  padding: 0 0 0 2px;
  cursor: pointer;
}
.chip-x:hover { color: var(--accent); }

/* ---------- Breakpoints ----------
   >=1440px      large desktop
   1024-1439px   desktop/laptop (hover sidebar)
   768-1023px    tablet (drawer sidebar)
   480-767px     large mobile (drawer sidebar)
   <480px        mobile (drawer sidebar)
------------------------------------ */
@media (max-width: 1023px) {
  .menu-btn { display: inline-flex; }
  .app.authed .sidebar { width: var(--sidebar-w); transform: translateX(-100%); overflow-y: auto; overflow-x: hidden; }
  .app.authed .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .app.authed .sidebar:not(.open) .sidebar-brand { justify-content: flex-start; height: 58px; padding: 0 18px; }
  .app.authed .sidebar:not(.open) .nav-item { justify-content: flex-start; padding: 9px 18px; gap: 12px; }
  .app.authed .sidebar:not(.open) .nav-item::after { display: none; }
  .app.authed .main { margin-left: 0; }
  .app.authed .main.sidebar-open { margin-left: 0; }
  .sidebar.open { width: min(320px, 82vw); }
}

@media (max-width: 767px) {
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .funnel-label { width: 110px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .input { width: 100%; min-width: 0; }
  .modal-backdrop { padding: 20px 12px; }
  .modal { max-height: calc(100dvh - 40px); }
}

/* ---------- Executive Dashboard ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.kpi-card.drillable:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 105, 0, .12);
  transform: translateY(-2px);
}
.kpi-card.accent .kpi-value { color: var(--accent); }
.kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--grey);
  line-height: 1.1;
}
.kpi-card .kpi-value.warn { color: var(--warn); }
.kpi-card .kpi-label {
  font-size: 11.5px;
  color: var(--grey-2);
  margin-top: 4px;
  font-weight: 500;
}

.dashboard-row {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.dashboard-row > .card {
  flex: 1;
  min-width: 320px;
  margin-bottom: 0;
}

.hbar-chart { display: flex; flex-direction: column; gap: 8px; }
.hbar-row { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.hbar-label { width: 140px; font-size: 12px; color: var(--grey); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { flex: 1; height: 20px; background: var(--line); border-radius: 4px; overflow: hidden; position: relative; min-width: 0; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s ease; }
.hbar-count { width: 50px; text-align: right; font-size: 12px; font-weight: 600; color: var(--grey); white-space: nowrap; }
.hbar-pct { width: 45px; text-align: right; font-size: 11px; color: var(--grey-2); white-space: nowrap; }

.aging-chart { display: flex; flex-direction: column; gap: 10px; }
.aging-row { display: flex; align-items: center; gap: 12px; min-height: 32px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.aging-row:last-child { border-bottom: none; }
.aging-label { width: 100px; font-size: 12px; font-weight: 600; color: var(--grey); white-space: nowrap; }
.aging-track { flex: 1; height: 24px; background: var(--line); border-radius: 4px; overflow: hidden; position: relative; min-width: 0; }
.aging-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s ease; }
.aging-count { width: 82px; text-align: right; font-size: 12px; font-weight: 600; color: var(--grey); white-space: nowrap; }

.alerts-panel { display: flex; flex-direction: column; gap: 8px; }
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: box-shadow 0.2s;
}
.alert-card.drillable:hover {
  box-shadow: var(--shadow);
}
.alert-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.alert-content { flex: 1; min-width: 0; }
.alert-title { font-size: 13px; font-weight: 600; color: var(--grey); margin-bottom: 2px; }
.alert-desc { font-size: 12px; color: var(--grey-2); }
.alert-count { font-size: 18px; font-weight: 700; flex-shrink: 0; margin-left: 8px; }

.pipeline-table th:nth-child(1),
.pipeline-table td:nth-child(1) { width: 180px; }
.pipeline-table th,
.pipeline-table td { text-align: right; padding: 10px; font-size: 13px; }
.pipeline-table th:first-child,
.pipeline-table td:first-child { text-align: left; }
