
/* --- Knowledge base --- */
.kb-hero { margin-bottom: 14px; }
.kb-breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.kb-breadcrumb a { color: var(--muted); text-decoration: none; }
.kb-breadcrumb a:hover { text-decoration: underline; }
.kb-sep { margin: 0 6px; opacity: 0.6; }

.kb-search { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.kb-search input { flex: 1; min-width: 260px; }

.kb-card { text-decoration: none; color: inherit; }
.kb-card:hover { border-color: rgba(37, 99, 235, 0.20); }
.kb-card-title { font-weight: 900; margin-bottom: 4px; }
.kb-card-desc { line-height: 1.45; }
.kb-card-meta { margin-top: 10px; font-size: 12px; color: var(--muted); }

.kb-list { display: grid; gap: 12px; }
.kb-item { text-decoration: none; color: inherit; }
.kb-item:hover { border-color: rgba(37, 99, 235, 0.20); }
.kb-item-title { font-weight: 900; margin-bottom: 4px; }
.kb-item-meta { margin-top: 8px; font-size: 12px; color: var(--muted); }

.kb-article { display: grid; gap: 14px; }
.kb-body { line-height: 1.62; }
.kb-body h2 { margin: 18px 0 10px; }
.kb-body h3 { margin: 16px 0 8px; }
.kb-body p { margin: 10px 0; }
.kb-body ul, .kb-body ol { margin: 10px 0; }
.kb-body code {
  background: rgba(15, 23, 42, 0.06);
  padding: 2px 6px;
  border-radius: 8px;
}
.kb-note {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.14);
}
.kb-related-title { font-weight: 900; margin-bottom: 8px; }
.kb-related-list { display: grid; gap: 10px; }
.kb-related-item {
  text-decoration: none;
  color: inherit;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.70);
}
.kb-related-item:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.18);
}
.kb-related-item-title { font-weight: 800; margin-bottom: 2px; }

/* --- Integrations --- */
.steps { margin: 10px 0 0; padding-left: 18px; }
.steps li { margin: 6px 0; }

/* === Integration Cards === */
.ic-list { display: grid; gap: 12px; }

.ic-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Header */
.ic-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-light); flex-wrap: wrap;
}
.ic-card-identity { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ic-provider-label {
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
}
.ic-card-name { font-weight: 700; color: var(--text); font-size: 15px; }
.ic-card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }

/* Body sections */
.ic-section { padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
.ic-section:last-of-type { border-bottom: none; }
.ic-field-label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}

/* Collapsible ic-card (details/summary) */
details.ic-collapse { }
details.ic-collapse > summary.ic-collapse-trigger {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.ic-collapse > summary.ic-collapse-trigger::-webkit-details-marker { display: none; }
details.ic-collapse > summary.ic-collapse-trigger::marker { display: none; content: ""; }
details.ic-collapse:not([open]) > summary.ic-card-header {
  border-bottom: 0;
}
.ic-collapse-chevron {
  transition: transform 200ms ease;
  color: var(--muted);
  flex-shrink: 0;
}
details.ic-collapse[open] > summary .ic-collapse-chevron {
  transform: rotate(90deg);
}

.settings-disclosure-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}
.settings-disclosure-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.settings-disclosure-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.settings-disclosure-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.settings-disclosure-body {
  padding: 16px;
  border-top: 1px solid var(--border-light);
}
.settings-disclosure-body .ic-section {
  padding-left: 0;
  padding-right: 0;
}
.settings-disclosure-body .ic-section:first-child {
  padding-top: 0;
}
.settings-disclosure-body .ic-section:last-child {
  padding-bottom: 0;
}
.settings-disclosure + .settings-disclosure {
  border-top: 1px solid var(--border-light);
}
.settings-muted-list {
  margin: 10px 0 0;
  padding-left: 18px;
}
.settings-muted-list li {
  margin: 6px 0;
}
.settings-compact-intro {
  padding: 16px;
}
.settings-section-heading {
  padding: 16px 16px 0;
}
.settings-summary-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.settings-list-disclosure {
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}
.settings-list-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.settings-list-summary::-webkit-details-marker { display: none; }
.settings-list-summary::marker { display: none; content: ""; }
.settings-list-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.settings-list-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 16px 14px;
}

/* Notification toggle switch */
.notif-toggle {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.notif-toggle input {
  position: absolute;
  left: 0;
  top: 1px;
  width: 38px;
  height: 22px;
  margin: 0;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
}
.notif-toggle-track {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.14);
  transition: background 180ms ease;
  margin-top: 1px;
}
.notif-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 180ms ease;
}
.notif-toggle input:checked + .notif-toggle-track {
  background: rgba(34, 197, 94, 0.75);
}
.notif-toggle input:focus-visible + .notif-toggle-track {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}
.notif-toggle input:checked + .notif-toggle-track .notif-toggle-thumb {
  transform: translateX(16px);
}

/* Webhook code block */
.ic-section .webhook-row { flex-wrap: nowrap; align-items: flex-start; gap: 8px; }
.ic-webhook-code {
  display: block; min-width: 0; flex: 1 1 0;
  white-space: normal; word-break: break-all; overflow-wrap: anywhere;
  line-height: 1.4; padding: 8px 10px; border-radius: 10px;
  background: rgba(2, 6, 23, 0.04); font-size: 12px;
}

/* Job status section */
.ic-job-section { border-left: 3px solid transparent; }
.ic-job-info {
  background: rgba(59, 130, 246, 0.05);
  border-left-color: rgba(59, 130, 246, 0.35);
}
.ic-job-error {
  background: rgba(239, 68, 68, 0.04);
  border-left-color: rgba(239, 68, 68, 0.35);
}
.ic-job-body { font-size: 13px; line-height: 1.5; }
.ic-job-msg { margin-top: 4px; overflow-wrap: anywhere; }
.ic-job-link { display: inline-block; margin-top: 6px; font-weight: 700; color: var(--accent); font-size: 12px; }
.ic-job-link:hover { text-decoration: underline; }

/* Actions bar */
.ic-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; position: relative;
  background: rgba(2, 6, 23, 0.015); border-top: 1px solid var(--border-light);
}
.ic-actions form { margin: 0; }

/* Collapsible advanced (details/summary — zero JS) */
.ic-advanced { margin-left: auto; }
.ic-advanced-toggle { cursor: pointer; list-style: none; font-size: 13px; }
.ic-advanced-toggle::-webkit-details-marker { display: none; }
.ic-advanced[open] .ic-advanced-toggle {
  background: rgba(37, 99, 235, 0.08); border-color: rgba(37, 99, 235, 0.20);
}
.ic-advanced-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  min-width: 320px; max-width: 420px; padding: 14px;
  border-radius: 14px; border: 1px solid rgba(15, 23, 42, 0.22);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.14);
  backdrop-filter: blur(10px); display: grid; gap: 14px;
}
.ic-advanced-form { display: grid; gap: 6px; }
.ic-advanced-form .action-row { gap: 8px; }
.ic-advanced-form input,
.ic-advanced-form select { min-width: 0; flex: 1; }

/* API key card meta */
.ak-meta { display: flex; gap: 16px; font-size: 12px; flex-wrap: wrap; }
.nav-credentials-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nav-credentials-summary .ic-field-label {
  margin-bottom: 0;
}
.nav-credentials-edit-label {
  flex-shrink: 0;
}

.api-permission-field {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.api-permission-field legend {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 6px;
  padding: 0;
}
.api-permission-segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  min-height: 42px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
}
.api-permission-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.api-permission-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.api-permission-option:hover {
  color: var(--text);
  background: rgba(37, 99, 235, 0.08);
}
.api-permission-input:checked + .api-permission-option {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}
.api-permission-input:focus-visible + .api-permission-option {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
}
.api-permission-hint {
  min-height: 18px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Security page split layout */
.sec-split { display: grid; grid-template-columns: 1fr 1fr; }
.sec-split-col + .sec-split-col { border-left: 1px solid var(--border-light); }
.security-action-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.security-action-summary .ic-field-label {
  margin-bottom: 0;
}
.security-action-summary-main {
  min-width: 0;
}
.security-action-open-label {
  flex-shrink: 0;
}

/* New integration card form */
.ic-new-card { margin-top: 12px; }
.ic-new-form { display: grid; gap: 14px; }
.ic-new-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.ic-new-submit {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.ic-setup-help { width: 100%; }
.ic-setup-help-body {
  padding: 14px 0 4px;
}
.webhook-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.webhook-row code { flex: 1 1 360px; }
.btn-copy { white-space: nowrap; }


/* --- Autocomplete dropdown --- */
.ac { position: relative; }
.ac-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  padding: 6px;
  max-height: 280px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.22);
  border-radius: 12px;
  box-shadow: 0 18px 38px rgba(2, 6, 23, 0.14);
  backdrop-filter: blur(10px);
}
.ac-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(15, 23, 42, 0.92);
  cursor: pointer;
}
.ac-item:hover { background: rgba(37, 99, 235, 0.08); }
.ac-item:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.ac-title { font-weight: 800; }
.ac-meta { margin-top: 2px; font-size: 12px; color: var(--muted); }
.ac-addr { margin-top: 1px; font-size: 12px; color: var(--muted); opacity: 0.7; }
.ac-empty { padding: 10px 12px; color: var(--muted); font-size: 12px; }

h1 { margin: 0 0 12px; letter-spacing: -0.02em; }
h2 { margin: 0 0 10px; letter-spacing: -0.02em; }
h3 { margin: 0 0 8px; color: rgba(15, 23, 42, 0.9); }

.content h1 { font-size: 24px; margin: 0 0 6px; }

label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.22);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  box-sizing: border-box;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5' stroke='%230f172a' stroke-opacity='0.55' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px 20px;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select {
  height: 42px;
}
textarea { min-height: 63px; height: 63px; resize: vertical; }
.inv-address-textarea {
  min-height: 50px;
  height: 50px;
  resize: vertical;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.flatpickr-calendar {
  border: 1px solid var(--border-light);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 22px 50px rgba(2, 6, 23, 0.14);
}

.flatpickr-calendar.arrowTop:before {
  border-bottom-color: var(--border-light);
}

.flatpickr-calendar.arrowTop:after {
  border-bottom-color: var(--panel);
}

.flatpickr-calendar.arrowBottom:before {
  border-top-color: var(--border-light);
}

.flatpickr-calendar.arrowBottom:after {
  border-top-color: var(--panel);
}

.flatpickr-months {
  align-items: center;
  height: 44px;
}
.flatpickr-months .flatpickr-month {
  height: 44px;
  overflow: visible;
}
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  position: relative;
  top: auto;
  height: auto;
  padding: 8px;
  display: flex;
  align-items: center;
}
.flatpickr-current-month {
  position: relative;
  left: auto;
  width: auto;
  height: auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.flatpickr-months .flatpickr-month,
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  color: var(--text);
  fill: var(--text);
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  font-weight: 800;
}

.flatpickr-weekdays {
  padding: 0 8px;
}

span.flatpickr-weekday {
  color: var(--muted);
  font-weight: 700;
}

.flatpickr-day {
  color: var(--text);
  border-radius: 10px;
}

.flatpickr-day:hover,
.flatpickr-day:focus {
  background: rgba(37, 99, 235, 0.08);
  border-color: transparent;
}

.flatpickr-day.today {
  border-color: rgba(37, 99, 235, 0.45);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay,
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
  color: rgba(100, 116, 139, 0.72);
}

.flatpickr-date-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border-light);
}

.flatpickr-date-action {
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  border-radius: 10px;
}

.flatpickr-date-action:hover {
  background: rgba(37, 99, 235, 0.08);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.btn-sm {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}

button { background: #fff; color: rgba(15, 23, 42, 0.88); border-color: rgba(15, 23, 42, 0.22); }
button:hover { filter: brightness(0.98); }

.btn:disabled, button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  filter: none !important;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: rgba(37, 99, 235, 0.55);
  text-decoration: none;
}
.btn-primary:hover { text-decoration: none; filter: brightness(0.98); }

.btn-secondary, .btn.btn-secondary {
  background: #fff;
  color: rgba(15, 23, 42, 0.88);
  border-color: rgba(15, 23, 42, 0.22);
  text-decoration: none;
}
.btn-secondary:hover { text-decoration: none; background: rgba(2, 6, 23, 0.02); }

.btn-ghost {
  background: transparent;
  color: rgba(15, 23, 42, 0.78);
  border-color: rgba(15, 23, 42, 0.12);
}
.btn-ghost:hover { background: rgba(2, 6, 23, 0.03); }

.btn-danger, .btn.btn-danger {
  background: rgba(239, 68, 68, 0.08);
  color: rgba(185, 28, 28, 0.95);
  border-color: rgba(239, 68, 68, 0.25);
  text-decoration: none;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.14); text-decoration: none; }

.linklike {
  background: transparent;
  border: 0;
  padding: 0;
  font-weight: 700;
  color: var(--muted);
}
.linklike:hover { color: var(--text); text-decoration: underline; }
.inline { display: inline; }

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.06);
  margin-bottom: 14px;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert-error {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.06);
}
.alert-success {
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.08);
}
.alert-warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.20);
  text-align: left;
  vertical-align: top;
}

thead th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(2, 6, 23, 0.02);
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }

tbody tr:hover td { background: rgba(37, 99, 235, 0.04); }

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

/* Sticky invoice table headers.
   Both table{overflow:hidden} and .table-scroll{overflow-x:auto} create
   scroll containers that break position:sticky. Override both to visible
   so thead sticks relative to the viewport. On mobile (<760px) the table
   becomes a card layout with hidden thead, so horizontal overflow is moot. */
.table-scroll:has(> .inv-table) {
  overflow: visible;
}

.inv-table {
  overflow: visible;
}

.inv-table thead th {
  position: sticky;
  top: 0; /* .main{overflow-y:auto} is the scroll container; topbar is in a separate grid row */
  z-index: 5;
  background: var(--panel);
  box-shadow: 0 1px 0 0 rgba(15, 23, 42, 0.12);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(15, 23, 42, 0.03);
  font-size: 12px;
  font-weight: 500;
  color: rgba(15, 23, 42, 0.48);
  text-decoration: none;
  transition: all 140ms ease;
  cursor: pointer;
}
.pill:hover {
  text-decoration: none;
  background: rgba(15, 23, 42, 0.07);
  color: rgba(15, 23, 42, 0.72);
  border-color: rgba(15, 23, 42, 0.16);
}
.pill.pill-active {
  border-color: rgba(37, 99, 235, 0.30);
  background: rgba(37, 99, 235, 0.10);
  color: rgba(29, 78, 216, 0.92);
  font-weight: 600;
}
.pill.pill-active:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.38);
  color: rgba(29, 78, 216, 1);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(2, 6, 23, 0.02);
  color: rgba(15, 23, 42, 0.82);
}
.badge-sm { padding: 2px 7px; font-size: 11px; font-weight: 600; }
.badge[hidden] {
  display: none !important;
}
#special_tax_summary_badge:empty,
#special_tax_state_status:empty {
  display: none !important;
  padding: 0 !important;
  border-width: 0 !important;
}
.badge.success { border-color: rgba(34, 197, 94, 0.28); background: rgba(34, 197, 94, 0.10); color: rgba(21, 128, 61, 0.95); }
.badge.warning { border-color: rgba(245, 158, 11, 0.30); background: rgba(245, 158, 11, 0.12); color: rgba(180, 83, 9, 0.95); }
.badge.danger { border-color: rgba(239, 68, 68, 0.28); background: rgba(239, 68, 68, 0.10); color: rgba(185, 28, 28, 0.95); }
.badge.info { border-color: rgba(37, 99, 235, 0.22); background: rgba(37, 99, 235, 0.10); color: rgba(29, 78, 216, 0.95); }

/* --- Responsive --- */
@media (max-width: 1100px) {
  .inv-form {
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "right"
      "lines"
      "total"
      "actions";
  }
  .inv-col-left { border-right: none; }
  .inv-col-right { position: static; top: auto; align-self: auto; border-top: 1.5px solid rgba(15, 23, 42, 0.20); }
  .inv-lines { border-right: none; }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .sidebar-brand-row { display: none; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: auto;
    width: 252px;
    padding-top: 16px;
    transform: translateX(-105%);
    transition: transform 160ms ease-out;
    z-index: 30;
    box-shadow: 0 30px 80px rgba(2, 6, 23, 0.18);
  }
  .sidebar-toggle { display: inline-flex; }
  .content { max-width: 980px; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-side {
    position: static; top: auto;
    border: none; background: transparent;
    box-shadow: none; padding: 0; margin-bottom: 8px;
  }

  /* Settings mobile nav */
  .settings-mobile-nav { display: block; }
  .settings-desktop-nav { display: none; }

  .settings-mobile-nav > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-weight: 800;
    font-size: 15px;
  }
  .settings-mobile-nav > summary::-webkit-details-marker { display: none; }
  .settings-mobile-nav > summary::marker { display: none; content: ""; }

  .settings-mobile-chevron {
    display: inline-flex;
    transition: transform 0.2s ease;
  }
  .settings-mobile-chevron svg { color: var(--muted); }
  .settings-mobile-nav[open] .settings-mobile-chevron { transform: rotate(180deg); }

  .settings-mobile-body {
    margin-top: 8px;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.08);
  }
  .page-head { flex-direction: column; align-items: stretch; }
  .search { min-width: 0; }
  .inv-line { grid-template-columns: 1fr 1fr; }
  .inv-line .inv-line-desc { grid-column: 1 / -1; }
  .doc-type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ic-new-fields { grid-template-columns: 1fr; }

  /* Always show full nav on mobile, even if it was collapsed on desktop. */
  .app-shell.sidebar-collapsed .brandmark-full,
  html[data-sidebar-collapsed="1"] .app-shell .brandmark-full { display: inline-block; }
  .app-shell.sidebar-collapsed .brandmark-mini,
  html[data-sidebar-collapsed="1"] .app-shell .brandmark-mini { display: none; }
  .app-shell.sidebar-collapsed .tenantname,
  html[data-sidebar-collapsed="1"] .app-shell .tenantname { display: block; }
  .app-shell.sidebar-collapsed .nav-item,
  html[data-sidebar-collapsed="1"] .app-shell .nav-item { justify-content: flex-start; }
  .app-shell.sidebar-collapsed .nav-item > span:not(.nav-ico),
  html[data-sidebar-collapsed="1"] .app-shell .nav-item > span:not(.nav-ico) { display: inline; }
  .app-shell.sidebar-collapsed .nav-submenu,
  html[data-sidebar-collapsed="1"] .app-shell .nav-submenu { display: grid; }
  .app-shell.sidebar-collapsed .userline,
  html[data-sidebar-collapsed="1"] .app-shell .userline { display: block; }
  .app-shell.sidebar-collapsed .btn-text,
  html[data-sidebar-collapsed="1"] .app-shell .btn-text { display: inline; }

  .nav-toggle:checked ~ .app-shell .sidebar { transform: translateX(0); }
  .nav-toggle:checked ~ .nav-overlay {
    display: block;
  }

  .landing-hero { padding: 100px 0 48px; }
  .referral-hero-inner { flex-direction: column; }
  .referral-codes-grid { grid-template-columns: 1fr; }

  /* --- Topbar: compact mobile layout --- */
  .topbar { padding: 9px 11px; gap: 7px; }
  .btn-label-full { display: none; }
  .btn-label-short { display: inline; }
  .profile-text { display: none; }
  .profile-chevron { display: none; }
  .profile-panel { width: calc(100vw - 24px); max-width: 380px; }
}

@media (max-width: 480px) {
  .topbar-actions > a.icon-btn[href*="tudastar"] { display: none; }
  #theme-toggle { display: none; }
  .profile-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    width: auto;
    max-width: none;
  }
}

@media (max-width: 640px) {
  .ic-card-header { flex-direction: column; gap: 8px; }
  .ic-section .webhook-row { flex-wrap: wrap; }
  .ic-advanced { margin-left: 0; width: 100%; }
  .ic-advanced-toggle { width: 100%; justify-content: center; }
  .ic-advanced-body {
    position: static; max-width: 100%; border-radius: 10px; margin-top: 10px;
    box-shadow: none; border-color: var(--border-light); background: rgba(2, 6, 23, 0.02);
  }
  .ic-new-fields { grid-template-columns: 1fr; }
  .sec-split { grid-template-columns: 1fr; }
  .sec-split-col + .sec-split-col { border-left: none; border-top: 1px solid var(--border-light); }
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .dash { grid-template-columns: 1fr; }
  .inv-date-deadline-row {
    grid-template-columns: 1fr;
  }
  .inv-date-deadline-side {
    grid-template-columns: minmax(72px, 88px) minmax(0, 1fr);
  }
  .inv-date-periodical-toggle-wrap {
    justify-self: start;
  }

  /* Invoice view mobile */
  .inv-view-parties { grid-template-columns: 1fr; gap: 14px; }
  .inv-view-dates { flex-direction: column; gap: 10px; }
  .inv-view-totals { max-width: none; }
  .inv-bottom-grid { grid-template-columns: 1fr; gap: 14px; }
  .inv-pay-form { flex-direction: column; }
  .inv-pay-form input { flex-basis: auto; }
  .inv-action-cards { grid-template-columns: repeat(2, 1fr); }
  .inv-related-item { flex-wrap: wrap; gap: 6px; }
  .filters input[name="q"] { min-width: 0; flex: 1 1 100%; }
  .filters .range { width: 100%; justify-content: space-between; }
  .filters .range input { width: calc(50% - 14px); }
  .partners-filters { min-width: 0; }
  .partner-card { flex-direction: column; gap: 8px; }
  .partner-card-meta { flex-direction: row; align-items: center; gap: 10px; }
  .products-filters { min-width: 0; }
  .public-topbar-inner { flex-wrap: wrap; gap: 10px; }
  .public-legal-links { width: 100%; margin: 0; order: 3; }
  .public-nav { flex-wrap: wrap; justify-content: flex-start; }
  .public-nav-spacer { display: none; }
  .auth-grid { grid-template-columns: 1fr; }
  .kb-search { flex-direction: column; align-items: stretch; }
  .kb-search input { min-width: 0; }

  /* --- Invoice table: card layout on mobile --- */
  .inv-table thead { display: none; }
  .inv-table,
  .inv-table tbody { display: block; }

  .inv-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.10);
    position: relative;
  }
  .inv-table:not(.pur-table) tbody tr { padding-right: 16px; }
  .inv-table tbody tr:hover td { background: transparent; }

  .inv-table td {
    padding: 0;
    border-bottom: none;
    vertical-align: middle;
  }

  /* Outgoing invoices: [icon][number+type][gross] / [buyer] / [date][status][payment][NAV][Kikuldve] */
  .inv-table:not(.pur-table) td:nth-child(1) { order: 1; flex: 0 0 auto; }
  .inv-table:not(.pur-table) td:nth-child(2) { order: 2; flex: 1 1 auto; min-width: 0; }
  .inv-table:not(.pur-table) td:nth-child(5) { order: 3; flex: 0 0 auto; margin-left: auto; font-weight: 800; }
  .inv-table:not(.pur-table) td:nth-child(4) { order: 4; flex: 0 0 100%; font-size: 13px; color: var(--muted); padding-top: 4px; }
  .inv-table:not(.pur-table) td:nth-child(3) { order: 5; flex: 0 0 auto; font-size: 12px; padding-top: 6px; }
  .inv-table:not(.pur-table) td:nth-child(6) { order: 6; flex: 0 0 auto; padding-top: 6px; }
  .inv-table:not(.pur-table) td:nth-child(7) { order: 7; flex: 0 0 auto; padding-top: 6px; }
  .inv-table:not(.pur-table) td:nth-child(8) { order: 8; flex: 0 0 auto; padding-top: 6px; }
  .inv-table:not(.pur-table) td:nth-child(9) { order: 9; flex: 0 0 auto; padding-top: 6px; }

  /* Purchases: [number][supplier][gross] / [date][PDF][operation][status][XML] */
  .pur-table td:nth-child(1) { order: 1; flex: 1 1 auto; min-width: 0; }
  .pur-table td:nth-child(3) { order: 2; flex: 0 0 100%; font-size: 13px; padding-top: 2px; }
  .pur-table td:nth-child(4) { order: 3; flex: 0 0 auto; font-weight: 800; padding-top: 4px; }
  .pur-table td:nth-child(5) { order: 4; flex: 0 0 auto; padding-top: 4px; }
  .pur-table td:nth-child(7) { order: 5; flex: 0 0 auto; padding-top: 4px; }
  .pur-table td:nth-child(2) { order: 6; flex: 0 0 auto; font-size: 12px; color: var(--muted); padding-top: 4px; }
  .pur-table td:nth-child(6) { order: 7; flex: 0 0 auto; font-size: 12px; color: var(--muted); padding-top: 4px; }
  .pur-table td:nth-child(8) { order: 8; flex: 0 0 auto; margin-left: auto; padding-top: 4px; }
  .inv-table tbody tr.purchase-editor-row {
    display: block;
    padding: 0 16px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.10);
  }
  .purchase-editor-row td {
    display: block;
    width: 100%;
    padding: 0;
  }

  /* Shared: smaller badges & icons on mobile */
  .inv-table .badge { font-size: 11px; padding: 3px 8px; }
  .inv-table .doc-ico { width: 28px; height: 28px; }
}
