:root {
  --brand-900: #5f2023;
  --brand-800: #74282b;
  --brand-700: #8f3034;
  --brand-600: #a4373a;
  --brand-500: #c65357;
  --brand-100: #f5dddd;
  --brand-050: #fbf1f1;
  --ink-900: #25282b;
  --ink-700: #4e555b;
  --ink-500: #777f86;
  --line: #e2e5e8;
  --surface: #ffffff;
  --canvas: #f4f5f6;
  --success: #257942;
  --success-bg: #e8f5ec;
  --warning: #9a5a00;
  --warning-bg: #fff3dc;
  --danger: #a2262c;
  --danger-bg: #fdecee;
  --info: #275d88;
  --info-bg: #eaf3fb;
  --shadow-sm: 0 2px 8px rgba(31, 37, 41, .08);
  --shadow-md: 0 18px 50px rgba(59, 24, 26, .16);
  --radius: 14px;
  --radius-sm: 9px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink-900); }
body { min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(330px, 46%) 1fr;
  background: radial-gradient(circle at 80% 20%, #fff 0, #f8efef 42%, #f1e5e5 100%);
}
.login-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(38px, 7vw, 92px);
  color: #fff;
  background: linear-gradient(145deg, var(--brand-900), var(--brand-700));
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-hero::before, .login-hero::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
}
.login-hero::before { width: 480px; height: 480px; right: -240px; top: -130px; }
.login-hero::after { width: 650px; height: 650px; right: -330px; bottom: -350px; }
.brand-mark {
  width: 62px; height: 62px; border-radius: 18px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.2);
  font-weight: 800; letter-spacing: .08em; font-size: 20px; margin-bottom: 28px;
}
.login-hero h1 { font-size: clamp(38px, 5vw, 66px); line-height: .98; margin: 0 0 18px; letter-spacing: -.045em; }
.login-hero p { font-size: 18px; line-height: 1.6; max-width: 560px; color: rgba(255,255,255,.82); margin: 0 0 36px; }
.hero-points { display: grid; gap: 16px; max-width: 540px; }
.hero-point { display: grid; grid-template-columns: 34px 1fr; gap: 14px; align-items: start; color: rgba(255,255,255,.88); }
.hero-point b { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.14); }
.hero-point span { line-height: 1.45; }
.login-panel { display: grid; place-items: center; padding: 34px; }
.login-card { width: min(440px, 100%); background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border: 1px solid rgba(116,40,43,.1); border-radius: 24px; box-shadow: var(--shadow-md); padding: 38px; }
.login-card h2 { margin: 0 0 8px; font-size: 28px; }
.login-card .lead { margin: 0 0 28px; color: var(--ink-700); line-height: 1.5; }

.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-700); }
.input, .select {
  width: 100%; border: 1px solid #cfd4d8; border-radius: 10px; background: #fff;
  padding: 12px 13px; color: var(--ink-900); outline: none; transition: .16s ease;
}
.input:focus, .select:focus { border-color: var(--brand-600); box-shadow: 0 0 0 4px rgba(164,55,58,.12); }
.input[disabled] { background: #f2f3f4; }
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: .16s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .6; transform: none; }
.btn-primary { color: #fff; background: var(--brand-600); box-shadow: 0 7px 18px rgba(164,55,58,.22); }
.btn-primary:hover { background: var(--brand-700); }
.btn-secondary { color: var(--brand-800); background: var(--brand-050); border: 1px solid #efd0d1; }
.btn-ghost { color: var(--ink-700); background: transparent; border: 1px solid var(--line); }
.btn-danger { color: var(--danger); background: var(--danger-bg); border: 1px solid #f3c6ca; }
.btn-wide { width: 100%; min-height: 46px; }
.form-error { min-height: 20px; color: var(--danger); font-size: 13px; margin: 8px 0 12px; }
.login-foot { color: var(--ink-500); font-size: 12px; text-align: center; margin: 20px 0 0; line-height: 1.5; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }
.sidebar { background: linear-gradient(180deg, var(--brand-900), #49181b); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 24px; }
.sidebar-brand .brand-mark { margin: 0; width: 44px; height: 44px; border-radius: 12px; font-size: 14px; flex: 0 0 auto; }
.sidebar-brand strong { display: block; font-size: 17px; }
.sidebar-brand small { color: rgba(255,255,255,.65); }
.nav-section { margin: 10px 8px 7px; color: rgba(255,255,255,.48); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.nav-button { width: 100%; border: 0; background: transparent; color: rgba(255,255,255,.78); border-radius: 10px; padding: 11px 12px; margin: 2px 0; display: flex; align-items: center; gap: 11px; text-align: left; font-weight: 650; }
.nav-button:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-button.active { color: #fff; background: rgba(255,255,255,.15); box-shadow: inset 3px 0 0 #e49ca0; }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }
.sidebar-spacer { flex: 1; }
.sidebar-version { padding: 18px 10px 2px; color: rgba(255,255,255,.45); font-size: 11px; }

.main-area { min-width: 0; }
.topbar { height: 72px; padding: 0 28px; background: rgba(255,255,255,.93); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
.topbar-title { display: grid; gap: 2px; }
.topbar-title strong { font-size: 18px; }
.topbar-title small { color: var(--ink-500); }
.user-menu { display: flex; gap: 12px; align-items: center; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-800); font-weight: 800; }
.user-meta { line-height: 1.2; }
.user-meta strong { display: block; font-size: 13px; }
.user-meta small { color: var(--ink-500); font-size: 11px; }
.content { padding: 28px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 6px; font-size: 29px; letter-spacing: -.025em; }
.page-head p { margin: 0; color: var(--ink-700); line-height: 1.5; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.metric-card { position: relative; overflow: hidden; min-height: 132px; }
.metric-card::after { content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%; background: var(--brand-050); right: -28px; top: -28px; }
.metric-label { color: var(--ink-700); font-size: 13px; font-weight: 700; position: relative; z-index: 1; }
.metric-value { font-size: 32px; font-weight: 820; margin: 12px 0 2px; letter-spacing: -.04em; position: relative; z-index: 1; }
.metric-foot { color: var(--ink-500); font-size: 12px; position: relative; z-index: 1; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title p { margin: 3px 0 0; color: var(--ink-500); font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-neutral { color: var(--ink-700); background: #eef0f2; }
.module-card { display: flex; gap: 14px; align-items: flex-start; }
.module-icon { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; background: var(--brand-050); color: var(--brand-800); font-size: 20px; }
.module-card h3 { margin: 0 0 5px; font-size: 15px; }
.module-card p { margin: 0; color: var(--ink-500); font-size: 12px; line-height: 1.5; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 760px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); background: #f8f9fa; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; word-break: break-all; }
.muted { color: var(--ink-500); }
.empty-state { padding: 42px 22px; text-align: center; color: var(--ink-500); }
.empty-state strong { display: block; color: var(--ink-700); font-size: 16px; margin-bottom: 6px; }

.upload-zone { border: 2px dashed #d6b4b6; border-radius: 14px; padding: 34px 22px; text-align: center; background: var(--brand-050); transition: .16s ease; }
.upload-zone.drag { border-color: var(--brand-600); background: #f8e5e6; }
.upload-zone input { display: none; }
.upload-zone h3 { margin: 10px 0 7px; }
.upload-zone p { margin: 0 0 16px; color: var(--ink-700); font-size: 13px; }
.upload-icon { font-size: 34px; }
.progress { height: 9px; background: #eceff1; border-radius: 999px; overflow: hidden; margin-top: 14px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--brand-600); transition: width .2s; }
.notice { border-left: 4px solid var(--info); background: var(--info-bg); color: #25465f; border-radius: 8px; padding: 13px 15px; font-size: 13px; line-height: 1.5; }
.notice.warning { border-color: var(--warning); background: var(--warning-bg); color: #6d440b; }
.notice.danger { border-color: var(--danger); background: var(--danger-bg); color: #7b1f24; }
.analysis-panel { margin-top: 18px; }
.stat-strip { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stat-strip > div { padding: 15px; background: #fff; border-right: 1px solid var(--line); }
.stat-strip > div:last-child { border-right: 0; }
.stat-strip strong { display: block; font-size: 21px; color: var(--brand-800); }
.stat-strip span { color: var(--ink-500); font-size: 11px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .input, .toolbar .select { width: auto; min-width: 220px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-small { padding: 7px 10px; border-radius: 8px; font-size: 12px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(21,24,26,.54); display: grid; place-items: center; padding: 20px; }
.modal { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 18px; box-shadow: var(--shadow-md); padding: 24px; }
.modal h2 { margin: 0 0 7px; }
.modal p { margin: 0 0 20px; color: var(--ink-700); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.toast-root { position: fixed; top: 18px; right: 18px; z-index: 200; display: grid; gap: 10px; }
.toast { min-width: 290px; max-width: 440px; padding: 13px 15px; border-radius: 11px; color: #fff; box-shadow: var(--shadow-md); animation: toast-in .18s ease; }
.toast.success { background: #266f40; }
.toast.error { background: #92272d; }
.toast.info { background: #385f7e; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }

.mobile-menu { display: none; }
.loading { min-height: 180px; display: grid; place-items: center; color: var(--ink-500); }
.spinner { width: 24px; height: 24px; border: 3px solid #ead8d9; border-top-color: var(--brand-600); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat-strip > div { border-bottom: 1px solid var(--line); }
}
@media (max-width: 850px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { min-height: 40vh; padding: 38px 28px; }
  .hero-points { display: none; }
  .login-panel { padding: 24px 16px 40px; margin-top: -28px; z-index: 2; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; transform: translateX(-100%); transition: transform .2s; z-index: 80; }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 14px; }
  .user-meta { display: none; }
}
@media (max-width: 620px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .stat-strip { grid-template-columns: 1fr; }
  .stat-strip > div { border-right: 0; }
  .login-card { padding: 27px 22px; }
}

.spacer-14 { height: 14px; }
.spacer-16 { height: 16px; }
.spacer-18 { height: 18px; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.text-small { font-size: 12px; }
.text-danger { color: var(--danger); margin-top: 5px; }
.hidden { display: none !important; }

/* Dane podstawowe 0.3.0 */
.card-button { appearance: none; border: 1px solid var(--line); text-align: left; font: inherit; cursor: pointer; color: inherit; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.card-button:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #d7b3b5; }
.master-toolbar { justify-content: space-between; }
.master-toolbar .input { flex: 1 1 360px; }
.toolbar-count { color: var(--ink-500); font-size: 12px; font-weight: 700; margin-left: auto; }
.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.field-span-2 { grid-column: 1 / -1; }
.textarea { width: 100%; min-height: 96px; resize: vertical; border: 1px solid #cfd5d9; border-radius: 9px; padding: 10px 12px; font: inherit; color: var(--ink-900); background: #fff; }
.textarea:focus { outline: 3px solid rgba(164,55,58,.12); border-color: var(--brand-600); }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.checkbox-field { display: inline-flex; align-items: center; gap: 9px; min-height: 36px; font-size: 13px; font-weight: 700; color: var(--ink-700); }
.checkbox-field input { width: 17px; height: 17px; accent-color: var(--brand-600); }
.link-button { appearance: none; border: 0; background: transparent; padding: 3px 0; color: var(--brand-700); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }
.empty-state.compact { padding: 20px 12px; }
.compact-table { min-width: 540px; }
.modal-wide { width: min(780px, 100%); }
.modal-mapping { width: min(1180px, 100%); }
.split-actions { justify-content: space-between; align-items: center; }
.dictionary-layout { display: grid; grid-template-columns: 250px minmax(0,1fr); min-height: 560px; }
.dictionary-nav { border-right: 1px solid var(--line); padding-right: 16px; display: flex; flex-direction: column; gap: 5px; }
.dictionary-nav-button { appearance: none; border: 0; background: transparent; color: var(--ink-700); padding: 10px 12px; border-radius: 9px; text-align: left; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.dictionary-nav-button:hover { background: #f4f5f6; }
.dictionary-nav-button.active { color: var(--brand-800); background: var(--brand-050); }
.dictionary-nav-divider { margin: 15px 10px 6px; color: var(--ink-500); font-size: 10px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.dictionary-content { padding-left: 22px; min-width: 0; }
.mapping-grid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; }
.mapping-table { min-width: 1020px; }
.mapping-table th, .mapping-table td { padding: 8px; vertical-align: middle; }
.input-compact { min-width: 130px; padding: 7px 8px; font-size: 12px; }
.compact-stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
.mini-metrics { gap: 9px; }
.mini-metrics > div { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fafbfb; }
.mini-metrics strong { display: block; color: var(--brand-800); font-size: 20px; }
.mini-metrics span { color: var(--ink-500); font-size: 11px; }

@media (max-width: 900px) {
  .dictionary-layout { grid-template-columns: 1fr; }
  .dictionary-nav { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 14px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dictionary-nav-divider { grid-column: 1 / -1; }
  .dictionary-content { padding: 18px 0 0; }
}
@media (max-width: 620px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .dictionary-nav { grid-template-columns: 1fr; }
  .split-actions { align-items: stretch; flex-direction: column-reverse; }
  .split-actions > div { display: flex; gap: 8px; justify-content: flex-end; }
}

/* Rejestry biznesowe 0.7.0 */
.module-card-button {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.module-card-button:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #d7b3b5; }
.business-amount { color: var(--brand-800); font-size: 18px; }
.business-metrics .metric-card { min-height: 132px; }
.metric-money { font-size: 25px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.search-box { flex: 1 1 340px; }
.search-box .input { width: 100%; min-width: 240px; }
.filter-select { min-width: 210px; }
.modal-business-form { width: min(980px, 100%); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.detail-head h2 { margin-bottom: 4px; }
.detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.detail-grid > div { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfb; }
.detail-grid span { display: block; margin-bottom: 4px; color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.detail-grid strong { display: block; color: var(--ink-900); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.detail-text { margin-top: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.detail-text > span { display: block; margin-bottom: 6px; color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.detail-text p { margin: 0; color: var(--ink-800); white-space: pre-wrap; overflow-wrap: anywhere; }
.subsection { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.subsection .section-title { margin-bottom: 12px; }
.attachment-grid { display: grid; gap: 8px; }
.attachment-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfb; }
.attachment-card > div:first-child { min-width: 0; }
.attachment-card strong { display: block; overflow-wrap: anywhere; }
.attachment-card span { display: block; margin-top: 3px; color: var(--ink-500); font-size: 11px; }
.checkbox-wrap { display: flex; align-items: end; padding-bottom: 8px; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .detail-head { flex-direction: column; }
  .detail-actions { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .detail-grid { grid-template-columns: 1fr; }
  .attachment-card { align-items: flex-start; flex-direction: column; }
  .modal-business-form { padding: 18px; }
}
