/* ============================================
   Metric™ — Technical catalog aesthetic
   ============================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f0efed;
  --surf: #e6e5e3;
  --side: #f0efed;
  --card: #e8e7e5;
  --t1: #1a1a1a;
  --t2: #595959;
  --t3: #636363;
  --t4: #c8c8c8;
  --line: #d4d3d1;
  --line-light: #dddcda;
  --hover: #e8e7e5;
  --accent: #b8441a;
  --highlight: #f0c94b;
  --highlight-muted: #e8c244;
  --gauge-bg: #d4d3d1;
  --gauge-fg: #1a1a1a;
  --bar-bg: #d4d3d1;
  --bar-fg: #1a1a1a;
  --chart-stroke: #1a1a1a;
  --chart-fill: rgba(26,26,26,0.05);
  --serif: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Type scale (8 sizes) */
  --fs-xs: 0.7rem;       /* 10.5px — labels, footer, avatar, gauge sub-text */
  --fs-sm: 0.75rem;      /* 11.25px — spec rows, tags, descriptions, small buttons */
  --fs-base: 0.875rem;   /* 13.1px — nav links, menu items, card buttons */
  --fs-md: 1rem;          /* 15px — metric/card names */
  --fs-lg: 1.6rem;       /* 24px — section headings */
  --fs-xl: 2rem;         /* 30px — page title */
  --fs-2xl: 2.28rem;     /* 34.2px — logo */
  --fs-display: 2.6rem;  /* 39px — stat numbers */
}

[data-theme="dark"] {
  --bg: #212121;
  --surf: #292929;
  --side: #212121;
  --card: #2a2a2a;
  --t1: #e8e8e8;
  --t2: #999999;
  --t3: #919191;
  --t4: #333333;
  --line: #333333;
  --line-light: #3a3a3a;
  --hover: #2e2e2e;
  --gauge-bg: #333333;
  --gauge-fg: #e8e8e8;
  --bar-bg: #333333;
  --bar-fg: #e8e8e8;
  --chart-stroke: #e8e8e8;
  --chart-fill: rgba(232,232,232,0.04);
  --accent: #e0734a;
  --highlight: #f0c94b;
  --highlight-muted: #d4b03e;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  background: #d5d4d1;
  transition: background .4s;
}
[data-theme="dark"] {
  background: #161616;
}
[data-theme="dark"] body {
  box-shadow: 0 4px 40px rgba(0,0,0,.3);
}
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--t1);
  display: flex;
  margin: 20px;
  height: calc(100vh - 40px);
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 30px rgba(0,0,0,.08);
  transition: background .4s, color .4s, box-shadow .4s;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--sans); }

/* ========== SIDEBAR ========== */
.sidebar {
  width: 200px; min-width: 200px;
  background: var(--side);
  border-right: none;
  display: flex; flex-direction: column;
  height: 100%; position: sticky; top: 0; z-index: 100;
  border-radius: 12px 0 0 12px;
  transition: background .4s;
  position: relative;
}
.sidebar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 20px;
  bottom: 20px;
  width: 1px;
  background: var(--line);
  transition: background .4s;
}
.sidebar-top { padding: 35px 20px 20px 43px; }
.logo { font-family: 'Oxanium', var(--sans); font-size: 2.6rem; font-weight: 700; letter-spacing: -0.04em; }
.logo sup { font-size: .5em; font-weight: 300; color: var(--t3); }
.logo-accent { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 27px 20px 0 35px; overflow-y: auto; }
.nav-group { margin-bottom: 22px; }
.nav-label {
  display: block; font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--t3); padding: 0 8px; margin-bottom: 5px;
}
.nav-summary {
  font-size: .58rem; font-weight: 400; color: var(--t3);
  padding: 0 8px; margin-bottom: 8px;
}
.nav-link {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 5px;
  font-size: var(--fs-base); font-weight: 400; color: var(--t2);
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--t1); background: var(--hover); }
.nav-link.active { color: var(--t1); font-weight: 600; }

.dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--t4); flex-shrink: 0; font-style: normal;
  transition: background .3s, transform .3s;
}
.nav-link.active .dot { background: #4a8c3f; transform: scale(1.3); }
[data-theme="dark"] .nav-link.active .dot { background: #6abf5e; }

.sidebar-foot {
  padding: 12px 20px 12px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar-welcome {
  padding: 0 8px 12px;
}
.sidebar-welcome .accent-rule {
  margin-bottom: 10px;
}
.sidebar-welcome .hero-desc {
  margin-bottom: 0;
  line-height: 1.55;
}
.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--t2); color: var(--bg);
  font-size: var(--fs-xs); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.02em; flex-shrink: 0;
  transition: background .4s, color .4s;
}
.user-name {
  font-size: var(--fs-sm); font-weight: 500; color: var(--t2);
  transition: color .4s;
}
.sidebar-user {
  cursor: pointer;
  position: relative;
}
.sidebar-user:hover .user-avatar { opacity: .8; }

/* User popup menu */
.user-menu {
  display: none;
  position: absolute;
  left: -8px;
  right: -8px;
  bottom: calc(100% + 8px);
  width: auto;
  background: var(--card);
  border-radius: 4px;
  padding: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  z-index: 110;
  transition: background .4s;
}
.user-menu.open { display: block; }
.um-header {
  padding: 10px 12px 8px;
}
.um-name {
  display: block;
  font-size: var(--fs-base);
  font-weight: 700;
  margin-bottom: 2px;
}
.um-email {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--t3);
}
.um-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 12px;
  transition: background .4s;
}
.um-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: var(--fs-xs);
}
.um-label { color: var(--t3); font-weight: 400; }
.um-value { font-weight: 600; }
.um-item {
  display: block;
  width: 100%;
  text-align: center;
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--bg);
  padding: 8px 12px;
  border: none;
  background: var(--t1);
  border-radius: 3px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.um-item:hover {
  background: var(--accent);
  color: #fff;
}
.um-logout {
  background: var(--highlight);
  color: #1a1a1a;
  margin-top: 4px;
}
.um-logout:hover {
  background: var(--highlight-muted);
  color: #1a1a1a;
}
.theme-btn {
  display: flex; align-items: center; padding: 6px 8px;
  background: none; border: none; cursor: pointer; border-radius: 5px;
  transition: background .15s;
}
.theme-btn:hover { background: var(--hover); }
.toggle-track {
  width: 28px; height: 14px; background: var(--t4);
  border-radius: 7px; position: relative; transition: background .3s;
}
.toggle-knob {
  width: 10px; height: 10px; background: var(--bg);
  border-radius: 50%; position: absolute; top: 2px; left: 2px;
  transition: transform .3s, background .3s;
}
[data-theme="dark"] .toggle-knob { transform: translateX(14px); }
[data-theme="dark"] .toggle-track { background: var(--t2); }

/* ========== MOBILE ========== */
.mobile-bar {
  display: none; align-items: center; justify-content: space-between;
  padding: 16px 18px; background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 90;
}
.burger {
  width: 18px; height: 12px; background: none; border: none;
  cursor: pointer; position: relative;
}
.burger span {
  display: block; width: 100%; height: 1.5px; background: var(--t1);
  position: absolute; left: 0; transition: transform .25s;
}
.burger span:first-child { top: 0; }
.burger span:last-child { bottom: 0; }
.burger.open span:first-child { transform: translateY(5px) rotate(45deg); }
.burger.open span:last-child { transform: translateY(-5px) rotate(-45deg); }
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 99;
  backdrop-filter: blur(3px);
}

/* ========== PAGE ========== */
.page {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding-bottom: 20px;
}
.page-header {
  flex-shrink: 0;
  padding: 40px 48px 0;
}
.header-sep {
  margin-bottom: 0;
}
.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 48px 32px;
  /* Slim scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--t4) transparent;
}
.page-scroll::-webkit-scrollbar { width: 4px; }
.page-scroll::-webkit-scrollbar-track { background: transparent; }
.page-scroll::-webkit-scrollbar-thumb {
  background: var(--t4);
  border-radius: 2px;
}
.page-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--t3);
}

/* ========== ANIMATIONS ========== */
.anim {
  opacity: 0; transform: translateY(20px);
  transition: opacity .6s cubic-bezier(.16,1,.3,1),
              transform .6s cubic-bezier(.16,1,.3,1);
}
.anim.visible { opacity: 1; transform: translateY(0); }

/* ========== SEPARATOR ========== */
.sep {
  border: none; height: 1px; background: var(--line);
  margin: 0 0 12px; transition: background .4s;
}

/* ========== TOPBAR ========== */
.pip-topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 12px;
}
.hero-title {
  font-family: var(--sans);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

/* Font toggle */
.font-toggle {
  display: flex;
  gap: 2px;
  background: var(--card);
  border-radius: 3px;
  padding: 2px;
  transition: background .4s;
}
.ft-btn {
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 5px 12px;
  border: none;
  border-radius: 2px;
  background: none;
  color: var(--t3);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.ft-btn:hover { color: var(--t1); }
.ft-btn.active {
  background: var(--t1);
  color: var(--bg);
  font-weight: 600;
}

/* Topbar actions row */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  position: relative;
}
/* Dark mode toggle — icon style */
.pip-contrast {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  flex-shrink: 0;
  color: var(--t3);
  transition: color .2s;
  margin-right: 8px;
}
.pip-contrast:hover { color: var(--t1); }
.pip-contrast .theme-icon {
  width: 20px;
  height: 20px;
  transition: transform .3s;
}
[data-theme="dark"] .pip-contrast .theme-icon {
  transform: rotate(180deg);
}
.pip-contrast .theme-track { display: none; }

/* Create button & menu */
.pip-create {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 10px 20px;
  background: var(--t1);
  color: var(--bg);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.pip-create:hover { opacity: .85; }

/* Export PDF button */
.pip-export-pdf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  border: 1.5px solid var(--t1);
  border-radius: 6px;
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--t1);
  background: transparent;
  cursor: pointer;
  transition: background .2s, color .2s;
  white-space: nowrap;
}
.pip-export-pdf:hover {
  background: var(--t1);
  color: var(--bg);
}

.create-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--card);
  border-radius: 4px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  white-space: nowrap;
  flex-direction: row;
  gap: 2px;
  transition: background .4s;
  z-index: 50;
}
.create-menu.open { display: flex; }
.cm-item {
  font-family: var(--sans);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--t2);
  padding: 8px 14px;
  border: none;
  background: none;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.cm-item:hover { background: var(--t1); color: var(--bg); font-weight: 600; }

/* Hero description row */
.hero-desc-row {
  max-width: 420px;
  margin-bottom: 0;
}
.hero-desc {
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--t2);
  line-height: 1.6;
  margin-bottom: 12px;
}
.hero-desc strong {
  font-weight: 700;
  color: var(--t1);
}
.accent-rule {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--highlight);
  margin-bottom: 20px;
}

/* ========== CLIENT CONTEXT BAR — attorney drill-in ========== */
.client-context-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}
.ctx-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .6rem;
  font-weight: 500;
  color: var(--t3);
  text-decoration: none;
  transition: color .15s;
  flex-shrink: 0;
}
.ctx-back:hover { color: var(--t1); }
.ctx-divider {
  color: var(--t4);
  font-size: .6rem;
}
.ctx-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.ctx-summary {
  font-size: .58rem;
  font-weight: 500;
  color: var(--t3);
  margin-left: auto;
  letter-spacing: .02em;
}
.ctx-client-name {
  color: var(--accent);
}
.ctx-page-sep {
  color: var(--t4);
  font-weight: 300;
}

/* ========== STATS BAR — big numbers ========== */
.stats-bar {
  background: var(--card);
  border-radius: 4px;
  padding: 18px 28px 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  margin-bottom: 8px;
  transition: background .4s;
}
.stat-group-label {
  font-size: var(--fs-base);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.stat-cols {
  display: flex;
  gap: 8px;
}
.stat-col {
  flex: 1;
  min-width: 0;
}
.stat-num {
  display: block;
  font-size: var(--fs-display);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--t2);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
  transition: color .4s;
}
.stat-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--t2);
}
.stat-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; font-style: normal;
}
.dot-green { background: #4a8c3f; }
.dot-orange { background: #b07a2a; }
.dot-red { background: #b04040; }
[data-theme="dark"] .dot-green { background: #6abf5e; }
[data-theme="dark"] .dot-orange { background: #e0a850; }
[data-theme="dark"] .dot-red { background: #e06060; }

.stat-divider {
  width: 1px;
  background: var(--line);
  margin: 0 32px;
  align-self: stretch;
  transition: background .4s;
}

/* ========== SECTION HEADERS ========== */
.rev-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.rev-code {
  font-family: var(--sans);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.rev-count {
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--t3);
}

/* ========== CARD GRIDS ========== */
.card-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.card-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.card-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }

/* ========== METRIC CARD ========== */
.metric-card {
  background: var(--card);
  border-radius: 4px;
  padding: 20px 22px;
  transition: background .4s;
  overflow: hidden;
}
.metric-card.compact { padding: 14px 18px; }
.metric-card.compact .metric-header { margin-bottom: 8px; }
.metric-card.compact .spec-row { padding: 4px 0; }

/* Card hover — action items & renewals */
.perf-section .metric-card,
.renew-section .metric-card {
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.perf-section .metric-card:hover,
.renew-section .metric-card:hover {
  background: #dcdbd8;
}
.perf-section .metric-card:hover .spec-row,
.renew-section .metric-card:hover .spec-row {
  border-color: #c8c7c4;
}
/* Highlight card hover */
.perf-section .metric-card.highlight:hover,
.renew-section .metric-card.highlight:hover {
  background: #e8c244;
}
.perf-section .metric-card.highlight:hover .spec-row,
.renew-section .metric-card.highlight:hover .spec-row {
  border-color: rgba(26,26,26,0.15);
}
/* Dark mode hover */
[data-theme="dark"] .perf-section .metric-card:hover,
[data-theme="dark"] .renew-section .metric-card:hover {
  background: #343434;
}
[data-theme="dark"] .perf-section .metric-card:hover .spec-row,
[data-theme="dark"] .renew-section .metric-card:hover .spec-row {
  border-color: #444;
}
[data-theme="dark"] .perf-section .metric-card.highlight:hover,
[data-theme="dark"] .renew-section .metric-card.highlight:hover {
  background: #d4b03e;
}
[data-theme="dark"] .perf-section .metric-card.highlight:hover .spec-row,
[data-theme="dark"] .renew-section .metric-card.highlight:hover .spec-row {
  border-color: rgba(26,26,26,0.2);
}

/* Highlight card — bold color block like Polestar */
.metric-card.highlight {
  background: var(--highlight);
  color: #1a1a1a;
}
.metric-card.highlight .spec-row dt { color: rgba(26,26,26,0.65); }
.metric-card.highlight .spec-row dt::after { border-color: rgba(26,26,26,0.2); }
.metric-card.highlight .spec-row { border-color: rgba(26,26,26,0.1); }
.metric-card.highlight .spec-row dd { color: #1a1a1a; }
.metric-card.highlight .bullet { background: #1a1a1a; }
.metric-card.highlight .gauge-bg { stroke: rgba(26,26,26,0.15); }
.metric-card.highlight .gauge-fg { stroke: #1a1a1a; }
.metric-card.highlight .gauge-label small { color: rgba(26,26,26,0.5); }
.metric-card.highlight .card-visual { background: rgba(26,26,26,0.06); }
.metric-card.highlight .accent-text { color: #1a1a1a; font-weight: 800; }

.metric-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.bullet {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--t1); flex-shrink: 0; font-style: normal;
  transition: background .4s;
}
.accent-bullet { background: var(--accent) !important; }

.metric-name {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== SPEC ROWS — with leader line ========== */
.spec-rows { display: flex; flex-direction: column; }
.spec-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-light);
  transition: border-color .4s;
}
.spec-row:last-child { border-bottom: none; }

.spec-row dt {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--t2);
  white-space: nowrap;
}
.spec-row dt::after {
  content: '';
  flex: 1;
  margin: 0 4px;
  min-width: 16px;
}
.spec-row {
  display: flex;
}
.spec-row dt {
  display: flex;
  align-items: baseline;
  flex: 1;
}
.spec-row dd {
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.accent-text { color: var(--accent); }

/* ========== CARD VISUALS ========== */
.card-visual {
  height: 100px;
  margin-top: 14px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  transition: background .4s;
}
.card-visual.tall { height: 140px; }
.card-visual canvas { width: 100% !important; height: 100% !important; }

/* ========== GAUGES ========== */
.card-gauge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  padding: 12px 0;
}
.card-gauge svg {
  width: 72px; height: 72px; transform: rotate(-90deg);
}
.gauge-bg {
  fill: none; stroke: var(--gauge-bg); stroke-width: 5;
  transition: stroke .4s;
}
.gauge-fg {
  fill: none; stroke: var(--gauge-fg); stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327;
  transition: stroke-dashoffset 1s cubic-bezier(.16,1,.3,1), stroke .4s;
}
.accent-stroke { stroke: var(--accent); }

.gauge-label {
  position: absolute;
  font-size: var(--fs-base);
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.gauge-label small {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--t3);
  margin-top: 1px;
}

/* ========== BARS ========== */
.bar-group {
  margin-top: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.bar-item {
  display: flex; align-items: center; gap: 12px;
}
.bar-name {
  width: 80px; flex-shrink: 0;
  font-size: var(--fs-xs); font-weight: 500; color: var(--t2);
}
.bar-track {
  flex: 1; height: 4px;
  background: var(--bar-bg); border-radius: 2px;
  overflow: hidden; transition: background .4s;
}
.bar-fill {
  height: 100%; background: var(--bar-fg);
  border-radius: 2px; width: 0;
  transition: width .8s cubic-bezier(.16,1,.3,1), background .4s;
}
.bar-fill.accent-bar { background: var(--accent); }
.bar-pct {
  width: 32px; text-align: right;
  font-size: var(--fs-xs); font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ========== CARD WITH ACTIONS — side by side layout ========== */
.metric-card.compact:has(.card-actions) {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  gap: 0 16px;
}
.metric-card.compact:has(.card-actions) .metric-header {
  grid-column: 1 / -1;
}
.metric-card.compact:has(.card-actions) .spec-rows {
  grid-column: 1;
  align-self: center;
}
.metric-card.compact:has(.card-actions) .card-actions {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
}

/* ========== CARD ACTIONS ========== */
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.btn-card {
  font-family: var(--sans);
  font-size: var(--fs-base);
  font-weight: 600;
  padding: 6px 16px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-review {
  background: var(--bg);
  color: var(--t2);
}
.btn-review:hover {
  background: var(--line);
  color: var(--t1);
}
.btn-done {
  background: var(--t1);
  color: var(--bg);
  transition: background .15s, color .15s, transform .1s;
}
.btn-done:hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.04);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  opacity: .85;
}
/* Buttons on highlight cards */
.metric-card.highlight .btn-review {
  background: rgba(26,26,26,0.08);
  color: rgba(26,26,26,0.7);
}
.metric-card.highlight .btn-review:hover {
  background: rgba(26,26,26,0.15);
  color: #1a1a1a;
}
.metric-card.highlight .btn-done {
  background: #1a1a1a;
  color: var(--highlight);
}
.metric-card.highlight .btn-done:hover {
  background: var(--accent);
  color: #fff;
}
.metric-card.highlight .btn-accent {
  background: #1a1a1a;
  color: var(--highlight);
}

/* ========== FOOTER ========== */
.page-foot {
  margin-top: 48px; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: 400;
  color: var(--t3); letter-spacing: .04em;
  transition: border-color .4s;
}

/* ========== RESPONSIVE ========== */

/* 4 → 2 columns — skip 3 to avoid name/button overlap */
@media (max-width: 1200px) {
  .card-grid-4, [class*="card-grid-4"] { grid-template-columns: repeat(2, 1fr) !important; }
  .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .page-header { padding: 32px 36px 0; }
  .page-scroll { padding: 0 36px 32px; }
}

/* Mobile — sidebar collapses, stacks to 1-2 columns */
@media (max-width: 768px) {
  body { margin: 10px !important; height: calc(100vh - 20px) !important; border-radius: 10px !important; }
  .sidebar {
    position: fixed; left: -240px; top: 0; height: 100vh;
    transition: left .3s cubic-bezier(.16,1,.3,1); z-index: 110;
    border-radius: 0;
  }
  .sidebar.open { left: 0; box-shadow: 6px 0 32px rgba(0,0,0,.15); }
  .overlay.open { display: block; }
  .mobile-bar { display: flex; }
  .page-header { padding: 20px 14px 0; }
  .page-scroll { padding: 0 14px 20px; }
  .card-grid-2,
  .card-grid-3 { grid-template-columns: 1fr; }
  .card-grid-4, [class*="card-grid-4"] { grid-template-columns: repeat(2, 1fr) !important; }
  .stats-bar { grid-template-columns: 1fr; }
  .stat-divider { width: 100%; height: 1px; margin: 20px 0; }
  .stat-num { font-size: 1.8rem; }
  .stat-cols { gap: 24px; flex-wrap: wrap; }
  .stat-col { min-width: 50px; }
  .stats-bar { padding: 18px 16px; overflow: hidden; }
  .pip-topbar { flex-wrap: wrap; gap: 10px; }
  .font-toggle { display: none; }
  .hero-title { font-size: 1.5rem; }
  .rev-code { font-size: 1.2rem; }
  .topbar-actions { margin-left: auto; }
}

/* Small mobile — everything single column */
@media (max-width: 480px) {
  .card-grid-2,
  .card-grid-3,
  .card-grid-4, [class*="card-grid-4"] { grid-template-columns: 1fr !important; }
  .hero-title { font-size: 1.3rem; }
}

/* ========== CHAT WIDGET ========== */

#pip-chat-btn {
  position: fixed; bottom: 24px; right: 24px;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--t1); color: var(--bg);
  border: none; cursor: pointer; z-index: 150;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
  transition: transform .2s, background .4s, color .4s;
}
#pip-chat-btn:hover { transform: scale(1.08); }
#pip-chat-btn svg { width: 22px; height: 22px; fill: currentColor; }

#pip-chat-panel {
  position: fixed; bottom: 84px; right: 24px;
  width: 380px; height: 520px;
  background: var(--bg); border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  z-index: 150; display: flex; flex-direction: column;
  overflow: hidden; border: 1px solid var(--line);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .25s cubic-bezier(.16,1,.3,1),
              transform .25s cubic-bezier(.16,1,.3,1),
              background .4s, border-color .4s;
}
#pip-chat-panel.open {
  opacity: 1; transform: translateY(0); pointer-events: auto;
}

.pip-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--card);
  border-bottom: 1px solid var(--line);
  transition: background .4s, border-color .4s;
}
.pip-chat-header-title {
  font-family: var(--sans); font-size: var(--fs-base);
  font-weight: 600; color: var(--t1); letter-spacing: .02em;
  transition: color .4s;
}
.pip-chat-header-title span { color: var(--accent); }
.pip-chat-close {
  width: 28px; height: 28px; border-radius: 4px;
  background: transparent; border: none; cursor: pointer;
  color: var(--t3); display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.pip-chat-close:hover { background: var(--line); color: var(--t1); }
.pip-chat-close svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.pip-chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.pip-chat-messages::-webkit-scrollbar { width: 4px; }
.pip-chat-messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

.pip-chat-msg {
  max-width: 82%; padding: 10px 14px;
  border-radius: 4px; font-size: var(--fs-sm);
  font-family: var(--sans); line-height: 1.6;
  word-wrap: break-word;
  opacity: 0; transform: translateY(6px);
  animation: chatMsgIn .3s cubic-bezier(.16,1,.3,1) forwards;
}
.pip-chat-msg.user {
  align-self: flex-end;
  background: var(--t1); color: var(--bg);
}
.pip-chat-msg.assistant {
  align-self: flex-start;
  background: var(--card); color: var(--t2);
  transition: background .4s, color .4s;
}

@keyframes chatMsgIn {
  to { opacity: 1; transform: translateY(0); }
}

.pip-chat-typing {
  display: flex; gap: 4px; align-items: center;
  padding: 12px 14px; align-self: flex-start;
}
.pip-chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--t3); animation: chatDot 1.2s infinite;
}
.pip-chat-typing span:nth-child(2) { animation-delay: .2s; }
.pip-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatDot {
  0%, 60%, 100% { opacity: .3; transform: scale(.8); }
  30% { opacity: 1; transform: scale(1); }
}

.pip-chat-input {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-top: 1px solid var(--line);
  background: var(--card); transition: background .4s, border-color .4s;
}
.pip-chat-input input {
  flex: 1; border: none; background: transparent;
  font-family: var(--sans); font-size: var(--fs-sm);
  color: var(--t1); outline: none;
  transition: color .4s;
}
.pip-chat-input input::placeholder { color: var(--t3); }
.pip-chat-send {
  width: 32px; height: 32px; border-radius: 4px;
  background: var(--t1); color: var(--bg);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s, color .4s;
}
.pip-chat-send:hover { transform: scale(1.06); }
.pip-chat-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.pip-chat-send svg { width: 16px; height: 16px; fill: currentColor; }

@media (max-width: 768px) {
  #pip-chat-panel {
    bottom: 10px; right: 10px; left: 10px;
    width: auto; height: calc(100vh - 80px);
    border-radius: 10px;
  }
  #pip-chat-btn { bottom: 16px; right: 16px; }
}

/* ========== ACCESSIBILITY ========== */

/* Skip to content */
.skip-link {
  position: absolute; top: -100%; left: 16px;
  padding: 8px 16px; background: var(--t1); color: var(--bg);
  font-size: var(--fs-sm); font-weight: 600; border-radius: 4px;
  z-index: 200; transition: top .2s;
}
.skip-link:focus { top: 12px; }

/* Focus-visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }
.nav-link:focus-visible { outline-offset: -2px; }
.theme-btn:focus-visible { outline-offset: 0; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .anim { opacity: 1; transform: none; }
  .gauge-fg { transition: none; }
  .bar-fill { transition: none; }
}

/* ============================================
   Tag Autocomplete — reusable component
   ============================================ */
.pip-tags-wrap {
  position: relative;
}
.pip-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  min-height: 38px;
  align-items: center;
  cursor: text;
  transition: border-color .15s, background .4s;
}
.pip-tags-row:focus-within { border-color: var(--t2); }

.pip-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9999px;
  font-size: .68rem;
  font-weight: 500;
  color: var(--t1);
  white-space: nowrap;
  transition: background .4s, border-color .4s, color .4s;
}
.pip-tag-text { pointer-events: none; }
.pip-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  border: none; background: none;
  color: var(--t3);
  font-size: .65rem; font-weight: 600;
  cursor: pointer;
  border-radius: 2px;
  padding: 0; line-height: 1;
  transition: color .12s, background .12s;
}
.pip-tag-remove:hover {
  color: var(--accent);
  background: rgba(212,82,31,0.08);
}

.pip-tags-input {
  flex: 1; min-width: 100px;
  border: none; background: none; outline: none;
  font-family: var(--sans);
  font-size: .72rem; color: var(--t1);
  padding: 2px 4px;
}
.pip-tags-input::placeholder { color: var(--t3); font-weight: 400; }

.pip-tags-dropdown {
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  z-index: 50;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 3px 3px;
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.pip-tags-option {
  padding: 7px 12px;
  font-size: .7rem;
  color: var(--t1);
  cursor: pointer;
  transition: background .1s;
}
.pip-tags-option:hover,
.pip-tags-option.active {
  background: var(--bg);
}
.pip-tags-option strong {
  font-weight: 700;
  color: var(--accent);
}
