@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=Source+Serif+4:wght@300;400;600;700&display=swap');

:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-alt: #f5f7fb;
  --ink: #1b2430;
  --muted: #5c6b81;
  --accent: #0c3b6f;
  --accent-2: #1f7a8c;
  --danger: #b42318;
  --border: #dbe3ef;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #f8fbff, var(--bg));
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

body.module-faktura {
  --bg: #edf6f3;
  --surface: #ffffff;
  --surface-alt: #e9f4f0;
  --ink: #122822;
  --muted: #4d6861;
  --accent: #0f8b6d;
  --accent-2: #d07a2f;
  --border: #c4ddd5;
  background: radial-gradient(circle at top right, #d9efe8 0%, #f4fbf8 45%, #edf6f3 100%);
}

body.module-faktura .sidebar {
  background: linear-gradient(175deg, #0e2a24 0%, #134137 52%, #1a6251 100%);
}

body.module-faktura .sidebar summary {
  color: rgba(200, 237, 227, 0.78);
}

body.module-faktura .sidebar a:hover {
  background: rgba(96, 190, 161, 0.22);
}

body.module-faktura .hero {
  background: linear-gradient(135deg, #fbfffd 0%, #eef9f5 50%, #e5f2ed 100%);
  border-color: #bad8cf;
  box-shadow: 0 18px 44px rgba(20, 86, 70, 0.16);
}

body.module-faktura .hero h1 {
  color: #0f5e4b;
}

body.module-faktura .card {
  border-color: #c5ddd5;
  box-shadow: 0 14px 34px rgba(22, 88, 72, 0.1);
}

body.module-faktura .button {
  background: linear-gradient(135deg, #0f8b6d, #0b6f5b);
}

body.module-faktura .button:hover {
  box-shadow: 0 12px 26px rgba(10, 112, 90, 0.36);
}

body.module-faktura .button.secondary {
  background: #fff4ea;
  color: #9b531a;
  border-color: #e9cfb8;
}

body.module-faktura .nav-card {
  border-color: #c9dfd7;
  background: linear-gradient(180deg, #ffffff 0%, #f0faf6 100%);
}

body.module-faktura .nav-card strong {
  color: #0f5f4c;
}

body.module-faktura .input:focus,
body.module-faktura textarea.input:focus,
body.module-faktura select.input:focus {
  border-color: #11a886;
  box-shadow: 0 0 0 3px rgba(34, 169, 136, 0.2);
}

body.module-faktura .table th {
  background: #eaf6f1;
}

body.module-faktura .card h2,
body.module-faktura .card h3 {
  margin-top: 0;
  color: #0f5e4b;
}

body.module-faktura .label {
  color: #2f6053;
  font-size: 13px;
  letter-spacing: 0.01em;
}

body.module-faktura .input,
body.module-faktura select.input,
body.module-faktura textarea.input {
  min-height: 42px;
  background: #ffffff;
  border-color: #c0d8cf;
}

body.module-faktura .form-row {
  align-items: start;
}

body.module-faktura .table tbody tr:nth-child(even) {
  background: #f8fcfa;
}

body.module-faktura .table tbody tr:hover {
  background: #edf8f3;
}

.faktura-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.faktura-kpi {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 14px;
}

.faktura-kpi .label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.faktura-kpi .value {
  margin: 6px 0 0;
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

.workspace-header {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(245, 249, 255, 0.92)),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 16rem);
  box-shadow: 0 20px 52px rgba(15, 23, 42, 0.1);
}

.workspace-header__row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.workspace-header__copy {
  min-width: 0;
}

.workspace-header__eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.workspace-header__title {
  margin: 0;
  font-family: "Source Serif 4", serif;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.05;
  color: var(--ink);
}

.workspace-header__description {
  margin: 10px 0 0;
  max-width: 68ch;
  color: var(--muted);
  line-height: 1.55;
}

.workspace-header__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.workspace-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace-tab {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.workspace-tab:hover {
  transform: translateY(-1px);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

.workspace-tab.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.16);
}

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

.settings-overview-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 252, 0.94));
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.08);
}

.settings-overview-card__kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.settings-overview-card__title {
  margin: 0;
  font-size: 20px;
  color: var(--ink);
}

.settings-overview-card__text {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.settings-overview-card__meta {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.settings-overview-card__meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  font-size: 14px;
}

.settings-overview-card__meta div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.settings-overview-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.settings-overview-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.65;
}

.settings-inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.workspace-anchor-card {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.workspace-anchor-card__title {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.workspace-anchor-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace-anchor-menu__item {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.workspace-anchor-menu__item:hover {
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.layout-auth {
  grid-template-columns: 1fr;
}

.auth-page .layout-auth .page {
  min-height: 100vh;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-page .layout-auth .app-footer {
  display: none;
}

.sidebar {
  background: #0c2f55;
  color: #e6edf6;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 900;
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  color: var(--accent);
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  font-size: 0;
}

.mobile-toggle::before {
  content: "☰";
  font-size: 20px;
  line-height: 1;
  margin: 0 auto;
}

.sidebar h2 {
  font-family: "Source Serif 4", serif;
  font-size: 20px;
  margin: 0 0 14px;
  color: #ffffff;
}

.sidebar-user {
  font-size: 14px;
  color: rgba(230, 237, 246, 0.85);
  margin-bottom: 14px;
}

.sidebar-mode-panel {
  margin: 0 0 14px;
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-mode-panel__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(230, 237, 246, 0.55);
}

.sidebar-mode-panel__value {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.96);
}

.sidebar-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.sidebar a.sidebar-mode-chip,
.sidebar a.sidebar-utility-link {
  margin-bottom: 0;
}

.sidebar-mode-chip {
  text-align: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 47, 85, 0.28);
  font-size: 12px;
  font-weight: 700;
}

.sidebar-mode-chip.is-active {
  background: rgba(255, 255, 255, 0.92);
  color: #0c2f55;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.sidebar-utility-link {
  margin-top: 7px;
  padding-left: 0;
  padding-right: 0;
  min-height: 28px;
  font-size: 12px;
  color: rgba(230, 237, 246, 0.78);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sidebar details {
  margin-bottom: 10px;
}

.sidebar summary {
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(230, 237, 246, 0.6);
  margin-bottom: 6px;
}

.sidebar summary::-webkit-details-marker {
  display: none;
}

.sidebar .submenu {
  margin-top: 6px;
}

.sidebar a {
  display: block;
  color: #e6edf6;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  font-weight: 600;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar a.active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
}

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 24px 24px 64px;
  overflow-x: hidden;
}

.hero {
  background: linear-gradient(120deg, #ffffff 0%, #f0f4fb 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.hero h1 {
  font-family: "Source Serif 4", serif;
  font-size: 36px;
  margin: 0 0 8px;
}

.hero p {
  color: var(--muted);
  margin: 0 0 16px;
}

.nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.nav-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.nav-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.nav-card span {
  color: var(--muted);
  font-size: 14px;
}

.attachment-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--accent);
  border: 1px solid var(--border);
}

.attachment-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.attachment-none {
  color: var(--muted);
}

.attachment-thumb-btn {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.attachment-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}

.attachment-file {
  font-size: 12px;
  color: inherit;
  text-decoration: underline;
}

.uva-hero {
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #f8fafc, #ffffff);
}

.uva-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}

.uva-header__info {
  min-width: 220px;
  font-size: 14px;
  color: var(--text);
}

.uva-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.uva-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.uva-top-card {
  min-width: 0;
}

.uva-card {
  text-align: left;
}

.uva-card__label {
  font-size: 13px;
  color: var(--muted);
}

.uva-card__value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
}

.uva-card__meta {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

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

  .uva-top-grid {
    grid-template-columns: 1fr;
  }

  .uva-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media print {
  .mobile-toggle,
  .sidebar,
  .sidebar-backdrop,
  .app-footer,
  .uva-header,
  form.form,
  .muted {
    display: none !important;
  }

  .page {
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(12, 59, 111, 0.2);
}

.button.secondary {
  background: var(--surface-alt);
  color: var(--accent);
  border: 1px solid var(--border);
}

.button.danger {
  background: #b42318;
  color: #fff;
}

.button.danger:hover {
  box-shadow: 0 10px 24px rgba(180, 35, 24, 0.3);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  overflow-wrap: anywhere;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.metric {
  font-size: 28px;
  margin: 8px 0 0;
  font-weight: 700;
}

.list {
  padding-left: 16px;
}

.form {
  display: grid;
  gap: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-row > div,
.form-row > label,
.form-row > section,
.form-row > article {
  min-width: 0;
}

.form-row > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.form-note,
.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.form-section {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--border) 88%, white 12%);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--surface-alt) 52%, white 48%) 100%);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.form-section__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.form-section__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.form-section__text {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.choice-stack {
  display: grid;
  gap: 10px;
}

.choice-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--border) 92%, white 8%);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-alt) 70%, white 30%);
  line-height: 1.45;
}

.choice-card input[type="checkbox"],
.choice-card input[type="radio"] {
  flex: 0 0 auto;
  margin-top: 2px;
}

.choice-card span {
  min-width: 0;
}

.downloads-form .downloads-search {
  flex: 2 1 320px;
}

.downloads-form .downloads-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
}

.downloads-form .downloads-actions .button {
  flex: 0 0 auto;
}

.export-form .field {
  min-width: 180px;
}

.export-form .export-search {
  flex: 2 1 320px;
}

.export-form .export-actions {
  flex: 3 1 560px;
}

.export-form .export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.button.compact {
  padding: 8px 12px;
  font-size: 14px;
}

.label {
  font-weight: 600;
  display: inline-block;
  margin: 0;
  line-height: 1.35;
}

.input,
select.input,
textarea.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-alt) 100%);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea.input {
  min-height: 108px;
  resize: vertical;
}

select.input {
  padding-right: 42px;
}

.input:required:invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.15);
}

.input:focus,
select.input:focus,
textarea.input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 70%, white 30%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent 84%);
  background: #ffffff;
}

.error {
  color: var(--danger);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll-lines {
  border: 1px solid var(--border);
  border-radius: 12px;
}

.table-scroll-lines .table-lines {
  min-width: 980px;
  border-radius: 0;
}

.table-lines .input {
  min-width: 90px;
}

.table-lines .line-name,
.table-lines .line-description {
  min-width: 180px;
}

.table-lines .remove-line {
  min-width: 42px;
  width: auto;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.table tr.has-continuation td {
  border-bottom: 0;
}

.help-index {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.help-shot {
  margin: 14px 0 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  overflow: hidden;
}

.help-shot img {
  display: block;
  width: 100%;
  height: auto;
}

.help-shot figcaption {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.table tr.is-continuation td {
  padding-top: 6px;
}

.tax-summary .extra-tax {
  display: none;
}

.tax-summary.show-all .extra-tax {
  display: block;
}

.table th {
  background: var(--surface-alt);
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, 0.55);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  width: min(900px, 92vw);
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}

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

.modal-content .form {
  gap: 14px;
}

.modal-content .form-row {
  align-items: flex-end;
}

.modal-content .input,
.modal-content textarea.input,
.modal-content select.input {
  background: #fff;
}

body.module-faktura .modal-content {
  border-color: #c9d9ea;
  background: linear-gradient(180deg, #fbfdff 0%, #f6fafe 100%);
}

body.module-faktura .modal-header {
  position: sticky;
  top: -20px;
  z-index: 2;
  margin: -20px -20px 12px -20px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #d7e5f4;
  background: linear-gradient(180deg, #ffffff 0%, #f3f8fd 100%);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.template-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.template-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  cursor: pointer;
}

.template-item__title {
  font-weight: 700;
  font-size: 14px;
}

.template-item__details,
.template-item__lines {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.template-item__lines {
  color: var(--text);
  opacity: 0.9;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--accent);
  cursor: pointer;
}

.icon-button:hover {
  background: #ffffff;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.table tr:last-child td {
  border-bottom: none;
}

@media (max-width: 980px) {
  body.sidebar-open {
    overflow: hidden;
    touch-action: none;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 0 auto 0;
    height: 100%;
    width: min(320px, 86vw);
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    box-shadow: 20px 0 60px rgba(8, 12, 20, 0.2);
    z-index: 1000;
    padding: 20px 16px 24px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: inline-flex;
  }

  .page {
    width: 100%;
    padding: 64px max(14px, env(safe-area-inset-left)) 56px max(14px, env(safe-area-inset-right));
  }

  .sidebar-logo {
    max-width: 140px;
    margin-bottom: 10px;
  }

  .sidebar h2 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .sidebar-user {
    font-size: 13px;
    margin-bottom: 12px;
  }

  .sidebar details {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sidebar summary {
    font-size: 11px;
    letter-spacing: 0.1em;
    color: rgba(230, 237, 246, 0.7);
  }

  .sidebar a {
    padding: 12px 12px;
    border-radius: 12px;
    margin-bottom: 8px;
  }

  .sidebar .submenu {
    margin-top: 8px;
  }

  .sidebar .submenu a {
    padding-left: 18px;
  }

  .sidebar-menu {
    gap: 8px;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .form-row > div,
  .field {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 60px 14px 48px;
  }

  .card {
    padding: 14px;
    margin-bottom: 12px;
  }

  .hero {
    padding: 16px;
    margin-bottom: 16px;
  }

  .form {
    gap: 8px;
  }

  .field {
    gap: 2px;
  }

  .input,
  select.input,
  textarea.input {
    padding: 8px 10px;
    font-size: 14px;
  }

  .label {
    font-size: 13px;
  }

  .button {
    padding: 10px 12px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .form-row > div {
    width: 100%;
  }

  .downloads-form .downloads-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: stretch;
  }

  .export-form .export-buttons {
    flex-direction: column;
    width: 100%;
    align-items: stretch;
  }

  .downloads-form .downloads-actions .button,
  .export-form .export-buttons .button,
  .export-form .export-buttons a.button {
    width: 100%;
  }

  .button {
    justify-content: center;
  }

  .form .button,
  .customers-actions .button,
  .auth-card .button {
    width: 100%;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .table th,
  .table td {
    padding: 10px;
    font-size: 13px;
  }

  .table .button,
  .table .icon-button {
    width: auto;
    min-width: 0;
  }

  .table .button {
    padding: 8px 10px;
    font-size: 13px;
  }

  .modal-content {
    width: 96vw;
    padding: 16px;
    max-height: 90vh;
  }

  .modal-header {
    flex-direction: column;
    align-items: stretch;
  }

  .hero {
    padding: 18px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .metric {
    font-size: 24px;
  }

  .sidebar h2 {
    font-size: 18px;
  }

  .sidebar a {
    padding: 9px 10px;
  }

  .auth-card {
    padding: 20px;
  }
}

@media (max-width: 420px) {
  .page {
    padding: 56px 12px 42px;
  }

  .hero h1 {
    font-size: 24px;
  }

  .button {
    font-size: 14px;
  }

  .input,
  select.input,
  textarea.input {
    font-size: 13px;
  }

  .table th,
  .table td {
    padding: 8px;
    font-size: 12px;
  }

  .modal-content {
    padding: 14px;
  }
}

.logout-link {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-weight: 700;
}

.logout-link:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-spacer {
  flex: 1;
}

.auth-wrap {
  width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card .hero {
  box-shadow: none;
  border: none;
  padding: 0;
  background: transparent;
}

.auth-card .hero h1 {
  font-size: 28px;
}

.brand-logo {
  display: block;
  max-width: 180px;
  width: 100%;
  height: auto;
  margin-bottom: 16px;
}

.sidebar-logo {
  max-width: 160px;
  margin-bottom: 12px;
}

.app-footer {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .page {
    padding: 16px;
  }

  .card,
  .hero {
    padding: 16px;
  }

  .uva-grid {
    grid-template-columns: 1fr;
  }

  .form {
    display: block;
  }

  .form .input,
  .form .select,
  .form .textarea,
  .form .button {
    width: 100%;
  }

  .form .button {
    margin-top: 8px;
  }

  .table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table th,
  .table td {
    white-space: nowrap;
  }

  .sidebar {
    width: min(320px, 86vw);
  }

  .main {
    margin-left: 0;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }

  .hero {
    padding: 16px;
  }

  .hero h1 {
    font-size: 22px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form {
    gap: 10px;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .form-row > div {
    flex: 1 1 100%;
  }

  .input,
  select.input,
  textarea.input {
    padding: 8px 10px;
    font-size: 14px;
  }

  .button {
    width: 100%;
  }

  .table th,
  .table td {
    padding: 8px;
  }

  .table {
    display: block;
    background: transparent;
    border: none;
  }

  .table thead {
    display: none;
  }

  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 10px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
  }

  .table tr.has-continuation {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
  }

  .table tr.is-continuation {
    border-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
  }

  .table td {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
  }

  .table td:last-child {
    border-bottom: none;
  }

  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    min-width: 42%;
    flex: 0 0 42%;
    padding-right: 8px;
  }

  .table td[data-label=""],
  .table td[data-label=" "] {
    justify-content: flex-end;
  }

  .table td[data-label=""]::before,
  .table td[data-label=" "]::before {
    display: none;
  }

  .table td[data-label="Aktion"],
  .table td[data-label="Aktionen"] {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .table td[data-label="Aktion"]::before,
  .table td[data-label="Aktionen"]::before {
    min-width: 0;
    flex: 0 0 auto;
    padding-right: 0;
  }

  .table td[data-label="Aktion"] .button,
  .table td[data-label="Aktionen"] .button,
  .table td[data-label="Aktion"] a.button,
  .table td[data-label="Aktionen"] a.button {
    width: 100%;
  }

  .table td[data-label="Aktion"] form,
  .table td[data-label="Aktionen"] form {
    width: 100%;
    margin: 0;
  }

  .table tfoot {
    display: block;
    margin-top: 8px;
  }

  .table tfoot tr {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    background: transparent;
    border: 0;
    padding: 0;
    box-shadow: none;
  }

  .table tfoot td {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .table tfoot td::before {
    order: 2;
    min-width: 0;
    font-size: 12px;
  }

  .table-scroll-lines {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    padding-bottom: 6px;
  }

  .table-scroll-lines .table.table-lines {
    display: table;
    width: max-content;
    min-width: 960px;
    border: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
  }

  .table-scroll-lines .table.table-lines thead {
    display: table-header-group;
  }

  .table-scroll-lines .table.table-lines tbody {
    display: table-row-group;
  }

  .table-scroll-lines .table.table-lines tr {
    display: table-row;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
  }

  .table-scroll-lines .table.table-lines td,
  .table-scroll-lines .table.table-lines th {
    display: table-cell;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }

  .table-scroll-lines .table.table-lines td::before {
    display: none;
    content: none;
  }

  .table-scroll-lines .table.table-lines td:last-child {
    border-bottom: 1px solid var(--border);
  }

  .table-scroll-lines .table.table-lines .input {
    width: 100%;
    min-width: 88px;
  }

  .table-scroll-lines .table.table-lines .line-name,
  .table-scroll-lines .table.table-lines .line-description {
    min-width: 160px;
  }

  .table-scroll-lines .table.table-lines .remove-line {
    width: auto;
    min-width: 40px;
  }

  .modal-content {
    width: 94vw;
    max-height: 90vh;
    padding: 14px;
  }

  .modal-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .template-list {
    grid-template-columns: 1fr;
  }

  .workspace-header {
    padding: 16px;
    border-radius: 20px;
  }

  .workspace-header__row {
    flex-direction: column;
  }

  .workspace-header__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .workspace-tabs,
  .workspace-anchor-menu {
    gap: 8px;
  }

  .workspace-tab,
  .workspace-anchor-menu__item {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  .settings-overview-grid,
  .sidebar-mode-switch {
    grid-template-columns: 1fr;
  }
}
