:root {
  --bg: #f4f1ea;
  --ink: #1c1915;
  --muted: #6b645b;
  --line: #ddd6cb;
  --paper: #fffdf8;
  --accent: #1f4d3a;
  --accent-2: #b45309;
  --bad: #9f1239;
  --ok: #166534;
  --header: #1c1915;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 28px 32px 18px;
  background: var(--header);
  color: #f4f1ea;
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c4b8a5;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
h1 { margin: 0; font-size: 28px; font-weight: 600; }
.top-actions {
  display: flex;
  gap: 12px;
  align-items: end;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.top-actions label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #c4b8a5;
}
select, input, button {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}
select, input[type="search"] {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 8px 10px;
  min-width: 140px;
}
.top-actions select {
  background: #2a261f;
  color: #f4f1ea;
  border-color: #3f3a32;
}
button {
  background: #f4f1ea;
  color: var(--ink);
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
}
button:disabled { opacity: 0.55; cursor: wait; }
a.head-link {
  color: #f4f1ea;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  text-decoration: none;
  padding: 10px 4px;
}
a.head-link:hover { text-decoration: underline; }

.status {
  margin: 0;
  padding: 10px 32px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.kpi {
  background: var(--paper);
  padding: 18px 24px;
}
.kpi span {
  display: block;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.kpi strong {
  font-size: 26px;
  font-weight: 600;
}
.kpi em {
  font-style: normal;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
  margin-left: 8px;
}
.kpi.good strong { color: var(--ok); }
.kpi.bad strong { color: var(--bad); }

.months {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.month-btn {
  background: var(--paper);
  border: 0;
  padding: 12px 8px;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.month-btn.on {
  background: var(--header);
  color: #f4f1ea;
}
.month-btn .m-name {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.month-btn.on .m-name { color: #c4b8a5; }
.month-btn .m-val {
  display: block;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dl {
  display: inline-block;
  margin-top: 4px;
  margin-right: 8px;
  padding: 6px 10px;
  background: var(--header);
  color: #f4f1ea;
  text-decoration: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
}
.dl.alt { background: var(--accent); }

.toolbar {
  display: flex;
  gap: 10px;
  padding: 16px 32px;
  flex-wrap: wrap;
}
.toolbar input[type="search"] { flex: 1; min-width: 220px; }

.table-wrap { padding: 0 32px 48px; overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}
th {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  background: #faf7f0;
  position: sticky;
  top: 0;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f1e4; }
.empty { text-align: center; color: var(--muted); padding: 40px; cursor: default; }
.neg { color: var(--bad); }
.pct-bar {
  display: inline-block;
  min-width: 52px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
}
.tag {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.tag.warn { color: var(--accent-2); border-color: #edc9a3; }
.tag.ok { color: var(--ok); border-color: #bbd5c4; }
.muted { color: var(--muted); font-size: 12px; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(28, 25, 21, 0.35);
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 100%);
  background: var(--paper);
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 24px;
  z-index: 2;
}
.hidden { display: none; }
.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}
.drawer-head h2 { margin: 0 0 6px; font-size: 22px; }
.drawer-head p { margin: 0; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.doc {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.doc h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.doc p { margin: 0 0 6px; }
.item-desc { color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .months { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 900px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .top { flex-direction: column; align-items: start; }
  .months { grid-template-columns: repeat(4, 1fr); }
  .split { grid-template-columns: 1fr; }
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 32px 28px;
}
.login-card h1 { font-size: 32px; margin: 0 0 8px; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.field input {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
}
.btn-microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #fff;
  color: #1c1915;
  border: 1px solid #c8c2b8;
  padding: 12px 14px;
  text-decoration: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
}
.btn-microsoft:hover { background: #f7f4ee; }
button.btn-microsoft { width: 100%; }
.device-code {
  margin: 16px 0 12px;
  text-align: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 32px;
  letter-spacing: 0.16em;
  font-weight: 650;
}
#deviceStatus {
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
}
.login-error { color: var(--bad); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; min-height: 1.2em; text-transform: none; letter-spacing: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 32px 0; }
.chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 7px 12px;
}
.chip.on { background: var(--header); color: #f4f1ea; }
.vendor { margin: 18px 32px 28px; background: var(--paper); border: 1px solid var(--line); }
.vendor-head { padding: 18px 20px 8px; display: flex; justify-content: space-between; gap: 16px; align-items: end; }
.vendor-head h2 { margin: 0; font-size: 24px; }
.vendor-head p { margin: 4px 0 0; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.vendor-kpis { display: flex; gap: 18px; font-family: ui-sans-serif, system-ui, sans-serif; }
.vendor-kpis span { display: block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.vendor-kpis strong { font-size: 16px; font-family: "Iowan Old Style", Palatino, Georgia, serif; }
.note { margin: 0 20px 12px; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.split { display: grid; grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.25fr); gap: 0; border-top: 1px solid var(--line); }
.pane { min-width: 0; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane h3 { margin: 0; padding: 12px 14px 0; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; }
.scroll { max-height: 520px; overflow: auto; }
.vendor table { font-size: 13px; }
.vendor td, .vendor th { padding: 8px 12px; }
.sub { color: var(--muted); font-size: 12px; display: block; }
.clickable { cursor: pointer; }
.clickable:hover { background: #faf7f0; }
.nested { background: #faf7f0; }
.nested td { border-bottom: 1px solid var(--line); font-size: 12px; }
.mail-list { padding: 0 20px 16px; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.user-label { color: #c4b8a5; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; align-self: center; }
