/* ATP AutoCount — custom CSS (anti-AI-slop)
   System font, asymmetric sidebar+main, restrained palette, dark mode, print. */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e4e4e0;
  --accent: #2b5a8c;
  --accent-soft: #e8f0f8;
  --good: #2d7a3e;
  --warn: #b67419;
  --bad: #b33a3a;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 6px rgba(0,0,0,.04);
}
[data-theme="dark"] {
  --bg: #14171c;
  --surface: #1c2026;
  --text: #e8e8e6;
  --muted: #9a9a98;
  --border: #2a2f37;
  --accent: #6ea3d3;
  --accent-soft: #1f2b3a;
  --good: #5db872;
  --warn: #e0a44d;
  --bad: #e07070;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 1px 6px rgba(0,0,0,.3);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar h1 { font-size: 1rem; margin: 0 0 .25rem; }
.sidebar .subtitle { font-size: .75rem; color: var(--muted); margin-bottom: 1.25rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .1rem; }
.sidebar nav a {
  padding: .45rem .6rem;
  border-radius: 4px;
  color: var(--text);
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sidebar nav a:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: .7rem;
  color: var(--muted);
}

.main { padding: 1.75rem 2rem 4rem; max-width: 1100px; }
.main header.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
  gap: 1rem; flex-wrap: wrap;
}
.main header.page-head h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
.main header.page-head .sub { color: var(--muted); font-size: .85rem; }
.theme-toggle {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: .35rem .65rem; border-radius: 4px; cursor: pointer; font-size: .8rem;
}
.theme-toggle:hover { border-color: var(--accent); }

/* Components */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: .85rem 1rem; border-radius: 3px;
}
.kpi.tone-good { border-left-color: var(--good); }
.kpi.tone-warn { border-left-color: var(--warn); }
.kpi.tone-bad  { border-left-color: var(--bad); }
.kpi .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kpi .value { font-size: 1.4rem; font-weight: 600; margin-top: .15rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  padding: 1rem 1.15rem; border-radius: 3px; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 .5rem; font-size: 1rem; }
.card .meta { font-size: .78rem; color: var(--muted); margin-bottom: .5rem; }

.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 2px;
  font-size: .7rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent);
}
.badge.good { background: rgba(45,122,62,.12); color: var(--good); }
.badge.warn { background: rgba(182,116,25,.14); color: var(--warn); }
.badge.bad  { background: rgba(179,58,58,.12); color: var(--bad); }
.badge.neutral { background: var(--accent-soft); color: var(--accent); }

table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .88rem; }
th { background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--bg); }

.collapsible { background: var(--surface); border: 1px solid var(--border); border-radius: 3px; margin-bottom: .6rem; }
.collapsible-head {
  cursor: pointer; padding: .7rem 1rem; display: flex; align-items: center; justify-content: space-between;
  user-select: none;
}
.collapsible-head:hover { background: var(--accent-soft); }
.collapsible-body { padding: 0 1rem 1rem; border-top: 1px solid var(--border); }

.section-title { font-size: 1.05rem; margin: 1.5rem 0 .75rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); }

.source-footer {
  margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border);
  font-size: .75rem; color: var(--muted);
}
.source-footer code { background: var(--accent-soft); padding: .05rem .35rem; border-radius: 2px; }

/* Charts container */
.chart-wrap { background: var(--surface); border: 1px solid var(--border); padding: 1rem; border-radius: 3px; margin-bottom: 1rem; }
.chart-wrap canvas { max-height: 280px; }

/* Mermaid */
.mermaid { background: var(--surface); padding: 1rem; border: 1px solid var(--border); border-radius: 3px; overflow-x: auto; }

/* Responsive */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 1rem; }
}

/* Print */
@media print {
  .sidebar, .theme-toggle, button { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .main { max-width: 100%; padding: 0; }
  body { background: white; color: black; font-size: 11pt; }
  .card, .kpi, .chart-wrap, .mermaid { break-inside: avoid; box-shadow: none; }
  .collapsible-body { display: block !important; }
  a { color: black; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
}

/* utility */
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.col { flex: 1 1 280px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; }
