:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2230;
  --text-muted: #6b7280;
  --accent: #2f6feb;
  --accent-soft: #eaf1ff;
  --good: #1a8f5e;
  --bad: #d64545;
  --warn: #c98a1d;
  --radius: 10px;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.topbar .brand { font-weight: 700; font-size: 16px; }

.topbar nav a {
  margin-right: 16px;
  color: var(--text);
  font-weight: 500;
}
.topbar nav a.active { color: var(--accent); }

.container { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 140px;
  flex: 1 1 140px;
}
.stat-tile .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.stat-tile .value { font-size: 22px; font-weight: 700; margin-top: 4px; }

.period-nav { display: flex; align-items: center; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.period-nav .tabs a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  margin-right: 6px;
}
.period-nav .tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.period-nav .nav-arrow {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.period-nav .label { font-weight: 700; font-size: 16px; margin: 0 6px; }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

table { border-collapse: collapse; width: 100%; min-width: 1200px; font-size: 13px; }
thead th {
  position: sticky; top: 0;
  background: #fafbfc;
  border-bottom: 2px solid var(--border);
  text-align: left;
  padding: 10px 10px;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-muted);
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:hover { background: var(--accent-soft); }
tr.total-row td { font-weight: 700; background: #fafbfc; border-top: 2px solid var(--border); }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 26px 0 8px; }

.pct-good { color: var(--good); font-weight: 600; }
.pct-bad { color: var(--bad); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 320px;
}
.login-box h1 { font-size: 18px; margin: 0 0 18px; }
.login-box input[type=password] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}
.login-box button {
  width: 100%;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.login-box .error { color: var(--bad); font-size: 13px; margin-bottom: 10px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.report-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.report-card h3 { margin: 0 0 4px; font-size: 15px; }
.report-card .date { color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
.report-card dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin: 0; }
.report-card dt { color: var(--text-muted); }
.report-card dd { margin: 0; font-weight: 600; text-align: right; }
.report-card .reasons { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.report-card .reasons-title { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
.report-card .reasons ul { margin: 0; padding-left: 18px; }

.sync-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 13px; }
.muted { color: var(--text-muted); font-size: 12px; }

#trendChart { max-height: 260px; }
