/* XL8 Lite – BT FATIX */

@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-ext-500-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex"; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-ext-600-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-ext-700-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #23262d;          /* pasek boczny */
  --ink-2: #2e323b;
  --paper: #f4f5f7;        /* tło */
  --surface: #ffffff;
  --line: #e3e5ea;
  --text: #2f2d27;         /* grafit FATIX, lekko ocieplony */
  --muted: #6b6f78;
  --red: #d72027;          /* czerwień FATIX – tylko główne akcje i alarmy */
  --red-dark: #b3181e;
  --red-tint: #fdecec;
  --green: #2e7d32;
  --green-tint: #e8f3e9;
  --amber: #a15c00;
  --amber-tint: #fff4e0;
  --radius: 10px;
  --radius-sm: 6px;

  --bs-body-font-family: "Plex", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--paper);
  --bs-border-color: var(--line);
  --bs-primary: var(--red);
  --bs-primary-rgb: 215, 32, 39;
  --bs-link-color: #9c1a1f;
  --bs-link-color-rgb: 156, 26, 31;
  --bs-link-hover-color: var(--red);
  --bs-focus-ring-color: rgba(215, 32, 39, .25);
}

body { font-size: .925rem; font-feature-settings: "tnum" 0; }
.num, .table td.num, .kpi-value { font-variant-numeric: tabular-nums; }

/* ---------- układ ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink); color: #c9ccd3; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 12px; overflow-y: auto;
}
.brand { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px 18px; color: #fff; text-decoration: none; }
.brand-mark { font-weight: 700; font-size: 1.25rem; letter-spacing: -.01em; }
.brand-mark b { color: var(--red); font-weight: 700; }
.brand-sub { font-size: .75rem; color: #8a8f99; }
.nav-group { margin-top: 14px; }
.nav-group-title { font-size: .72rem; color: #7d828c; padding: 0 10px 6px; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: #d4d6dc; text-decoration: none; font-weight: 500;
}
.side-link i { font-size: 1.05rem; opacity: .75; width: 18px; text-align: center; }
.side-link:hover { background: var(--ink-2); color: #fff; }
.side-link.active { background: #fff; color: var(--ink); }
.side-link.active i { color: var(--red); opacity: 1; }
.side-link .badge { margin-left: auto; background: var(--red); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; font-size: .75rem; color: #7d828c; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .search { max-width: 420px; flex: 1; }
.topbar .search .form-control { background: var(--paper); border-color: transparent; padding-left: 34px; }
.topbar .search .bi { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); font-weight: 500; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600;
}
.menu-toggle { display: none; }
.content { padding: 24px 28px 48px; max-width: 1440px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.45rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--red); }

/* ---------- powierzchnie ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel, .row + .panel, .panel + .row, .ledger + .row, .row + .row { margin-top: 18px; }
.row > [class*=col] > .panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }

/* ---------- pulpit: listwa wyników ---------- */
.ledger {
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px;
}
.ledger-cell { padding: 18px 22px; border-right: 1px solid var(--line); position: relative; }
.ledger-cell:last-child { border-right: 0; }
.ledger-cell.lead { background: var(--ink); color: #fff; }
.ledger-cell.lead .kpi-label, .ledger-cell.lead .kpi-foot { color: #b9bdc6; }
.ledger-cell.lead .kpi-value { color: #fff; }
.kpi-label { font-size: .82rem; color: var(--muted); }
.kpi-value { font-size: 1.9rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin: 4px 0 2px; color: var(--text); }
.kpi-value small { font-size: .9rem; font-weight: 500; color: inherit; opacity: .7; margin-left: 4px; }
.kpi-foot { font-size: .8rem; color: var(--muted); }
.kpi-foot .up { color: #3fae4b; }
.ledger-cell.lead .kpi-foot .up { color: #7ed887; }
.kpi-foot .down { color: var(--red); }
.ledger-cell.lead .kpi-foot .down { color: #ff8a8f; }
.ledger-cell a.stretched { position: absolute; inset: 0; }

/* ---------- tabele ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .62rem .9rem; border-bottom-color: var(--line); }
.table thead th { font-size: .78rem; font-weight: 600; color: var(--muted); background: #fafbfc; white-space: nowrap; }
.table tbody tr:hover { background: #fafbfc; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table .row-link { color: var(--text); font-weight: 600; text-decoration: none; }
.table .row-link:hover { color: var(--red); }
.table-actions { white-space: nowrap; text-align: right; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty .bi { font-size: 1.8rem; display: block; margin-bottom: 6px; opacity: .5; }

/* para językowa – element rozpoznawczy */
.pair {
  display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 999px;
  font-size: .76rem; font-weight: 600; background: var(--surface); white-space: nowrap; overflow: hidden;
}
.pair span { padding: 1px 8px; }
.pair span:first-child { background: #f1f2f5; }
.pair span:last-child { border-left: 1px solid var(--line); }

/* statusy */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-draft, .st-proforma { color: #7a7f89; }
.st-sent, .st-confirmed { color: #2563a8; }
.st-accepted, .st-translation, .st-review { color: var(--amber); }
.st-delivery, .st-converted, .st-closed { color: var(--green); }
.st-rejected, .st-expired { color: var(--red); }
.deadline-late { color: var(--red); font-weight: 600; }
.deadline-today { color: var(--amber); font-weight: 600; }

/* ---------- formularze ---------- */
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }
.form-control, .form-select, .ts-control, .ts-wrapper.single .ts-control, .input-group-text { border-color: #d6d9df; background-color: #fff; }
.form-control:disabled, .form-select:disabled { background-color: #f1f2f5; }
.form-control:focus, .form-select:focus { border-color: var(--red); }
.form-text { font-size: .78rem; }
.form-section { font-size: .95rem; font-weight: 600; margin: 4px 0 12px; }
.btn { font-weight: 500; border-radius: var(--radius-sm); }
.btn-primary { --bs-btn-bg: var(--red); --bs-btn-border-color: var(--red); --bs-btn-hover-bg: var(--red-dark); --bs-btn-hover-border-color: var(--red-dark); --bs-btn-active-bg: var(--red-dark); --bs-btn-disabled-bg: var(--red); --bs-btn-disabled-border-color: var(--red); }
.btn-dark { --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink); }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: #d6d9df; --bs-btn-hover-bg: #f3f4f6; --bs-btn-hover-border-color: #c9cdd4; }
.btn-icon { padding: .25rem .5rem; }
.form-check-input:checked { background-color: var(--red); border-color: var(--red); }

/* pozycje wyceny / zlecenia – edytowalna tabela */
.items-table td { vertical-align: top; }
.items-table .form-control, .items-table .form-select { font-size: .85rem; }
.items-table .ts-wrapper { min-width: 150px; }
.items-total { font-size: .95rem; }
.items-total td { padding: .3rem .9rem; }
.items-total .grand td { font-size: 1.15rem; font-weight: 600; border-top: 2px solid var(--text); }

/* Tom Select w stylu aplikacji */
.ts-control { border-color: #d6d9df; border-radius: var(--bs-border-radius); min-height: 38px; }
.focus .ts-control { border-color: var(--red); box-shadow: 0 0 0 .25rem rgba(215, 32, 39, .15); }
.ts-dropdown .active { background: var(--red-tint); color: var(--text); }
.ts-dropdown .optgroup-header { font-weight: 600; color: var(--muted); font-size: .78rem; }

/* definicje (widok szczegółów) */
.dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 14px; margin: 0; }
.dl dt { font-weight: 500; color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; }

/* oś czasu */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-top: 7px; }
.timeline .dot.red { background: var(--red); }
.timeline .meta { font-size: .78rem; color: var(--muted); }

/* poczta */
.mail-list a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.mail-list a:hover { background: #fafbfc; }
.mail-list a.unread .from, .mail-list a.unread .subj { font-weight: 600; }
.mail-list a.unread { box-shadow: inset 3px 0 0 var(--red); }
.mail-list .from { font-size: .9rem; }
.mail-list .date { font-size: .78rem; color: var(--muted); text-align: right; }
.mail-list .subj { grid-column: 1 / -1; font-size: .88rem; }
.mail-list .snip { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-frame { width: 100%; border: 0; min-height: 420px; background: #fff; }

/* logowanie / instalator */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .big { font-size: 2.4rem; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; max-width: 14ch; }
.auth-side .pairs { display: flex; flex-wrap: wrap; gap: 8px; opacity: .9; }
.auth-side .pairs .pair { background: transparent; border-color: #4a4f59; color: #e4e6ea; }
.auth-side .pairs .pair span:first-child { background: #31353d; }
.auth-side .pairs .pair span:last-child { border-color: #4a4f59; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.install-card { max-width: 760px; }

.flash-stack { position: fixed; right: 20px; bottom: 20px; z-index: 1080; display: grid; gap: 8px; max-width: 420px; }
.flash-stack .alert { margin: 0; box-shadow: 0 6px 24px rgba(20, 22, 28, .12); }

@media (max-width: 1100px) {
  .ledger { grid-template-columns: repeat(2, 1fr); }
  .ledger-cell:nth-child(2) { border-right: 0; }
  .ledger-cell:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  .app.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-toggle { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
}
@media (max-width: 560px) {
  .ledger { grid-template-columns: 1fr; }
  .ledger-cell { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
