/* DevCleaner Pro dashboard — paper/cream + ink sidebar + green accent */
:root {
  --paper: #faf7f1;
  --paper-deep: #f1ece2;
  --cream: #fffdf8;
  --ink: #16130e;
  --ink-soft: #4a453c;
  --ink-muted: #8e877a;
  --hairline: #ded7c8;
  --safe: #1e7a44;
  --safe-soft: #e2f0e6;
  --safe-mid: #5aaa72;
  --safe-light: #a8d4b5;
  --sidebar: #16130e;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --radius: 18px;
  --gap: 18px;
}

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url(/fonts/bricolage-latin.woff2) format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/jbmono-400.woff2) format("woff2");
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--display);
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(30, 122, 68, 0.07), transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(222, 215, 200, 0.55), transparent 50%),
    var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: var(--cream);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--cream);
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--safe);
  box-shadow: 0 0 0 3px rgba(30, 122, 68, 0.35);
}
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255, 253, 248, 0.62);
  font-weight: 600;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { color: var(--cream); background: rgba(255, 253, 248, 0.06); }
.nav-item.active {
  color: var(--cream);
  background: rgba(30, 122, 68, 0.18);
  border-left-color: var(--safe);
}
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,253,248,0.1); }
.sidebar-foot .email {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(255,253,248,0.45);
  word-break: break-all;
  margin-bottom: 10px;
}
.signout {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,253,248,0.7);
  text-decoration: none;
}
.signout:hover { color: var(--cream); }

.main {
  padding: 40px 48px 64px;
  width: 100%;
  min-width: 0;
  /* Fill the shell's 1fr column — no narrow max-width leaving empty cream on the right */
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
}
.page-head-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 4px;
}
.page-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 10px;
}
h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 8px;
}
.lede {
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 42em;
  margin-bottom: 0;
}
.refresh-stamp {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  min-height: 1em;
}

/* Card grid — Heard-style full-width blocks, DevCleaner palette */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--gap);
  width: 100%;
}
.dash-grid--usage {
  grid-template-columns: 1fr;
}

.stat-card {
  background: var(--cream);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 24px 26px;
  animation: fadeUp 0.45s ease both;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.stat-card:nth-child(1) { animation-delay: 0.02s; }
.stat-card:nth-child(2) { animation-delay: 0.06s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.14s; }
.stat-card:nth-child(5) { animation-delay: 0.18s; }
.stat-card:nth-child(6) { animation-delay: 0.22s; }

/* Top row: Total freed + Your plan (1fr 1fr) */
.stat-card--hero {
  grid-column: span 3;
  background:
    linear-gradient(145deg, rgba(30, 122, 68, 0.08) 0%, transparent 55%),
    var(--cream);
  padding: 28px 30px;
  min-height: 168px;
  justify-content: center;
}
.stat-card--plan {
  grid-column: span 3;
  min-height: 168px;
}
/* Bottom metric row: three equal cards */
.stat-card--metric {
  grid-column: span 2;
}
/* Recent + categories side-by-side when both present */
.stat-card--half {
  grid-column: span 3;
}
.stat-card--wide {
  grid-column: 1 / -1;
}

/* Mini activity sparkline (Overview) */
.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 52px;
  margin-top: 4px;
  flex: 1;
}
.sparkline span {
  flex: 1;
  min-width: 0;
  min-height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--safe-light);
}
.sparkline span.on {
  background: var(--safe);
}
.sparkline span[data-h="1"] { height: 18%; }
.sparkline span[data-h="2"] { height: 36%; }
.sparkline span[data-h="3"] { height: 58%; }
.sparkline span[data-h="4"] { height: 78%; }
.sparkline span[data-h="5"] { height: 100%; }

.stat-card .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 10px;
}
.stat-card .value {
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.stat-card .value--md {
  font-size: clamp(28px, 3.5vw, 40px);
}
.stat-card .value--code {
  font-size: clamp(20px, 2.5vw, 26px);
  font-family: var(--mono);
  letter-spacing: 0.06em;
  font-weight: 700;
}
.stat-card .sub {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}
.stat-card .plan-name {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: -0.03em;
  text-transform: capitalize;
  margin-bottom: 12px;
}
.stat-card .plan-note {
  margin-top: auto;
  padding-top: 14px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.45;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.stat-card h2,
.card h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0;
}

.inline-link {
  color: var(--safe);
  font-weight: 700;
  text-decoration: none;
}
.inline-link:hover { text-decoration: underline; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 11px;
  border-radius: 999px;
  width: fit-content;
  background: var(--paper-deep);
  color: var(--ink-soft);
}
.status-pill--ok {
  background: var(--safe-soft);
  color: var(--safe);
}
.status-pill--ok::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--safe);
}

/* Legacy metric / card aliases (referral + login) */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  margin-bottom: 28px;
}
.metric {
  background: var(--cream);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 22px 24px;
  animation: fadeUp 0.45s ease both;
}
.metric:nth-child(2) { animation-delay: 0.06s; }
.metric:nth-child(3) { animation-delay: 0.12s; }
.metric .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 8px;
}
.metric .value {
  font-size: clamp(26px, 3.5vw, 36px);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.metric .sub { margin-top: 4px; font-size: 13px; color: var(--ink-soft); }

.card {
  background: var(--cream);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 18px;
}
.card h2 { margin-bottom: 14px; }

.list { list-style: none; }
.list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
}
.list li:last-child { border-bottom: none; }
.list .meta { color: var(--ink-soft); font-size: 13px; }
.list .bytes {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.empty {
  color: var(--ink-soft);
  font-size: 14px;
  padding: 8px 0;
}
.empty a { color: var(--safe); font-weight: 700; text-decoration: none; border-bottom: 1px solid var(--safe-soft); }

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--safe-soft);
  color: var(--safe);
  padding: 5px 12px;
  border-radius: 999px;
}

/* Heatmap — fluid columns fill card width (GitHub-style) */
.heatmap-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, auto);
  grid-auto-columns: minmax(0, 1fr);
  gap: clamp(2px, 0.45vw, 4px);
  width: 100%;
}
.hm-cell {
  aspect-ratio: 1;
  width: 100%;
  height: auto;
  min-width: 0;
  border-radius: 2px;
  background: var(--paper-deep);
  animation: hmIn 0.35s ease both;
}
.hm-cell.l1 { background: #e2f0e6; }
.hm-cell.l2 { background: var(--safe-light); }
.hm-cell.l3 { background: var(--safe-mid); }
.hm-cell.l4 { background: var(--safe); }
.hm-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
}
.hm-legend .swatch {
  width: 11px; height: 11px; border-radius: 2px;
}

.ref-code {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--paper);
  border: 1px dashed var(--hairline);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  margin: 8px 0 16px;
}
.share-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.share-url {
  flex: 1;
  min-width: 200px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink-soft);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--cream);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn:hover { background: var(--safe); border-color: var(--safe); transform: translateY(-1px); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
}
.btn.ghost:hover { color: var(--cream); }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  background:
    linear-gradient(var(--hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--hairline) 1px, transparent 1px),
    var(--paper);
  background-size: 72px 72px, 72px 72px, auto;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--cream);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 32px 30px;
  animation: fadeUp 0.4s ease both;
}
.login-card .brand { color: var(--ink); margin-bottom: 22px; }
.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.login-card .lede { margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink-soft);
}
.field input {
  width: 100%;
  font-family: var(--display);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--paper);
  color: var(--ink);
}
.field input:focus {
  outline: 2px solid var(--safe-soft);
  border-color: var(--safe);
}
.msg {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-soft);
  min-height: 1.2em;
}
.msg.ok { color: var(--safe); }
.msg.err { color: #9a3412; }
.login-note {
  margin-top: 20px;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.55;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes hmIn {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card--hero,
  .stat-card--plan,
  .stat-card--metric,
  .stat-card--half { grid-column: span 1; }
  .stat-card--wide { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
  }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .sidebar-foot {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0;
    padding-top: 10px;
  }
  .sidebar-foot .email { margin-bottom: 0; }
  .main { padding: 24px 18px 40px; }
  .page-head { flex-direction: column; gap: 12px; }
  .page-head-meta { align-items: flex-start; }
  .metrics { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .stat-card--hero,
  .stat-card--plan,
  .stat-card--metric,
  .stat-card--half,
  .stat-card--wide { grid-column: span 1; }
}
