/* Zakupy — LP Konstal. Jeden arkusz, bez preprocesora (konwencja "bez builda"). */

:root {
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F8;
  --border: #E1E6EF;
  --text: #1F2733;
  --text-muted: #6B7688;
  --text-faint: #99A2B3;
  --accent: #2F5FDB;
  --accent-hover: #274FB8;
  --accent-soft: #C9D4EA;
  --ok-bg: #E6F4EA;
  --ok-text: #1E7C3E;
  --err-bg: #FCE8E8;
  --err-text: #B42318;
  --warn-bg: #FDF3E3;
  --warn-text: #92600A;
  --best-bg: #E9F7EE;
  --radius: 6px;
  --radius-lg: 10px;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 24px 0 10px; color: var(--text); }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--text-muted); }

.sub { color: var(--text-muted); margin: 0 0 18px; font-size: 13.5px; }
.hint { color: var(--text-muted); font-size: 12px; }

/* ------------------------------------------------------------- layout */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); font-size: 15px; }
.brand-sub { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.topnav { display: flex; gap: 18px; }
.topnav a { color: var(--text-muted); font-size: 13.5px; font-weight: 600; }
.topnav a:hover { color: var(--accent); text-decoration: none; }

.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.stat {
  flex: 1 1 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.stat .n { font-size: 26px; font-weight: 700; color: var(--text); }
.stat .l { font-size: 12.5px; color: var(--text-muted); }

/* ------------------------------------------------------------ formularze */

label { display: block; font-size: 12.5px; color: var(--text-muted); margin: 0 0 4px; font-weight: 600; }
.field { margin-bottom: 14px; }

input[type=text], input[type=email], input[type=number], input[type=date],
input[type=password], input:not([type]), select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
input.num { text-align: right; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 95, 219, .12);
}

.chk { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); font-weight: 400; }
.chk input { width: auto; }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--err-text); border-color: var(--err-text); }
.btn.danger:hover { background: #8f1c12; border-color: #8f1c12; }
.btn.small, button.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled], button[disabled] { opacity: .5; cursor: not-allowed; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

/* --------------------------------------------------------------- tabele */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th, table.list td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.list th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
table.list tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }

table.matrix { border-collapse: collapse; }
table.matrix th, table.matrix td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 13px;
  vertical-align: top;
}
table.matrix th { background: var(--surface-2); color: var(--text-muted); font-weight: 600; font-size: 12px; }
table.matrix td.best { background: var(--best-bg); }
table.matrix input, table.matrix select { font-size: 12.5px; padding: 4px 6px; }
table.matrix input.num { width: 68px; display: inline-block; }
table.matrix select { display: inline-block; width: auto; }

/* Wynik przeliczenia pod komórką — wartość pozycji po sprowadzeniu ilości
   do jednostki ceny. To jest liczba, którą operator naprawdę porównuje. */
.cell-calc { margin-top: 5px; padding-top: 5px; border-top: 1px dotted var(--border); line-height: 1.35; }
.cell-calc b { font-size: 13px; color: var(--text); display: block; }
.cell-calc .hint { display: block; font-size: 11px; }
.cell-calc.err-txt { color: var(--err-text); font-size: 11.5px; }
.cell-calc.err-txt .hint { color: var(--err-text); opacity: .8; }

/* --------------------------------------------------------------- znaczki */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.err { background: var(--err-bg); color: var(--err-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.accent { background: var(--accent-soft); color: var(--accent-hover); }

/* --------------------------------------------------------------- komunikaty */

.msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--ok-bg);
  color: var(--ok-text);
  font-size: 13.5px;
  margin-bottom: 16px;
}
.msg.err { background: var(--err-bg); color: var(--err-text); }
.msg.warn { background: var(--warn-bg); color: var(--warn-text); }

/* -------------------------------------------------------------- dropzone */

.dropzone {
  border: 2px dashed var(--accent-soft);
  border-radius: var(--radius-lg);
  padding: 26px 16px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--surface);
  margin-bottom: 16px;
}
.dropzone b { color: var(--text); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* --------------------------------------------------------------- rozne */

.row-item {
  display: grid;
  grid-template-columns: 1.3fr 1fr 90px 110px 80px 90px 1.2fr auto;
  gap: 6px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.row-item input, .row-item select { font-size: 12.5px; padding: 6px 8px; }
.remove-row {
  background: transparent; border: none; color: var(--err-text); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 4px 8px;
}

.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 18px; }
.checklist label {
  display: flex; align-items: flex-start; gap: 7px; font-weight: 400;
  color: var(--text); font-size: 13.5px; line-height: 1.35; padding: 4px 0;
}
.checklist label input { width: auto; margin-top: 2px; flex: none; }
.checklist label .hint { font-size: 11.5px; }

.mail-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 6px; font-size: 13px; background: var(--surface);
}
.mail-item .fmt { font-size: 10.5px; text-transform: uppercase; color: var(--text-faint); }
.mail-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.preview-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .preview-split { grid-template-columns: 1fr; } }
.preview-pane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.preview-pane iframe, .preview-pane embed { width: 100%; height: 70vh; border: 0; display: block; }
.preview-pane .head { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }

details.quickadd { margin: 10px 0 18px; }
details.quickadd summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; }
details.quickadd .card { margin-top: 8px; }

/* ------------------------------------------------------- ekrany logowania */

.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px 30px; box-shadow: 0 1px 3px rgba(31,39,51,.06), 0 12px 32px -16px rgba(31,39,51,.18);
}
.auth-card--wide { max-width: 520px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card .sub { font-size: 13px; margin-bottom: 20px; }

.totp-qr {
  display: flex; justify-content: center; padding: 16px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); margin: 4px 0 12px;
}
.totp-qr svg { width: 200px; height: 200px; }
.totp-secret {
  display: inline-block; font-size: 13px; letter-spacing: .08em;
  background: var(--surface-2); padding: 6px 10px; border-radius: var(--radius);
  word-break: break-all; margin-top: 4px;
}

.backup-codes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 16px; background: var(--surface-2); border-radius: var(--radius);
}
.backup-codes code {
  font-size: 14px; letter-spacing: .04em; text-align: center;
  background: var(--surface); padding: 7px 4px; border-radius: 4px;
  border: 1px solid var(--border); font-variant-numeric: tabular-nums;
}

.whoami {
  font-size: 12.5px; color: var(--text-muted); display: flex;
  align-items: center; gap: 7px; margin-right: 12px; white-space: nowrap;
}
