:root {
  --sidebar-w: 228px;
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #0f1117;
  --text-2: #374151;
  --muted: #9099a8;
  --line: #eaecf0;
  --line-2: #f3f4f6;
  --accent: #003c71;
  --accent-light: #e6eef5;
  --accent-dark: #002952;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warn: #d97706;
  --warn-light: #fffbeb;
  --sidebar-bg: #ffffff;
  --sidebar-text: #6b7280;
  --sidebar-active: #1f2937;
  --sidebar-hover: #f9fafb;
  --radius: 8px;
  --radius-lg: 10px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 8px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.mobile-nav-open {
  overflow: hidden;
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 17px 16px 15px;
  border-bottom: 1px solid var(--line);
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 2px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(230, 238, 245, 0.92));
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 10px 24px rgba(0, 60, 113, 0.12);
  overflow: hidden;
}

.logo-mark {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  object-fit: cover;
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.nav-menu {
  list-style: none;
  padding: 8px 8px;
  flex: 1;
}

.nav-menu li { margin-bottom: 1px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--text-2);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 600;
}

.nav-icon {
  width: 16px;
  min-width: 16px;
  flex-shrink: 0;
  opacity: 0.65;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-label {
  line-height: 1.2;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 50px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  min-width: 0;
  max-width: 100%;
}

/* ── Status Bar ── */
.status-bar {
  min-height: 0;
  padding: 0 24px;
  font-size: 12.5px;
  color: var(--muted);
  transition: all 0.15s;
}

.status-bar:not(:empty) {
  padding: 7px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.status-bar.error { color: var(--danger); background: var(--danger-light); border-bottom-color: #fecaca; }

/* ── Loading Banner ── */
.loading-banner {
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: var(--accent-light);
  border: 1px solid #b3c9e0;
  border-radius: var(--radius);
  color: var(--accent-dark);
  font-size: 12.5px;
  font-weight: 500;
}

.loading-banner.visible { display: flex; }

.loading-spinner {
  width: 13px; height: 13px;
  border: 2px solid #b3c9e0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pages ── */
.page {
  padding: 24px;
  min-width: 0;
  max-width: 100%;
}
.hidden { display: none !important; }

/* ── Dashboard ── */
.dashboard-widget-manager {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, 100%);
  padding: 14px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  z-index: 40;
}

.dashboard-widget-manager-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.dashboard-widget-manager-title {
  font-size: 13px;
  font-weight: 700;
}

.dashboard-widget-manager-sub {
  font-size: 12px;
  color: var(--muted);
}

.dashboard-widget-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dashboard-widget-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.dashboard-widget-list-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dashboard-widget-list-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.dashboard-widget-list-state {
  font-size: 11.5px;
  color: var(--muted);
}

.dashboard-widget-list-item button {
  min-width: 88px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
  /* Inset by 4px each side to align with the 4px widget-content inset */
  padding: 0 4px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
}

.stat-card[data-dashboard-target-page] {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.stat-card[data-dashboard-target-page]:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.stat-card[data-dashboard-target-page]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-card.accent {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
}

.stat-card.accent .stat-label,
.stat-card.accent .stat-sub { color: #fff; }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.stat-sub {
  font-size: 12px;
  color: var(--muted);
}

.dashboard-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  font-size: 13.5px;
  font-weight: 600;
}

/* ── Orders Toolbar ── */
.orders-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  min-width: 0;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.search-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s;
  min-width: 0;
  max-width: 100%;
}

.search-group:focus-within { border-color: var(--accent); }

.search-input {
  border: none;
  outline: none;
  padding: 7px 11px;
  min-width: 220px;
  width: 100%;
  max-width: 100%;
  font-size: 13px;
  background: transparent;
  color: var(--text);
}

input[readonly].search-input {
  background: var(--line-2);
  color: var(--muted);
}

.search-group .btn-icon {
  border: none;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 7px 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  box-shadow: none;
}

.search-group .btn-icon:hover { background: var(--line-2); color: var(--text-2); }

/* ── Buttons ── */
button,
a.btn-primary,
a.btn-secondary {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: background 0.1s, border-color 0.1s;
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
}

button:hover,
a.btn-primary:hover,
a.btn-secondary:hover { background: var(--line-2); border-color: #d1d5db; text-decoration: none; }
button:active,
a.btn-primary:active,
a.btn-secondary:active { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
  box-shadow: 0 1px 3px rgba(37,99,235,.2);
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-secondary {
  background: var(--card);
  border-color: var(--line);
  color: var(--text-2);
}

.btn-secondary:hover { background: var(--line-2); }

.btn-icon { padding: 6px 9px; }

button i[class^="ri-"],
button i[class*=" ri-"] {
  font-size: 15px;
  line-height: 1;
}

/* ── Select / Inputs ── */
select {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
}

input:not([type="checkbox"]):not(.search-input) {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 13px;
  background: var(--card);
  box-shadow: var(--shadow);
}

textarea {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 13px;
  background: var(--card);
  box-shadow: var(--shadow);
  resize: vertical;
  min-height: 120px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  width: 100%;
  max-width: 100%;
}

input[type="file"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

input[type="checkbox"] {
  width: 16px; height: 16px;
  min-width: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Page Sections ── */
.page-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-xs);
}

.page-panel-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.page-panel-header h2 {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.page-panel-header p {
  font-size: 13px;
  color: var(--muted);
}

.options-page-content,
.logs-page-content,
.other-tools-page-content,
.cardmarket-orders-page-content {
  display: grid;
  gap: 20px;
  min-width: 0;
  max-width: 100%;
}

.other-tools-page-content {
  gap: 24px;
}

.cardmarket-orders-page-content {
  gap: 18px;
}

.logs-page-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0;
}

.invoice-orders-page-content {
  display: grid;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}

.restock-page-content {
  display: grid;
  gap: 8px;
}

.restock-page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.restock-help-inline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12.5px;
}

.restock-help-inline code {
  font-size: 0.95em;
}

.restock-help-label {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(230, 238, 245, 0.9);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.restock-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.restock-empty {
  grid-column: 1 / -1;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.72);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.restock-section-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  background: var(--card);
  overflow: hidden;
}

.restock-section-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 164px;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.restock-section-main {
  display: grid;
  gap: 12px;
}

.restock-section-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 196px;
  gap: 12px;
  align-items: end;
}

.restock-section-actions,
.restock-filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.restock-section-title-row input {
  min-width: 0;
  width: 100%;
}

.restock-days-control {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.restock-days-control span {
  margin-bottom: 0;
}

.restock-section-actions {
  display: grid;
  grid-auto-flow: row;
  justify-items: stretch;
  align-self: end;
  align-content: end;
  gap: 8px;
  min-width: 0;
}

.restock-section-actions button {
  width: 100%;
}

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

.btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.restock-section-body {
  padding: 18px;
  display: grid;
  gap: 18px;
  background: var(--bg);
}

.restock-section-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.restock-stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 14px 16px;
}

.restock-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}

.restock-stat-value {
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.restock-filters {
  display: grid;
  gap: 10px;
}

.restock-filters.collapsed .restock-filters-body {
  display: none;
}

.restock-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.restock-filter-toggle {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  min-height: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
}

.restock-filter-toggle:hover {
  background: transparent;
  border-color: transparent;
}

.restock-filter-toggle .tool-card-kicker {
  margin-bottom: 0;
}

.restock-filter-toggle-icon {
  font-size: 12px;
  color: var(--muted);
}

.restock-filters-note {
  font-size: 12px;
  color: var(--muted);
}

.restock-filters-body {
  display: grid;
  gap: 10px;
}

.restock-filter-row select,
.restock-filter-row input {
  min-width: 170px;
}

.restock-filter-row input {
  flex: 1;
}

.restock-results-wrap {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 430px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
}

.restock-results-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.restock-results-table th,
.restock-results-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

.restock-results-table th:first-child,
.restock-results-table td:first-child {
  width: 42%;
}

.restock-results-table th:nth-child(2),
.restock-results-table td:nth-child(2),
.restock-results-table th:nth-child(3),
.restock-results-table td:nth-child(3),
.restock-results-table th:nth-child(4),
.restock-results-table td:nth-child(4),
.restock-results-table th:nth-child(5),
.restock-results-table td:nth-child(5) {
  width: 10%;
}

.restock-results-table th:nth-child(6),
.restock-results-table td:nth-child(6) {
  width: 11%;
}

.restock-results-table th:nth-child(7),
.restock-results-table td:nth-child(7) {
  width: 17%;
}

.restock-results-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.restock-sort-btn {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  min-height: 0;
  font: inherit;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.restock-sort-btn:hover {
  background: transparent;
  border-color: transparent;
}

.restock-sort-indicator {
  font-size: 12px;
  color: var(--muted);
}

.restock-results-table tbody tr:last-child td {
  border-bottom: none;
}

.restock-results-table tbody tr:hover {
  background: #fafbfc;
}

.restock-results-table tbody tr {
  height: 56px;
}

.restock-results-table .st-name,
.restock-results-table .st-sku {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.restock-results-table .st-name {
  line-height: 1.35;
}

.restock-results-table td:last-child {
  padding-right: 8px;
}

.restock-status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 10.5px;
  font-weight: 700;
  max-width: 100%;
}

.restock-status-badge.low {
  color: var(--danger);
  background: var(--danger-light);
}

.restock-status-badge.warn {
  color: var(--warn);
  background: var(--warn-light);
}

.restock-status-badge.ok {
  color: var(--success);
  background: var(--success-light);
}

@media (max-width: 1400px) {
  .restock-section-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .restock-page-toolbar,
  .restock-section-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .restock-help-inline {
    padding: 0;
  }

  .restock-sections {
    grid-template-columns: 1fr;
  }

  .restock-section-title-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .restock-section-meta {
    grid-template-columns: 1fr;
  }

  .restock-help-inline {
    flex-direction: column;
    align-items: flex-start;
  }
}

.invoice-flow-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  background: var(--card);
  padding: 18px;
  min-width: 0;
  max-width: 100%;
}

.invoice-flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.invoice-flow-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.invoice-flow-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.invoice-flow-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

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

.invoice-flow-table th,
.invoice-flow-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12.5px;
  vertical-align: top;
}

.invoice-flow-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.invoice-flow-table tbody tr:last-child td {
  border-bottom: none;
}

.invoice-flow-empty {
  text-align: center;
  color: var(--muted);
}

.invoice-flow-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.invoice-flow-status.ok {
  color: var(--success);
  background: var(--success-light);
}

.invoice-flow-status.error {
  color: var(--danger);
  background: var(--danger-light);
}

.invoice-flow-status.warn {
  color: var(--warn);
  background: var(--warn-light);
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-modal.hidden {
  display: none !important;
}

.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
}

.app-modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.97), rgba(241,247,255,0.95));
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
}

.app-modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.app-modal-header h3 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.app-modal-body {
  padding: 22px 24px 18px;
  display: grid;
  gap: 14px;
}

.app-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 24px;
  flex-wrap: wrap;
}

.invoice-flow-modal-order {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.invoice-flow-modal-prompt {
  font-size: 15px;
  color: var(--text-2);
}

.confirm-modal-card {
  width: min(560px, 100%);
}

.config-import-modal-card {
  width: min(760px, 100%);
}

.confirm-modal-message {
  margin: 0;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-2);
}

.invoice-flow-modal-error {
  margin: 0;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 244, 244, 0.92);
  border: 1px solid #fecaca;
  color: #991b1b;
  white-space: pre-wrap;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.tool-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  background: var(--card);
  padding: 18px;
}

.tool-card-header h3,
.label-preview-header h3,
.settings-section-header h3,
.reports-header h3,
.reports-viewer-header h3,
.page-panel-header h2 {
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.tool-card-header h3 {
  margin-bottom: 8px;
}

.tool-card-header p,
.settings-section-header p,
.reports-header p,
.page-panel-header p {
  color: var(--muted);
}

.tool-card-header p,
.page-panel-header p {
  max-width: 760px;
}

.tool-card-kicker,
.label-preview-kicker,
.settings-section-kicker,
.page-panel-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-card-kicker {
  margin-bottom: 8px;
}

.label-preview-kicker,
.settings-section-kicker,
.page-panel-kicker {
  margin-bottom: 6px;
}

.tool-form {
  display: grid;
  grid-template-columns: minmax(240px, 360px) auto;
  gap: 16px;
  align-items: end;
  margin-top: 18px;
}

.tool-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tool-result {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.tool-result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tool-result-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.tool-summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 14px;
}

.tool-summary-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.tool-summary-value {
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.tool-result-meta {
  margin-bottom: 14px;
  color: var(--text-2);
}

.tool-inline-meta {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.tool-result-table-wrap {
  overflow-x: auto;
}

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

.tool-result-table th,
.tool-result-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12.5px;
  vertical-align: top;
}

.tool-result-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.tool-result-empty {
  text-align: center;
  color: var(--muted);
  padding: 20px 12px;
}

.cardmarket-orders-grid,
.cardmarket-mapping-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
  min-width: 0;
  max-width: 100%;
}

.cardmarket-csv-field {
  grid-column: 1 / -1;
}

.cardmarket-csv-field textarea {
  min-height: 280px;
  resize: vertical;
}

.cardmarket-orders-actions,
.cardmarket-mappings-result {
  margin-top: 18px;
  min-width: 0;
  max-width: 100%;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.cardmarket-status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cardmarket-status-badge.ready,
.cardmarket-status-badge.success {
  color: var(--success);
  background: var(--success-light);
}

.cardmarket-status-badge.already_processed,
.cardmarket-status-badge.skipped {
  color: var(--muted);
  background: rgba(226, 232, 240, 0.8);
}

.cardmarket-status-badge.needs_mapping {
  color: var(--warn);
  background: var(--warn-light);
}

.cardmarket-status-badge.failed {
  color: var(--danger);
  background: var(--danger-light);
}

.label-generator-sections {
  display: grid;
  gap: 20px;
  min-width: 0;
  max-width: 100%;
}

.label-generator-page-content {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(280px, 0.9fr);
  gap: 20px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

.import-psa-page-content {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(300px, 0.95fr);
  gap: 20px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

.label-generator-layout,
.label-generator-form {
  display: block;
  min-width: 0;
  max-width: 100%;
}

.import-psa-layout {
  display: block;
  min-width: 0;
  max-width: 100%;
}

.label-generator-form {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 18px;
  background: var(--card);
  min-width: 0;
  max-width: 100%;
}

.import-psa-form-card,
.import-psa-summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 18px;
  background: var(--card);
  min-width: 0;
  max-width: 100%;
}

.import-psa-textarea {
  min-height: 240px;
  resize: vertical;
  font: inherit;
}

.import-psa-helper {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.import-psa-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 18px;
}

.import-psa-summary-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.import-psa-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.import-psa-stat-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--bg);
}

.import-psa-stat-card.ok {
  border-color: rgba(7, 126, 105, 0.18);
}

.import-psa-stat-card.warn {
  border-color: rgba(184, 103, 0, 0.18);
}

.import-psa-stat-card.danger {
  border-color: rgba(184, 47, 62, 0.18);
}

.import-psa-stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.import-psa-stat-card strong {
  font-size: 24px;
  line-height: 1;
}

.import-psa-report-section + .import-psa-report-section {
  margin-top: 18px;
}

.import-psa-report-section h4 {
  font-size: 13px;
  margin-bottom: 8px;
}

.import-psa-report-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.import-psa-report-list li,
.import-psa-report-empty {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg);
  font-size: 12.5px;
  line-height: 1.45;
}

.import-psa-inline-meta {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  min-width: 0;
  max-width: 100%;
}

.field-group span {
  color: var(--text-2);
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.label-generator-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 18px;
  min-width: 0;
  max-width: 100%;
}

.label-preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 18px;
  background: var(--card);
  min-width: 0;
  max-width: 100%;
}

.label-history-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 22px 24px;
  background: var(--card);
  min-width: 0;
  max-width: 100%;
}

.label-history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.label-history-header h3 {
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.label-history-table-wrap {
  overflow-x: auto;
}

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

.label-history-table th,
.label-history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12.5px;
  vertical-align: middle;
}

.label-history-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.label-history-table tbody tr:last-child td {
  border-bottom: none;
}

.label-history-actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.label-history-action {
  min-height: 32px;
  padding: 6px 10px;
}

.label-history-delete {
  min-height: 32px;
  padding: 6px 10px;
  color: var(--danger);
  border-color: #fecaca;
  background: var(--danger-light);
}

.label-history-empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px 18px;
}

.label-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.label-preview-size {
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.warehouse-label-preview {
  min-height: 280px;
}

.warehouse-preview-placeholder {
  min-height: 280px;
  border: 1px dashed #c9d4e1;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

.warehouse-label-sheet {
  border: 1px solid #d8e0ea;
  border-radius: 16px;
  min-height: 280px;
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.warehouse-label-sheet-reference {
  justify-content: space-between;
  aspect-ratio: 1.5 / 1;
}

.warehouse-reference-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.warehouse-reference-brand {
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 14px;
}

.warehouse-reference-company {
  font-size: 19px;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.warehouse-reference-mark {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}

.warehouse-reference-meta {
  font-size: 18px;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.warehouse-reference-meta-label {
  margin-right: 6px;
}

.warehouse-reference-bottom {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  align-items: end;
  gap: 20px;
}

.warehouse-reference-pieces {
  font-size: 17px;
  line-height: 1.15;
  padding-bottom: 26px;
}

.warehouse-preview-barcode-block-reference {
  border: none;
  border-radius: 0;
  padding: 0;
  gap: 4px;
  align-items: stretch;
}

.warehouse-reference-barcode-topline,
.warehouse-reference-barcode-bottomline {
  height: 1px;
  background: #111;
}

.warehouse-preview-barcode-block-reference img {
  width: 100%;
  max-height: 92px;
  object-fit: fill;
}

.warehouse-preview-barcode-block-reference .warehouse-preview-barcode-value {
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.warehouse-sheet-collection,
.warehouse-sheet-summary,
.warehouse-summary-item,
.warehouse-summary-label,
.warehouse-preview-barcode-block:not(.warehouse-preview-barcode-block-reference),
.warehouse-preview-barcode-label {
  display: none;
}

.option-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-2);
}

.terms-manager { margin-top: 10px; }

.settings-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  padding: 18px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.settings-section + .settings-section {
  margin-top: 0;
}

.settings-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.settings-section-header p {
  font-size: 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.settings-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(248,250,252,0.92));
  box-shadow: var(--shadow-xs);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.settings-card-wide {
  grid-column: span 1;
}

.settings-card-header {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.settings-card-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.settings-config-meta {
  display: flex;
  align-items: center;
}

.config-path {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--line-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.config-group {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(248,250,252,0.92));
  box-shadow: var(--shadow-xs);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.config-group-header {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.config-group-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

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

.config-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}

#config-import-textarea {
  min-height: 320px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.settings-inline-field {
  margin-top: 16px;
}

.settings-inline-input {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.settings-inline-input input {
  width: 120px;
  min-width: 120px;
}

.settings-inline-unit {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.terms-title {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.terms-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.terms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.term-chip {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 10px 2px 8px;
  background: var(--card);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--text-2);
}

.term-move {
  border: none;
  background: transparent;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  box-shadow: none;
}

.term-remove {
  border: none;
  background: transparent;
  padding: 0 0 0 2px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  box-shadow: none;
}

.term-remove:hover { color: var(--danger); background: transparent; }

.reports-page-content {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 20px;
}

.reports-sidebar-card,
.reports-viewer-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  padding: 18px;
}

.reports-header,
.reports-viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.reports-header h3,
.reports-viewer-header h3 {
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.reports-header p {
  font-size: 13px;
  color: var(--muted);
}

.reports-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 70vh;
  overflow: auto;
}

.reports-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: var(--line-2);
}

.report-list-item {
  width: 100%;
  display: block;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.report-list-item:hover {
  border-color: rgba(14, 116, 144, 0.45);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.report-list-item.active {
  border-color: rgba(14, 116, 144, 0.8);
  background: #f0fdfa;
}

.report-list-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
}

.report-list-title {
  display: block;
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.report-list-meta {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.reports-content {
  margin: 0;
  min-height: 70vh;
  max-height: 70vh;
  overflow: auto;
  padding: 0;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--line);
}

.reports-content-empty {
  padding: 18px;
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.reports-preview-frame {
  width: 100%;
  min-height: 70vh;
  border: none;
  background: white;
}

@media (min-width: 1101px) {
  .settings-grid {
    grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.1fr);
  }

  .settings-card-wide {
    grid-column: span 2;
  }
}

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

  .settings-card-wide {
    grid-column: span 1;
  }

  .reports-page-content {
    grid-template-columns: 1fr;
  }

  .reports-list,
  .reports-content {
    max-height: none;
  }

  .reports-content {
    min-height: 50vh;
  }
}

#logs-output {
  margin-top: 0;
  background: #0f1117;
  color: #a5f3c0;
  border: 1px solid #1e2433;
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 320px;
  max-height: 70vh;
  overflow: auto;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ── Bulk Actions ── */
.bulk-actions {
  display: none;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  padding: 9px 14px;
  background: var(--accent-light);
  border: 1px solid #b3c9e0;
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.bulk-actions.visible { display: flex; }

#bulk-selected-count {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent-dark);
  margin-right: 2px;
}

/* ── Pagination ── */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  min-width: 0;
}

.pagination-left, .pagination-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 960px) {
  .config-grid,
  .label-generator-grid,
  .label-generator-page-content,
  .import-psa-page-content {
    grid-template-columns: 1fr;
  }

  .config-span-2 {
    grid-column: auto;
  }

  .settings-section-header {
    flex-direction: column;
  }

  .config-path {
    white-space: normal;
  }

  .label-history-panel {
    padding: 20px 22px;
  }
}

#page-info { font-size: 13px; color: var(--muted); }

/* ── Table ── */
.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

/* When the table is inside a scrollable widget body, remove redundant chrome */
.widget-body .orders-table {
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.widget-body .orders-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.orders-table th,
.orders-table td {
  padding: 9px 13px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 13px;
}

.orders-table th {
  background: var(--line-2);
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.orders-table tbody tr:last-child td { border-bottom: none; }

.orders-table tbody tr:hover { background: #fafbfc; }

.orders-table tbody tr.order-row {
  cursor: pointer;
}

.table-scroll .orders-table,
.invoice-flow-table-wrap .invoice-flow-table,
.label-history-table-wrap .label-history-table,
.tool-result-table-wrap table {
  min-width: max-content;
}

.order-volume-input {
  width: 72px;
  padding: 6px 8px;
}

.order-volume-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Badges ── */
.checkbox-cell {
  width: 36px;
  padding-left: 12px;
  padding-right: 4px;
}

.country-code-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--line-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-weight: 600;
  font-size: 11.5px;
}

.country-code-badge.non-pt {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
}

.paid-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--success-light);
  border: 1px solid #bbf7d0;
  color: var(--success);
  font-weight: 600;
  font-size: 11.5px;
}

.paid-badge.no {
  background: var(--danger-light);
  border-color: #fecaca;
  color: var(--danger);
}

/* ── Order Detail Row ── */
.order-detail {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--bg);
}

.order-detail h4 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.items {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.7;
}

.detail-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Tags ── */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--line-2);
  color: var(--muted);
  font-size: 11px;
  margin: 1px 1px;
}

/* ── Dashboard Widgets (GridStack) ── */
.grid-stack {
  margin-bottom: 16px;
}

.grid-stack.grid-stack-pending {
  opacity: 0;
  visibility: hidden;
}

.grid-stack.grid-stack-ready {
  opacity: 1;
  visibility: visible;
}

/* GridStack sets grid-stack-item-content to absolute fill — add inner gap via inset */
.grid-stack > .grid-stack-item > .grid-stack-item-content {
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  overflow: hidden;
  border-radius: var(--radius-lg, 10px);
}

/* Widget fills the content area completely */
.grid-stack-item-content .widget {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 10px);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.grid-stack-item-content .widget .widget-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* GridStack resize south handle — styled to match the app */
.grid-stack-item > .ui-resizable-s {
  bottom: 6px !important;
  height: 8px !important;
  cursor: s-resize;
  display: none;
  align-items: center;
  justify-content: center;
}

.grid-stack.dashboard-edit-mode .grid-stack-item > .ui-resizable-s {
  display: flex;
}

.grid-stack-item > .ui-resizable-s::after {
  content: '';
  width: 32px;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  transition: background 0.15s, width 0.1s;
  display: block;
}

.grid-stack-item:hover > .ui-resizable-s::after,
.grid-stack-item > .ui-resizable-s:hover::after {
  background: var(--accent);
  width: 48px;
}

/* GridStack drag placeholder */
.grid-stack-placeholder > .placeholder-content {
  background: var(--accent-light, #dcfce7);
  border: 2px dashed var(--accent, #16a34a);
  border-radius: var(--radius-lg, 10px);
  opacity: 0.7;
  inset: 4px;
}

.widget {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* Widget drag handle */
.widget-drag-handle {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: grab;
  color: var(--muted);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
  line-height: 1;
  user-select: none;
}

.grid-stack:not(.dashboard-edit-mode) .widget-drag-handle,
.grid-stack:not(.dashboard-edit-mode) .widget-remove-btn {
  display: none;
}

.widget-drag-handle i {
  font-size: 16px;
  line-height: 1;
}

.widget-drag-handle:hover {
  color: var(--text);
  background: var(--line);
  border: none;
}

.widget-drag-handle:active { cursor: grabbing; }

.widget.dragging-source {
  opacity: 0.45;
  box-shadow: none;
}

/* Drag ghost — kept for any tooltip/label uses */
.widget-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0.92;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
  flex-wrap: wrap;
}

.widget-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.widget-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.widget-sub {
  font-size: 12px;
  color: var(--muted);
}

.widget-select {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  box-shadow: none;
}

.widget-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.widget-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.widget-remove-btn:hover {
  background: var(--danger-light);
  border-color: #fecaca;
  color: var(--danger);
}

.dashboard-edit-toggle.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light, #dcfce7);
}

.widget-sku-input {
  width: 150px;
}

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

.widget-body {
  padding: 0;
}

.sales-chart-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.widget-loading {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.sales-trend-widget {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
  min-height: 100%;
  height: 100%;
}

.sales-trend-metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.sales-trend-chart {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 220px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(241, 245, 249, 0.55));
  border: 1px solid rgba(148, 163, 184, 0.14);
  overflow: hidden;
}

.sales-trend-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sales-trend-grid-line {
  stroke: rgba(148, 163, 184, 0.18);
  stroke-width: 1;
}

.sales-trend-axis-line {
  stroke: rgba(100, 116, 139, 0.4);
  stroke-width: 1;
}

.sales-trend-hover-line {
  stroke: rgba(15, 23, 42, 0.28);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.sales-trend-y-label {
  fill: var(--muted);
  font-size: 11px;
}

.sales-trend-hit {
  cursor: pointer;
}

.sales-trend-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.sales-trend-tooltip-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.sales-trend-tooltip-metric {
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 8px;
}

.sales-trend-tooltip-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.sales-trend-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.sales-trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

.sales-trend-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
}

.sales-trend-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.sales-pie-widget {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 220px);
  gap: 18px;
  padding: 16px 18px 18px;
  min-height: 100%;
  height: 100%;
  align-items: center;
}

.sales-pie-chart-wrap {
  position: relative;
  min-height: 260px;
  height: 100%;
}

.sales-pie-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sales-pie-center-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.sales-pie-center-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.sales-pie-center-sub {
  font-size: 12px;
  color: var(--muted);
}

.sales-pie-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.sales-pie-legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-size: 12px;
}

.sales-pie-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-pie-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.sales-pie-value {
  font-weight: 700;
  color: var(--text);
}

.sales-pie-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

/* ── Seller rows ── */
.sellers-list {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.seller-row {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-2);
  gap: 8px;
  flex: 1;
  min-height: 36px;
}

.seller-row:last-child { border-bottom: none; }

.seller-rank {
  width: 18px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
}

.seller-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.seller-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seller-sku {
  font-size: 11px;
  color: var(--muted);
  font-family: "SF Mono", "Fira Code", monospace;
}

.seller-bar-wrap {
  width: 60px;
  height: 4px;
  background: var(--line-2);
  border-radius: 2px;
  flex-shrink: 0;
}

.seller-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.seller-qty {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

/* ── Carrier & Country rows ── */
.carrier-list {
  overflow-y: auto;
  max-height: 100%;
}

.carrier-row {
  display: flex;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line-2);
  gap: 8px;
}

.carrier-row:last-child { border-bottom: none; }

.carrier-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.carrier-bar-wrap {
  width: 80px;
  height: 5px;
  background: var(--line-2);
  border-radius: 3px;
  flex-shrink: 0;
}

.carrier-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.carrier-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 22px;
  text-align: right;
}

/* ── Stock Monitor ── */
.stock-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

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

.stock-table th,
.stock-table td {
  padding: 9px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}

.stock-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--line-2);
}

.stock-table tbody tr:last-child td { border-bottom: none; }
.stock-table tbody tr:hover { background: var(--bg); }

.stock-sku-badge {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11.5px;
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-2);
}

.stock-level {
  font-weight: 700;
  font-size: 13px;
}

.stock-level.low { color: var(--danger); }
.stock-level.mid { color: var(--warn); }
.stock-level.ok  { color: var(--success); }

.stock-status-label {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

.stock-remove-btn {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 3px 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  border-radius: 4px;
  line-height: 1;
}

.stock-remove-btn:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* ── Seller stock badges ── */
.seller-stock-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.seller-stock-badge.ok  { background: #dcfce7; color: #15803d; }
.seller-stock-badge.low { background: #fef9c3; color: #a16207; }
.seller-stock-badge.out { background: #fee2e2; color: #dc2626; }

/* ── Sell-through widget ── */
.sell-through-table {
  width: 100%;
  border-collapse: collapse;
}

.sell-through-table th,
.sell-through-table td {
  padding: 8px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}

.sell-through-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--line-2);
  position: sticky;
  top: 0;
  z-index: 2;
}

.sell-through-table tbody tr:last-child td { border-bottom: none; }
.sell-through-table tbody tr:hover { background: var(--bg); }

.st-name {
  font-weight: 500;
}

.st-sku {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  color: var(--muted);
}

.st-bar-wrap { width: 48px; height: 4px; background: var(--line-2); border-radius: 2px; }
.st-bar      { height: 100%; border-radius: 2px; }
.st-bar.ok   { background: var(--success); }
.st-bar.warn { background: var(--warn); }
.st-bar.low  { background: var(--danger); }

.days-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.days-badge.ok   { background: #dcfce7; color: #15803d; }
.days-badge.warn { background: #fef9c3; color: #a16207; }
.days-badge.low  { background: #fee2e2; color: #dc2626; }
.days-badge.na   { background: var(--line-2); color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { width: 56px; }
  .logo-copy, .nav-label { display: none; }
  .main-content { margin-left: 56px; }
  .dashboard-grid { grid-template-columns: repeat(3, 1fr); }
  .widget-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Modern Apple-inspired refresh ── */
:root {
  --sidebar-w: 256px;
  --bg: #eef2f7;
  --bg-secondary: rgba(255, 255, 255, 0.52);
  --card: rgba(255, 255, 255, 0.72);
  --card-strong: rgba(255, 255, 255, 0.9);
  --text: #111827;
  --text-2: #334155;
  --muted: #64748b;
  --line: rgba(148, 163, 184, 0.2);
  --line-2: rgba(241, 245, 249, 0.96);
  --accent: #0a84ff;
  --accent-light: rgba(10, 132, 255, 0.14);
  --accent-dark: #0060df;
  --sidebar-bg: rgba(248, 250, 252, 0.62);
  --sidebar-text: #475569;
  --sidebar-hover: rgba(255, 255, 255, 0.7);
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-xs: 0 8px 22px rgba(15, 23, 42, 0.05);
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 26px 60px rgba(15, 23, 42, 0.14);
}

html {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 34%),
    linear-gradient(180deg, #f7f9fc 0%, #eef3f9 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
  background: transparent;
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.95), transparent 26%),
    radial-gradient(circle at 85% 18%, rgba(191, 219, 254, 0.55), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  pointer-events: none;
  z-index: -3;
}

.app-background {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -2;
}

.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  z-index: 105;
}

body.mobile-nav-open .mobile-nav-backdrop {
  opacity: 1;
  visibility: visible;
}

.bg-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.85;
}

.orb-blue {
  width: 28rem;
  height: 28rem;
  top: -8rem;
  right: -6rem;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.35), rgba(59, 130, 246, 0.06) 60%, transparent 72%);
}

.orb-slate {
  width: 30rem;
  height: 30rem;
  left: -10rem;
  bottom: -12rem;
  background: radial-gradient(circle, rgba(148, 163, 184, 0.18), rgba(255, 255, 255, 0.03) 62%, transparent 74%);
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.34) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.34) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.22), transparent 72%);
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: calc(var(--sidebar-w) - 16px);
  background: var(--sidebar-bg);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-right: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.sidebar-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.logo-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-subtext {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-menu {
  padding: 14px 10px;
}

.nav-menu li {
  margin-bottom: 4px;
}

.nav-item {
  padding: 11px 12px;
  border-radius: 16px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 600;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 249, 255, 0.9));
  color: var(--accent-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 10px 24px rgba(10, 132, 255, 0.12);
}

.nav-icon {
  opacity: 0.8;
}

.main-content {
  margin-left: calc(var(--sidebar-w) + 12px);
  padding: 16px 16px 24px 0;
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
}

.topbar {
  height: auto;
  min-height: 84px;
  margin-bottom: 12px;
  padding: 18px 24px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  max-width: 100%;
}

.topbar-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  margin-bottom: 10px;
  border-radius: 16px;
}

.topbar-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar-title-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.topbar-subtitle {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: -0.01em;
}

.topbar-actions {
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.status-bar:not(:empty) {
  margin: 0 4px 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 18px;
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(18px);
}

.status-bar.error {
  background: rgba(254, 242, 242, 0.88);
  border-bottom-color: rgba(248, 113, 113, 0.26);
}

.page {
  padding: 4px;
  min-width: 0;
  max-width: 100%;
}

.dashboard-grid {
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card,
.orders-table,
.options-drawer,
.logs-drawer,
.bulk-actions,
.search-group,
.grid-stack-item-content .widget {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.stat-card {
  padding: 20px 22px;
  border-radius: 24px;
}

.stat-card.accent {
  background:
    linear-gradient(180deg, rgba(14, 165, 233, 0.95), rgba(10, 132, 255, 0.88)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0));
  border-color: rgba(125, 211, 252, 0.45);
  box-shadow: 0 20px 45px rgba(10, 132, 255, 0.24);
}

.stat-label {
  color: #475569;
  font-size: 10.5px;
  letter-spacing: 0.12em;
}

.stat-value {
  font-size: 34px;
  font-weight: 700;
}

.stat-sub {
  font-size: 12.5px;
}

button,
select,
input:not([type="checkbox"]):not(.search-input) {
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 8px 18px rgba(15, 23, 42, 0.06);
}

button {
  min-height: 38px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-2);
}

button:hover {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(148, 163, 184, 0.28);
}

.btn-primary {
  background: linear-gradient(180deg, #1b93ff, #007aff);
  border-color: rgba(0, 122, 255, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 14px 24px rgba(0, 122, 255, 0.24);
}

.btn-primary:hover,
.btn-secondary:hover {
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.74);
}

.search-group {
  border-radius: 18px;
  overflow: hidden;
}

.search-input {
  min-width: 260px;
  padding: 11px 14px;
  font-size: 13.5px;
}

input[readonly].search-input {
  background: rgba(241, 245, 249, 0.72);
}

.search-group .btn-icon {
  padding: 10px 11px;
}

.loading-banner {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(147, 197, 253, 0.5);
  box-shadow: var(--shadow-xs);
}

.orders-toolbar,
.pagination-bar {
  gap: 14px;
}

.options-drawer,
.logs-drawer {
  border-radius: 22px;
}

.options-drawer summary,
.logs-drawer summary {
  padding: 14px 18px;
}

.options,
.logs-panel {
  background: rgba(248, 250, 252, 0.46);
}

.bulk-actions {
  border-radius: 22px;
  padding: 12px 16px;
  background: rgba(235, 245, 255, 0.72);
  border-color: rgba(147, 197, 253, 0.42);
}

.orders-table {
  border-radius: 24px;
  overflow: hidden;
}

.orders-table th {
  background: rgba(248, 250, 252, 0.9);
  color: #64748b;
}

.orders-table th,
.orders-table td,
.stock-table th,
.stock-table td,
.sell-through-table th,
.sell-through-table td {
  padding: 12px 14px;
}

.orders-table tbody tr:hover,
.stock-table tbody tr:hover,
.sell-through-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.78);
}

.tag,
.country-code-badge,
.paid-badge,
.days-badge,
.seller-stock-badge,
.stock-sku-badge {
  border-radius: 999px;
}

.tag {
  padding: 4px 9px;
  background: rgba(241, 245, 249, 0.92);
}

.grid-stack {
  margin-top: 2px;
}

.grid-stack > .grid-stack-item > .grid-stack-item-content {
  top: 6px;
  left: 6px;
  right: 6px;
  bottom: 6px;
  border-radius: 24px;
}

.grid-stack-item-content .widget {
  border-radius: 24px;
}

.widget {
  position: relative;
}

.widget::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 68px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.widget-header {
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.widget-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.widget-select {
  min-height: 34px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.88);
}

.widget-actions {
  gap: 8px;
}

.widget-sku-input {
  width: 170px;
}

.widget-loading,
.stock-empty {
  padding: 28px 18px;
  color: var(--muted);
}

.widget-drag-handle {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.9);
}

.widget-drag-handle:hover {
  background: rgba(10, 132, 255, 0.12);
  color: var(--accent-dark);
}

.seller-row,
.carrier-row {
  padding-left: 18px;
  padding-right: 18px;
}

.seller-bar-wrap,
.carrier-bar-wrap,
.st-bar-wrap {
  background: rgba(226, 232, 240, 0.9);
}

.grid-stack-item > .ui-resizable-s::after {
  background: rgba(148, 163, 184, 0.4);
}

.grid-stack-item:hover > .ui-resizable-s::after,
.grid-stack-item > .ui-resizable-s:hover::after {
  background: rgba(10, 132, 255, 0.62);
}

/* ── Unified Glass UI Foundation ── */
.ui-button {
  border-radius: 12px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ui-control {
  border-radius: 12px !important;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.58));
  border-color: rgba(148, 163, 184, 0.34) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.ui-control:focus {
  border-color: rgba(0, 60, 113, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(0, 60, 113, 0.16) !important;
}

.ui-table {
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.ui-table thead th {
  cursor: pointer;
  position: relative;
  user-select: none;
  padding-right: 22px;
}

.ui-table thead th.checkbox-cell,
.ui-table thead th:has(input[type="checkbox"]) {
  cursor: default;
}

.ui-table thead th.is-sorted-asc::after,
.ui-table thead th.is-sorted-desc::after {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--accent-dark);
  opacity: 0.9;
}

.ui-table thead th.is-sorted-asc::after { content: '▲'; }
.ui-table thead th.is-sorted-desc::after { content: '▼'; }

@media (max-width: 1180px) {
  :root {
    --sidebar-w: 228px;
  }

  .dashboard-widget-manager {
    width: min(340px, calc(100vw - 56px));
  }

  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }

}

@media (max-width: 900px) {
  .invoice-flow-grid,
  .invoice-flow-summary-grid,
  .tool-form,
  .tool-result-summary,
  .cardmarket-orders-grid,
  .cardmarket-mapping-form {
    grid-template-columns: 1fr;
  }

  .label-generator-page-content {
    grid-template-columns: 1fr;
  }

  .import-psa-page-content {
    grid-template-columns: 1fr;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .dashboard-edit-toggle {
    display: none !important;
  }

  .sidebar {
    left: 0;
    top: 0;
    bottom: 0;
    width: min(82vw, 320px);
    border-radius: 0 28px 28px 0;
    transform: translateX(calc(-100% - 16px));
    transition: transform 0.24s ease;
    z-index: 110;
  }

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

  .logo-copy,
  .nav-label {
    display: flex;
  }

  .sidebar-logo {
    justify-content: flex-start;
    padding-left: 18px;
    padding-right: 18px;
  }

  .logo-icon {
    width: 40px;
    height: 40px;
    padding: 2px;
    border-radius: 14px;
  }

  .logo-mark {
    border-radius: 12px;
  }

  .nav-item {
    justify-content: flex-start;
  }

  .main-content {
    margin-left: 0;
    padding: 10px;
  }

  .topbar {
    padding: 18px;
    border-radius: 22px;
  }

  .topbar-title {
    font-size: 24px;
  }

  .dashboard-widget-manager {
    position: static;
    width: 100%;
    margin-top: 8px;
  }

  .sales-pie-widget {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .label-generator-grid,
  .warehouse-sheet-summary {
    grid-template-columns: 1fr;
  }

  .label-history-panel {
    padding: 18px;
  }

  .tool-actions button,
  .label-generator-actions button {
    width: 100%;
  }

  .label-history-actions-cell {
    flex-direction: column;
    align-items: stretch;
  }

  .app-shell {
    flex-direction: column;
  }

  .topbar,
  .orders-table,
  .grid-stack-item-content .widget,
  .stat-card,
  .options-drawer,
  .logs-drawer,
  .bulk-actions {
    border-radius: 20px;
  }

  .topbar {
    padding: 18px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .widget-header,
  .widget-header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-widget-list-item {
    flex-direction: column;
    align-items: stretch;
  }

  .orders-toolbar,
  .toolbar-left,
  .toolbar-right,
  .pagination-bar,
  .pagination-left,
  .pagination-right,
  .widget-actions,
  .invoice-flow-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .invoice-flow-card {
    padding: 16px;
  }

  .invoice-flow-grid,
  .invoice-flow-summary-grid {
    gap: 12px;
  }

  .search-input,
  .widget-sku-input {
    min-width: 0;
    width: 100%;
  }

  .table-scroll {
    margin-left: -4px;
    margin-right: -4px;
    padding-left: 4px;
    padding-right: 4px;
  }

  .app-modal {
    padding: 14px;
  }

  .app-modal-footer {
    flex-direction: column;
    align-items: stretch;
  }
}
