:root {
  color-scheme: light;
  --ink: #111113;
  --ink-soft: #36363b;
  --muted: #5b5b62;
  --line: #e4e7e9;
  --line-strong: #d2d9dc;
  --surface: #ffffff;
  --surface-soft: #fbfcfc;
  --canvas: #f7f8f8;
  --moth-blue: #c8e3eb;
  --accent: #2c5a6b;
  --accent-strong: #244d5c;
  --accent-deep: #193b47;
  --accent-soft: #e6f1f5;
  --aqua: #75b8c8;
  --aqua-soft: #eef7f9;
  --coral: #d76751;
  --accent-ring: rgba(44, 90, 107, 0.24);
  --blue: #2c5a6b;
  --blue-soft: #e6f1f5;
  --amber: #8a5f0c;
  --amber-soft: #fdf3d8;
  --red: #a53d37;
  --red-soft: #fceae8;
  --shadow-card: 0 1px 2px rgba(18, 26, 22, 0.04), 0 10px 30px rgba(18, 26, 22, 0.05);
  --shadow-raised: 0 1px 3px rgba(18, 26, 22, 0.08), 0 18px 50px rgba(18, 26, 22, 0.14);
  font-family: "Avenir Next", "SF Pro Text", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, ui-sans-serif, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #edf6f8 0, var(--canvas) 340px, var(--canvas) 100%);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; color: inherit; }

button, input, select, textarea, summary, .posting-choice {
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    box-shadow 0.16s ease, transform 0.08s ease;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 70px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid rgba(178, 197, 204, 0.56);
  box-shadow: 0 8px 28px rgba(44, 90, 107, 0.08);
}
.topbar > *, .topbar-actions > *, main, #dashboard, .content-section,
.wizard-guide, .summary-band, .intro, .notice { min-width: 0; }
.brand {
  flex: 0 0 auto; display: flex; align-items: center; gap: 11px;
  font-weight: 700; letter-spacing: 0; white-space: nowrap;
}
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: #fff;
  color: var(--ink);
  background: linear-gradient(145deg, #d9eef3, var(--moth-blue));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 5px 14px rgba(44, 90, 107, 0.18);
  font-size: 15px;
}
.topbar-actions {
  min-width: 0; display: flex; align-items: center; justify-content: flex-end;
  gap: 9px; flex-wrap: wrap;
}
.primary-nav {
  display: inline-grid; grid-template-columns: repeat(3, 1fr); padding: 3px;
  border: 1px solid var(--line); border-radius: 8px; background: #f0f3f4;
}
.primary-nav button {
  min-height: 32px; padding: 0 13px; border: 0; border-radius: 8px;
  color: var(--muted); background: transparent; box-shadow: none;
  font-size: 12px; font-weight: 650; white-space: nowrap;
}
.primary-nav button[aria-pressed="true"] {
  color: var(--ink); background: #fff; box-shadow: 0 1px 5px rgba(44, 90, 107, 0.12);
}
.top-issue-button { min-height: 38px; padding-inline: 15px; white-space: nowrap; }
.company-switcher {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.company-switcher select {
  min-height: 38px; max-width: 260px;
  padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: rgba(255, 255, 255, 0.86); color: var(--ink);
}
.icon-command {
  width: 38px; height: 38px; padding: 0;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 21px; line-height: 1;
}
.local-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.local-status span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #3d9a79;
  box-shadow: 0 0 0 3px rgba(61, 154, 121, 0.14);
}
.verified-actor { display: block; padding: 9px 0; font-size: 0.95rem; }

.mode-switch {
  display: inline-grid; grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #f0f3f4;
}
.mode-switch button {
  min-height: 32px; padding: 0 12px;
  border: 0; border-radius: 8px;
  color: var(--muted); background: transparent;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.mode-switch button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.72); }
.mode-switch button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--moth-blue);
  box-shadow: 0 1px 2px rgba(44, 90, 107, 0.12), 0 5px 14px rgba(44, 90, 107, 0.12);
}

.topbar button.secondary {
  color: var(--accent-deep);
  background: rgba(255, 255, 255, 0.76);
  border-color: var(--line-strong);
  box-shadow: none;
}
.topbar button.secondary:hover { color: var(--ink); background: var(--blue-soft); }

/* ---------- Base controls ---------- */

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}
textarea { padding: 10px 12px; }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px;
  margin: 0;
  accent-color: var(--accent);
}
input[type="file"] { padding: 8px 12px; }
input:disabled, select:disabled { background: var(--surface-soft); color: var(--muted); }
input[readonly] { background: var(--surface-soft); }

button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #9fcbd7;
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(180deg, #d9eef3, var(--moth-blue));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 6px rgba(44, 90, 107, 0.16);
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: linear-gradient(180deg, #cfe8ee, #b8dbe5); border-color: #81b7c5; }
button:active { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(44, 90, 107, 0.14); }
button:disabled { opacity: 0.55; cursor: wait; transform: none; }

button.secondary, .secondary {
  color: var(--accent-strong);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 1px 2px rgba(18, 26, 22, 0.05);
}
button.secondary:hover, .secondary:hover {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: rgba(23, 107, 75, 0.35);
}
.small-command { min-height: 38px; padding: 0 12px; font-size: 13.5px; white-space: nowrap; }

summary {
  width: fit-content;
  color: var(--blue);
  cursor: pointer;
  font-weight: 600;
  border-radius: 6px;
}
summary:hover { color: #1e4d73; }
details { margin-top: 13px; }

/* ---------- Layout ---------- */

main { width: 100%; max-width: 1220px; margin: 0 auto; padding: 42px 32px 64px; }

.intro {
  display: flex; justify-content: space-between; align-items: end; gap: 32px;
  margin-bottom: 30px;
}
.eyebrow, .section-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0;
}
h1 { margin: 0; font-size: 40px; font-weight: 720; line-height: 1.08; letter-spacing: 0; }
h2 { margin: 0; font-size: 20px; font-weight: 650; line-height: 1.3; letter-spacing: 0; }
h3 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: 0; }
.intro-copy { margin: 10px 0 0; color: var(--muted); font-size: 16.5px; }

.date-control { min-width: 300px; }
.date-control label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.date-control > label:not(:first-child) { margin-top: 12px; }
.date-control > input { width: 100%; }
.date-control > div { display: flex; gap: 8px; }

#dashboard { display: grid; gap: 16px; }

.notice {
  margin-bottom: 18px;
  padding: 13px 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}
.loading, .empty-state { padding: 18px 0; color: var(--muted); }

/* ---------- Wizard ---------- */

.wizard-guide {
  position: relative;
  overflow: hidden;
  padding: 30px 32px 28px;
  border: 1px solid #c8dfe6;
  border-radius: 8px;
  background: linear-gradient(125deg, #ffffff 0%, #f4f9fa 58%, var(--blue-soft) 100%);
  box-shadow: 0 18px 50px rgba(44, 90, 107, 0.09);
}
.wizard-guide::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--accent), var(--aqua));
}
.wizard-progress-copy { max-width: 680px; }
.wizard-progress-copy .muted { margin: 8px 0 0; }
.wizard-progress-list {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
  margin: 22px 0; padding: 0; list-style: none;
}
.wizard-progress-list li { min-width: 0; height: 7px; border-radius: 999px; background: #d9e4df; }
.wizard-progress-list li.done { background: #94c5d1; }
.wizard-progress-list li.current {
  background: linear-gradient(90deg, var(--accent), var(--aqua));
  box-shadow: 0 0 0 3px rgba(44, 90, 107, 0.12);
}
.wizard-actions { display: flex; justify-content: space-between; gap: 12px; }
.wizard-start-summary {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--line);
}
.wizard-start-item { padding: 16px 18px; background: var(--surface); }
.wizard-start-item span, .wizard-start-item strong { display: block; }
.wizard-start-item span { color: var(--muted); font-size: 13px; }
.wizard-start-item strong { margin-top: 5px; overflow-wrap: anywhere; }
.wizard-result { margin-top: 15px; }

body.wizard-mode [data-wizard-step]:not(.wizard-current) { display: none !important; }
body:not(.ksef-view) #ksef-section { display: none !important; }
body.invoices-view #dashboard > :not(#invoice-section) { display: none !important; }
body.invoices-view #invoice-section { display: block !important; }
body.ksef-view #dashboard > :not(#ksef-section) { display: none !important; }
body.ksef-view #ksef-section { display: block !important; }
body.panel-mode #wizard-guide { display: none; }

/* ---------- Summary band ---------- */

.summary-band {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  color: #fff;
  background: linear-gradient(125deg, #111113 0%, #203d47 58%, #2c5a6b 100%);
  border: 1px solid #171b1d;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.metric {
  min-height: 96px; padding: 18px 22px;
  display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid rgba(255, 255, 255, 0.09);
}
.metric:last-child { border-right: 0; }
.metric span { color: rgba(235, 249, 243, 0.72); font-size: 13px; }
.metric strong { font-size: 26px; font-weight: 650; letter-spacing: 0; }

.metric:first-child strong { color: #c8e3eb; }
.metric:nth-child(3) strong { color: #ffd8a8; }

/* ---------- Sections as cards ---------- */

.content-section {
  width: 100%; overflow: hidden;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(22, 43, 34, 0.055);
}
.content-section.compact { padding: 22px 24px; }
.section-heading {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 16px;
}
.section-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: end; }
.status-pill {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px; font-weight: 650;
  color: var(--muted); background: #eef1ef;
  white-space: nowrap;
}
.status-pill.warning { color: var(--amber); background: var(--amber-soft); }
.status-pill.good { color: var(--accent-strong); background: var(--accent-soft); }
.muted { color: var(--muted); font-size: 14px; }

.two-column {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  padding: 0; border: 0; background: transparent; box-shadow: none;
}

/* ---------- Lists and cards ---------- */

.item-list { display: grid; gap: 10px; }

.ksef-help { max-width: 760px; margin: -4px 0 18px; }
.ksef-summary {
  margin-bottom: 12px; color: var(--ink-soft); font-size: 14px; font-weight: 600;
}
.ksef-invoice-list { display: grid; gap: 10px; }
.ksef-invoice-card {
  min-width: 0; padding: 17px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  border: 1px solid var(--line); border-left: 4px solid var(--aqua);
  border-radius: 8px; background: var(--surface-soft);
}
.ksef-invoice-copy { min-width: 0; }
.ksef-invoice-copy strong, .ksef-invoice-copy span, .ksef-invoice-copy small { display: block; }
.ksef-invoice-copy span { margin-top: 3px; color: var(--ink-soft); }
.ksef-invoice-copy small {
  margin-top: 5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis;
}
.ksef-invoice-amount { text-align: right; white-space: nowrap; }
.ksef-invoice-amount strong, .ksef-invoice-amount span { display: block; }
.ksef-invoice-amount .status-pill { margin-top: 7px; }

.month-payment-list { display: grid; gap: 12px; margin-top: 20px; }
.month-payment-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.month-payment-top { display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.month-payment-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px;
  margin-top: 15px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--line);
}
.month-payment-detail { min-width: 0; padding: 12px 14px; background: var(--surface-soft); }
.month-payment-detail span, .month-payment-detail strong { display: block; }
.month-payment-detail span { color: var(--muted); font-size: 12px; }
.month-payment-detail strong { margin-top: 4px; overflow-wrap: anywhere; }
.month-missing-heading { margin: 26px 0 10px; }
.month-missing-row { align-items: start; }

.task-list {
  display: grid; gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--line);
}
.task-row {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto;
  gap: 14px; align-items: center;
  min-height: 74px; padding: 13px 16px;
  background: var(--surface);
}
.task-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.task-mark.blocked { background: var(--amber); }
.task-mark.overdue { background: var(--red); }
.task-copy { min-width: 0; }
.task-copy strong, .task-copy span { display: block; }
.task-copy span { margin-top: 3px; overflow-wrap: anywhere; }
.task-amount { text-align: right; white-space: nowrap; font-weight: 650; }
.task-action {
  min-height: 36px; padding: 0 12px;
  color: var(--accent-strong); background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: none;
  white-space: nowrap; font-size: 13px;
}
.task-action:hover { color: var(--accent-deep); background: var(--accent-soft); border-color: rgba(23, 107, 75, 0.35); }

.notification-list { display: grid; gap: 9px; }
.notification-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px; align-items: center;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--surface);
}
.notification-row.blocked, .notification-row.today { border-left-color: var(--amber); background: var(--amber-soft); border-color: #f0e2bb; }
.notification-row.overdue { border-left-color: var(--red); background: #fff2f0; border-color: #f2d4d0; }
.notification-copy { min-width: 0; }
.notification-copy strong, .notification-copy span { display: block; }
.notification-copy span { margin-top: 3px; overflow-wrap: anywhere; }

.tax-card {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}
.tax-card-top, .tax-meta { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.tax-meta { margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.amount { font-size: 21px; font-weight: 650; letter-spacing: 0; white-space: nowrap; }
.danger-text { color: var(--red); font-weight: 650; }
.inline-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 8px;
  font-size: 13.5px;
}
.steps { margin-bottom: 0; padding-left: 24px; }

/* ---------- Tables ---------- */

.table-wrap {
  width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid #eef1ef; text-align: left; white-space: nowrap; }
th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0;
}
tbody tr { transition: background-color 0.14s ease; }
tbody tr:hover { background: #f8faf9; }
tbody tr:last-child td { border-bottom: 0; }
.status-cell { color: var(--amber); font-weight: 650; }
.status-cell.paid { color: var(--accent-strong); }
.payment-action, .jdg-action, .posting-action { min-height: 36px; padding: 0 12px; white-space: nowrap; font-size: 13px; }
.jdg-registered { color: var(--accent-strong); font-weight: 650; }
.invoice-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pending-decision {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--amber); background: var(--amber-soft);
  font-size: 12px; font-weight: 650;
  white-space: nowrap;
}

/* ---------- Decision modal (five simple categories) ---------- */

.posting-context { margin: 0 0 4px; font-weight: 650; }
.pending-note {
  margin: 10px 0 0;
  padding: 11px 13px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #f0e2bb;
  border-radius: 8px;
  font-size: 13.5px;
}
.posting-choices { display: grid; gap: 10px; margin: 16px 0; }
.posting-choice {
  display: grid; grid-template-columns: 20px 1fr; gap: 12px; align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.posting-choice:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.posting-choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(23, 107, 75, 0.12);
}
.posting-choice input { margin-top: 3px; }
.posting-choice-content { display: grid; gap: 4px; min-width: 0; }
.posting-choice-title { font-weight: 650; letter-spacing: 0; }
.posting-choice.blocked { cursor: default; border-style: dashed; background: var(--surface-soft); }
.posting-choice.blocked .posting-choice-title { color: var(--muted); }
.posting-choice-flag {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--amber); background: var(--amber-soft);
  font-size: 13px; font-weight: 700;
}
.posting-choice .inline-warning { margin-top: 6px; }
.posting-lines {
  color: var(--muted);
  font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

/* ---------- Review / questions ---------- */

.check-list { display: grid; gap: 9px; }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.count {
  min-width: 34px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-weight: 650;
}
.count.good { color: var(--accent-strong); background: var(--accent-soft); }
.count.warning { color: var(--amber); background: var(--amber-soft); }
.question-list { display: grid; gap: 10px; margin-top: 18px; }
.question-card {
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}
.question-card p { margin: 10px 0 13px; }
.question-heading, .question-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.question-actions { justify-content: flex-start; flex-wrap: wrap; }
.question-actions input { min-width: 180px; flex: 1; }
.question-actions button { min-height: 38px; padding: 0 13px; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }

.close-message { margin: 0 0 12px; padding: 13px 15px; border-radius: 8px; font-weight: 650; }
.good-bg { color: var(--accent-strong); background: var(--accent-soft); }
.warning-bg { color: var(--amber); background: var(--amber-soft); }
.blocker { padding: 12px 0; border-bottom: 1px solid var(--line); }
.blocker:last-child { border-bottom: 0; }
.blocker p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Tax panels ---------- */

.pit-panel {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.pit-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  margin: 14px 0;
  background: var(--line);
  border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden;
}
.pit-value { min-width: 0; padding: 12px 14px; background: var(--surface-soft); }
.pit-value span { display: block; color: var(--muted); font-size: 12px; }
.pit-value strong { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.pit-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.vat-candidate-meta { display: flex; gap: 16px; flex-wrap: wrap; margin: 9px 0; color: var(--muted); font-size: 13px; }

/* ---------- Dialogs ---------- */

dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}
.wide-dialog { width: min(820px, calc(100vw - 32px)); }
dialog::backdrop {
  background: rgba(17, 24, 21, 0.44);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
dialog form { padding: 26px 28px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: end; gap: 10px; margin-top: 22px; }

dialog form > label:not(.check-option),
dialog fieldset > label:not(.check-option) {
  display: block;
  margin: 16px 0 6px;
  color: var(--muted);
  font-size: 13px; font-weight: 600;
}
dialog form > input:not([type="checkbox"]):not([type="radio"]),
dialog form > select,
dialog form > textarea { display: block; width: 100%; }
dialog form > div > label { display: block; margin: 16px 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
dialog form > div > select, dialog form > div > input:not([type="checkbox"]) { width: 100%; }
dialog textarea { min-height: 88px; resize: vertical; }
dialog fieldset { margin: 18px 0 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; }
dialog legend { padding: 0 6px; font-weight: 650; }

.check-option {
  display: flex; align-items: start; gap: 10px;
  margin-top: 14px;
  font-weight: 500;
}
.check-option input { flex: 0 0 auto; margin-top: 3px; }
.confirm-option { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

.profile-summary { margin: 16px 0; border-block: 1px solid var(--line); }
.profile-summary-row { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.profile-summary-row:last-child { border-bottom: 0; }
.profile-summary-row strong { text-align: right; }

.invoice-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.invoice-form-grid label, .invoice-line label { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.invoice-form-grid input, .invoice-form-grid select,
.invoice-line input, .invoice-line select { width: 100%; margin-top: 6px; }
.invoice-lines { display: grid; gap: 12px; margin-bottom: 12px; }
.invoice-line {
  display: grid; grid-template-columns: 2fr repeat(6, minmax(90px, 1fr)) auto;
  gap: 8px; align-items: end;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.invoice-line .icon-command { margin-bottom: 1px; }
.totals-grid { margin-top: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.invoice-reading-status {
  margin: 0 0 16px;
  padding: 12px 14px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid #c4e0d2;
  border-radius: 8px;
}
.invoice-reading-status.manual { color: var(--amber); background: var(--amber-soft); border-color: #ead4a7; }

.sales-invoice-dialog { width: min(760px, calc(100vw - 32px)); }
.sales-invoice-dialog form { min-height: 590px; display: flex; flex-direction: column; }
.invoice-wizard-progress {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px;
  margin: 0 0 18px; padding: 0; list-style: none;
}
.invoice-wizard-progress li {
  height: 5px; border-radius: 3px; background: var(--line);
}
.invoice-wizard-progress li.done { background: var(--aqua); }
.invoice-wizard-progress li.current {
  background: linear-gradient(90deg, var(--accent), var(--aqua));
}
.invoice-wizard-step { flex: 1; min-height: 365px; }
.invoice-wizard-step > h3 { margin-bottom: 5px; font-size: 19px; }
.invoice-wizard-step .muted { margin-top: 0; }
.invoice-wizard-step .invoice-form-grid { margin-top: 18px; }
.invoice-wizard-step .wide-field { grid-column: 1 / -1; }
#sales-settings-exemption-wrap {
  display: grid; gap: 6px; margin-top: 14px;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
#sales-settings-exemption-wrap input { width: 100%; }
.sales-logo-field {
  display: grid; gap: 7px; margin-top: 16px; padding: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft);
  color: var(--text); font-weight: 650;
}
.sales-logo-field input[type="file"] { width: 100%; }
.sales-logo-field .muted { margin: 0; font-size: 12px; font-weight: 450; }
.nip-lookup-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px; align-items: end; margin-top: 18px;
}
.nip-lookup-row label { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.nip-lookup-row input { display: block; width: 100%; margin-top: 6px; }
.sales-invoice-lines { display: grid; gap: 10px; margin: 18px 0 12px; }
.sales-invoice-line {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) 82px 82px minmax(120px, 1fr) 86px 38px;
  gap: 8px; align-items: end; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft);
}
.sales-invoice-line label {
  margin: 0; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 600;
}
.sales-invoice-line input, .sales-invoice-line select {
  width: 100%; margin-top: 5px;
}
.invoice-live-total {
  margin-top: 18px; padding: 14px 16px; text-align: right;
  color: var(--accent-deep); background: var(--accent-soft);
  border: 1px solid #c3dfe7; border-radius: 8px; font-size: 18px; font-weight: 700;
}
.sales-invoice-preview {
  display: grid; gap: 0; margin-top: 18px;
  border-block: 1px solid var(--line);
}
.sales-invoice-preview-row {
  display: flex; justify-content: space-between; gap: 24px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.sales-invoice-preview-row:last-child { border-bottom: 0; }
.sales-invoice-preview-row span { color: var(--muted); }
.sales-invoice-preview-row strong { text-align: right; overflow-wrap: anywhere; }
.invoice-success-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.invoice-wizard-actions { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }
.invoice-success { max-width: 470px; margin: 42px auto 0; text-align: center; }
.invoice-success-mark {
  width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 16px;
  border-radius: 50%; color: #fff; background: var(--accent); font-size: 26px; font-weight: 700;
}
.button-link {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  margin: 14px 0 8px; padding: 0 18px; border-radius: 8px;
  color: var(--ink); background: linear-gradient(180deg, #d9eef3, var(--moth-blue));
  border: 1px solid #9fcbd7; text-decoration: none; font-weight: 650;
}
.button-link:hover { background: linear-gradient(180deg, #cfe8ee, #b8dbe5); }

/* ---------- Technical details and footer ---------- */

.technical-details {
  margin: 4px 0 0;
  padding: 18px 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.technical-details[open] { padding-bottom: 24px; }
pre {
  max-height: 420px;
  overflow: auto;
  padding: 16px;
  color: #e6eeea;
  background: linear-gradient(180deg, #222b27, #1b2320);
  border-radius: 8px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
footer { margin-top: 12px; padding: 4px 8px 0; color: var(--muted); font-size: 13px; }

/* ---------- Sign in ---------- */

.login-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 14% 12%, rgba(109, 196, 221, 0.26), transparent 35%),
    linear-gradient(145deg, #f6fbfc 0%, #edf5f7 48%, #dcecf1 100%);
}
.login-screen[hidden] { display: none; }
.login-panel {
  width: min(430px, 100%); display: grid; gap: 12px;
  padding: 38px; border: 1px solid rgba(37, 91, 109, 0.18); border-radius: 18px;
  background: rgba(255, 255, 255, 0.88); box-shadow: 0 24px 70px rgba(29, 71, 84, 0.18);
  backdrop-filter: blur(24px);
}
.login-brand {
  width: 48px; height: 48px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(145deg, var(--accent), var(--aqua));
  border-radius: 12px; font-size: 24px; font-weight: 750;
}
.login-panel h1 { margin: 0; font-size: 38px; }
.login-panel .muted { margin: 0 0 10px; }
.login-panel label { margin-top: 3px; color: var(--text); font-size: 14px; font-weight: 650; }
.login-panel input { width: 100%; }
.login-panel button { width: 100%; margin-top: 8px; }
.login-error {
  margin: 2px 0 0; padding: 10px 12px; border-radius: 8px;
  color: #8d2020; background: #fdeaea; border: 1px solid #f2c5c5; font-size: 13px;
}

/* ---------- Responsive ---------- */

@media (min-width: 761px) {
  .topbar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    min-height: 100vh;
    padding: 28px 18px 22px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 22px;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid rgba(178, 197, 204, 0.56);
    border-bottom: 0;
  }
  .brand { padding-inline: 6px; font-size: 17px; }
  .brand-mark { width: 38px; height: 38px; }
  .topbar-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
  }
  .primary-nav {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 4px;
  }
  .primary-nav button { width: 100%; min-height: 40px; text-align: left; padding-inline: 14px; }
  .top-issue-button, #company-settings, #configure-company, #confirm-company-profile {
    width: 100%;
    min-height: 42px;
  }
  .company-switcher {
    width: 100%;
    display: grid;
    gap: 6px;
  }
  .company-switcher select { width: 100%; max-width: 100%; min-width: 0; }
  #add-company { align-self: flex-start; }
  .mode-switch { width: 100%; }
  .local-status { margin-top: auto; padding: 10px 4px 0; white-space: normal; }
  main {
    width: calc(100% - 248px);
    max-width: 1500px;
    margin: 0 0 0 248px;
    padding: 48px 42px 70px;
  }
}

@media (max-width: 760px) {
  .topbar { position: static; min-height: 0; padding: 14px 18px; align-items: stretch; flex-direction: column; gap: 12px; }
  .topbar-actions { width: 100%; gap: 8px; flex-wrap: wrap; }
  .primary-nav { flex: 1; }
  .primary-nav button { width: 100%; }
  .top-issue-button { flex: 0 0 auto; }
  .company-switcher { min-width: 0; flex: 1; }
  .company-switcher > span, .local-status { display: none; }
  .company-switcher select { width: 100%; max-width: none; min-width: 0; }
  #configure-company, #confirm-company-profile { flex: 1 0 100%; }
  .mode-switch { width: 100%; }
  main { width: 100%; max-width: 100%; padding: 26px 14px 42px; overflow: hidden; }
  .intro { display: block; }
  h1 { font-size: 32px; }
  .date-control { margin-top: 20px; min-width: 0; }
  .date-control > div { width: 100%; }
  .date-control input { min-width: 0; flex: 1; }
  .content-section, .wizard-guide { width: 100%; max-width: 100%; padding: 20px 18px; border-radius: 8px; }
  .summary-band { grid-template-columns: 1fr 1fr; border-radius: 8px; }
  .metric { min-height: 84px; padding: 15px 18px; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid rgba(255, 255, 255, 0.09); }
  .wizard-start-summary { grid-template-columns: 1fr; }
  .two-column { grid-template-columns: 1fr; }
  .pit-grid { grid-template-columns: 1fr 1fr; }
  .tax-card-top { display: block; }
  .month-payment-top { display: block; }
  .month-payment-grid { grid-template-columns: 1fr; }
  .amount { display: block; margin-top: 10px; }
  .section-actions { justify-content: start; }
  .ksef-invoice-card { align-items: start; flex-direction: column; }
  .ksef-invoice-amount { text-align: left; }
  .task-row { grid-template-columns: 12px minmax(0, 1fr) auto; }
  .task-action { grid-column: 2 / -1; width: fit-content; }
  .invoice-form-grid, .totals-grid { grid-template-columns: 1fr; }
  .invoice-line { grid-template-columns: 1fr 1fr; }
  .sales-invoice-dialog form { min-height: 0; }
  .invoice-wizard-step { min-height: 0; }
  .nip-lookup-row { grid-template-columns: 1fr; }
  .sales-invoice-line { grid-template-columns: 1fr 1fr; }
  .sales-invoice-line label:first-child { grid-column: 1 / -1; }
  .sales-invoice-line .icon-command { align-self: end; }
  .technical-details { padding: 16px 18px; }
  .table-wrap { margin-inline: 0; }
  th, td { padding: 11px 13px; }
}

@media (max-width: 420px) {
  dialog { width: calc(100vw - 20px); }
  dialog form { padding: 20px 18px; }
  .profile-summary-row { display: grid; gap: 3px; }
  .profile-summary-row strong { text-align: left; }
  .task-row { grid-template-columns: 10px minmax(0, 1fr); }
  .task-amount, .task-action { grid-column: 2; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
