:root {
  /* paleta closermusic.com — near-black + złoto/szampan, monochrom, Inter */
  --bg: #0a0a0a;
  --bg-elev: #141519;
  --bg-card: #1b1d22;
  --line: #2a2d34;
  --txt: #e8e8e8;
  --txt-dim: #9a9a9a;
  --accent: #d5b58f;      /* złoto/szampan — akcent marki */
  --accent-2: #cd9f78;    /* copper (focus) */
  --accent-3: #e8d3b5;    /* sand */
  --warn: #e0b566;
  --bad: #e06a6a;
  --good: #7fb196;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.5);
  --font-head: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: radial-gradient(1100px 560px at 82% -12%, rgba(213,181,143,.10), transparent 60%),
              radial-gradient(800px 460px at -10% 8%, rgba(213,181,143,.05), transparent 55%),
              var(--bg);
  color: var(--txt);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #04130c;
  padding: .6rem 1rem;
  border-radius: 0 0 8px 0;
  font-weight: 700;
  z-index: 100;
}
.skip-link:focus { left: 0; }

a { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 4px;
}

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.75rem; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--bg-card); border: 1px solid var(--accent);
  display: grid; place-items: center;
  color: var(--accent); font-weight: 700; font-family: var(--font-head); letter-spacing: .04em;
}
.brand-name { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; letter-spacing: .02em; text-transform: uppercase; }
.brand-sub { color: var(--txt-dim); font-size: .72rem; }

.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.nav a {
  display: block; padding: .55rem .75rem; border-radius: 9px;
  color: var(--txt-dim); text-decoration: none; font-size: .9rem; font-weight: 600;
}
.nav a:hover, .nav a:focus-visible { background: var(--bg-card); color: var(--txt); }
.nav a[aria-current="true"] { background: var(--bg-card); color: var(--accent); }

/* Main */
.main { flex: 1; padding: 1.75rem clamp(1rem, 3vw, 2.5rem); max-width: 1400px; }

.topbar { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; margin-bottom: .5rem; }
.topbar h1 { font-family: var(--font-head); font-size: clamp(1.4rem, 3vw, 2rem); margin: 0; letter-spacing: -.02em; }
.topbar .meta { color: var(--txt-dim); font-size: .85rem; }

.demo-banner {
  background: rgba(252,211,77,.12);
  border: 1px solid rgba(252,211,77,.40);
  color: var(--warn);
  padding: .65rem .9rem; border-radius: 10px;
  font-size: .85rem; margin: 1rem 0 1.75rem; font-weight: 600;
}

section { margin-bottom: 2.5rem; scroll-margin-top: 1rem; }
section > h2 {
  font-family: var(--font-head); font-size: 1.15rem; font-weight: 700;
  margin: 0 0 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line);
  letter-spacing: -.01em;
}

/* Scorecards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; list-style: none; padding: 0; margin: 0; }
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
  margin: 0;
}
.card .label { color: var(--txt-dim); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-family: var(--font-head); font-size: 1.7rem; font-weight: 700; margin: .35rem 0 0; letter-spacing: -.02em; }
.card .unit { font-size: .9rem; color: var(--txt-dim); font-weight: 600; }
.card.accent .value { color: var(--accent); }
.card.violet .value { color: var(--accent-3); }
.card.warn .value { color: var(--warn); }
.card.bad .value { color: var(--bad); }

/* Chart panels */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1.25rem; }
.panel {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}
.panel h3 { font-family: var(--font-head); font-size: 1rem; margin: 0 0 .25rem; font-weight: 700; }
.panel .hint { color: var(--txt-dim); font-size: .8rem; margin: 0 0 1rem; }
.chart-wrap { position: relative; height: 280px; }

/* Accessible data tables */
.data-table-toggle {
  margin-top: 1rem; background: transparent; border: 1px solid var(--line);
  color: var(--txt-dim); padding: .4rem .7rem; border-radius: 8px; cursor: pointer;
  font-family: var(--font-body); font-size: .8rem; font-weight: 600;
}
.data-table-toggle:hover { color: var(--txt); border-color: var(--accent-2); }
table.data { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .82rem; }
table.data caption { text-align: left; color: var(--txt-dim); font-size: .8rem; margin-bottom: .5rem; }
table.data th, table.data td { padding: .4rem .6rem; border-bottom: 1px solid var(--line); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { color: var(--txt-dim); font-weight: 700; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

footer { color: var(--txt-dim); font-size: .8rem; border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 2rem; }

/* ===== Moduł windykacji ===== */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; border: 1px solid transparent; }
.badge.b-wait { color: var(--txt); background: rgba(170,179,200,.14); border-color: var(--line); }
.badge.b-warn { color: #1b1403; background: var(--warn); }
.badge.b-bad  { color: #2a0710; background: var(--bad); }
.badge.b-good { color: #04130c; background: var(--good); }

.btn-action {
  background: var(--accent); color: #04130c; border: 0; border-radius: 8px;
  padding: .35rem .7rem; font-family: var(--font-body); font-size: .78rem; font-weight: 700; cursor: pointer;
}
.btn-action:hover { filter: brightness(1.08); }
.btn-action.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-action.muted { background: transparent; color: var(--txt-dim); border: 1px solid var(--line); cursor: default; }

.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }

/* Modal podglądu maila */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 1rem; z-index: 200;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  max-width: 620px; width: 100%; max-height: 85vh; overflow: auto; box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: var(--font-head); font-size: 1.05rem; }
.modal-close { background: transparent; border: 1px solid var(--line); color: var(--txt); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 1.1rem; }
.modal-close:hover { border-color: var(--accent-2); }
.modal-body { padding: 1.25rem; }
.email-preview { background: #0f1219; border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.25rem; }
.email-preview .e-meta { color: var(--txt-dim); font-size: .8rem; border-bottom: 1px solid var(--line); padding-bottom: .6rem; margin-bottom: .8rem; }
.email-preview p { margin: 0 0 .7rem; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--bg-elev); border: 1px solid var(--accent-2); color: var(--txt);
  padding: .7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow); font-size: .85rem; font-weight: 600; z-index: 300; max-width: 90vw;
}
.toast[hidden] { display: none; }

.mode-pill { display: inline-block; background: rgba(252,211,77,.14); border: 1px solid rgba(252,211,77,.4); color: var(--warn); padding: .25rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }

.mt-s { margin-top: .35rem; }
.mt-m { margin-top: 1rem; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .nav ul { flex-direction: row; flex-wrap: wrap; }
  .chart-wrap { height: 240px; }
}
