:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --text: #17211d;
  --muted: #66736d;
  --line: #dce4df;
  --accent: #B11520;
  --accent-dark: #7c1018;
  --accent-soft: rgba(177, 21, 32, 0.1);
  --accent-line: rgba(177, 21, 32, 0.28);
  --accent-2: #B11520;
  --danger: #b73e3e;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(18, 24, 21, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 16px;
  box-shadow: none;
}

button:hover,
.primary-link:hover {
  filter: brightness(0.96);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(177, 21, 32, 0.16);
  outline: 0;
}

.shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfb;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 26px;
  padding: 12px;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  object-fit: contain;
}

.brand strong {
  display: block;
  color: var(--accent);
  font-size: 20px;
  letter-spacing: 0;
}

.brand span,
.metric span,
.table-head p,
.panel-heading p,
.title-cell span {
  color: var(--muted);
  font-size: 13px;
}

.side-nav {
  display: grid;
  gap: 8px;
  border-top: 1px solid #e7ece8;
  border-bottom: 1px solid #e7ece8;
  margin-bottom: 18px;
  padding: 16px 0;
}

.side-nav a,
.ghost-button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  justify-content: flex-start;
  padding: 0 12px;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.side-nav a.active {
  border-color: var(--accent);
  background: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--accent);
}

.side-nav a:hover,
.ghost-button:hover,
.sidebar-actions a:hover {
  border-color: #cbd6cf;
  background: #fff;
}

.ghost-button {
  cursor: pointer;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.flash {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
}

.flash-success {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.flash-error {
  border-color: rgba(183, 62, 62, 0.24);
  background: rgba(183, 62, 62, 0.08);
  color: var(--danger);
}

.side-section {
  border-top: 1px solid #e7ece8;
  padding: 18px 0;
}

.side-title,
.field-label {
  display: block;
  margin-bottom: 10px;
  color: #2c3933;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-search {
  margin-bottom: 10px;
}

.check-list {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  border-radius: 6px;
  padding: 7px 6px;
}

.check-row:hover {
  background: var(--accent-soft);
}

.check-row input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
}

.check-row span {
  font-size: 13px;
  line-height: 1.35;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 18px 0 4px;
}

.sidebar-actions a {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: none;
  margin-bottom: 22px;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #111816;
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.top-actions span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
  padding: 16px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.15;
}

.metric.wide strong {
  font-size: 21px;
}

.panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
  margin-bottom: 18px;
}

.panel-heading,
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  padding: 18px;
}

.advanced-grid label {
  display: grid;
  gap: 7px;
}

.advanced-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f8f7;
  color: #405047;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  font-size: 13px;
  line-height: 1.4;
}

.title-cell {
  min-width: 310px;
}

.title-cell strong {
  display: block;
  margin-bottom: 5px;
}

.title-link {
  display: block;
  color: var(--text);
  font-weight: 800;
  margin-bottom: 5px;
  text-decoration: none;
}

.title-link:hover {
  color: var(--accent);
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-otwarty {
  background: rgba(15, 143, 115, 0.14);
  color: #08735d;
}

.status-planowany {
  background: rgba(184, 107, 32, 0.14);
  color: #925112;
}

.status-zakonczony {
  background: rgba(183, 62, 62, 0.13);
  color: var(--danger);
}

.link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.category-cell {
  min-width: 260px;
}

.money {
  color: #26332d;
  font-weight: 800;
  white-space: nowrap;
}

.empty {
  height: 120px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 14px 18px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  padding: 0 11px;
  text-decoration: none;
}

.pagination a.active {
  border-color: var(--accent-line);
  background: var(--accent);
  color: #fff;
}

.pagination span {
  color: #a2ada8;
}

.hidden {
  display: none;
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
  padding: 30px;
}

.auth-brand {
  margin-bottom: 22px;
}

.auth-copy {
  color: var(--muted);
  margin: 10px 0 22px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label,
.upload-form label {
  display: grid;
  gap: 7px;
}

.login-form span,
.upload-form span,
.import-meta span,
.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.login-hints span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.compact-shell {
  grid-template-columns: 260px minmax(0, 1fr);
}

.upload-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

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

.settings-grid label {
  display: grid;
  gap: 7px;
}

.settings-grid span,
.switch-row span,
.generation-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  padding: 16px;
}

.switch-row input {
  width: 18px;
  min-height: 18px;
}

.subtle-switch {
  border-color: var(--line);
  background: #fff;
}

.upload-box {
  border: 1px dashed #b9c7c0;
  border-radius: var(--radius);
  background: #fbfcfb;
  padding: 18px;
}

.generation-preview {
  display: grid;
  gap: 10px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px;
}

.generation-preview strong {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 22px;
}

.generation-preview-live,
.generation-live {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbfa;
  padding: 12px;
}

.generation-preview-live {
  display: grid;
  gap: 5px;
}

.generation-preview-live em,
.generation-status {
  color: var(--accent);
  font-style: normal;
  font-weight: 800;
}

.generation-preview p,
.generation-note {
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  width: 100%;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0d8db;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease;
}

.import-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 18px;
}

.import-meta div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.import-meta strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.generation-settings-panel {
  border: 1px solid var(--accent-line);
  box-shadow: none;
}

.generation-heading {
  align-items: flex-start;
  background: #fff;
}

.generation-heading h2 {
  color: var(--accent);
  font-size: 24px;
}

.generation-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  padding: 0 14px;
  white-space: nowrap;
}

.detail-hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
  margin-bottom: 18px;
  padding: 24px;
}

.detail-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-kicker a {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.detail-hero h1 {
  max-width: 980px;
}

.detail-hero p {
  color: var(--muted);
  margin-top: 10px;
}

.detail-actions {
  margin-top: 18px;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 0 16px;
  text-decoration: none;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
  padding: 20px;
}

.detail-card h2 {
  margin-bottom: 14px;
}

.narrative p {
  color: #2d3833;
  line-height: 1.7;
  white-space: pre-line;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.detail-list div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  padding: 12px;
}

.detail-list dd {
  margin: 7px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.generation-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(244, 246, 245, 0.36);
  backdrop-filter: blur(1px);
  padding: 24px;
}

.generation-modal {
  width: min(460px, 100%);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 24px rgba(18, 24, 21, 0.12);
  padding: 30px;
  text-align: center;
}

.generation-modal h2 {
  margin: 8px 0 14px;
  font-size: 26px;
}

.generation-percent {
  color: var(--accent);
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 16px;
}

.generation-live {
  display: grid;
  gap: 6px;
  margin: 0 0 16px;
  text-align: left;
}

.generation-live-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.generation-live strong {
  color: var(--text);
  font-size: 22px;
}

.generation-note {
  margin-top: 14px;
}

.loading-ring {
  width: 46px;
  height: 46px;
  border: 4px solid #f0d8db;
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .metrics,
  .detail-metrics,
  .settings-grid,
  .advanced-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .content,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-heading,
  .table-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .detail-metrics,
  .detail-list,
  .import-meta,
  .settings-grid,
  .advanced-grid {
    grid-template-columns: 1fr;
  }
}
