:root {
  /* Profero brand palette (from logo) */
  --brand-purple: #5F3279;
  --brand-purple-light: #7a4f93;
  --brand-blue: #3787B4;
  --brand-green: #A5C82B;

  --color-bg-1: #E7F5FE;
  --color-bg-2: #C9DEED;
  --color-surface: #ffffff;
  --color-border: #e7e8ef;
  --color-primary: #5F3279;
  --color-primary-light: #7a4f93;
  --color-link: #2f6f99;
  --color-accent: #A5C82B;
  --color-success: #3f9d5b;
  --color-danger: #c0392b;
  --color-muted: #6b7280;
  --color-text: #23232b;
  --color-row-alt: #faf9fc;
  --color-novartis: #1a3c6e;
  --color-jnj: #cc0000;
  --color-madrigal: #5b2d8e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,0.04), 0 1px 3px rgba(16,24,40,0.06);
  --shadow-md: 0 10px 30px rgba(40,30,60,0.12);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--color-bg-2); }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  background: radial-gradient(120% 120% at 50% 0%, var(--color-bg-1) 0%, var(--color-bg-2) 100%);
  background-attachment: fixed;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar-logo { padding: 20px 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-logo img { width: 116px; height: auto; }
.sidebar-logo span { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--color-muted); text-transform: uppercase; padding-left: 2px; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.side-nav a { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 8px; color: #4b5566; font-weight: 500; font-size: 13.5px; text-decoration: none; transition: background 0.12s, color 0.12s; }
.side-nav a:hover { background: #f5f2f9; color: var(--color-primary); }
.side-nav a.active { background: #f1eaf8; color: var(--color-primary); font-weight: 600; }
.side-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: #9aa1ad; font-weight: 700; padding: 16px 12px 4px; }

details.side-group { margin: 1px 0; }
details.side-group > summary { list-style: none; cursor: pointer; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: #4b5566; display: flex; align-items: center; justify-content: space-between; }
details.side-group > summary::-webkit-details-marker { display: none; }
details.side-group > summary::after { content: '⌄'; font-size: 13px; color: #9aa1ad; transform: translateY(-2px); transition: transform 0.15s; }
details.side-group[open] > summary::after { transform: translateY(0) rotate(180deg); }
details.side-group > summary:hover { background: #f5f2f9; color: var(--color-primary); }
.side-group-body { padding: 2px 0 6px 6px; }
.side-area { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: #aab0bc; font-weight: 700; padding: 8px 12px 2px; }
.side-sub { display: block; padding: 6px 12px 6px 18px; border-radius: 8px; font-size: 13px; color: #5a6373; text-decoration: none; }
.side-sub:hover { background: #f5f2f9; color: var(--color-primary); }
.side-sub.active { background: #f1eaf8; color: var(--color-primary); font-weight: 600; }

.sidebar-footer { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 10px; }
.presence { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--color-muted); }
.presence-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-success); box-shadow: 0 0 0 3px rgba(63,157,91,0.18); }
.sidebar-footer .year-select { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-muted); }
.sidebar-footer select { flex: 1; background: #fff; border: 1px solid var(--color-border); color: var(--color-text); padding: 6px 8px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.side-logout { width: 100%; background: #fff; border: 1px solid var(--color-border); color: var(--color-muted); padding: 7px; border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.side-logout:hover { background: #f5f2f9; color: var(--color-primary); border-color: #e0d7ea; }

/* ===== CONTENT WRAP / TOPBAR ===== */
.content-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 12px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 10px 14px; position: sticky; top: 0; z-index: 60; }
.hamburger { font-size: 22px; line-height: 1; background: none; border: none; cursor: pointer; color: var(--color-primary); padding: 2px 6px; }
.topbar img { height: 22px; width: auto; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(20,16,30,0.42); z-index: 90; }

/* Collapse / expand the left nav (desktop) */
.side-collapse { background: none; border: none; cursor: pointer; color: var(--color-muted); font-size: 18px; line-height: 1; padding: 2px 7px; border-radius: 6px; }
.side-collapse:hover { background: #f5f2f9; color: var(--color-primary); }
.nav-reopen { display: none; position: fixed; top: 14px; left: 14px; z-index: 120; width: 34px; height: 34px; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--color-border); color: var(--color-primary); border-radius: 8px; cursor: pointer; box-shadow: var(--shadow); font-size: 15px; }
.nav-reopen:hover { background: #f5f2f9; }
@media (min-width: 901px) {
  html.nav-collapsed .sidebar { display: none; }
  html.nav-collapsed .nav-reopen { display: flex; }
}
@media (max-width: 900px) {
  .side-collapse { display: none; }
  .nav-reopen { display: none !important; }
}

/* ===== MAIN / LAYOUT ===== */
.main { flex: 1; max-width: 1480px; width: 100%; margin: 0 auto; padding: 28px; }
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--color-primary); letter-spacing: -0.2px; }
.page-header p { color: var(--color-muted); font-size: 13px; margin-top: 2px; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.alert-success { background: #eaf7ef; color: #1f6b3b; border: 1px solid #c6ebcf; }
.alert-danger { background: #fdecea; color: #9a2218; border: 1px solid #f6c9c2; }

/* CARDS */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-header h2 { font-size: 14px; font-weight: 600; color: var(--color-primary); }
.card-body { padding: 18px; }

/* KPI ROW */
.kpi-row { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.kpi { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px 20px; flex: 1; min-width: 160px; box-shadow: var(--shadow); }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-muted); margin-bottom: 4px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--color-primary); font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 12px; margin-top: 4px; font-weight: 500; }
.kpi-delta.up { color: var(--color-success); }
.kpi-delta.down { color: var(--color-danger); }
.kpi-delta.neutral { color: var(--color-muted); }

/* WEEK OVER WEEK BANNER */
.wow-banner { background: linear-gradient(135deg, var(--brand-purple) 0%, var(--brand-blue) 100%); color: #fff; border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; display: flex; gap: 32px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
.wow-banner h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255,255,255,0.65); margin-bottom: 4px; }
.wow-banner .val { font-size: 18px; font-weight: 700; }
.wow-banner .val.up { color: #c8ec6b; }
.wow-banner .val.down { color: #fca5a5; }
.wow-item { border-right: 1px solid rgba(255,255,255,0.15); padding-right: 32px; }
.wow-item:last-child { border-right: none; }

/* PROGRESS BAR */
.progress-wrap { margin: 4px 0; }
.progress-bar-bg { background: #ebedf3; border-radius: 4px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 4px; background: var(--brand-blue); transition: width 0.3s; }
.progress-bar-fill.good { background: var(--color-success); }
.progress-bar-fill.warn { background: #e0a32e; }
.progress-bar-fill.bad { background: var(--color-danger); }
.progress-pct { font-size: 12px; font-weight: 600; color: var(--color-muted); margin-top: 2px; }

/* QUARTERLY SUMMARY */
.quarterly-grid { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.quarter-card { flex: 1; min-width: 140px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.quarter-card h3 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-muted); margin-bottom: 8px; }
.quarter-card .ap { font-size: 18px; font-weight: 700; color: var(--color-primary); font-variant-numeric: tabular-nums; }
.quarter-card .goal { font-size: 11px; color: var(--color-muted); margin-top: 2px; }
.quarter-card .gap { font-size: 12px; font-weight: 600; margin-top: 6px; }
.quarter-card .gap.positive { color: var(--color-success); }
.quarter-card .gap.negative { color: var(--color-danger); }

/* CONSOLIDATED TABLE */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.consolidated { width: 100%; border-collapse: collapse; font-size: 11px; table-layout: fixed; min-width: 1320px; }
table.consolidated th { background: var(--color-primary); color: #fff; padding: 7px 6px; text-align: right; font-weight: 600; white-space: nowrap; font-size: 10.5px; }
table.consolidated th:first-child { text-align: left; position: sticky; left: 0; z-index: 3; background: var(--color-primary); width: 150px; box-shadow: 1px 0 0 rgba(0,0,0,0.06); }
table.consolidated td { padding: 6px 6px; text-align: right; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
table.consolidated td:first-child { text-align: left; position: sticky; left: 0; z-index: 1; width: 150px; white-space: normal; box-shadow: 1px 0 0 rgba(0,0,0,0.06); }
table.consolidated tr.area-row td { background: #f4eefa; font-weight: 700; font-size: 12px; color: var(--color-primary); }
table.consolidated tr.brand-row td { color: var(--color-text); background: #fff; }
table.consolidated tr.brand-row:nth-child(even) td { background: var(--color-row-alt); }
table.consolidated tr.total-row td { background: var(--color-primary); color: #fff; font-weight: 700; }
table.consolidated tr:hover td { background: #f6f1fb; }
table.consolidated tr.area-row:hover td { background: #f4eefa; }
table.consolidated tr.total-row:hover td { background: var(--color-primary); }
table.consolidated td.money { font-variant-numeric: tabular-nums; }
table.consolidated td.zero { color: #cbd5e1; }
table.consolidated td a { color: var(--color-link); text-decoration: none; font-weight: 600; }
table.consolidated td a:hover { text-decoration: underline; }
/* Monthly goal / % rows under the TOTAL row */
table.consolidated tr.goal-amt-row td { background: #f7f3fc; color: var(--color-muted); font-weight: 600; font-size: 11px; }
table.consolidated tr.goal-pct-row td { background: #f7f3fc; color: var(--color-primary); font-weight: 700; font-size: 11px; }
table.consolidated tr.goal-amt-row:hover td, table.consolidated tr.goal-pct-row:hover td { background: #f7f3fc; }
/* Activity report: wrap text so it fits without horizontal scroll */
table.consolidated.activity { table-layout: fixed; min-width: 0; }
table.consolidated.activity th, table.consolidated.activity td { white-space: normal; word-break: break-word; vertical-align: top; overflow: visible; text-overflow: clip; }
table.consolidated.activity th:first-child, table.consolidated.activity td:first-child { width: auto; }

/* BRAND PAGE */
.brand-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.brand-header h1 { font-size: 24px; font-weight: 700; color: var(--color-primary); }
.brand-badge { background: var(--color-primary); color: #fff; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }

.monthly-grid { display: flex; flex-direction: column; gap: 0; }
.monthly-table { width: 100%; border-collapse: collapse; }
.monthly-table th { padding: 8px 12px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--color-muted); border-bottom: 2px solid var(--color-border); }
.monthly-table td { padding: 0; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
/* Tint the month rows so each stands apart from the gray detail panel below. */
.monthly-table tr.month-row > td { background: #eef2f8; }
.monthly-table tr.month-row:hover > td { background: #e6ecf6; }
.monthly-table td input, .monthly-table td textarea { width: 100%; border: none; padding: 10px 12px; font-size: 13px; background: transparent; text-align: right; color: var(--color-text); font-family: inherit; }
.monthly-table td textarea { resize: none; overflow: hidden; line-height: 1.4; display: block; min-height: 40px; box-sizing: border-box; }
.monthly-table td input:focus, .monthly-table td textarea:focus { outline: none; background: #f6f1fb; }
.monthly-table td.month-name { padding: 10px 12px; font-weight: 600; color: var(--color-primary); width: 120px; }
.monthly-table td.month-name.past { color: var(--color-muted); }
.monthly-table td.month-name.current { color: var(--brand-blue); }
.monthly-table td.ytd { padding: 10px 12px; color: var(--color-success); font-weight: 600; }

/* LINE ITEMS */
.line-items-section { margin-top: 8px; }
.li-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; flex-wrap: wrap; }
.li-row input, .li-row select, .li-row textarea { border: 1px solid var(--color-border); border-radius: 5px; padding: 7px 10px; font-size: 13px; color: var(--color-text); background: #fff; font-family: inherit; }
.li-row textarea { resize: none; overflow: hidden; line-height: 1.4; min-height: 34px; }
.li-row input:focus, .li-row select:focus, .li-row textarea:focus { outline: none; border-color: var(--brand-blue); }
.li-title { flex: 2; min-width: 160px; }
.li-cat { flex: 1; min-width: 140px; }
.li-po { flex: 1; min-width: 120px; }
.li-amt { flex: 0 0 120px; }
.li-desc { flex: 3; min-width: 200px; }
.btn-remove { background: none; border: none; color: var(--color-danger); cursor: pointer; font-size: 18px; line-height: 1; padding: 7px; }
.btn-remove:hover { color: #7f1d1d; }

/* PO TABLE */
.po-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.po-row input { border: 1px solid var(--color-border); border-radius: 5px; padding: 7px 10px; font-size: 13px; }
.po-row input:focus { outline: none; border-color: var(--brand-blue); }

/* TABS */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--color-border); margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn { padding: 10px 18px; border: none; background: none; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--color-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.tab-btn:hover { color: var(--color-primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: none; transition: all 0.15s; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-light); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #f5f2f9; color: var(--color-primary); }
.btn-accent { background: var(--brand-green); color: #2c3a08; }
.btn-accent:hover { filter: brightness(0.96); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* GOALS PAGE */
.goals-grid { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 560px; }
.goals-group { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.goals-group-header { padding: 12px 16px; font-weight: 700; font-size: 13px; }
.goals-group-header.novartis { background: #dbeafe; color: var(--color-novartis); }
.goals-group-header.jnj { background: #fee2e2; color: var(--color-jnj); }
.goals-group-header.madrigal { background: #f3e8ff; color: var(--color-madrigal); }
.goals-group-header.overall { background: var(--color-primary); color: #fff; }
.goals-group-body { padding: 16px; }
.goal-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.goal-row label { width: 30px; font-weight: 700; font-size: 12px; color: var(--color-muted); }
.goal-row input { flex: 1; border: 1px solid var(--color-border); border-radius: 5px; padding: 7px 10px; font-size: 13px; }
.goal-row input:focus { outline: none; border-color: var(--brand-blue); }
.goal-annual { padding: 10px 16px; background: #f6f1fb; font-size: 12px; font-weight: 600; color: var(--color-primary); border-top: 1px solid var(--color-border); }

/* ASK — chat transcript */
.chat-q { background: #f1eaf8; color: var(--color-primary); padding: 10px 14px; border-radius: 12px 12px 2px 12px; margin: 0 0 6px auto; max-width: 80%; width: fit-content; font-weight: 600; font-size: 14px; }
.chat-a { background: #f6f7f9; color: var(--color-text); padding: 12px 14px; border-radius: 12px 12px 12px 2px; margin: 0 auto 16px 0; max-width: 92%; white-space: pre-wrap; line-height: 1.55; font-size: 14px; }

/* Inline monthly detail-items table: thin separators between rows. */
.detail-table .detail-row td { border-bottom: 1px solid #e6eaf0; }

/* Report tables (Brand Overview + exports) */
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th, .report-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.report-table thead th { background: #f8fafc; font-size: 11px; text-transform: uppercase; letter-spacing: .02em; color: var(--color-muted); font-weight: 700; }
.report-table td.num, .report-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tr.row-current { background: #eff6ff; }
.report-table tr.row-current td:first-child { font-weight: 700; }

/* Drag-to-reorder handles (Manage page) */
.drag-handle { cursor: grab; color: #b9b2c6; font-size: 16px; line-height: 1; user-select: none; padding: 0 4px; flex: 0 0 auto; }
.drag-handle:hover { color: var(--color-primary); }
.area-card[draggable="true"], .brand-row-item[draggable="true"] { cursor: grabbing; opacity: 0.6; }

/* UTILITY */
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.text-muted { color: var(--color-muted); font-size: 12px; }
.text-right { text-align: right; }
.text-danger { color: var(--color-danger); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-novartis { background: #dbeafe; color: var(--color-novartis); }
.badge-jnj { background: #fee2e2; color: var(--color-jnj); }
.badge-madrigal { background: #f3e8ff; color: var(--color-madrigal); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { position: fixed; top: 0; left: 0; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-md); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .topbar { display: flex; }
  .main { padding: 16px; }
}

@media (max-width: 700px) {
  .overview-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 600px) {
  .main { padding: 12px; }
  .page-header h1 { font-size: 19px; }
  .card-body { padding: 14px; }
  .kpi-row, .quarterly-grid { flex-direction: column; }
  .wow-banner { flex-direction: column; gap: 16px; align-items: stretch; }
  .wow-item { border-right: none; padding-right: 0; border-bottom: 1px solid rgba(255,255,255,0.15); padding-bottom: 16px; }
  .wow-item:last-child { border-bottom: none; padding-bottom: 0; }
  .brand-header h1 { font-size: 20px; }
}
