/* Wygląd aplikacji. Kolory marki pochodzą z brandingu (zmienne --primary, --accent, --sidebar). */
:root {
  --primary: #1f5eff; --accent: #12b886; --sidebar: #0f172a;
  --bg: #f4f6fb; --surface: #ffffff; --text: #101828; --muted: #667085; --border: #e4e7ec;
  --danger: #e5484d; --warning: #f59f00; --success: #12b886;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.right { text-align: right; } .nowrap { white-space: nowrap; }

/* układ */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--sidebar); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; color: #fff; font-weight: 700; font-size: 15px; }
.brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; background: rgba(255,255,255,.04); }
.nav { padding: 8px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; color: #cbd5e1; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 14px 12px 6px; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 8px; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot form { display: inline; }
.linkbtn { background: none; border: 0; color: #93c5fd; cursor: pointer; padding: 0; font: inherit; }
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.footer { margin-top: 40px; color: var(--muted); font-size: 12px; }

/* karty */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }

/* przyciski */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f5c2c4; }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* formularze */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=search], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 30%, transparent); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.checkbox input { width: 16px; height: 16px; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.alert.success { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.alert.error { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.alert.warning { background: #fffaeb; border-color: #fedf89; color: #b54708; }
.alert.info { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }

/* tabele */
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
table.data th a { color: inherit; }
table.data th a.sorted { color: var(--primary); }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #f9fafb; }
table.data tr.unread td:nth-child(2) { font-weight: 700; }
table.data tr.clickable { cursor: pointer; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; white-space: nowrap; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f2f4f7; color: #344054; }
.badge.green { background: #ecfdf3; color: #067647; } .badge.red { background: #fef3f2; color: #b42318; }
.badge.blue { background: #eff8ff; color: #175cd3; } .badge.amber { background: #fffaeb; color: #b54708; }
.badge.violet { background: #f4f3ff; color: #5925dc; }

/* filtry */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.filters .f { min-width: 140px; }
.filters .f.grow { flex: 1; min-width: 220px; }
.filters label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; padding: 12px 20px 0; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.bulkbar { display: flex; gap: 10px; align-items: center; padding: 10px 20px; background: #f9fafb; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; gap: 12px; flex-wrap: wrap; }

/* logowanie */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 18%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { color: var(--text); padding: 0 0 18px; font-size: 18px; justify-content: center; }
.auth-card .brand img { width: 44px; height: 44px; }

/* poświadczenia */
.cred-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.cred-type { border: 2px solid var(--border); border-radius: 12px; padding: 16px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; background: #fff; }
.cred-type:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.cred-type.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, #fff); }
.cred-type .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--primary) 12%, #fff); color: var(--primary); flex-shrink: 0; }
.cred-type .ico svg { width: 22px; height: 22px; }
.cred-type strong { display: block; }
.cred-list { display: grid; gap: 12px; }
.cred { display: flex; gap: 14px; align-items: center; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: #fff; }
.cred.active { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.cred .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; color: #fff; background: var(--primary); }
.cred .ico.cert { background: #7a5af8; }
.cred .ico svg { width: 22px; height: 22px; }
.cred .body { flex: 1; min-width: 0; }
.cred .body .meta { color: var(--muted); font-size: 12px; word-break: break-all; }
.dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbfc; transition: .15s; }
.dropzone.drag, .dropzone:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, #fff); color: var(--text); }
.dropzone input { display: none; }
.dropzone svg { width: 28px; height: 28px; margin-bottom: 4px; }
.dropzone .fname { color: var(--text); font-weight: 600; margin-top: 6px; }
.secret-input { position: relative; }
.secret-input textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; padding-right: 44px; }
.hidden { display: none !important; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; padding-left: 34px; position: relative; margin-bottom: 10px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 12%, #fff); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 12px; }

/* faktura */
.inv-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.party { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.party .t { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.total-box { background: color-mix(in srgb, var(--primary) 7%, #fff); border-radius: 10px; padding: 14px 18px; text-align: right; }
.total-box .v { font-size: 24px; font-weight: 800; color: var(--primary); }
pre.xml { background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 10px; overflow: auto; max-height: 560px; font-size: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* wykres */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 46px; background: var(--primary); border-radius: 6px 6px 2px 2px; min-height: 2px; opacity: .85; }
.bars .b:hover .bar { opacity: 1; }
.bars .l { font-size: 11px; color: var(--muted); }

.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: #98a2b3; margin-bottom: 8px; }

.menu-toggle { display: none; }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { display: none; } .sidebar.open .nav { display: block; }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  .main { padding: 20px 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .parties, .cred-types { grid-template-columns: 1fr; }
}
@media print { .sidebar, .no-print { display: none !important; } .main { padding: 0; } .card { box-shadow: none; } }
[hidden] { display: none !important; }
h1 svg, h2 svg { width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px; flex: none; }
.tabs { flex-wrap: wrap; }
.tabs-right { order: 9; margin-left: auto; display: flex; gap: 6px; align-items: center; padding-bottom: 8px; flex-wrap: wrap; }
.tabs a.chip { padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); background: #fff; }
.tabs a.chip:hover { color: var(--text); border-color: #c5cad3; }
.tabs a.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tabs a.chip.red.active { background: #d92d20; border-color: #d92d20; }
.bulkbar { flex-wrap: wrap; }
.pay-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; background: #f8f9fb; border: 1px solid var(--border); margin-top: 12px; }
