/* Styl aplikacji „Kokpit”: jeden plik, bez stylów wbudowanych w szablony (CSP
   dopuszcza wyłącznie style z 'self'). Kolory są tylko w tokenach poniżej. */

:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-alt: #eef1f7;
  --fg: #141b2d;
  --muted: #5a6478;
  --line: #dde2ec;
  --accent: #1e3a8a;
  --accent-hover: #172e6e;
  --on-accent: #ffffff;
  --warning: #b45309;
  --error: #b91c1c;
  --success: #166534;
  --info: #1e3a8a;
  --warning-bg: #fdf3e3;
  --error-bg: #fbeaea;
  --success-bg: #e8f5ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(20 27 45 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1321;
    --surface: #161e2e;
    --surface-alt: #1f2839;
    --fg: #e7ecf5;
    --muted: #98a3b8;
    --line: #2a3448;
    --accent: #8fb0ff;
    --accent-hover: #abc4ff;
    --on-accent: #0d1321;
    --warning: #fbbf24;
    --error: #f87171;
    --success: #4ade80;
    --info: #8fb0ff;
    --warning-bg: #2c2412;
    --error-bg: #2f1a1d;
    --success-bg: #14291c;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1321;
  --surface: #161e2e;
  --surface-alt: #1f2839;
  --fg: #e7ecf5;
  --muted: #98a3b8;
  --line: #2a3448;
  --accent: #8fb0ff;
  --accent-hover: #abc4ff;
  --on-accent: #0d1321;
  --warning: #fbbf24;
  --error: #f87171;
  --success: #4ade80;
  --info: #8fb0ff;
  --warning-bg: #2c2412;
  --error-bg: #2f1a1d;
  --success-bg: #14291c;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 96px;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 0.95rem; font-weight: 600; margin: 12px 0 6px; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); font-weight: 400; }
.grow { flex: 1 1 auto; min-width: 0; }
.mono { font-family: ui-monospace, monospace; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Górny pasek */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 650; text-decoration: none; }
.brand-mark { display: block; width: 28px; height: 28px; }
.topnav { display: flex; gap: 4px; margin-right: auto; }
.topnav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.topnav a:hover { background: var(--surface-alt); color: var(--fg); }
.public-topbar { justify-content: space-between; }
.public-actions { display: flex; align-items: center; gap: 8px; }
.public-wordmark { margin-right: 8px; }

.menu { position: relative; margin-left: auto; }
.menu-toggle {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px;
  cursor: pointer; list-style: none; font-size: 1.1rem; color: var(--fg);
}
.menu-toggle::-webkit-details-marker { display: none; }
.menu-toggle:hover, .menu[open] .menu-toggle { background: var(--surface-alt); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: min(320px, calc(100vw - 32px)); max-height: calc(100vh - 80px); overflow-y: auto;
  padding: 4px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(13 19 33 / 22%);
}
.menu-section { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.menu-section:last-child { border-bottom: 0; }
.menu-section > form, .menu-section .field { width: 100%; }
.menu-label { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.segmented { display: flex; width: 100%; padding: 3px; gap: 3px; border-radius: 8px; background: var(--surface-alt); }
.segmented button { flex: 1; min-height: 30px; padding: 0 8px; background: transparent; color: var(--muted); font-size: 0.85rem; border: 0; }
.segmented button:hover { background: transparent; color: var(--fg); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

/* Ścieżka i nagłówek strony */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: 0.875rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs > * + *::before { content: "›"; margin-right: 4px; color: var(--muted); }
.crumbs span { color: var(--fg); overflow-wrap: anywhere; }
.crumbs .back-link { margin-right: 8px; color: var(--accent); font-weight: 550; }
.crumbs .back-link + *::before { content: none; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-header h1 + .badge { margin-top: 6px; }
.actions, .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.section-actions { margin-top: 12px; }

/* Przyciski: jedna rodzina, główny wygląd to akcent */
button, .button, .button-secondary, .button-danger, .button-small, .button-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap;
}
button:hover, .button:hover { background: var(--accent-hover); color: var(--on-accent); }
button:disabled { opacity: 0.45; cursor: default; }
.button-secondary, button.button-secondary, .button-ghost { background: var(--surface); border-color: var(--line); color: var(--fg); }
.button-secondary:hover, button.button-secondary:hover, .button-ghost:hover { background: var(--surface-alt); color: var(--fg); }
.button-danger, button.button-danger { background: transparent; border-color: var(--error); color: var(--error); }
.button-danger:hover, button.button-danger:hover { background: var(--error-bg); color: var(--error); }
.button-small { min-height: 30px; padding: 0 10px; font-size: 0.85rem; }
.link-button, button.link-button {
  display: inline; min-height: 0; padding: 0; border: 0; background: none; color: var(--accent);
  font-weight: 500; font-size: 0.9rem; text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
button.link-button:hover { background: none; color: var(--accent-hover); }
.icon-button, button.icon-button {
  width: 30px; min-height: 30px; padding: 0; background: transparent; color: var(--muted); font-size: 1.15rem; border: 0;
}
button.icon-button:hover { background: var(--error-bg); color: var(--error); }

/* Formularze */
input, select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--fg); font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 1px solid var(--accent); }
input[type="checkbox"], .checkbox { flex: 0 0 auto; width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: var(--accent); }
label { font-size: 0.875rem; font-weight: 500; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.field > input, .field > select, .field > textarea { width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-section, .fieldset { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.fieldset legend { padding: 0 6px; font-weight: 600; }
.field-hint { margin: 0; color: var(--muted); font-size: 0.82rem; }
.field-error, .inline-error, .error { margin: 0; color: var(--error); font-size: 0.85rem; }
.field-invalid input, .field-invalid select { border-color: var(--warning); }
.options { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.checkbox-label { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; font-size: 0.925rem; cursor: pointer; }
.inline, .inline-form { display: inline; }
.inline-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.new-batch { display: flex; gap: 8px; flex: 1 1 280px; max-width: 420px; }
.save-bar {
  position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: flex-end;
  margin: 0 -16px -16px; padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--line);
}

/* Listy wierszy */
.rows { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.rows > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--fg); text-decoration: none; }
a.row:hover, .row:has(.row-link:hover) { background: var(--surface-alt); color: var(--fg); }
.row-main { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.row-link { color: var(--fg); text-decoration: none; }
.row-link:hover { color: var(--fg); }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-arrow { color: var(--muted); font-size: 1.2rem; }
.row-progress { flex: 0 0 96px; height: 6px; border: 0; border-radius: 3px; overflow: hidden; background: var(--surface-alt); appearance: none; }
.row-progress::-webkit-progress-bar { background: var(--surface-alt); }
.row-progress::-webkit-progress-value { background: var(--accent); }
.row-progress::-moz-progress-bar { background: var(--accent); }
.row form { flex: 0 0 auto; }
.row-select { display: flex; align-items: center; padding-left: 14px; }
.row-select .row { flex: 1 1 auto; min-width: 0; }
.row-select > .checkbox { margin: 0; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; margin-bottom: 8px; padding-left: 14px; }
.dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.tone-success { background: var(--success); }
.dot.tone-warning { background: var(--warning); }
.dot.tone-error { background: var(--error); }
.dot.tone-info { background: var(--info); }

/* Znaczniki stanu */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--surface-alt); color: var(--muted); font-size: 0.78rem; font-weight: 550; white-space: nowrap; }
.badge.tone-success, .badge.status-ready, .badge.status-draft_created { background: var(--success-bg); color: var(--success); }
.badge.tone-warning, .badge.status-needs_input { background: var(--warning-bg); color: var(--warning); }
.badge.tone-error, .badge.status-error { background: var(--error-bg); color: var(--error); }

/* Karty i panele zwijane */
.card, .panel { margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card { padding: 16px; }
.panel > summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: 600; cursor: pointer; list-style: none; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.2rem; transition: transform 0.15s; }
.panel[open] > summary::after { transform: rotate(90deg); }
.panel-body { display: flex; flex-direction: column; gap: 14px; padding: 4px 16px 16px; }
.panel-body.form-grid { display: grid; }
.summary-value { color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#offers, #ustawienia { margin-top: 12px; }
.subtle > summary { color: var(--muted); font-size: 0.875rem; cursor: pointer; }
.subtle[open] > summary { margin-bottom: 6px; }
.checklist { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.checklist-item { display: flex; align-items: flex-start; gap: 10px; }
.checklist-item .dot { margin-top: 6px; }
.checklist-item p { font-size: 0.875rem; }
.ready-note { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.plain-list { margin: 0; padding-left: 18px; font-size: 0.9rem; }
.data-list { display: grid; grid-template-columns: minmax(100px, 200px) 1fr; gap: 6px 12px; margin: 0; font-size: 0.9rem; }
.data-list dt { color: var(--muted); }
.data-list dd { margin: 0; overflow-wrap: anywhere; }
.image-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.image-preview { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.offer-description { overflow-wrap: anywhere; }
.description-row-preview { overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
.offer-data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.offer-data th, .offer-data td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.offer-data th { color: var(--muted); font-weight: 500; }

/* Zakładki */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; font-weight: 500; }
.tab.active { border-color: var(--accent); color: var(--fg); }

/* Komunikaty */
.alert { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-alt); font-size: 0.925rem; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-error { background: var(--error-bg); color: var(--error); }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 16px; padding: 10px 14px; background: var(--warning-bg); color: var(--fg); border-radius: var(--radius); font-size: 0.925rem; }
.empty-state { padding: 40px 16px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--fg); }

/* Reguły ceny */
.pricing-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pricing-rule { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: grab; }
.pricing-rule > span:nth-child(2) { flex: 1 1 auto; min-width: 0; }
.drag-handle { color: var(--muted); }

/* Logowanie i błędy */
.auth-card { display: flex; flex-direction: column; gap: 12px; max-width: 400px; margin: 8vh auto 0; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Strona publiczna */
.hero { padding: 48px 0 32px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); margin-bottom: 12px; }
.hero-lead { max-width: 600px; color: var(--muted); font-size: 1.1rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.eyebrow { margin-bottom: 6px; color: var(--accent); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.section { padding: 24px 0; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 12px 0 0; padding: 0; list-style: none; }
.steps li { display: flex; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps li > span { display: grid; place-items: center; flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 0.85rem; font-weight: 600; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.feature-card, .pricing-placeholder, .cta { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.feature-card h3 { margin-top: 0; }
.cta { margin-top: 24px; text-align: center; }
.cta h2 { margin-bottom: 6px; }
.marketing-footer { display: flex; justify-content: space-between; padding: 24px 0 0; color: var(--muted); font-size: 0.85rem; }

@media (max-width: 560px) {
  .topnav a { padding: 6px 8px; }
  .row-progress { display: none; }
  .row .badge { display: none; }
  a.row .badge { display: inline-flex; }
  .page-header > form, .page-header > .button, .page-header > .actions { width: 100%; }
  .page-header > form button, .page-header > .button { width: 100%; }
  .new-batch { max-width: none; }
  .new-batch button { width: auto; }
  .data-list { grid-template-columns: 1fr; gap: 0; }
  .data-list dd { margin-bottom: 8px; }
}

/* Poradnik */
.guide { display: flex; flex-direction: column; gap: 20px; max-width: 720px; }
.guide section { scroll-margin-top: 80px; }
.guide h3 { font-size: 0.95rem; font-weight: 600; margin: 14px 0 6px; }
.guide ul, .guide ol { display: flex; flex-direction: column; gap: 6px; padding-left: 20px; }
