  :root {
    --bg: #0e1410;
    --bg-panel: #141b16;
    --bg-card: #182019;
    --bg-hover: #1e2922;
    --border: #2a342c;
    --border-strong: #3a463c;
    --text-primary: #eef2ee;
    --text-secondary: #9aa89e;
    --text-muted: #647167;
    --accent: #4fb37a;
    --accent-dim: #2c5c41;
    --accent-bg: #16291e;
    --opus: #d98b4f;
    --sonnet: #4fb37a;
    --haiku: #6a9fd8;
    --fable: #c86bd8;
    --chat: #4fb37a;
    --cowork: #d98b4f;
    --code: #9d7fd8;
    --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  }

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

  body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
  }

  .wrap { max-width: 1280px; margin: 0 auto; padding: 32px 24px 80px; }

  /* Header */
  header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 16px;
  }
  .brand-mark {
    display: flex;
    align-items: baseline;
    gap: 10px;
  }
  .brand-mark .dot {
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
    display: inline-block;
    transform: translateY(-2px);
  }
  h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
  }
  .date-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
  }
  .quick-ranges {
    display: flex;
    gap: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
  }
  .quick-ranges button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--sans);
    font-size: 12.5px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .quick-ranges button.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 0 0 1px var(--border-strong);
  }
  .quick-ranges button:hover:not(.active) { color: var(--text-primary); }
  .date-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .date-range-inputs input[type="date"] {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-primary);
    font-family: var(--mono);
    font-size: 12.5px;
    padding: 6px 10px;
    color-scheme: dark;
  }
  .date-range-inputs input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-dim);
  }
  .date-sep { color: var(--text-muted); font-size: 12px; }

  /* KPI row */
  .kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 24px;
  }
  .kpi {
    background: var(--bg-panel);
    padding: 18px 20px;
  }
  .kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .kpi-value {
    font-family: var(--mono);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }
  .kpi-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-family: var(--mono);
  }
  .kpi-sub.up { color: var(--accent); }

  /* Layout: main grid */
  .grid-main {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
  }

  .panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
  }
  .panel-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
  }
  .panel-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
  }

  /* Model bars */
  .model-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .model-row:last-child { border-bottom: none; }
  .model-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .model-name {
    font-family: var(--mono);
    font-size: 12.5px;
    width: 150px;
    flex-shrink: 0;
    color: var(--text-secondary);
  }
  .model-bar-track {
    flex: 1;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
  }
  .model-bar-fill { height: 100%; border-radius: 3px; }
  .model-stat {
    font-family: var(--mono);
    font-size: 12.5px;
    width: 90px;
    text-align: right;
    flex-shrink: 0;
  }

  /* Product chips */
  .product-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
  }
  .chip {
    font-size: 12px;
    padding: 5px 11px;
    border-radius: 100px;
    border: 1px solid var(--border-strong);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--mono);
  }
  .chip.active {
    background: var(--accent-bg);
    border-color: var(--accent-dim);
    color: var(--accent);
  }

  .donut-wrap {
    display: flex;
    align-items: center;
    gap: 24px;
  }
  .donut-legend { flex: 1; }
  .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    padding: 6px 0;
  }
  .legend-item .sq { width: 9px; height: 9px; border-radius: 2px; }
  .legend-item .lbl { color: var(--text-secondary); flex: 1; }
  .legend-item .val { font-family: var(--mono); color: var(--text-primary); }

  /* Table */
  .table-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
  }
  .table-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px 14px;
  }
  table { width: 100%; border-collapse: collapse; }
  thead th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 500;
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
  }
  thead th:hover { color: var(--text-secondary); }
  thead th.sorted { color: var(--accent); }
  thead th.num, td.num { text-align: right; }
  tbody tr {
    cursor: pointer;
    transition: background 0.1s;
  }
  tbody tr:hover { background: var(--bg-hover); }
  tbody tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
  td { padding: 13px 20px; font-size: 13px; }
  td.num { font-family: var(--mono); font-size: 12.5px; }
  .user-cell { display: flex; align-items: center; gap: 10px; }
  .avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
    font-family: var(--mono);
    flex-shrink: 0;
  }
  .user-name { font-weight: 500; }
  .user-email { font-size: 11.5px; color: var(--text-muted); }
  .model-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--mono);
    font-size: 11.5px;
    padding: 3px 8px;
    border-radius: 5px;
    background: var(--bg-card);
    color: var(--text-secondary);
    margin: 1px 3px 1px 0;
  }
  .model-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
  .arrow { color: var(--text-muted); font-size: 14px; }

  /* Drill-down view */
  #detail-view { display: none; }
  .back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--sans);
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 20px;
    padding: 0;
  }
  .back-btn:hover { color: var(--text-primary); }
  .detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
  }
  .avatar-lg {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; font-weight: 600;
    font-family: var(--mono);
  }
  .detail-name { font-size: 18px; font-weight: 600; }
  .detail-email { font-size: 13px; color: var(--text-muted); font-family: var(--mono); }
  .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
  }
  .empty-state .big { font-size: 32px; margin-bottom: 12px; }

  @media (max-width: 860px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .grid-main { grid-template-columns: 1fr; }
    .model-name { width: 100px; }
  }
