:root {
  --bg1: #667eea; --bg2: #764ba2; --ink: #222; --muted: #666; --card: #fff;
  --ok: #27ae60; --ok-bg: #d5f4e6; --err: #c0392b; --err-bg: #fadbd8;
  --warn: #b7791f; --warn-bg: #fdf3d8; --info: #1565c0; --info-bg: #e3f2fd;
  --line: #e6e8f0;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
  min-height: 100vh; padding: 24px; color: var(--ink);
}
a { color: var(--bg1); }
.topbar { max-width: 1200px; margin: 0 auto 18px; display: flex; align-items: center; justify-content: space-between; color: #fff; }
.topbar a.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 20px; }
.topbar nav a { color: rgba(255,255,255,.9); text-decoration: none; margin-left: 18px; font-size: 14px; }
.topbar nav a:hover { text-decoration: underline; }
.container { background: var(--card); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 36px; max-width: 1200px; margin: 0 auto; }
.container.narrow { max-width: 560px; }
h1 { font-size: 28px; margin-bottom: 8px; }
h2 { font-size: 20px; margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
h3 { font-size: 16px; margin: 18px 0 8px; }
.subtitle { color: var(--muted); margin-bottom: 26px; font-size: 14px; }
.center { text-align: center; }

/* kafelki narzędzi */
.group { margin-bottom: 30px; }
.group-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.group-title h2 { margin: 0; border: 0; padding: 0; font-size: 22px; }
.group-title span { color: var(--muted); font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile { display: block; text-decoration: none; color: var(--ink); border: 2px solid var(--line); border-radius: 10px; padding: 20px; background: #f8f9ff; transition: all .2s; }
.tile:hover { border-color: var(--bg1); transform: translateY(-3px); box-shadow: 0 10px 25px rgba(102,126,234,.25); }
.tile .icon { font-size: 30px; margin-bottom: 8px; }
.tile .name { font-weight: 700; font-size: 16px; color: var(--bg2); margin-bottom: 6px; }
.tile .desc { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* formularze */
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.file-input-wrapper input[type="file"] { position: absolute; left: -9999px; }
.file-input-label { display: flex; align-items: center; justify-content: center; padding: 26px; border: 2px dashed var(--bg1); border-radius: 8px; cursor: pointer; background: #f8f9ff; transition: all .3s; font-weight: 500; color: var(--bg1); text-align: center; }
.file-input-label:hover, .file-input-label.dragover { background: #f0f1ff; border-color: var(--bg2); }
.file-input-label.selected { border-style: solid; border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.options { display: flex; gap: 12px; align-items: center; font-size: 14px; margin-bottom: 20px; }
.options input[type="number"] { width: 70px; padding: 6px; border: 1px solid #ccc; border-radius: 6px; }
button.primary { width: 100%; padding: 12px; background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%); color: #fff; border: 0; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; transition: all .3s; }
button.primary:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(102,126,234,.4); }
button.primary:disabled { background: #ccc; cursor: not-allowed; transform: none; box-shadow: none; }
button.secondary { padding: 8px 14px; background: #fff; color: var(--bg2); border: 2px solid var(--bg1); border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
button.secondary:hover { background: #f0f1ff; }
.message { margin-top: 20px; padding: 15px; border-radius: 8px; font-size: 14px; display: none; }
.message.success { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); display: block; }
.message.error { background: var(--err-bg); color: var(--err); border: 1px solid var(--err); display: block; }
.loading { display: none; text-align: center; margin-top: 20px; }
.loading.show { display: block; }
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid var(--bg1); border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite; margin: 0 auto 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.info-box { background: var(--info-bg); border-left: 4px solid #2196f3; padding: 12px; border-radius: 4px; font-size: 13px; color: var(--info); margin-top: 20px; line-height: 1.5; }
code { background: #eef; padding: 1px 4px; border-radius: 3px; font-size: 12px; }

/* raport */
#report { display: none; margin-top: 30px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fafbff; }
.card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.card .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card.good { border-color: var(--ok); background: var(--ok-bg); }
.card.bad { border-color: var(--err); background: var(--err-bg); }
.card.warn { border-color: var(--warn); background: var(--warn-bg); }
.verdict { padding: 16px 18px; border-radius: 10px; font-size: 15px; margin-bottom: 18px; line-height: 1.5; }
.verdict.good { background: var(--ok-bg); border: 1px solid var(--ok); color: #1e7d47; }
.verdict.bad { background: var(--err-bg); border: 1px solid var(--err); color: #922b21; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f3f4fb; font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.desc { max-width: 380px; white-space: pre-line; word-break: break-word; }
tr.wn td.num.amt { color: #1e7d47; }
tr.ma td.num.amt { color: #922b21; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.exact { background: var(--ok-bg); color: var(--ok); }
.badge.near_date { background: var(--info-bg); color: var(--info); }
.badge.any_date { background: var(--warn-bg); color: var(--warn); }
.badge.flipped { background: var(--err-bg); color: var(--err); }
.badge.wn { background: #e8f7ee; color: #1e7d47; }
.badge.ma { background: #fdecea; color: #922b21; }
.empty { padding: 14px; color: var(--muted); font-style: italic; }
.sugg { font-size: 12px; color: var(--muted); margin-top: 4px; padding-left: 12px; border-left: 2px solid var(--line); }
.sugg b { color: var(--ink); }
.meta { font-size: 13px; color: var(--muted); line-height: 1.7; }
.meta b { color: var(--ink); }
.filter { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13px; flex-wrap: wrap; }
.filter input[type="search"] { padding: 6px 10px; border: 1px solid #ccc; border-radius: 6px; min-width: 240px; }
details summary { cursor: pointer; font-weight: 600; margin: 10px 0; }
@media print {
  body { background: #fff; padding: 0; }
  .container { box-shadow: none; padding: 0; max-width: none; }
  .topbar, form, .toolbar, .no-print { display: none !important; }
  #report { display: block !important; }
  th { position: static; }
}
