/* Etap 1 — wspólny motyw wizualny. Ładowany po stylach strony, więc go uzupełnia. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #dbe2ec;
  --line-strong: #c7d2e1;
  --text: #142033;
  --muted: #5d6b7e;
  --brand: #1d4ed8;
  --brand-2: #0f2f5f;
  --brand-soft: #eaf1ff;
  --ok: #157347;
  --warn: #9a6700;
  --red: #b42318;
  --orange: #c2410c;
  --grey: #7b8798;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(15, 39, 66, .06);
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 420px at 8% -8%, #e7efff 0%, rgba(231, 239, 255, 0) 62%),
    radial-gradient(900px 380px at 100% 0%, #eef7f3 0%, rgba(238, 247, 243, 0) 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 8px;
}

header h1 {
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: 0 0 4px;
  font-weight: 750;
}

header .sub {
  max-width: 840px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  box-shadow: 0 8px 20px rgba(29, 78, 216, .22);
}

.brand-kicker {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 2px;
}

nav {
  max-width: 1180px;
  margin: 18px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

nav a {
  padding: 9px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 650;
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

nav a:hover {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

nav a.on {
  background: var(--brand-2);
  color: #fff;
  border-color: var(--brand-2);
  box-shadow: 0 6px 16px rgba(15, 47, 95, .18);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 56px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: -.01em;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.step {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #3b82f6);
  color: #fff;
  font-size: 12px;
  box-shadow: 0 3px 8px rgba(29, 78, 216, .2);
}

label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--muted);
  margin-bottom: 5px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  min-height: 42px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input::placeholder,
textarea::placeholder { color: #98a3b3; }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(29, 78, 216, .18);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, background .15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, .22);
}

button:disabled {
  opacity: .5;
  cursor: default;
  box-shadow: none;
}

button.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
  box-shadow: none;
}

button.ghost:hover:not(:disabled) {
  background: #f8fafc;
  border-color: var(--line-strong);
  transform: none;
  box-shadow: none;
}

.hint {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 6px;
}

.msg {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 10px;
  margin: 10px 0;
  font-size: 13.5px;
  background: #f8fafc;
}

.msg.warn {
  background: #fffbeb;
  border-color: #fde68a;
  border-left-color: #d97706;
  color: #7c4a03;
}

.msg.err {
  background: #fff1f0;
  border-color: #fecaca;
  border-left-color: var(--red);
  color: #8a1f1f;
}

.msg.ok {
  background: #effaf3;
  border-color: #bbf7d0;
  border-left-color: var(--ok);
  color: #14532d;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:hover td { background: #f8fbff; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
}

.chip {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: none;
  white-space: normal;
  text-align: left;
  line-height: 1.35;
}

.chip:hover {
  background: var(--brand-soft);
  border-color: #bfd3ff;
  color: var(--brand);
  transform: none;
  box-shadow: none;
}

#taxChips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.tile {
  border-radius: 9px;
  background: #f8fafc;
  border: 1px solid var(--line);
  font-weight: 650;
}

.tile:hover {
  background: var(--brand-soft);
  border-color: #bfd3ff;
  color: var(--brand);
}

.tile.sf {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  padding: 9px 12px;
  background: var(--brand-soft);
  color: var(--brand);
}

.company-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.span-all { grid-column: 1 / -1; }

.krs-tile {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.krs-actions {
  display: grid;
  gap: 6px;
}

.krs-actions .tile { width: 100%; }

.stat {
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.stat b {
  font-size: 26px;
  letter-spacing: -.02em;
}

.stats { gap: 12px; }

.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer span { opacity: .9; }

@media (max-width: 820px) {
  .company-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  header { padding: 20px 16px 6px; }
  header h1 { font-size: 22px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 11px; }
  nav {
    padding: 0 16px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  nav a { white-space: nowrap; }
  main { padding: 0 16px 40px; }
  .card { padding: 18px; border-radius: 14px; }
  .site-footer { padding: 0 16px 24px; }
}

/* --- Etap 3: lewy pasek nawigacji (chowany) ------------------------------ */

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-main > main { flex: 1 0 auto; }

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  box-sizing: border-box;
  width: 252px;
  flex: 0 0 252px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 12px 14px;
  background: rgba(255, 255, 255, .78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(8px);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 10.5px;
}

.sidebar-title { min-width: 0; }

.sidebar-title b {
  display: block;
  font-size: 13.5px;
  line-height: 1.2;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.sidebar-title span {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.nav-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  box-shadow: none;
}

.nav-toggle svg { width: 15px; height: 15px; flex: 0 0 15px; }

.nav-toggle:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  background: #f4f7fb;
  border-color: var(--line-strong);
  color: var(--text);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  max-width: none;
  margin: 0;
  padding: 0;
}

.nav-label {
  padding: 8px 10px 2px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.sidebar nav a svg { flex: 0 0 18px; width: 18px; height: 18px; }

.sidebar nav a:hover {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
  box-shadow: none;
}

.sidebar nav a.on {
  background: var(--brand-soft);
  border-color: #c9dbff;
  color: var(--brand);
  font-weight: 750;
  box-shadow: none;
}

.sidebar nav a.on::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px 2px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

.nav-user {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.nav-user b {
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.nav-user span {
  font-size: 10.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-user button {
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 8px;
  background: #f6f8fb;
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: none;
}

.nav-user button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #eef2f7;
}

/* zwinięty pasek: same ikony */
html.nav-collapsed .sidebar {
  width: 72px;
  flex-basis: 72px;
  padding-left: 8px;
  padding-right: 8px;
}

html.nav-collapsed .sidebar-title,
html.nav-collapsed .nav-label,
html.nav-collapsed .sidebar nav a span,
html.nav-collapsed .sidebar-foot,
html.nav-collapsed .nav-toggle span { display: none; }

html.nav-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }

html.nav-collapsed .nav-toggle { justify-content: center; padding: 8px; }

html.nav-collapsed .sidebar nav a { justify-content: center; padding: 10px; }

html.nav-collapsed .sidebar nav a.on::before { left: -8px; }

/* zakładki lokalne (np. Kontakty: Wklej / Baza) */
.page-tabs {
  max-width: 1180px;
  width: 100%;
  margin: 16px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.page-tabs button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

.page-tabs button:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  border-color: var(--line-strong);
  color: var(--text);
}

.page-tabs button.on {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
}

.nav-close {
  display: none;
  margin-left: auto;
  width: 34px;
  height: 34px;
  padding: 0;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  place-items: center;
}

.nav-close:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  background: #eef2f7;
  color: var(--text);
}

#navMobile { display: none; }
#navScrim { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    width: 276px;
    flex-basis: 276px;
    padding: 16px 12px 14px;
    background: #fff;
    transform: translateX(-102%);
    transition: transform .2s ease;
  }

  html.nav-open .sidebar {
    transform: none;
    box-shadow: 24px 0 60px rgba(15, 39, 66, .2);
  }

  html.nav-collapsed .sidebar {
    width: 276px;
    flex-basis: 276px;
    padding: 16px 12px 14px;
  }

  html.nav-collapsed .sidebar-title,
  html.nav-collapsed .nav-label,
  html.nav-collapsed .sidebar nav a span,
  html.nav-collapsed .sidebar-foot { display: block; }

  html.nav-collapsed .sidebar-brand { justify-content: flex-start; }
  html.nav-collapsed .sidebar nav a { justify-content: flex-start; padding: 9px 10px; }
  html.nav-collapsed .sidebar nav a.on::before { left: -12px; }
  html.nav-collapsed .sidebar-foot { display: flex; }

  #navCollapse { display: none; }

  .nav-close { display: grid; }

  html.nav-open #navMobile { opacity: 0; pointer-events: none; }

  #navMobile {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    box-shadow: 0 6px 18px rgba(15, 39, 66, .14);
  }

  #navMobile:hover:not(:disabled) { transform: none; box-shadow: 0 6px 18px rgba(15, 39, 66, .14); }

  #navMobile svg { width: 20px; height: 20px; }

  .app-main > header { padding-top: 64px; }

  #navScrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, .4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }

  html.nav-open #navScrim { opacity: 1; pointer-events: auto; }
}

@media print {
  nav, button, .parp-cta, .drop, .sidebar, #navMobile, #navScrim { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  .app-shell, .app-main { display: block; }
}
