:root {
  --ink: #17221f;
  --muted: #68756f;
  --line: #dfe6e2;
  --canvas: #f4f7f5;
  --white: #ffffff;
  --forest: #173c35;
  --forest-2: #225247;
  --mint: #e8f5ef;
  --green: #2e8b67;
  --orange: #e66b2c;
  --orange-pale: #fff0e7;
  --blue: #3972c6;
  --blue-pale: #eaf1fb;
  --red: #c84040;
  --red-pale: #fdecec;
  --yellow: #c98b18;
  --yellow-pale: #fff7df;
  --shadow: 0 12px 30px rgba(29, 54, 46, 0.07);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: "DM Sans", sans-serif; font-size: 14px; letter-spacing: 0; }
button, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }

.sidebar { position: sticky; top: 0; height: 100vh; background: var(--forest); color: white; padding: 22px 14px 18px; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 24px; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand-mark { width: 38px; height: 38px; border-radius: 6px; display: grid; place-items: center; background: var(--orange); }
.brand-mark svg { width: 21px; }
.brand strong { display: block; font: 800 16px Manrope, sans-serif; }
.brand span { display: block; color: #bcd0c8; font-size: 11px; margin-top: 2px; }
.nav { margin-top: 20px; display: grid; gap: 3px; }
.nav-item { border: 0; border-radius: 5px; background: transparent; color: #d4e2dc; height: 43px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 9px; text-align: left; padding: 0 11px; font-weight: 600; }
.nav-item svg { width: 18px; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: white; }
.nav-item b { min-width: 21px; height: 20px; display: grid; place-items: center; background: rgba(255,255,255,.13); border-radius: 10px; font-size: 10px; }
.system-card { margin-top: auto; border: 1px solid rgba(255,255,255,.16); border-radius: 6px; padding: 12px; background: rgba(0,0,0,.08); }
.system-top, .system-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.system-top { padding-bottom: 9px; margin-bottom: 5px; border-bottom: 1px solid rgba(255,255,255,.12); font-size: 11px; }
.system-top span { display: flex; align-items: center; gap: 7px; color: #d4e2dc; }
.system-top strong { color: #8de0b7; font-size: 10px; text-transform: uppercase; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #5ad18b; box-shadow: 0 0 0 3px rgba(90,209,139,.16); }
.system-row { color: #bcd0c8; font-size: 10px; padding-top: 7px; }
.system-row b { color: white; }
.role-box { padding-top: 15px; }
.role-box > span { display: block; color: #a9c0b7; font-size: 10px; text-transform: uppercase; margin: 0 0 7px 2px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid rgba(255,255,255,.18); padding: 3px; border-radius: 5px; }
.segmented button { border: 0; color: #c8dbd3; background: transparent; height: 29px; border-radius: 3px; font-size: 11px; }
.segmented button.active { background: white; color: var(--forest); font-weight: 700; }

.main { min-width: 0; }
.topbar { min-height: 76px; background: var(--white); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 28px; position: sticky; top: 0; z-index: 20; }
.page-title span { display: block; color: var(--green); text-transform: uppercase; font-size: 10px; letter-spacing: .8px; font-weight: 800; }
.page-title h1 { margin: 3px 0 0; font: 800 22px Manrope, sans-serif; }
.global-filters { display: flex; align-items: flex-end; gap: 8px; }
.global-filters label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .45px; font-weight: 700; }
select { min-width: 148px; height: 36px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: white; padding: 0 30px 0 10px; outline: none; }
select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,139,103,.1); }
.icon-button { width: 36px; height: 36px; border-radius: 5px; border: 1px solid var(--line); background: white; color: var(--forest); display: grid; place-items: center; }
.icon-button:hover { background: var(--mint); }
.icon-button svg { width: 17px; }
.mobile-menu { display: none; }
.workspace { padding: 20px 28px 32px; }
.freshness { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 7px 11px; border: 1px solid #cfe2d9; color: var(--forest-2); background: var(--mint); border-radius: 5px; margin-bottom: 14px; font-size: 11px; }
.freshness svg { width: 15px; }
.freshness b { margin-left: auto; color: var(--muted); font-weight: 600; }
.view { display: none; }
.view.active { display: block; }
footer { color: var(--muted); font-size: 10px; margin-top: 18px; text-align: center; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; margin-bottom: 12px; }
.metric-card, .panel { background: var(--white); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.metric-card { padding: 14px 15px; min-height: 113px; position: relative; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--green); }
.metric-card.orange::before { background: var(--orange); }
.metric-card.blue::before { background: var(--blue); }
.metric-card.red::before { background: var(--red); }
.metric-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); text-transform: uppercase; letter-spacing: .55px; font-size: 9px; font-weight: 800; }
.metric-label svg { width: 16px; color: var(--green); }
.metric-value { font: 800 25px Manrope, sans-serif; margin-top: 12px; }
.metric-meta { color: var(--muted); font-size: 10px; margin-top: 5px; display: flex; justify-content: space-between; gap: 8px; }
.trend-up { color: var(--green); font-weight: 700; }
.trend-down { color: var(--red); font-weight: 700; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr); gap: 12px; margin-bottom: 12px; }
.dashboard-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { overflow: hidden; }
.panel-head { min-height: 50px; padding: 12px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font: 700 13px Manrope, sans-serif; }
.panel-head span { color: var(--muted); font-size: 10px; }
.panel-head .panel-actions { display: flex; gap: 7px; }
.panel-body { padding: 14px 15px; }
.chart-box { height: 245px; position: relative; }
.chart-box.compact { height: 220px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { color: var(--muted); text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .45px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid #edf1ef; white-space: nowrap; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-record] { cursor: pointer; }
tbody tr[data-record]:hover { background: #f7faf8; }
.right { text-align: right; }
.person { display: flex; align-items: center; gap: 8px; }
.avatar { width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center; color: white; background: var(--forest-2); font-size: 9px; font-weight: 800; }
.badge { display: inline-flex; align-items: center; min-height: 22px; border-radius: 3px; padding: 3px 7px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.badge.green { color: #1d6a4c; background: var(--mint); }
.badge.orange { color: #a54c1c; background: var(--orange-pale); }
.badge.blue { color: #285998; background: var(--blue-pale); }
.badge.red { color: #a92f2f; background: var(--red-pale); }
.badge.yellow { color: #966510; background: var(--yellow-pale); }
.stage-list { display: grid; gap: 10px; }
.stage-row { display: grid; grid-template-columns: 105px 1fr 62px; gap: 9px; align-items: center; font-size: 11px; }
.stage-row strong { text-align: right; }
.track { height: 8px; border-radius: 4px; background: #edf1ef; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 4px; background: var(--green); }
.activity-list { display: grid; gap: 0; }
.activity { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.activity:last-child { border-bottom: 0; }
.activity-icon { width: 28px; height: 28px; border-radius: 5px; display: grid; place-items: center; background: var(--mint); color: var(--green); }
.activity-icon svg { width: 14px; }
.activity strong { display: block; font-size: 11px; }
.activity span, .activity time { color: var(--muted); font-size: 9px; }
.kpi-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.kpi-strip div { background: white; padding: 11px 15px; }
.kpi-strip span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.kpi-strip strong { display: block; margin-top: 4px; font: 700 16px Manrope; }
.empty { padding: 36px; color: var(--muted); text-align: center; }

.pipeline-columns { display: grid; grid-template-columns: repeat(5, minmax(205px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 7px; }
.pipeline-col { min-height: 470px; background: #eef3f0; border: 1px solid var(--line); border-radius: 6px; padding: 9px; }
.pipeline-col-head { display: flex; justify-content: space-between; align-items: center; padding: 3px 3px 9px; }
.pipeline-col-head strong { font-size: 11px; }
.pipeline-col-head span { color: var(--muted); font-size: 10px; }
.deal-card { background: white; border: 1px solid var(--line); border-radius: 5px; padding: 11px; margin-bottom: 8px; cursor: pointer; }
.deal-card:hover { border-color: #aacbbd; box-shadow: 0 7px 18px rgba(29,54,46,.07); }
.deal-card strong { display: block; font-size: 11px; margin-bottom: 7px; }
.deal-value { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; margin-top: 9px; }
.deal-value b { color: var(--ink); }
.deal-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 9px; color: var(--muted); }
.mini-avatar { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--forest); color: white; font-size: 8px; font-weight: 800; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(16,33,28,.22); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.detail-drawer { position: fixed; z-index: 60; top: 0; right: 0; bottom: 0; width: min(430px, 100vw); background: white; box-shadow: -20px 0 45px rgba(17,37,30,.18); padding: 25px; transform: translateX(105%); transition: transform .25s ease; overflow-y: auto; }
.detail-drawer.open { transform: translateX(0); }
.drawer-close { margin-left: auto; }
.drawer-kicker { color: var(--green); text-transform: uppercase; font-size: 10px; font-weight: 800; margin-top: 20px; }
.detail-drawer h2 { font: 800 23px Manrope; margin: 5px 0 3px; }
.drawer-sub { color: var(--muted); }
.drawer-value { font: 800 28px Manrope; margin: 22px 0; color: var(--forest); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-field { border: 1px solid var(--line); border-radius: 5px; padding: 10px; }
.detail-field span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.detail-field strong { display: block; margin-top: 5px; font-size: 12px; }
.notes { margin-top: 16px; background: var(--canvas); border-radius: 6px; padding: 13px; line-height: 1.55; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { padding: 18px 9px; }
  .brand { justify-content: center; padding: 0 0 18px; }
  .brand > div:last-child, .nav-item span, .nav-item b, .system-card, .role-box { display: none; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 238px; padding: 22px 14px 18px; transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .brand { justify-content: flex-start; padding: 0 10px 24px; }
  .brand > div:last-child, .nav-item span, .nav-item b, .system-card, .role-box { display: block; }
  .nav-item { grid-template-columns: 22px 1fr auto; justify-items: start; padding: 0 11px; }
  .topbar { flex-wrap: wrap; padding: 12px 15px; }
  .mobile-menu { display: grid; }
  .page-title { flex: 1; }
  .global-filters { width: 100%; }
  .global-filters label { flex: 1; }
  select { width: 100%; min-width: 0; }
  .workspace { padding: 15px; }
  .dashboard-grid, .dashboard-grid.equal { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; gap: 8px; }
  .metric-card { min-height: 103px; padding: 12px; }
  .metric-value { font-size: 20px; }
  .freshness { align-items: flex-start; flex-wrap: wrap; }
  .freshness b { width: 100%; margin-left: 23px; }
  .global-filters { display: grid; grid-template-columns: 1fr 36px; }
  .global-filters label { grid-column: 1 / -1; }
  .global-filters .icon-button { grid-column: 2; grid-row: 3; }
  .page-title h1 { font-size: 18px; }
  .kpi-strip { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; }
  .panel-head span { max-width: 46%; text-align: right; }
}
