@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --background: #f4f4f5;
  --foreground: #09090b;
  --card: #ffffff;
  --border: #e4e4e7;
  --border-subtle: #f4f4f5;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --muted: #71717a;
  --sidebar-w: 248px;
  --sidebar-collapsed: 68px;
  --header-h: 60px;
  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius: 8px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.18);
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #18181b;
  --border: #27272a;
  --border-subtle: #1f1f23;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: #172554;
  --muted: #a1a1aa;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ─── App shell ─── */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed; left: 0; top: 0; z-index: 40;
  width: var(--sidebar-w); height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width var(--transition);
  box-shadow: var(--shadow-xs);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-head {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--foreground); text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--foreground); }

.brand-icon {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin-bottom: 3px;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  color: var(--muted); text-decoration: none;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  border: 1px solid transparent;
}
.nav-link:hover {
  background: var(--border-subtle);
  color: var(--foreground);
  text-decoration: none;
}
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.12);
  font-weight: 600;
}
.dark .nav-link.active { border-color: rgba(59, 130, 246, 0.2); }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-link.active svg { opacity: 1; }

.sidebar-foot {
  border-top: 1px solid var(--border-subtle);
  padding: 14px 16px; font-size: 11px; color: var(--muted);
  letter-spacing: 0.02em;
}

.main-wrap {
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
  min-height: 100vh;
}
.sidebar.collapsed ~ .main-wrap { margin-left: var(--sidebar-collapsed); }

/* ─── Header ─── */
.header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 72%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.header-search { position: relative; flex: 1; max-width: 400px; }
.header-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.header-search input {
  width: 100%; height: 38px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--foreground);
  font: inherit; font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search input::placeholder { color: #a1a1aa; }
.header-search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: var(--ring);
}

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

.header select {
  height: 38px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--foreground);
  font-size: 13px; font-weight: 500; padding: 0 10px; cursor: pointer;
  transition: border-color var(--transition);
}
.header select:hover { border-color: #d4d4d8; }
.header select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 14px 4px 4px;
  font-size: 13px; font-weight: 500;
  background: var(--card);
  transition: box-shadow var(--transition);
}
.user-chip:hover { box-shadow: var(--shadow-sm); }

.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1d4ed8;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.dark .user-avatar { background: linear-gradient(135deg, #1e3a8a, #1e40af); color: #93c5fd; }

.main {
  padding: 28px 28px 40px;
  max-width: 1600px;
  animation: pageIn 0.35s ease-out;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ─── Page layout ─── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-header-text { flex: 1; min-width: 200px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.page-title {
  font-size: 1.625rem; font-weight: 700;
  letter-spacing: -0.03em; line-height: 1.2;
  margin: 0 0 6px;
}
.page-sub {
  font-size: 14px; color: var(--muted);
  margin: 0; line-height: 1.5;
}
/* legacy: page-sub bez page-header */
.page-title + .page-sub { margin-bottom: 24px; }
.page-header .page-sub { margin-bottom: 0; }

/* ─── Cards ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.card-compact { padding: 16px 20px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .table-wrap { margin: 0; }
.card-flush table.data-table th:first-child,
.card-flush table.data-table td:first-child { padding-left: 20px; }
.card-flush table.data-table th:last-child,
.card-flush table.data-table td:last-child { padding-right: 20px; }
.card-flush .pagination,
.card-flush .table-footer { padding: 0 20px 16px; }

.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--border) 60%, var(--accent));
}

.card-title {
  font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 0 0 10px;
}
.card-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1.2; }

.grid-stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
@media (min-width: 1280px) { .grid-stats-7 { grid-template-columns: repeat(7, 1fr); } }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* Stat colors */
.stat-blue { color: #2563eb; }
.stat-green { color: #16a34a; }
.stat-red { color: #dc2626; }
.stat-orange { color: #ea580c; }
.stat-amber { color: #d97706; }
.stat-purple { color: #9333ea; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--foreground);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition),
    box-shadow var(--transition), transform 0.1s ease;
}
.btn:hover {
  background: var(--border-subtle);
  text-decoration: none;
  color: var(--foreground);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #2563eb; color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25), 0 2px 8px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #1d4ed8; color: #fff;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.35);
}

.btn-outline {
  background: var(--card);
  border-color: var(--border);
  color: var(--foreground);
}
.btn-outline:hover { border-color: #d4d4d8; box-shadow: var(--shadow-sm); }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--border-subtle); }
.btn-danger { color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.btn-danger:hover { background: #fee2e2; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-blue { background: #eff6ff; color: #1d4ed8; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-amber { background: #fffbeb; color: #b45309; }
.badge-green { background: #f0fdf4; color: #15803d; }
.badge-gray { background: #f4f4f5; color: #71717a; }
.badge-gray-light { background: #fafafa; color: #a1a1aa; }
.dark .badge-blue { background: #172554; color: #93c5fd; }
.dark .badge-orange { background: #431407; color: #fdba74; }
.dark .badge-red { background: #450a0a; color: #fca5a5; }
.dark .badge-amber { background: #451a03; color: #fcd34d; }
.dark .badge-green { background: #052e16; color: #86efac; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
table.data-table th {
  text-align: left; padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
  background: color-mix(in srgb, var(--card) 92%, var(--border-subtle));
  position: sticky; top: 0; z-index: 1;
}
table.data-table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
table.data-table tbody tr {
  transition: background var(--transition);
}
table.data-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

.table-link {
  font-weight: 600; color: var(--foreground);
  text-decoration: none;
}
.table-link:hover { color: var(--accent); text-decoration: none; }

.table-footer {
  padding-top: 4px;
  font-size: 12px; color: var(--muted);
}

.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--accent); text-decoration: none; }
.data-table th .sort-link { font-weight: 600; color: var(--muted); }

.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.btn-icon-success { color: #16a34a; }
.btn-icon-success:hover { background: #f0fdf4; color: #15803d; }
.dark .btn-icon-success:hover { background: #052e16; color: #86efac; }

/* ─── Filter bar ─── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.filter-bar input[type="search"],
.filter-bar select {
  height: 38px; min-width: 160px;
  padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--foreground);
  font: inherit; font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-bar input[type="search"] { flex: 1; min-width: 200px; max-width: 320px; }
.filter-bar input:focus, .filter-bar select:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input, .filters select {
  width: auto; min-width: 140px; height: 38px;
  border-radius: 10px;
}

/* ─── Forms ─── */
label.field { display: block; margin-bottom: 18px; font-size: 14px; font-weight: 500; }
label.field span { display: block; margin-bottom: 6px; color: var(--muted); font-weight: 500; font-size: 13px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--foreground);
  font: inherit; font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
textarea { resize: vertical; min-height: 88px; }

/* ─── Auth ─── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37, 99, 235, 0.12), transparent),
    var(--background);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 36px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 28px; }

/* ─── Toasts ─── */
#toast-root {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 14px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); max-width: 380px;
  pointer-events: auto;
  animation: toastIn 0.32s cubic-bezier(0.21, 1.02, 0.73, 1);
  display: flex; align-items: center; gap: 10px;
}
.toast-success {
  background: #f0fdf4; color: #14532d;
  border: 1px solid #bbf7d0;
}
.toast-error {
  background: #fef2f2; color: #7f1d1d;
  border: 1px solid #fecaca;
}
.toast-loading { background: var(--card); border: 1px solid var(--border); }
@keyframes toastIn {
  from { transform: translateX(110%) scale(0.95); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.alert {
  padding: 14px 16px; border-radius: 12px; margin-bottom: 16px;
  font-size: 14px; border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.dark .alert-warning { background: #451a03; color: #fde68a; border-color: #78350f; }

/* ─── Invoice panel ─── */
.panel-overlay {
  position: fixed; inset: 0;
  background: rgba(9, 9, 11, 0.45);
  backdrop-filter: blur(4px);
  z-index: 50; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
.panel-overlay.open { opacity: 1; pointer-events: auto; }

.invoice-panel {
  position: fixed; top: 0; right: 0; z-index: 51;
  width: 100%; max-width: 720px; height: 100vh;
  background: var(--card); border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto; padding: 28px 32px;
}
.invoice-panel.open { transform: none; }
.panel-close {
  position: absolute; top: 18px; right: 18px;
  width: 36px; height: 36px; border: 1px solid var(--border);
  background: var(--card); cursor: pointer; color: var(--muted);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.panel-close:hover { background: var(--border-subtle); color: var(--foreground); }

/* ─── Dropzone ─── */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius-xl);
  padding: 52px 28px; text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  background: color-mix(in srgb, var(--card) 80%, var(--border-subtle));
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--ring);
}

/* ─── Pagination ─── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 13px; font-weight: 500;
  text-decoration: none; border: 1px solid transparent;
  color: var(--foreground); transition: background var(--transition);
}
.pagination a:hover { background: var(--border-subtle); text-decoration: none; }
.pagination .active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* ─── Notifications ─── */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--card);
}
.notif-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  width: 340px; max-height: 400px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.notif-menu.open { display: block; animation: pageIn 0.2s ease-out; }
.notif-item {
  display: block; padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none; color: inherit; font-size: 13px;
  transition: background var(--transition);
}
.notif-item:hover { background: var(--border-subtle); text-decoration: none; }
.notif-item.unread { background: var(--accent-soft); }
.notif-item strong { display: block; font-size: 14px; margin-bottom: 3px; font-weight: 600; }

/* ─── Matches ─── */
.match-pending {
  padding: 18px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--card);
  transition: box-shadow var(--transition);
}
.match-pending:hover { box-shadow: var(--shadow-sm); }
.match-pending-body { flex: 1; }
.match-pending-actions { margin-top: 12px; }
@media (min-width: 900px) {
  .match-pending { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; }
  .match-pending-actions { margin-top: 0; flex-shrink: 0; }
}
.match-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .match-tiles { grid-template-columns: 1fr; } }
.match-tile { padding: 14px; border-radius: var(--radius-lg); font-size: 14px; border: 1px solid var(--border-subtle); }
.match-tile-tx { background: #fafafa; }
.dark .match-tile-tx { background: #18181b; }
.match-tile-inv { background: var(--accent-soft); border-color: rgba(37, 99, 235, 0.1); }
.match-tile-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px; }
.match-tile-value { font-weight: 600; font-size: 15px; }

.recent-matches-list { display: flex; flex-direction: column; gap: 8px; }
.recent-match-item {
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); transition: box-shadow var(--transition);
}
.recent-match-item:hover { box-shadow: var(--shadow-sm); }
.line-clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.vendor-row, .overdue-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 8px;
  transition: box-shadow var(--transition);
}
.vendor-row:hover { box-shadow: var(--shadow-xs); }
.overdue-row { border-color: #fecaca; background: #fef2f2; }
.dark .overdue-row { border-color: #7f1d1d; background: rgba(69, 10, 10, 0.35); }
.vendor-rank {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--border-subtle);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--muted);
}

.settings-ksef-info {
  display: grid; gap: 10px; padding: 16px;
  border-radius: var(--radius-lg); border: 1px solid var(--border-subtle);
  background: var(--border-subtle); font-size: 14px;
}
.settings-dl dt { margin-top: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.settings-dl dd { margin: 0 0 4px; font-weight: 600; }

.chart-box { height: 280px; position: relative; }

/* ─── Utils ─── */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.shrink-0 { flex-shrink: 0; }
.hidden { display: none !important; }

.xml-preview {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  font-size: 12px; font-family: ui-monospace, 'Cascadia Code', monospace;
  max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.dark .xml-preview { background: #0f172a; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 4px; }
.dark ::-webkit-scrollbar-thumb { background: #3f3f46; }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

dl { margin: 0; }
dl dt { color: var(--muted); font-size: 13px; margin-top: 8px; }
dl dd { margin: 0 0 4px; }

/* ─── Przychód ─── */
.revenue-section-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 20px 20px 12px;
}
.revenue-table input.amount-input {
  width: 100%; max-width: 140px; margin-left: auto; display: block;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14px; text-align: right;
}
.revenue-table input.amount-input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.revenue-table td.num { width: 22%; }
.vat-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: rgba(37,99,235,.08); color: var(--accent); font-size: 12px; font-weight: 600;
}
.revenue-notes {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; resize: vertical;
}
.revenue-notes:focus { outline: none; border-color: var(--accent); }
.revenue-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 24px; }
.revenue-actions .btn { display: inline-flex; align-items: center; gap: 8px; }

/* ─── Ręczna faktura ─── */
.manual-invoice-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 16px; align-items: end;
}
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field span { font-size: 13px; color: var(--muted); font-weight: 500; }
.form-field input[type="text"],
.form-field input[type="date"] {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14px;
}
.form-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.manual-invoice-form .amount-input { text-align: right; }
.manual-invoice-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.manual-invoice-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
@media (max-width: 900px) {
  .manual-invoice-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .main { padding: 20px 16px 32px; }
  .header { padding: 0 16px; gap: 8px; }
  .header-search { max-width: 220px; }
  .user-chip span:not(.user-avatar) { display: none; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.collapsed { transform: translateX(-100%); }
  .main-wrap, .sidebar.collapsed ~ .main-wrap { margin-left: 0; }
  .header-search { display: none; }
  .grid-stats-7 { grid-template-columns: repeat(2, 1fr); }
}
