/* Gemini IT · KSeF — wspólny wygląd */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6ec;
  --text: #1b2232;
  --muted: #6b7386;
  --accent: #3b5bdb;
  --accent-600: #2f4ac0;
  --accent-50: #eef2ff;
  --success: #12805c;
  --success-50: #e7f6ef;
  --warn: #b25e09;
  --warn-50: #fff4e5;
  --danger: #c92a2a;
  --danger-50: #fff0f0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.05);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-primary: var(--accent);
  --bs-primary-rgb: 59,91,219;
  --bs-body-color: var(--text);
}
* { -webkit-font-smoothing: antialiased; }
body { background: var(--bg); color: var(--text); font-size: 15px; }
.num, .money { font-variant-numeric: tabular-nums; }
a { color: var(--accent); }

/* ---------- Pasek górny ---------- */
.topbar { background: #141a2b; color: #fff; position: sticky; top: 0; z-index: 1030; }
.topbar .inner { max-width: 1320px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; color: #fff; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #5c7cfa, #3b5bdb); display: grid; place-items: center; font-size: 16px; }
.brand small { font-weight: 500; color: #9aa3b8; margin-left: 2px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { color: #c3c9d6; text-decoration: none; padding: 8px 14px; border-radius: 9px; font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.topnav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.topnav a.active { color: #fff; background: rgba(255,255,255,.12); }
.topbar .logout { color: #9aa3b8; text-decoration: none; font-size: 14px; }
.topbar .logout:hover { color: #fff; }
@media (max-width: 767px) {
  .topbar .inner { gap: 12px; padding: 0 12px; }
  .brand small, .topnav a span { display: none; }
  .topnav a { padding: 8px 10px; font-size: 17px; }
}

.page { max-width: 1320px; margin: 0 auto; padding: 28px 20px 80px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; }

/* ---------- Karty / panele ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.panel-head h2 { font-size: 16px; font-weight: 650; margin: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.panel-head .step { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-50); color: var(--accent); font-size: 13px; font-weight: 700; display: grid; place-items: center; flex: none; }
.panel-body { padding: 20px; }

.form-label { font-size: 13px; font-weight: 600; color: #3d4557; margin-bottom: 6px; }
.form-control, .form-select { border-color: var(--border); border-radius: 10px; padding: .55rem .8rem; font-size: 15px; }
.form-control:focus, .form-select:focus { border-color: #91a7ff; box-shadow: 0 0 0 4px rgba(59,91,219,.12); }
.form-control[readonly] { background: var(--surface-2); }
.form-text { color: var(--muted); font-size: 12.5px; }
.btn { border-radius: 10px; font-weight: 600; font-size: 14px; padding: .55rem 1rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-600); border-color: var(--accent-600); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-soft { background: var(--accent-50); color: var(--accent); border: 0; }
.btn-soft:hover { background: #dfe6ff; color: var(--accent-600); }
.btn-ghost { background: transparent; border: 0; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; }
.btn-lg { padding: .8rem 1.2rem; font-size: 16px; border-radius: 12px; }

/* segmentowe przyciski (termin płatności) */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg input { display: none; }
.seg label { border: 1px solid var(--border); border-radius: 10px; padding: .5rem .9rem; font-size: 14px; font-weight: 500; cursor: pointer; background: #fff; user-select: none; }
.seg input:checked + label { border-color: var(--accent); background: var(--accent-50); color: var(--accent); font-weight: 600; }

/* ---------- Wyszukiwarka (klienci / usługi) ---------- */
.picker { position: relative; }
.picker .search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.picker > input { padding-left: 38px; }
.dropdown-list { position: absolute; z-index: 1050; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(16,24,40,.14); max-height: 340px; overflow-y: auto; padding: 6px; display: none; }
.dropdown-list.open { display: block; }
.dd-item { padding: 9px 12px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.dd-item:hover, .dd-item.active { background: var(--accent-50); }
.dd-item .dd-main { flex: 1; min-width: 0; }
.dd-item .dd-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-item .dd-sub { font-size: 12.5px; color: var(--muted); }
.dd-item .dd-price { text-align: right; font-size: 13px; white-space: nowrap; }
.dd-item .dd-price b { display: block; font-size: 14px; }
.dd-empty { padding: 12px; color: var(--muted); font-size: 14px; }
.dd-item mark { background: #fff3bf; padding: 0; border-radius: 2px; }
.avatar { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-50); color: var(--accent); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex: none; }

.client-card { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 14px 16px; display: flex; gap: 14px; align-items: flex-start; }
.client-card .name { font-weight: 650; }
.client-card .meta { color: var(--muted); font-size: 13.5px; }

/* ---------- Układ strony: formularz + panel boczny ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
@media (min-width: 1200px) { .layout { grid-template-columns: minmax(0, 1fr) 340px; } }

/* ---------- Pozycje faktury ---------- */
.items-wrap { container-type: inline-size; }
.items-head, .item-row { display: grid; grid-template-columns: minmax(180px, 1fr) 64px 64px 104px 104px 80px 112px 36px; gap: 8px; align-items: center; }
.items-head { padding: 0 20px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.item-row { padding: 10px 20px; border-top: 1px solid var(--border); }
.item-row .form-control, .item-row .form-select { padding: .45rem .55rem; font-size: 14px; }
.item-row .form-select { padding-right: 1.6rem; background-position: right .4rem center; }
.item-row input.num { text-align: right; }
.item-row .line-total { text-align: right; font-weight: 650; }
.item-row .line-total small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.item-row .gross-input { background: var(--success-50); border-color: #bfe5d3; }
.item-row .dropdown-list { right: auto; width: 520px; max-width: calc(100vw - 48px); }
.items-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.mlabel { display: none; }
@container (max-width: 760px) {
  .items-head { display: none; }
  .item-row { grid-template-columns: repeat(6, 1fr); row-gap: 8px; padding: 14px 16px; }
  .item-row > .c-name { grid-column: 1 / -1; }
  .item-row > .c-qty, .item-row > .c-unit, .item-row > .c-vat { grid-column: span 2; }
  .item-row > .c-net, .item-row > .c-gross { grid-column: span 3; }
  .item-row > .c-total { grid-column: span 5; text-align: left; }
  .item-row > .c-del { grid-column: span 1; justify-self: end; }
  .mlabel { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
}

/* ---------- Podsumowanie (prawa kolumna) ---------- */
.sticky-side { position: sticky; top: 80px; }
.summary-row { display: flex; justify-content: space-between; padding: 7px 0; color: #3d4557; }
.summary-row b { color: var(--text); }
.summary-total { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 14px; display: flex; justify-content: space-between; align-items: baseline; }
.summary-total .amount { font-size: 28px; font-weight: 750; letter-spacing: -.02em; color: var(--text); }
.issuer-mini { font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.issuer-mini strong { color: var(--text); font-size: 14.5px; }
.number-box { display: flex; gap: 8px; }
.number-box input { font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.hint.warn { color: var(--warn); }
.hint.ok { color: var(--success); }

.badge-soft { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; }
.badge-sent { background: var(--success-50); color: var(--success); }
.badge-old { background: #eef0f4; color: #555e70; }
.badge-draft { background: var(--warn-50); color: var(--warn); }

/* ---------- Tabele (historia, bazy) ---------- */
.table-clean { margin: 0; }
.table-clean th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 10px 14px; white-space: nowrap; }
.table-clean td { padding: 11px 14px; vertical-align: middle; border-color: var(--border); }
.table-clean tbody tr:hover { background: #fafbfd; }
/* Kolumna, która zabiera resztę miejsca i skraca długie nazwy "…", żeby tabela nigdy nie wychodziła poza ekran */
.table-clean td.cell-fill { width: 100%; max-width: 0; }
@media (max-width: 575px) { .table-clean th, .table-clean td { padding: 10px 8px; } }
.modal-content { border: 0; border-radius: 16px; }
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-footer { border-top: 1px solid var(--border); }

/* ---------- Powiadomienia ---------- */
.toast-box { position: fixed; right: 20px; bottom: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { background: #1b2232; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 14px; animation: tin .2s ease-out; }
.toast-msg.err { background: var(--danger); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Podgląd faktury ---------- */
.invoice-paper { background: #fff; max-width: 920px; margin: 0 auto; padding: 48px 52px; border-radius: 6px; box-shadow: 0 2px 4px rgba(16,24,40,.05), 0 18px 48px rgba(16,24,40,.10); }
.invoice-paper .doc-title { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.invoice-paper .doc-no { color: var(--accent); font-weight: 700; font-size: 18px; }
.invoice-paper .party { background: var(--surface-2); border-radius: 10px; padding: 16px 18px; height: 100%; }
.invoice-paper .party h6 { font-size: 11.5px; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.invoice-paper table th { background: #141a2b; color: #fff; font-weight: 600; font-size: 12.5px; }
.invoice-paper .to-pay { background: var(--accent-50); border-radius: 10px; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; }
.invoice-paper .to-pay .amount { font-size: 26px; font-weight: 800; color: var(--accent); }
.action-bar { max-width: 920px; margin: 0 auto 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
@media (max-width: 767px) { .invoice-paper { padding: 24px 18px; } }
@media print { .topbar, .action-bar, .no-print { display: none !important; } body { background: #fff; } .invoice-paper { box-shadow: none; padding: 0; } }

/* ---------- Wysyłka KSeF ---------- */
.send-log { font-size: 14.5px; line-height: 1.9; }
.send-log b { color: var(--text); }
.send-log pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 12.5px; white-space: pre-wrap; }
