/* Local UI font */
@font-face {
  font-family: 'Modam';
  src: url('assets/fonts/Modam-ExtraLight.ttf') format('truetype');
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Modam';
  src: url('assets/fonts/Modam-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Modam';
  src: url('assets/fonts/Modam-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Modam';
  src: url('assets/fonts/Modam-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Modam';
  src: url('assets/fonts/Modam-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Modam';
  src: url('assets/fonts/Modam-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Modam';
  src: url('assets/fonts/Modam-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Modam';
  src: url('assets/fonts/Modam-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* Dashboard theme and reusable UI components */
:root {
  --background: #f8fafc;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --primary: #0f766e;
  --primary-foreground: #ffffff;
  --accent: #fef3c7;
  --accent-foreground: #92400e;
  --destructive: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --ring: #14b8a6;
  --sidebar-width: 16rem;
  --sidebar-collapsed: 4.5rem;
  --shell-header-height: 4.5rem;
  --radius: 0.75rem;
  --shadow-card: 0 1px 3px rgb(15 23 42 / 0.06), 0 4px 12px rgb(15 23 42 / 0.04);
  --font-sans: 'Modam', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

html.dark {
  --background: #0a0a0b;
  --foreground: #f8fafc;
  --card: #18181b;
  --card-foreground: #f8fafc;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --border: #3f3f46;
  --primary: #2dd4bf;
  --primary-foreground: #042f2e;
  --accent: #422006;
  --accent-foreground: #fde68a;
  --shadow-card: 0 1px 3px rgb(0 0 0 / 0.4), 0 4px 12px rgb(0 0 0 / 0.25);
}

html {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  transition: background 0.2s, color 0.2s;
}

/* Modam on all UI — form controls do not inherit font by default */
button,
input,
select,
textarea,
optgroup,
option,
label,
.btn,
.btn-icon,
.input,
.select,
.textarea,
.nav-item,
.tab-btn,
.badge,
.toast,
.label,
.data-table,
.data-table th,
.data-table td,
.modal-panel,
.modal-title,
.modal-body,
.modal-footer,
.sidebar,
.sidebar-brand,
.topbar,
.page-content,
.page-title,
.page-desc,
.card,
.card-header,
.card-title,
.card-body,
.stat-card,
.stat-label,
.stat-value,
.notif-item,
.notif-dropdown,
.alert-banner,
.empty-state,
.tabs,
#toast-root,
#app,
#print-area,
.invoice-print,
.shipping-label,
.font-medium,
.font-semibold,
.font-bold {
  font-family: var(--font-sans);
}

button,
input,
select,
textarea,
.btn {
  font-feature-settings: inherit;
}

#app {
  display: flex;
  min-height: 100vh;
}

.icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  display: block;
}

svg.icon {
  overflow: visible;
}

.icon-lg {
  width: 1.5rem;
  height: 1.5rem;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width 0.25s ease, transform 0.25s ease;
  box-shadow: var(--shadow-card);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  box-sizing: border-box;
  height: var(--shell-header-height);
  min-height: var(--shell-header-height);
  max-height: var(--shell-header-height);
  flex-shrink: 0;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-footer-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Collapsed nav: fixed square buttons — labels must not affect height */
.sidebar.collapsed .nav-item {
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 0;
  width: 2.5rem;
  height: 2.5rem;
  min-height: 2.5rem;
  max-height: 2.5rem;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.sidebar.collapsed .nav-item .nav-label {
  display: none;
}

.sidebar.collapsed .nav-icon-slot {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
}

.sidebar.collapsed .sidebar-nav {
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar.collapsed .sidebar-footer {
  padding: 0.75rem 0.5rem;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .sidebar-footer .nav-item {
  margin-bottom: 0;
}

.brand-logo-wrap {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #d97706, #b45309);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-logo-wrap .icon {
  width: 1.25rem;
  height: 1.25rem;
  color: #fff;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
}

.nav-icon-slot {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon-slot .icon {
  width: 1.25rem;
  height: 1.25rem;
  opacity: 0.9;
}

.nav-item:hover .nav-icon-slot .icon,
.nav-item.active .nav-icon-slot .icon {
  opacity: 1;
  color: var(--primary);
}

.nav-item .nav-label {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
  text-align: right;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: right;
}

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

.nav-item.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

/* Sidebar accordion groups */
.sidebar-group {
  margin-bottom: 0.15rem;
}

.sidebar-group-toggle {
  position: relative;
}

.sidebar-group-chevron {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.75;
}

.sidebar-group-chevron .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.sidebar-group-chevron.is-open {
  transform: rotate(-90deg);
}

.sidebar-group.has-active-child > .sidebar-group-toggle {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.sidebar-group-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
  overflow: hidden;
}

.sidebar-group-panel-inner {
  min-height: 0;
  overflow: hidden;
}

.sidebar-group-panel.is-open {
  grid-template-rows: 1fr;
}

.sidebar-group-panel.is-open .sidebar-group-panel-inner {
  overflow: visible;
  padding-block-end: 0.15rem;
}

.sidebar--accordion .sidebar-route,
.sidebar--accordion .sidebar-group-toggle,
.sidebar--accordion .sidebar-group .sidebar-group {
  margin-inline-end: 0;
}

.sidebar-item-level-1 > .sidebar-group-toggle,
.sidebar-item-level-1.sidebar-route {
  padding-inline-start: 1.35rem;
}

.sidebar-item-level-2 > .sidebar-group-toggle,
.sidebar-item-level-2.sidebar-route {
  padding-inline-start: 2rem;
}

.sidebar-item-level-3 > .sidebar-group-toggle,
.sidebar-item-level-3.sidebar-route {
  padding-inline-start: 2.65rem;
}

.sidebar-route.is-active,
.sidebar-route.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.sidebar.collapsed .sidebar-group-chevron,
.sidebar.collapsed .sidebar-group-panel {
  display: none;
}

.sidebar.collapsed .sidebar-group.has-active-child > .sidebar-group-toggle {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.sidebar-footer .sidebar-mobile-close {
  display: none;
}

/* Hamburger — mobile only (override .btn-icon) */
.btn-icon.mobile-menu-btn {
  display: inline-flex;
}

@media (min-width: 768px) {
  .btn-icon.mobile-menu-btn {
    display: none !important;
  }
}

.logo-placeholder {
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: 5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.logo-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-upload-btn {
  margin-bottom: 0.35rem;
}

.sidebar-brand-field {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.sidebar.collapsed .brand-logo-wrap {
  margin: 0 auto;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.main-wrap {
  flex: 1;
  margin-right: var(--sidebar-width);
  transition: margin-right 0.25s ease;
  min-width: 0;
}

.sidebar.collapsed ~ .main-wrap {
  margin-right: var(--sidebar-collapsed);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  box-sizing: border-box;
  height: var(--shell-header-height);
  min-height: var(--shell-header-height);
  max-height: var(--shell-header-height);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--background) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-content {
  padding: 1.25rem;
  max-width: 1400px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.page-desc {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin: 0 0 1.5rem;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
}

.card-body {
  padding: 1.25rem;
}

.stat-card {
  padding: 1.25rem;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-trend {
  font-size: 0.75rem;
  margin-top: 0.35rem;
  color: var(--success);
}

/* Buttons */
.btn .icon,
.btn-icon .icon,
.tab-btn .icon {
  flex-shrink: 0;
}

.btn-sm .icon {
  width: 1rem;
  height: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

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

.btn-outline:hover:not(:disabled) {
  background: var(--muted);
}

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

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

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

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}

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

/* Forms */
.input, .select, .textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--card);
  color: var(--foreground);
}

.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid var(--ring);
  outline-offset: 0;
  border-color: var(--ring);
}

.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--foreground);
}

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

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

table.data-table th,
table.data-table td {
  padding: 0.75rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  font-weight: 600;
  color: var(--muted-foreground);
  background: var(--muted);
  font-size: 0.8125rem;
}

table.data-table tr:hover td {
  background: color-mix(in srgb, var(--muted) 50%, transparent);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid transparent;
}

.badge-success {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
}

.badge-warning {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
}

.badge-info {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
}

.badge-destructive {
  background: color-mix(in srgb, var(--destructive) 15%, transparent);
  color: var(--destructive);
}

.badge-secondary {
  background: var(--muted);
  color: var(--muted-foreground);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  animation: slideUp 0.2s ease;
}

.modal-panel.modal-lg {
  max-width: 42rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.brand-settings-page .brand-settings-brand-block {
  display: grid;
  gap: 0.75rem;
}

.brand-settings-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

@media (max-width: 767px) {
  .brand-settings-cards {
    grid-template-columns: 1fr;
  }
}

.brand-settings-upload-btn {
  justify-content: center;
}

.brand-settings-accent-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.brand-settings-accent-swatch {
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  background: var(--preview-accent, var(--primary-gradient, var(--primary)));
  border: 2px solid rgb(255 255 255 / 0.8);
  box-shadow: var(--shadow-card);
  flex-shrink: 0;
}

.brand-settings-accent-sample {
  margin-inline-start: auto;
  background: var(--preview-accent, var(--primary-gradient, var(--primary)));
  border-color: transparent;
  color: #fff;
}

.brand-settings-accent-picker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-settings-color-input {
  width: 3rem;
  height: 3rem;
  padding: 0.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
}

.brand-settings-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.brand-settings-preset {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.brand-settings-preset span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.brand-settings-preset.active {
  border-color: var(--foreground);
}

.brand-settings-gradient-presets {
  gap: 0.65rem;
}

.brand-settings-gradient-preset {
  width: 3.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
}

.brand-settings-gradient-preset span {
  border-radius: inherit;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Notifications dropdown */
.notif-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 0.5rem);
  width: 20rem;
  max-height: 24rem;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: none;
}

.notif-dropdown.open {
  display: block;
}

.notif-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  cursor: pointer;
}

.notif-item:hover {
  background: var(--muted);
}

.notif-item.unread {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.notif-badge {
  position: absolute;
  top: -2px;
  left: -2px;
  min-width: 1.125rem;
  height: 1.125rem;
  font-size: 0.65rem;
  background: var(--destructive);
  color: #fff;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast */
#toast-root {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  font-size: 0.875rem;
  animation: slideUp 0.2s ease;
}

.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--destructive); }

.toast-out {
  opacity: 0;
  transform: translateY(4px);
  transition: 0.2s;
}

/* Charts */
.chart-canvas {
  width: 100%;
  height: 220px;
  display: block;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted-foreground);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  z-index: 35;
}

@media (max-width: 767px) {
  .sidebar {
    transform: translateX(100%);
    width: var(--sidebar-width) !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.mobile-open ~ .sidebar-overlay {
    display: block;
  }

  .sidebar .sidebar-footer .sidebar-desktop-collapse {
    display: none;
  }

  .sidebar .sidebar-footer .sidebar-mobile-close {
    display: flex;
  }

  .main-wrap {
    margin-right: 0 !important;
  }
}

/* Print invoice */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area *, #print-root, #print-root * { visibility: visible; }
  #print-area {
    position: absolute;
    inset: 0;
    padding: 2rem;
    background: #fff;
    color: #000;
  }
  body:not(.invoice-printing-thermal-80):not(.invoice-printing-thermal-58) #print-root {
    position: absolute;
    inset: 0;
    background: #fff;
    color: #000;
  }

  body.invoice-printing-thermal-80 #print-root,
  body.invoice-printing-thermal-58 #print-root {
    position: relative;
    inset: auto;
    width: auto;
    height: auto;
    background: #fff;
    color: #000;
  }
  .sidebar, .modal-backdrop, .topbar, .no-print { display: none !important; }
}

.invoice-print {
  font-family: var(--font-sans);
  direction: rtl;
  max-width: 210mm;
  margin: 0 auto;
}

.shipping-label {
  width: 100mm;
  border: 2px dashed #000;
  padding: 1rem;
  font-size: 12px;
}

/* Reusable invoice builder and PDF-ready print view */
.invoice-builder-modal {
  max-width: min(76rem, calc(100vw - 2rem));
}

.invoice-preview-modal {
  max-width: min(64rem, calc(100vw - 2rem));
}

.invoice-builder-form .invoice-items-editor th,
.invoice-builder-form .invoice-items-editor td {
  vertical-align: top;
}

.invoice-items-editor input,
.invoice-items-editor textarea {
  min-width: 7rem;
}

.invoice-totals-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
}

.invoice-totals-editor > div,
.invoice-total-box > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.invoice-branding-logo-preview {
  width: 100%;
  min-height: 7rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  overflow: hidden;
}

.invoice-branding-logo-img {
  max-width: 14rem;
  max-height: 7rem;
  object-fit: contain;
}

.invoice-preview {
  direction: rtl;
  background: #fff;
  color: #111827;
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--border);
}

.invoice-preview-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.invoice-preview-header,
.invoice-parties,
.invoice-bottom {
  display: grid;
  grid-template-columns: 1fr 0.85fr;
  gap: 1.5rem;
}

.invoice-preview-header {
  align-items: start;
  border-bottom: 2px solid #111827;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
}

.invoice-brand-block {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.invoice-logo,
.invoice-logo-placeholder {
  width: 6rem;
  height: 6rem;
  flex-shrink: 0;
  object-fit: contain;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.invoice-logo-placeholder {
  color: #6b7280;
  background: #f9fafb;
}

.invoice-preview h1,
.invoice-preview h2,
.invoice-preview h3,
.invoice-preview p {
  margin-top: 0;
}

.invoice-preview h1 {
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
}

.invoice-preview h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.invoice-preview h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.invoice-preview p {
  font-size: 0.85rem;
  line-height: 1.8;
  margin-bottom: 0.25rem;
}

.invoice-meta-block {
  text-align: left;
}

.invoice-meta-block p {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.invoice-parties {
  margin-bottom: 1.25rem;
}

.invoice-print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 1.25rem;
}

.invoice-print-table th,
.invoice-print-table td {
  border: 1px solid #d1d5db;
  padding: 0.55rem;
  text-align: right;
  vertical-align: top;
}

.invoice-print-table th {
  background: #f3f4f6;
  font-weight: 700;
}

.invoice-notes {
  min-height: 7rem;
}

.invoice-total-box {
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 0.85rem;
  display: grid;
  gap: 0.55rem;
  align-self: start;
}

.invoice-total-final {
  border-top: 1px solid #d1d5db;
  padding-top: 0.55rem;
  font-size: 1.05rem;
}

.invoice-footer {
  margin-top: 2rem;
  padding-top: 0.85rem;
  border-top: 1px solid #d1d5db;
  text-align: center;
  font-size: 0.82rem;
  color: #4b5563;
}

#print-area {
  background: #fff;
}

@page {
  size: A4 portrait;
  margin: 14mm;
}

@media (max-width: 700px) {
  .invoice-preview {
    padding: 1rem;
  }

  .invoice-preview-header,
  .invoice-parties,
  .invoice-bottom {
    grid-template-columns: 1fr;
  }

  .invoice-meta-block {
    text-align: right;
  }

  .invoice-brand-block {
    flex-direction: column;
  }
}

@media print {
  html,
  body,
  #print-area {
    background: #fff !important;
    color: #000 !important;
  }

  #print-area {
    position: absolute;
    inset: 0;
    width: 100%;
    padding: 0;
  }

  #print-area .invoice-preview {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    color: #000;
    background: #fff;
  }

  .invoice-preview-controls,
  .no-print {
    display: none !important;
  }

  .invoice-preview-header,
  .invoice-parties,
  .invoice-bottom,
  .invoice-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .invoice-print-table {
    page-break-inside: auto;
  }

  .invoice-print-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .invoice-print-table thead {
    display: table-header-group;
  }

  .invoice-print-table tfoot {
    display: table-footer-group;
  }

  .invoice-logo {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

.text-muted { color: var(--muted-foreground); }
.text-success { color: var(--success); }
.text-destructive { color: var(--destructive); }

.kbd-hint {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.search-box {
  max-width: 16rem;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 16rem;
}

.input-with-icon > .icon {
  position: absolute;
  right: 0.75rem;
  color: var(--muted-foreground);
  pointer-events: none;
}

.input-with-icon .input {
  padding-right: 2.5rem;
}

.jalali-date {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr 0.9fr;
  gap: 0.5rem;
  width: 100%;
}

@media (max-width: 480px) {
  .jalali-date {
    grid-template-columns: 1fr;
  }
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  overflow-x: auto;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border: none;
  background: none;
  color: var(--muted-foreground);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.product-thumb {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  object-fit: cover;
  background: var(--muted);
}

.alert-banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--warning);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--accent-foreground);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

html.dark .alert-banner {
  color: #fde68a;
}
