/* ============================================================
   DS Steel — invoice workspace
   Flat, square, shadcn-inspired. No shadows, no rounded corners.
   ============================================================ */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --foreground: #09090b;
  --foreground-2: #27272a;
  --muted: #f4f4f5;
  --muted-2: #e4e4e7;
  --muted-foreground: #71717a;
  --muted-foreground-2: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --primary: #18181b;
  --primary-hover: #27272a;
  --primary-foreground: #fafafa;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --warning: #a16207;
  --warning-bg: #fefce8;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --accent: #f4f4f5;
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --header-h: 64px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--foreground);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, figure {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

img {
  max-width: 100%;
}

::selection {
  background: #18181b;
  color: #fff;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
}

.text-muted { color: var(--muted-foreground); }
.text-right { text-align: right; }
.data-table thead th.text-right,
.data-table tbody td.text-right { text-align: right; }
.nav-link i { font-size: 0.72rem; }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

[hidden] {
  display: none !important;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

/* ---------- shell ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}

.brand-mark img {
  height: 30px;
  width: auto;
}

.brand-name {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.account-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--foreground);
  background: var(--muted);
}

.nav-link.active {
  color: var(--foreground);
  background: var(--muted);
}

.nav-sep {
  width: 1px;
  height: 22px;
  margin: 0 10px;
  background: var(--border);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 6px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.68rem;
  font-weight: 800;
}

.user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
}

.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted-foreground);
}

.logout-link:hover {
  color: var(--danger);
  background: var(--muted);
}

.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--foreground);
  cursor: pointer;
}

.site-main {
  padding: 30px 0 56px;
  min-height: calc(100vh - var(--header-h) - 60px);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 0;
  color: var(--muted-foreground);
  font-size: 0.72rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- page head ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.page-sub {
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.btn i {
  font-size: 0.78rem;
}

.btn:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 1px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-foreground);
}

.btn-secondary,
.btn-light {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--foreground-2);
}

.btn-secondary:hover,
.btn-light:hover,
.btn-secondary:focus,
.btn-light:focus {
  background: var(--muted);
  color: var(--foreground);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
}

.btn-ghost:hover {
  background: var(--muted);
  color: var(--foreground);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

.btn-danger-soft {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger-soft:hover {
  background: #fee2e2;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.74rem;
}

.btn-lg {
  height: 42px;
  padding: 0 20px;
  font-size: 0.84rem;
}

.btn-block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--muted);
  color: var(--foreground);
}

.btn-icon--danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}

.row-action-form {
  display: inline-flex;
  margin: 0;
}

.row-action-form .btn-icon {
  padding: 0;
}

.sheet-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sheet-foot.sheet-actions {
  display: grid;
}

.sheet-actions .sheet-action-form {
  display: flex;
}

.sheet-actions .sheet-action-form .btn {
  width: 100%;
  justify-content: center;
  flex: none;
}

.sheet-actions .btn {
  width: 100%;
  justify-content: center;
  flex: none;
}

.sheet-actions .is-wide {
  grid-column: 1 / -1;
}

/* ---------- stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 22px;
}

.stat {
  padding: 16px 18px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.stat:last-child {
  border-right: 0;
}

.stat-label {
  color: var(--muted-foreground);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 6px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value small {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  margin-right: 4px;
}

.stat-meta {
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 0.7rem;
}

/* ---------- cards / panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.panel-head h2 i {
  color: var(--muted-foreground-2);
  font-size: 0.82rem;
}

.panel-body {
  padding: 18px;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-note {
  color: var(--muted-foreground);
  font-size: 0.76rem;
}

/* ---------- forms ---------- */

.form-group,
.field {
  margin-bottom: 14px;
}

.form-group:last-child,
.field:last-child {
  margin-bottom: 0;
}

.form-label,
label {
  display: block;
  margin-bottom: 5px;
  color: var(--foreground-2);
  font-size: 0.74rem;
  font-weight: 700;
}

.form-control {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.4;
  transition: border-color 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
}

textarea.form-control {
  height: auto;
  min-height: 86px;
  padding: 9px 10px;
  resize: vertical;
}

select.form-control {
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.form-control::placeholder {
  color: var(--muted-foreground-2);
}

.form-control:focus {
  outline: none;
  border-color: var(--foreground);
}

.form-control[readonly] {
  background: var(--surface-2);
  color: var(--muted-foreground);
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group-text {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-right: 0;
  background: var(--surface-2);
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 700;
}

.input-group .form-control {
  min-width: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}

.form-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.toolbar-spacer {
  flex: 1;
}

.search-field {
  position: relative;
  flex: 1 1 240px;
  min-width: 180px;
  max-width: 340px;
}

.search-field i {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  color: var(--muted-foreground-2);
  font-size: 0.74rem;
  pointer-events: none;
}

.search-field .form-control {
  height: 34px;
  padding-left: 32px;
  font-size: 0.8rem;
}

.toolbar .form-control {
  height: 34px;
  font-size: 0.78rem;
}

.select-compact {
  width: auto;
  min-width: 130px;
}

/* ---------- tables ---------- */

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table thead th {
  height: 38px;
  padding: 0 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.data-table thead th.th-actions {
  text-align: right;
}

.data-table th[data-sort] {
  cursor: pointer;
}

.data-table th[data-sort]:hover {
  color: var(--foreground);
}

.data-table th[data-sort] .sort-mark {
  display: inline-block;
  margin-left: 5px;
  color: var(--muted-foreground-2);
  font-size: 0.6rem;
}

.data-table th[aria-sort="ascending"] .sort-mark,
.data-table th[aria-sort="descending"] .sort-mark {
  color: var(--foreground);
}

.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--foreground-2);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr {
  cursor: default;
}

[data-open-sheet] .data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.data-table tbody tr.is-selected,
.data-table tbody tr.is-selected:hover {
  background: var(--muted);
}

.data-table .cell-id {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table .cell-main {
  color: var(--foreground);
  font-weight: 600;
}

.data-table .cell-sub {
  margin-top: 1px;
  color: var(--muted-foreground);
  font-size: 0.73rem;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cell-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.cell-amount small {
  margin-right: 4px;
  color: var(--muted-foreground);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
}

td.cell-actions {
  padding-top: 6px;
  padding-bottom: 6px;
}

.check-cell {
  width: 42px;
  padding-right: 0 !important;
  text-align: center;
}

.check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  background: var(--surface);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  vertical-align: middle;
  position: relative;
}

.check:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.check:checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-1px) rotate(45deg);
}

.check:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 1px;
}

/* badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border: 1px solid transparent;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  background: currentColor;
}

.badge-paid {
  background: var(--success-bg);
  border-color: #bbf7d0;
  color: var(--success);
}

.badge-partial {
  background: var(--warning-bg);
  border-color: #fef08a;
  color: var(--warning);
}

.badge-due {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

.badge-type,
.badge-neutral {
  background: var(--muted);
  border-color: var(--border);
  color: var(--muted-foreground);
}

/* bulk bar */

.bulk-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--foreground);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
}

.bulk-bar.is-open {
  display: flex;
}

.bulk-bar .btn {
  height: 28px;
  padding: 0 10px;
  font-size: 0.72rem;
}

.bulk-bar .btn-light {
  background: transparent;
  border-color: #3f3f46;
  color: #fff;
}

.bulk-bar .btn-light:hover {
  background: #27272a;
}

/* table footer */

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.table-count {
  color: var(--muted-foreground);
  font-size: 0.73rem;
}

.pager {
  display: flex;
  align-items: center;
  gap: 3px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--foreground-2);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.page-btn:hover {
  background: var(--muted);
}

.page-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.page-btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

.page-size {
  width: auto;
  height: 28px;
  padding: 0 24px 0 8px;
  font-size: 0.72rem;
}

/* empty */

.empty-state {
  padding: 56px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
}

.empty-state h3 {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.empty-state p {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  margin-bottom: 16px;
}

/* ---------- invoice form ---------- */

.invoice-form .panel-body {
  padding: 18px;
}

.party-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.party-card {
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.party-label {
  margin-bottom: 10px;
  color: var(--muted-foreground);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.party-name {
  font-size: 0.92rem;
  font-weight: 800;
}

.party-line {
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.party-card--customer {
  background: var(--surface);
}

.scroll-hint {
  display: none;
  margin-bottom: 10px;
  color: var(--muted-foreground);
  font-size: 0.72rem;
}

.items-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.items-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.items-table thead th {
  height: 34px;
  padding: 0 8px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

.items-table tbody td {
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.items-table tbody tr:last-child td {
  border-bottom: 0;
}

.items-table .form-control {
  height: 32px;
  border-color: transparent;
  background: transparent;
  font-size: 0.8rem;
}

.items-table .form-control:hover {
  border-color: var(--border);
  background: var(--surface);
}

.items-table .form-control:focus {
  border-color: var(--foreground);
  background: var(--surface);
}

.items-table .total {
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.items-table .col-check { width: 34px; }
.items-table .col-num { width: 36px; color: var(--muted-foreground); font-size: 0.72rem; font-weight: 700; text-align: center; }
.items-table .col-code { width: 110px; }
.items-table .col-unit { width: 100px; }
.items-table .col-qty { width: 84px; }
.items-table .col-price { width: 130px; }
.items-table .col-total { width: 130px; }
.items-table .col-remove { width: 40px; text-align: right; }

.items-table .product-cell {
  position: relative;
  min-width: 260px;
}

.totals-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: start;
}

.summary {
  border: 1px solid var(--border);
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.summary-row:last-child {
  border-bottom: 0;
}

.summary-row .label {
  color: var(--muted-foreground);
  font-weight: 600;
}

.summary-row .value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.summary-row.is-total {
  background: var(--foreground);
  color: #fff;
}

.summary-row.is-total .label {
  color: #d4d4d8;
  font-weight: 700;
}

.summary-row.is-total .value {
  font-size: 1rem;
  font-weight: 800;
}

.summary-row input.form-control {
  width: 130px;
  height: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-row.is-total input.form-control {
  background: transparent;
  border-color: #3f3f46;
  color: #fff;
  font-weight: 800;
}

.summary-row.is-total input.form-control:focus {
  border-color: #fafafa;
}

.summary-tax .form-control {
  width: 80px;
  height: 30px;
  text-align: right;
}

.summary-tax {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.summary-tax label {
  margin: 0;
  white-space: nowrap;
}

.summary-tax .form-control {
  width: 80px;
  height: 30px;
  text-align: right;
}

/* ---------- combobox ---------- */

.combo {
  position: relative;
}

.combo-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1300;
  display: none;
  width: 240px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  overscroll-behavior: contain;
}

.combo.is-open .combo-menu {
  display: block;
}

.combo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
}

.combo-item:hover,
.combo-item.is-active {
  background: var(--muted);
}

.combo-item .combo-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.combo-item .combo-meta {
  flex: 0 0 auto;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.combo-empty {
  padding: 10px;
  color: var(--muted-foreground);
  font-size: 0.76rem;
}

.combo-footer {
  border-top: 1px solid var(--border);
}

.combo-footer a {
  display: block;
  padding: 8px 10px;
  color: var(--foreground);
  font-size: 0.74rem;
  font-weight: 700;
}

.combo-footer a:hover {
  background: var(--muted);
}

/* ---------- sheet (invoice detail) ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(9, 9, 11, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

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

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1010;
  display: flex;
  flex-direction: column;
  width: 480px;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.sheet.is-open {
  transform: translateX(0);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.sheet-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sheet-sub {
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 0.74rem;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

.sheet-foot {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.sheet-foot .btn {
  flex: 1;
}

.sheet-section {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sheet-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sheet-section h4 {
  margin-bottom: 10px;
  color: var(--muted-foreground);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}

.detail-grid .label {
  color: var(--muted-foreground);
  font-size: 0.68rem;
  font-weight: 600;
}

.detail-grid .value {
  margin-top: 2px;
  font-size: 0.82rem;
  font-weight: 700;
  word-break: break-word;
}

.detail-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}

.detail-item:last-child {
  border-bottom: 0;
}

.detail-item .name {
  font-weight: 700;
}

.detail-item .meta {
  color: var(--muted-foreground);
  font-size: 0.7rem;
}

.detail-item .amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.detail-totals {
  margin-top: 4px;
}

.detail-totals .row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  font-size: 0.78rem;
}

.detail-totals .row.is-total {
  margin-top: 4px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 800;
}

.sheet-loading {
  padding: 40px 0;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  text-align: center;
}

/* ---------- dialogs ---------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 16px;
  background: rgba(9, 9, 11, 0.48);
  overflow-y: auto;
}

.dialog-backdrop.is-open {
  display: flex;
}

.dialog-card {
  width: 560px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.dialog-head p {
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 0.74rem;
}

.dialog-body {
  padding: 18px;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ---------- auth ---------- */

.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h) - 190px);
  padding: 24px 0;
}

.auth-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 900px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
}

.auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px;
  background: var(--primary);
  color: var(--primary-foreground);
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 1px solid #3f3f46;
}

.auth-logo img {
  height: 40px;
  width: auto;
}

.auth-aside h1 {
  margin: 40px 0 10px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.auth-aside p {
  color: #a1a1aa;
  font-size: 0.82rem;
  max-width: 280px;
}

.auth-points {
  margin-top: 26px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
}

.auth-points li {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d4d4d8;
  font-size: 0.76rem;
}

.auth-points i {
  color: #71717a;
  font-size: 0.7rem;
}

.auth-meta {
  color: #71717a;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-form-panel {
  padding: 44px 40px;
}

.auth-form-head {
  margin-bottom: 24px;
}

.auth-form-head h2 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.auth-form-head p {
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.field-icon {
  position: relative;
}

.field-icon > i {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  color: var(--muted-foreground-2);
  font-size: 0.76rem;
  pointer-events: none;
}

.field-icon .form-control {
  height: 40px;
  padding-left: 33px;
  padding-right: 36px;
}

.pwd-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}

.pwd-toggle:hover {
  color: var(--foreground);
}

.auth-form .btn {
  margin-top: 6px;
}

.auth-foot {
  margin-top: 18px;
  color: var(--muted-foreground);
  font-size: 0.7rem;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 600;
}

.alert-danger {
  margin-bottom: 16px;
  border-color: #fecaca;
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-success {
  border-color: #bbf7d0;
  background: var(--success-bg);
  color: var(--success);
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 14px;
  border: 1px solid #bbf7d0;
  background: var(--success-bg);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 600;
}

/* ---------- small utilities ---------- */

.result-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  margin-left: 8px;
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}

.link {
  color: var(--foreground);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-muted {
  color: var(--muted-foreground);
  font-size: 0.74rem;
  font-weight: 600;
}

.link-muted:hover {
  color: var(--foreground);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.is-hidden {
  display: none !important;
}

/* ---------- settings ---------- */

.settings-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.settings-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  height: 42px;
  padding: 0 16px;
  border-bottom: 2px solid transparent;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.settings-tab i {
  font-size: 0.75rem;
}

.settings-tab:hover {
  color: var(--foreground);
}

.settings-tab.is-active {
  border-bottom-color: var(--foreground);
  color: var(--foreground);
}

.settings-divider {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.settings-divider span {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-divider small {
  color: var(--muted-foreground);
  font-size: 0.72rem;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-hint {
  margin-top: 6px;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  line-height: 1.45;
}

.form-control[type="file"] {
  height: auto;
  padding: 6px 8px;
  line-height: 1.4;
}

.logo-field {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-top: 6px;
}

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 128px;
  height: 88px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}

.logo-preview img {
  max-width: 108px;
  max-height: 68px;
}

.logo-empty {
  color: var(--muted-foreground);
  font-size: 0.7rem;
  text-align: center;
}

.logo-empty i {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

.logo-input {
  flex: 1 1 auto;
  min-width: 0;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 0.74rem;
  font-weight: 600;
}

.check-inline input {
  width: 14px;
  height: 14px;
  accent-color: var(--foreground);
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 18px;
}

.switch {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.switch > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 18px;
  margin-top: 1px;
  background: var(--muted-2);
  border: 1px solid var(--border-strong);
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.switch > input:checked + .switch-track {
  background: var(--foreground);
  border-color: var(--foreground);
}

.switch > input:checked + .switch-track::after {
  transform: translateX(16px);
  border-color: var(--foreground);
}

.switch > input:focus-visible + .switch-track {
  outline: 2px solid var(--foreground);
  outline-offset: 2px;
}

.switch-text strong {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.3;
}

.switch-text small {
  display: block;
  margin-top: 1px;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  line-height: 1.35;
}

.design-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.doc-switch {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.doc-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.76rem;
  font-weight: 700;
}

.doc-switch-btn:last-child {
  border-right: 0;
}

.doc-switch-btn.is-active {
  background: var(--foreground);
  color: var(--primary-foreground);
}

.design-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.designer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 470px;
  gap: 20px;
  align-items: start;
}

.designer-form .panel:last-of-type {
  margin-bottom: 0;
}

.designer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  bottom: 0;
  z-index: 20;
}

.designer-hint {
  color: var(--muted-foreground);
  font-size: 0.74rem;
}

.designer-hint i {
  margin-right: 5px;
}

.designer-preview {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  border: 1px solid var(--border);
  background: var(--surface);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.preview-head .eyebrow {
  margin-bottom: 2px;
}

.preview-head strong {
  font-size: 0.82rem;
  font-weight: 800;
}

.designer-preview iframe {
  display: block;
  width: 100%;
  height: 640px;
  border: 0;
  background: #f4f4f5;
}

.preview-note {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.7rem;
}

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

.template-option {
  display: block;
  cursor: pointer;
}

.template-option > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.template-card {
  display: block;
  height: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.template-option > input:checked + .template-card {
  border-color: var(--foreground);
  outline: 1px solid var(--foreground);
}

.template-option > input:focus-visible + .template-card {
  outline: 2px solid var(--foreground);
  outline-offset: 2px;
}

.template-thumb {
  display: block;
  height: 56px;
  margin-bottom: 7px;
  padding: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
}

.template-thumb span {
  display: block;
  height: 3px;
  margin-bottom: 4px;
  background: var(--muted-2);
}

.template-thumb span:nth-child(1) {
  width: 40%;
  height: 6px;
  background: var(--foreground-2);
}

.template-thumb span:nth-child(2) {
  width: 100%;
  margin-top: 9px;
}

.template-thumb span:nth-child(3) {
  width: 72%;
}

.template-thumb--modern {
  padding-top: 0;
}

.template-thumb--modern::before {
  content: "";
  display: block;
  height: 15px;
  margin: 0 -6px 8px;
  background: var(--foreground);
}

.template-thumb--minimal span:nth-child(1) {
  width: 28%;
  height: 5px;
}

.template-thumb--minimal span:nth-child(2) {
  height: 1px;
}

.template-name {
  display: block;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.3;
}

.template-desc {
  display: block;
  margin-top: 1px;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  line-height: 1.35;
}

.design-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.design-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.label-value {
  float: right;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.range-control {
  width: 100%;
  height: 36px;
  margin: 0;
  accent-color: var(--foreground);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.color-input {
  width: 46px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
}

.color-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-strong);
  cursor: pointer;
}

.color-swatch.is-active {
  outline: 2px solid var(--foreground);
  outline-offset: 1px;
}

.info-strip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted-foreground);
  font-size: 0.76rem;
}

.info-strip i {
  margin-top: 2px;
}

.info-strip p {
  line-height: 1.5;
}

.test-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.test-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.test-link:hover {
  border-color: var(--foreground);
}

.test-link > i {
  color: var(--muted-foreground);
}

.test-link span {
  display: block;
  min-width: 0;
}

.test-link strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
}

.test-link small {
  display: block;
  color: var(--muted-foreground);
  font-size: 0.7rem;
}

/* ---------- sharing ---------- */

.share-summary {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 18px;
}

.share-summary > div {
  padding: 14px 18px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.share-summary > div:last-child {
  border-right: 0;
}

.share-number {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.share-customer {
  margin-top: 2px;
  font-size: 0.74rem;
  color: var(--muted-foreground);
}

.share-amount {
  margin-top: 5px;
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.share-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  align-items: start;
}

.share-message {
  min-height: 150px;
  resize: vertical;
  font-size: 0.8rem;
  line-height: 1.6;
}

.share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.share-tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.share-tile:hover {
  border-color: var(--foreground);
}

.share-tile strong {
  display: block;
  font-size: 0.8rem;
}

.share-tile small {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  color: var(--muted-foreground);
  word-break: break-word;
}

.share-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  background: var(--muted);
  color: var(--foreground);
}

.share-icon--whatsapp {
  background: #e7f8ee;
  color: #128c4a;
}

.share-link-row {
  display: flex;
  gap: 8px;
}

.share-link-row .form-control {
  flex: 1;
  min-width: 0;
  font-size: 0.74rem;
}

.form-hint {
  margin: 8px 0 0;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  line-height: 1.5;
}

/* ---------- reports ---------- */

.report-filter {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

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

.filter-field label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.filter-field .form-control {
  height: 34px;
  font-size: 0.78rem;
}

.report-filter .btn {
  height: 34px;
}

.report-chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding: 10px 2px 0;
  overflow-x: auto;
}

.chart-col {
  flex: 0 0 30px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  height: 170px;
}

.chart-track {
  display: flex;
  align-items: flex-end;
  height: 150px;
  border-bottom: 1px solid var(--border);
}

.chart-bar {
  display: block;
  width: 100%;
  background: var(--foreground);
}

.chart-bar.is-zero {
  background: var(--border);
}

.chart-col:hover .chart-bar {
  background: #3f3f46;
}

.chart-x {
  text-align: center;
  font-size: 0.62rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.report-data {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.report-data summary {
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted-foreground);
}

.report-data summary:hover {
  color: var(--foreground);
}

.report-data[open] summary {
  margin-bottom: 8px;
}

.report-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table th {
  text-align: left;
  padding: 8px 14px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.mini-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  vertical-align: top;
}

.mini-table tbody tr:last-child td {
  border-bottom: 0;
}

.mini-table .text-right {
  text-align: right;
}

.mini-table .tabular {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mini-table .muted {
  color: var(--muted-foreground-2);
}

.mini-table .cell-main {
  font-weight: 600;
}

.mini-table tr.is-total td {
  background: var(--muted);
  border-bottom: 0;
}

.panel-body--flush {
  padding: 0;
}

.panel-foot-link {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.link-quiet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--foreground);
  text-decoration: none;
}

.link-quiet:hover {
  text-decoration: underline;
}

.report-empty {
  padding: 18px 14px;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.report-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.aging-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.aging-cell {
  padding: 12px 14px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.aging-cell:last-child {
  border-right: 0;
}

.aging-value {
  margin-top: 5px;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aging-cell.is-overdue .aging-value {
  color: var(--danger);
}

.page-foot-note {
  margin: 4px 0 0;
  font-size: 0.7rem;
  color: var(--muted-foreground);
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat:nth-child(2) {
    border-right: 0;
  }
  .stat:nth-child(1),
  .stat:nth-child(2) {
    border-bottom: 1px solid var(--border);
  }
  .totals-grid {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
  }
  .designer {
    grid-template-columns: minmax(0, 1fr);
  }
  .designer-preview {
    position: static;
  }
  .designer-preview iframe {
    height: 70vh;
    min-height: 460px;
  }
  .design-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .switch-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1099.98px) {
  .container {
    padding: 0 20px;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .header-right {
    position: absolute;
    top: calc(100% + 1px);
    right: 16px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 250px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    z-index: 950;
  }
  .header-right.is-open {
    display: flex;
  }
  .main-nav {
    flex-direction: column;
    align-items: stretch;
  }
  .nav-link {
    height: 38px;
  }
  .nav-sep {
    width: auto;
    height: 1px;
    margin: 4px 0;
  }
  .header-right > .btn {
    margin: 2px 0;
  }
  .header-right .account-row {
    justify-content: space-between;
    margin-top: 4px;
    padding: 8px 10px 2px;
    border-top: 1px solid var(--border);
  }
  .header-right .account-row .nav-sep {
    display: none;
  }
  .header-right .account-row .user-chip {
    padding: 0;
  }
  .user-chip {
    justify-content: flex-start;
    padding: 6px 10px;
  }
  .user-name {
    max-width: none;
    flex: 1;
  }
  .site-main {
    padding-top: 22px;
  }
  .totals-grid,
  .party-grid,
  .report-split,
  .share-grid {
    grid-template-columns: 1fr;
  }
  .summary {
    max-width: none;
  }
}

@media (max-width: 767.98px) {
  .container {
    padding: 0 16px;
  }
  .site-main {
    padding: 18px 0 44px;
  }
  .page-title {
    font-size: 1.25rem;
  }
  .page-head {
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
  }
  .page-actions {
    width: 100%;
  }
  .page-actions .btn {
    flex: 1;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .stat {
    padding: 12px 14px;
  }
  .stat-value {
    font-size: 1.05rem;
  }
  .panel-head {
    padding: 12px 14px;
    flex-wrap: wrap;
  }
  .panel-body {
    padding: 14px;
  }
  .share-summary {
    grid-template-columns: 1fr 1fr;
  }
  .share-summary > div:nth-child(2n) {
    border-right: 0;
  }
  .share-summary > div:nth-child(-n+2) {
    border-bottom: 1px solid var(--border);
  }
  .report-filter .filter-field {
    flex: 1 1 calc(50% - 5px);
  }
  .report-filter .btn {
    flex: 1 1 100%;
  }
  .report-chart {
    padding-bottom: 4px;
    gap: 3px;
  }
  .chart-col {
    flex: 1 1 0;
    min-width: 16px;
  }
  .chart-x {
    font-size: 0.55rem;
  }
  .aging-grid {
    grid-template-columns: 1fr 1fr;
  }
  .aging-cell:nth-child(2n) {
    border-right: 0;
  }
  .aging-cell:nth-child(-n+2) {
    border-bottom: 1px solid var(--border);
  }
  .mini-table th,
  .mini-table td {
    padding-left: 12px;
    padding-right: 12px;
  }
  .panel-tools {
    width: 100%;
  }
  .panel-tools .btn {
    flex: 1;
  }
  .toolbar {
    padding: 10px;
  }
  .search-field {
    max-width: none;
    flex: 1 1 100%;
  }
  .toolbar .select-compact {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 {
    grid-column: auto;
  }
  .form-actions .btn {
    flex: 1;
  }
  .scroll-hint {
    display: block;
  }
  .items-table {
    min-width: 820px;
  }
  .sheet {
    width: 100%;
    border-left: 0;
  }
  .auth-card {
    grid-template-columns: 1fr;
  }
  .auth-aside {
    padding: 24px;
  }
  .auth-aside h1 {
    margin: 14px 0 8px;
    font-size: 1.3rem;
  }
  .auth-points,
  .auth-meta {
    display: none;
  }
  .auth-form-panel {
    padding: 26px 22px;
  }
  .auth-wrap {
    min-height: 0;
    padding: 8px 0;
  }
  .table-footer {
    gap: 8px;
  }
  .bulk-bar {
    flex-wrap: wrap;
  }
  /* stacked cards for small data tables */
  .data-table.is-stacked thead {
    display: none;
  }
  .data-table.is-stacked tbody,
  .data-table.is-stacked tr,
  .data-table.is-stacked td {
    display: block;
    width: 100%;
  }
  .data-table.is-stacked tbody tr {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
  }
  .data-table.is-stacked tbody tr:last-child {
    border-bottom: 0;
  }
  .data-table.is-stacked tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 5px 0;
    border: 0;
    text-align: right;
  }
  .data-table.is-stacked tbody td::before {
    content: attr(data-label);
    color: var(--muted-foreground);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 auto;
  }
  .data-table.is-stacked td.check-cell {
    justify-content: flex-end;
  }
  .data-table.is-stacked td.check-cell::before {
    content: "Select";
  }
  .data-table.is-stacked tbody td.cell-amount {
    gap: 4px;
  }
  .data-table.is-stacked tbody td.cell-amount::before {
    margin-right: auto;
  }
  .data-table.is-stacked td.cell-actions {
    justify-content: flex-end;
  }
  .data-table.is-stacked .row-actions {
    justify-content: flex-end;
  }
  .settings-tabs {
    margin-bottom: 16px;
  }
  .settings-tab {
    height: 40px;
    padding: 0 12px;
  }
  .form-grid.three {
    grid-template-columns: 1fr;
  }
  .logo-field {
    flex-direction: column;
  }
  .logo-preview {
    width: 100%;
    flex-basis: auto;
  }
  .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .template-card {
    padding: 6px;
  }
  .template-desc {
    display: none;
  }
  .design-grid,
  .design-grid.two {
    grid-template-columns: 1fr;
  }
  .switch-grid {
    grid-template-columns: 1fr;
  }
  .designer-actions {
    position: static;
  }
  .designer-actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }
  .designer-preview iframe {
    height: 60vh;
    min-height: 380px;
  }
  .test-links {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .brand-sub {
    display: none;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .stat {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .stat:last-child {
    border-bottom: 0;
  }
  .report-filter .filter-field {
    flex-basis: 100%;
  }
  .aging-grid {
    grid-template-columns: 1fr;
  }
  .aging-cell {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .aging-cell:nth-child(-n+2) {
    border-bottom: 1px solid var(--border);
  }
  .aging-cell:last-child {
    border-bottom: 0;
  }
  .share-summary {
    grid-template-columns: 1fr;
  }
  .share-summary > div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .share-summary > div:last-child {
    border-bottom: 0;
  }
  .share-actions {
    grid-template-columns: 1fr;
  }
}

/* ---------- print page fallback ---------- */

@media print {
  .site-header,
  .site-footer,
  .page-actions,
  .toolbar,
  .sheet,
  .sheet-backdrop {
    display: none !important;
  }
}
