:root {
  --bg: #f1f1f1;
  --card: #ffffff;
  --fg: #1a1a1a;
  --muted: #616161;
  --faint: #8a8a8a;
  --line: #e3e3e3;
  --line-soft: #ebebeb;
  --blue: #005bd3;
  --blue-soft: #eaf4ff;
  --green: #0c7a43;
  --green-soft: #e3f5ea;
  --red: #c70a24;
  --red-soft: #fee9e8;
  --grey-soft: #f1f1f1;
  --dark: #1a1a1a;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.07), 0 0 0 1px rgba(0, 0, 0, 0.05);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--dark); color: #fff;
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: #fff; color: var(--dark);
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
}
.brand small { color: #b5b5b5; font-weight: 500; }
.topbar .spacer { flex: 1; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.1); border: 0; color: #fff; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-weight: 550; font-size: 13px;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.18); }

main.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 16px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); margin-top: 4px; }

.week-select {
  appearance: none; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23616161' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 0; box-shadow: var(--shadow); border-radius: 10px; padding: 9px 34px 9px 12px; font-weight: 600; cursor: pointer;
}

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card h2 { font-size: 14px; font-weight: 650; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }

/* Headline banner */
.headline {
  background: var(--dark); color: #fff; border-radius: var(--radius); padding: 20px;
  display: grid; gap: 6px;
}
.headline .eyebrow { color: #b5b5b5; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.headline .text { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.35; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.kpi { display: grid; gap: 6px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .tag { font-size: 11px; font-weight: 650; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.kpi .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.kpi .explain { color: var(--faint); font-size: 12px; }

.chip { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; font-size: 12px; border-radius: 6px; padding: 2px 6px; }
.chip.good { color: var(--green); background: var(--green-soft); }
.chip.bad { color: var(--red); background: var(--red-soft); }
.chip.flat { color: var(--muted); background: var(--grey-soft); }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-size: 11px; fill: var(--faint); font-family: inherit; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip {
  position: absolute; pointer-events: none; background: var(--card); box-shadow: 0 4px 16px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.06);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; white-space: nowrap; display: none; z-index: 2;
}
.tip b { display: block; margin-bottom: 3px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; text-align: right; white-space: nowrap; border-top: 1px solid var(--line-soft); }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafafa; border-top: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover td { background: #fafafa; }
td .bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--blue); vertical-align: middle; margin-right: 8px; opacity: .85; }
td.camp { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.status { font-size: 11px; font-weight: 650; color: var(--muted); background: var(--grey-soft); border-radius: 5px; padding: 1px 6px; margin-left: 6px; }

/* Notes */
.notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.note h3 { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.note h3 .dot { width: 8px; height: 8px; border-radius: 50%; }
.note ul { list-style: none; display: grid; gap: 8px; }
.note li { line-height: 1.5; color: #303030; padding-left: 14px; position: relative; }
.note li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: #c4c4c4; }

.foot { color: var(--faint); font-size: 12px; text-align: center; line-height: 1.6; }

/* Login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.login .brand { color: var(--fg); justify-content: center; }
.login .brand-mark { background: var(--dark); color: #fff; }
.login form { display: grid; gap: 12px; }
.login label { font-weight: 600; font-size: 13px; }
.login input {
  width: 100%; border: 1px solid #8a8a8a; border-radius: 8px; padding: 10px 12px; background: #fff;
}
.login input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }
.btn-primary {
  background: var(--dark); color: #fff; border: 0; border-radius: 8px; padding: 11px 14px; font-weight: 650; cursor: pointer;
}
.btn-primary:hover { background: #303030; }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.error { color: var(--red); font-size: 13px; min-height: 18px; }
.login .hint { color: var(--muted); font-size: 12.5px; text-align: center; }

.spinner { width: 28px; height: 28px; border: 3px solid #d4d4d4; border-top-color: var(--dark); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--muted); padding: 24px; }

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts, .notes { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .kpi .value { font-size: 22px; }
  .brand small { display: none; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
