/* ============================================================
   assets/app.css — system wyglądu panelu (SaaS).
   Ładowany PO stylach strony (head.php), więc:
     * tokeny kolorów nadpisują stare definicje stron,
     * komponenty wspólne (przyciski, karty, tabele, pola) wyglądają wszędzie tak samo.
   Strony definiują już tylko własny układ.
   ============================================================ */

:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

  /* Neutralne */
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #f9fafb;
  --line:      #e5e7eb;
  --input-line: #cbd5e1;   /* ramki pól formularzy */
  --line-2:    #eef0f3;
  --text:      #111827;
  --text-2:    #374151;
  --muted:     #6b7280;

  /* Marka */
  --accent:       #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft:  #eef2ff;
  --accent-line:  #c7d2fe;
  --ring:         rgba(79, 70, 229, .18);

  /* Stany */
  --green: #047857;  --green-soft: #ecfdf5;  --green-line: #a7f3d0;
  --red:   #b91c1c;  --red-soft:   #fef2f2;  --red-line:   #fecaca;
  --amber: #b45309;  --amber-soft: #fffbeb;  --amber-line: #fde68a;

  /* Kształt */
  --radius:    10px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow:    0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

  --sidebar-w: 248px;

  /* Zgodność ze starymi nazwami używanymi w stylach stron */
  --pink:      var(--accent);
  --pink-dark: var(--accent-hover);
}

/* ---------- Baza ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
button, input, select, textarea { font-family: inherit; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }

h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
h3 { font-weight: 600; }

/* Liczby w tabelach i kwotach — równe szerokości cyfr */
td, .amount, .num, .v, .val, .opaid { font-variant-numeric: tabular-nums; }

/* ---------- Układ z panelem bocznym ---------- */
body:has(> .sb) { padding-left: var(--sidebar-w); }

.sb {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
  background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column;
  border-right: 1px solid #1e293b;
}
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; text-decoration: none; }
.sb-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.sb-name { color: #f8fafc; font-weight: 700; font-size: 15px; letter-spacing: -.01em; line-height: 1.15; }
.sb-tag  { color: #64748b; font-size: 11.5px; font-weight: 500; }

.sb-nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.sb-sec { color: #64748b; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 16px 10px 6px; }
.sb-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin: 1px 0; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s;
}
.sb-link svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.sb-link:hover { background: #1e293b; color: #f8fafc; }
.sb-link.on { background: #1e293b; color: #fff; box-shadow: inset 2px 0 0 #818cf8; }
.sb-link.on svg { opacity: 1; color: #a5b4fc; }
.sb-link .sb-badge {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 10px;
  background: #6366f1; color: #fff; font-size: 11px; font-weight: 600; text-align: center;
}
.sb-link .sb-badge:empty { display: none; }

.sb-foot { border-top: 1px solid #1e293b; padding: 12px; display: flex; align-items: center; gap: 10px; }
.sb-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.sb-avatar { width: 30px; height: 30px; border-radius: 50%; background: #334155; color: #e2e8f0;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; }
.sb-user-txt { min-width: 0; }
.sb-user-txt b { display: block; color: #f1f5f9; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-txt span { display: block; color: #64748b; font-size: 11.5px; }
.sb-out { color: #94a3b8; padding: 7px; border-radius: 8px; display: flex; }
.sb-out:hover { background: #1e293b; color: #fff; }
.sb-out svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Pasek górny — tylko na telefonie */
.tb { display: none; }
.sb-mask { display: none; }

@media (max-width: 900px) {
  body:has(> .sb) { padding-left: 0; padding-top: 56px; }
  .tb {
    display: flex; align-items: center; gap: 10px;
    position: fixed; inset: 0 0 auto 0; height: 56px; z-index: 55;
    background: #0f172a; color: #f8fafc; padding: 0 12px;
  }
  .tb button { background: none; border: none; color: #e2e8f0; padding: 8px; border-radius: 8px; display: flex; cursor: pointer; }
  .tb button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
  .tb .sb-mark { width: 28px; height: 28px; font-size: 14px; }
  .tb b { font-weight: 600; font-size: 15px; }
  .sb { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.sb-open .sb { transform: none; }
  body.sb-open .sb-mask { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 58; }
}

/* ---------- Nagłówki stron ---------- */
.wrap { padding-top: 28px !important; }
.top { margin-bottom: 20px !important; align-items: center; }
.top h1, .wrap > h1 { margin: 0; }
.sub { color: var(--muted); }

/* ---------- Przyciski ---------- */
.btn, .submit, .bar button, .search button, .polacz-baner button, .acts2 button, .a-all, .a-par, .a-par2 {
  font-family: inherit;
  font-weight: 600 !important;
  letter-spacing: -.005em;
  border-radius: 8px !important;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn { font-size: 13.5px !important; padding: 8px 14px !important; line-height: 1.35; box-shadow: var(--shadow-sm); }
.btn.dark { background: var(--text) !important; color: #fff !important; }
.btn.on { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.submit { font-size: 14.5px !important; padding: 12px 16px !important; }
.submit.ghost { background: var(--surface) !important; color: var(--accent) !important; border: 1px solid var(--accent-line) !important; }
.submit.ghost:hover { background: var(--accent-soft) !important; }
button:focus-visible, a:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Karty i powierzchnie ---------- */
.card, .ord, .kpi, .sum, .empty, .zam {
  border-color: var(--line) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow) !important;
}
.kpi .l, .sum span { font-weight: 500 !important; }
.kpi .v, .sum strong { font-weight: 700 !important; letter-spacing: -.02em; }
.kpi.main { box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow) !important; border-color: var(--accent) !important; }

/* ---------- Tabele ---------- */
th {
  font-size: 11.5px !important; font-weight: 600 !important; letter-spacing: .04em !important;
  text-transform: uppercase; color: var(--muted) !important; background: var(--surface-2);
}
td { border-color: var(--line-2) !important; }
tbody tr:hover td { background: #fafbff; }
.heat td, .heat tr:hover td { background: unset; }

/* ---------- Pola formularzy ---------- */
/* Ramka pól wyraźnie ciemniejsza niż linie kart — inaczej puste pole ginie na białym tle. */
input[type=text], input[type=number], input[type=search], input[type=date], input[type=password],
input[type=email], input[type=tel], input:not([type]), select, textarea {
  font-family: inherit;
  border: 1px solid var(--input-line) !important;
  border-radius: 8px !important;
  background-color: #fff;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, .05);
  transition: border-color .12s, box-shadow .12s;
}
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) {
  border-color: #94a3b8 !important;
}
input:disabled, select:disabled, textarea:disabled {
  background-color: var(--surface-2) !important;
  color: var(--muted);
  cursor: not-allowed;
  box-shadow: none;
}
input::placeholder, textarea::placeholder { color: #9ca3af; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--ring) !important;
  outline: none;
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* ---------- Plakietki i komunikaty ---------- */
.badge, .tag { font-weight: 600 !important; letter-spacing: 0; border-radius: 6px !important; }
.b-ok, .t-ok { background: var(--green-soft) !important; color: var(--green) !important; }
.b-err, .b-cancel, .t-zwrot { background: var(--red-soft) !important; color: var(--red) !important; }
.b-wait, .t-anul { background: var(--amber-soft) !important; color: var(--amber) !important; }
.b-mut { background: #f3f4f6 !important; color: var(--muted) !important; }
.b-join { background: var(--accent-soft) !important; color: var(--accent) !important; }

.fail, .err, .msg.err, .blad {
  background: var(--red-soft) !important; color: var(--red) !important; border-color: var(--red-line) !important;
  border-radius: var(--radius) !important;
}
.ok, .msg.ok {
  background: var(--green-soft) !important; color: var(--green) !important; border-color: var(--green-line) !important;
  border-radius: var(--radius) !important;
}
.warn, .sync-info, .ruch-info, .refresh-bar, .blokada {
  background: var(--amber-soft) !important; color: #92400e !important; border-color: var(--amber-line) !important;
}
.warn, .sync-info, .ruch-info, .refresh-bar { border-radius: var(--radius) !important; }
.refresh-bar.done { background: var(--green-soft) !important; color: var(--green) !important; border-color: var(--green-line) !important; }

/* ---------- Drobne ---------- */
code { background: #f3f4f6; border-radius: 5px; }
pre { background: #0f172a !important; }
hr { border: none; border-top: 1px solid var(--line); }

/* ---------- SaaS: okres próbny, podgląd administratora ---------- */
.sb-trial { display: block; margin: 0 12px 10px; padding: 8px 10px; border-radius: 8px; background: #1e293b;
  color: #fde68a; font-size: 12.5px; font-weight: 600; text-decoration: none; text-align: center; }
.sb-trial:hover { background: #334155; }
.imp-bar { position: sticky; top: 0; z-index: 50; background: #fef3c7; color: #92400e; border-bottom: 1px solid #fde68a;
  padding: 8px 18px; font-size: 13px; }
.imp-bar a { margin-left: 10px; font-weight: 600; color: #92400e; }

/* ---------- Formularze ustawień / konta ---------- */
.set-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 16px; }
.set-card h2 { margin: 0 0 4px; font-size: 16px; }
.set-card > .sub { margin: 0 0 16px; font-size: 13.5px; }
.fld { margin-bottom: 14px; }
.fld > label, .fld > .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.fld input[type=text], .fld input[type=email], .fld input[type=password], .fld input[type=number], .fld input[type=date],
.fld select, .fld textarea { width: 100%; max-width: 460px; padding: 9px 11px; border: 1px solid var(--line); font-size: 14px; background: #fff; }
.fld textarea { min-height: 70px; }
.fld .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.opts { display: grid; gap: 8px; max-width: 640px; }
.opt { display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; background: #fff; transition: border-color .12s, background .12s; }
.opt:hover { border-color: var(--accent-line); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt input { margin-top: 3px; flex: none; }
.opt b { display: block; font-size: 14px; }
.opt span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.btn-primary { display: inline-block; background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sec { display: inline-block; background: #fff; color: var(--text-2); border: 1px solid var(--input-line); border-radius: 8px; padding: 8px 14px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-sec:hover { border-color: var(--accent-line); }
.btn-danger { display: inline-block; background: var(--red); color: #fff; border: none; border-radius: 8px; padding: 8px 14px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; }
.flash { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash.ok { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.flash.err { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
@media (max-width: 600px) { .dl { grid-template-columns: 1fr; } }
