/* ===== Final layer: standard form grid, collapsible sidebar, dark theme, calendar and product search ===== */

/* ---------- Standard form layout (replaces the spreadsheet-like boxed grid in forms) ---------- */
.form-card .form-grid,
.document-editor > .form-grid,
.document-lines .form-grid {
  gap: 16px 16px;
  border: 0;
  background: transparent;
}
.form-card .form-grid > .form-field,
.document-editor .form-grid > .form-field,
.document-lines .form-grid > .form-field {
  padding: 0;
  border: 0;
  background: transparent;
}
.form-card .form-grid > .form-field:hover,
.document-editor .form-grid > .form-field:hover {
  background: transparent;
}
.form-card .form-grid .form-field .form-label,
.document-editor .form-grid .form-field .form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.form-card .form-grid .form-field .form-control,
.form-card .form-grid .form-field .form-select,
.document-editor .form-grid .form-control,
.document-editor .form-grid .form-select {
  min-height: 40px !important;
  padding: 8px 11px;
  border: 1px solid #d0d7e5;
  border-radius: 9px;
  background: #fff;
  font-size: 13px;
}
.form-card .form-grid .form-field .form-control:hover,
.form-card .form-grid .form-field .form-select:hover,
.document-editor .form-grid .form-control:hover,
.document-editor .form-grid .form-select:hover {
  border-color: #aab6cc;
  background: #fff;
}
.form-card .form-grid .form-field .form-control:focus,
.form-card .form-grid .form-field .form-select:focus,
.document-editor .form-grid .form-control:focus,
.document-editor .form-grid .form-select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: var(--ring);
}
.form-card .form-grid .form-field .form-text,
.document-editor .form-grid .form-text {
  margin-top: 4px;
}
.payment-section .form-grid { border: 0; background: transparent; }
.payment-section .form-grid > .form-field { padding: 0; }

/* Payment and document sections read as ordinary panels, not spreadsheets. */
.document-lines { border-top: 1px solid var(--border); padding-top: 18px; }
.document-lines h2 { font-size: 15px; }

/* Exchange-rate cards: one standard panel style. */
.exchange-rate-grid { gap: 16px; }
.exchange-rate-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ---------- Invoice lines: product search ---------- */
.product-search { position: relative; min-width: 0; }
.editable-grid-table { overflow: visible; }
.product-search-select { display: none !important; }
.product-search-results {
  position: fixed;
  z-index: 3000;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
}
.product-search-results[hidden] { display: none; }
.product-search-option {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: start;
  font-size: 12px;
  cursor: pointer;
}
.product-search-option.is-active,
.product-search-option:hover { background: var(--primary-soft); }
.product-search-code { font-variant-numeric: tabular-nums; color: var(--muted); direction: ltr; text-align: left; }
.product-search-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.product-search-price { color: var(--primary-dark); font-weight: 700; font-variant-numeric: tabular-nums; }
.product-search-empty { padding: 10px; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- Jalali calendar picker ---------- */
.jalali-picker {
  position: absolute;
  z-index: 3000;
  width: 284px;
  padding: 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, .2);
  font-size: 12px;
  user-select: none;
}
.jalali-picker[hidden] { display: none; }
.jalali-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.jalali-head strong { font-size: 13px; }
.jalali-nav {
  width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer;
}
.jalali-nav:hover { background: var(--primary-soft); }
.jalali-week, .jalali-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.jalali-week span { color: var(--muted); font-size: 11px; padding: 4px 0; }
.jalali-blank { display: block; }
.jalali-day {
  height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink);
  font-variant-numeric: tabular-nums; cursor: pointer;
}
.jalali-day:hover { background: var(--primary-soft); }
.jalali-day.is-today { box-shadow: inset 0 0 0 1px var(--primary); color: var(--primary-dark); font-weight: 700; }
.jalali-day.is-selected, .jalali-day.is-selected:hover { background: var(--primary); color: #fff; }
.jalali-foot { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.jalali-foot button { border: 0; background: transparent; color: var(--primary-dark); font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px 6px; }

/* ---------- Topbar: theme toggle and sidebar collapse ---------- */
.theme-toggle, .sidebar-collapse {
  width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer;
  transition: background .15s, color .15s;
}
.theme-toggle:hover, .sidebar-collapse:hover { background: var(--primary-soft); color: var(--primary-dark); }
.theme-toggle svg, .sidebar-collapse svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
.sidebar-collapse svg { transition: transform .2s; }
html.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
.topbar { gap: 12px; }
.topbar .menu-toggle + .sidebar-collapse { margin-inline-start: 4px; }
@media (max-width: 900px) { .sidebar-collapse { display: none; } }

/* ---------- Collapsible sidebar (desktop) ---------- */
@media (min-width: 901px) {
  html.sidebar-collapsed .sidebar { width: 78px; padding-inline: 10px; overflow-x: hidden; }
  html.sidebar-collapsed .main-area { margin-right: 78px; }
  html.sidebar-collapsed .brand { justify-content: center; padding-inline: 0; }
  html.sidebar-collapsed .sidebar .brand-text,
  html.sidebar-collapsed .sidebar .nav-text,
  html.sidebar-collapsed .sidebar .user-name,
  html.sidebar-collapsed .sidebar .nav-caption { display: none !important; }
  html.sidebar-collapsed .sidebar .nav-caption { display: block; height: 1px; margin: 10px 8px; padding: 0; background: rgba(255,255,255,.08); }
  html.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding: 10px 0; gap: 0; }
  html.sidebar-collapsed .sidebar .nav-link.active::before { inset-inline-start: -10px; }
  html.sidebar-collapsed .sidebar-bottom { justify-content: center; flex-direction: column; gap: 8px; padding-inline: 0; }
}
.sidebar .nav-link .nav-text { width: auto; font-size: inherit; text-align: inherit; line-height: 1.5; }
.sidebar .nav-link .nav-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Dark theme ---------- */
html[data-theme="dark"] {
  --bg: #0b1220;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --border: #243047;
  --surface: #131c2e;
  --surface-2: #18223a;
  --primary-soft: rgba(79, 115, 235, .18);
  --primary-dark: #8fb0ff;
  --navy: #0b1220;
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
html[data-theme="dark"] .topbar { background: var(--surface); border-bottom-color: var(--border); }
html[data-theme="dark"] .breadcrumb-lite strong,
html[data-theme="dark"] .page-heading h1,
html[data-theme="dark"] .panel-heading h2,
html[data-theme="dark"] h2, html[data-theme="dark"] h3 { color: var(--ink); }
html[data-theme="dark"] .date-chip { background: var(--surface-2); color: var(--muted); }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .cashbox-card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .exchange-rate-card,
html[data-theme="dark"] .exchange-rate-section,
html[data-theme="dark"] .column-chooser-menu,
html[data-theme="dark"] .purchase-history-dialog { background: var(--surface); border-color: var(--border); color: var(--ink); }
html[data-theme="dark"] .stat-card strong,
html[data-theme="dark"] .cashbox-balance strong,
html[data-theme="dark"] .cash-summary b,
html[data-theme="dark"] .doc-summary b { color: var(--ink); }
html[data-theme="dark"] .cashbox-balance,
html[data-theme="dark"] .cash-summary > div,
html[data-theme="dark"] .doc-summary,
html[data-theme="dark"] .doc-header { background: var(--surface-2); }
html[data-theme="dark"] .app-table thead th { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
html[data-theme="dark"] .app-table tbody td,
html[data-theme="dark"] .table > :not(caption) > * > * { color: var(--ink); background-color: transparent; border-color: var(--border); }
html[data-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: var(--surface-2); }
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-card .form-grid .form-field .form-control,
html[data-theme="dark"] .form-card .form-grid .form-field .form-select,
html[data-theme="dark"] .document-editor .form-grid .form-control,
html[data-theme="dark"] .document-editor .form-grid .form-select,
html[data-theme="dark"] .editable-grid-table td[data-field] .form-control,
html[data-theme="dark"] .editable-grid-table td[data-field] .form-select {
  background-color: #0f1729; color: var(--ink); border-color: #2c3a57;
}
html[data-theme="dark"] .form-control::placeholder { color: #64748b; }
html[data-theme="dark"] .editable-grid-table tbody tr:nth-child(even) { background: #101a2d; }
html[data-theme="dark"] .editable-grid-table tbody tr:hover { background: #17233b; }
html[data-theme="dark"] .editable-grid-table tbody td.line-amount { background: #17233b; color: #9db8ff; }
html[data-theme="dark"] .editable-grid-table thead th { background: var(--surface-2) !important; color: var(--muted) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .editable-grid-table { border-color: var(--border); }
html[data-theme="dark"] .editable-grid-table tbody td { border-color: var(--border) !important; }
html[data-theme="dark"] .form-card .form-grid,
html[data-theme="dark"] .document-editor .form-grid { background: transparent; }
html[data-theme="dark"] .doc-summary { border: 0; }
html[data-theme="dark"] .panel-heading p,
html[data-theme="dark"] .page-heading p,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] .helptext { color: var(--muted); }
html[data-theme="dark"] .btn-light { background: var(--surface-2); border-color: var(--border); color: var(--ink); }
html[data-theme="dark"] .btn-outline-primary { color: #9db8ff; border-color: #33466e; }
html[data-theme="dark"] .btn-outline-primary:hover { background: var(--primary-soft); color: #fff; }
html[data-theme="dark"] .icon-check-delete { background: #2a1517; border-color: #5b2226; color: #fca5a5; }
html[data-theme="dark"] .page-link { background: var(--surface); border-color: var(--border); color: #9db8ff; }
html[data-theme="dark"] .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .column-chooser summary { background: var(--surface); }
html[data-theme="dark"] .product-search-results { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .product-search-input { background:var(--surface-2)!important; border-color:var(--border)!important; color:var(--ink)!important; }
html[data-theme="dark"] .product-search-option.is-active,
html[data-theme="dark"] .product-search-option:hover { background: var(--primary-soft); }
html[data-theme="dark"] .jalali-picker { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .jalali-nav { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
html[data-theme="dark"] .jalali-day { color: var(--ink); }
html[data-theme="dark"] .alert { border-color: transparent; }
html[data-theme="dark"] .login-body { background: var(--bg); }
html[data-theme="dark"] .messages .alert-success { background: #0f2e25; color: #a7f3d0; }
html[data-theme="dark"] .messages .alert-danger { background: #3a1517; color: #fecaca; }
html[data-theme="dark"] .messages .alert-warning { background: #3a2a10; color: #fde68a; }
html[data-theme="dark"] .messages .alert-info { background: #13233f; color: #bfdbfe; }
html[data-theme="dark"] .app-tab-bar { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .app-tab { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
html[data-theme="dark"] .app-tab.is-active { background: var(--surface); color: var(--ink); }
html[data-theme="dark"] .app-tab-tools button { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
html[data-theme="dark"] .badge-status { background: var(--surface-2); color: var(--muted); }
html[data-theme="dark"] .chart-area { background: transparent; border-color: var(--border); }
html[data-theme="dark"] .compact-row { border-color: var(--border); }
html[data-theme="dark"] .barcode-label { background: #fff; }

/* Hover label for collapsed menu icons (positioned by ui.js next to the sidebar). */
.sidebar-tip {
  position: fixed;
  z-index: 4000;
  transform: translate(-100%, -50%);
  padding: 6px 10px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .25);
}
.sidebar-tip[hidden] { display: none; }
@media (max-width: 900px) { .sidebar-tip { display: none !important; } }

/* ===== Light sidebar in both themes ===== */
.sidebar {
  background: #ffffff;
  color: #1f2937;
  border-left: 1px solid #e6ebf3;
  box-shadow: 4px 0 24px rgba(15, 23, 42, .04);
}
.sidebar .brand { color: #111827; border-bottom-color: #e6ebf3; }
.sidebar .brand small,
.sidebar .user-name small { color: #64748b; }
.sidebar .user-name { color: #111827; }
.sidebar .nav-caption { color: #94a3b8; }
.sidebar .nav-link { color: #475569; }
.sidebar .nav-link:hover { background: #f1f5fd; color: #1d4ed8; }
.sidebar .nav-link.active {
  background: #eef3ff;
  color: #2442b8;
  font-weight: 700;
  box-shadow: inset -3px 0 #3b5bdb;
}
.sidebar-bottom { border-top-color: #e6ebf3; }
.sidebar .icon-button { color: #475569; }
.sidebar .icon-button:hover { background: #eef3ff; color: #2442b8; }
html.sidebar-collapsed .sidebar .nav-caption { background: #e6ebf3; }

/* ===== Key amounts: payable balances and debts stand out ===== */
.key-metric {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eef3ff, #f8fbff);
  border: 1px solid #d6e0ff;
}
.key-metric em { font-style: normal; font-size: 11px; font-weight: 600; color: #4a5f99; }
.key-metric b { font-size: 17px; font-weight: 800; color: #1e2e6b; font-variant-numeric: tabular-nums; }
.key-metric.payable-metric { background: linear-gradient(135deg, #fff7e5, #fffbeb); border-color: #f5d891; }
.key-metric.payable-metric em { color: #8a5a08; }
.key-metric.payable-metric b { color: #7a3e08; font-size: 19px; }
.key-metric.payable-metric [data-document-currency] { color: #8a5a08; font-size: 11px; font-weight: 600; }
.stat-card.is-key {
  border-color: #fcd5d5;
  background: linear-gradient(180deg, #ffffff, #fff7f7);
}
.stat-card.is-key strong { color: #b42318; font-size: 26px; font-weight: 800; }
html[data-theme="dark"] .key-metric { background: #1a2544; border-color: #33466e; }
html[data-theme="dark"] .key-metric em { color: #9db8ff; }
html[data-theme="dark"] .key-metric b { color: #dbe6ff; }
html[data-theme="dark"] .key-metric.payable-metric { background: #302719; border-color: #73582a; }
html[data-theme="dark"] .key-metric.payable-metric em,
html[data-theme="dark"] .key-metric.payable-metric b,
html[data-theme="dark"] .key-metric.payable-metric [data-document-currency] { color: #ffdb91; }
html[data-theme="dark"] .stat-card.is-key { background: linear-gradient(180deg, #131c2e, #2a1517); border-color: #5b2226; }

/* Keep the tab refresh action easy to spot and show progress while its page reloads. */
.app-tab-tools .tab-refresh-button { width: auto; min-width: 104px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: #2442b8; border-color: #c7d6ff; background: #f5f8ff; font-weight: 700; }
.app-tab-tools .tab-refresh-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app-tab-tools .tab-refresh-button.is-loading svg { animation: spin .7s linear infinite; }
.app-tab-tools .tab-refresh-button:disabled { opacity: .58; }
@media (max-width: 520px) { .app-tab-tools .tab-refresh-button { min-width: 34px; width: 34px; padding: 0; } .app-tab-tools .tab-refresh-button span { display: none; } }
.woo-connection-form .sensitive-field { padding: 14px; border: 1px solid #e4d9ff; border-radius: 12px; background: #faf7ff; }
.woo-connection-form .sensitive-field .form-label { color: #593c9f; }
.woo-connection-form .sensitive-field .form-control { background: #fff; }
.woo-import-form { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.woo-import-form > .form-text { flex: 1 1 420px; margin: 0; line-height: 1.9; }
.access-shortcuts .heading-actions { justify-content: flex-start; }
.role-picker, .permission-picker { padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.role-choice-list > div, .role-choice-list > ul, .role-choice-list > fieldset, .permission-choice-list > div, .permission-choice-list > ul, .permission-choice-list > fieldset { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 7px 12px; margin: 0; padding: 0; list-style: none; }
.role-choice-list li, .permission-choice-list li { list-style: none; margin: 0; }
.role-choice-list label, .permission-choice-list label { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 12px; }
.role-choice-list input, .permission-choice-list input { margin: 0; }
.permission-picker legend { float: none; width: auto; margin: 0; color: var(--ink); font-size: 14px; font-weight: 700; }
.permission-picker .form-text { margin-bottom: 12px; }
.danger-link { border: 0; background: transparent; color: #b42318; font: inherit; cursor: pointer; }
@media (max-width: 850px) { .woo-import-form { align-items: stretch; flex-direction: column; } .woo-import-form .btn { width: 100%; } }

/* Configurable, restrained accent colors and readable font scaling. */
html[data-accent="teal"] { --primary:#0f8b83; --primary-dark:#0b6c66; --primary-soft:#e5f7f5; --ring:0 0 0 3px rgba(15,139,131,.18); }
html[data-accent="violet"] { --primary:#7255c7; --primary-dark:#5e43ad; --primary-soft:#f0ebfb; --ring:0 0 0 3px rgba(114,85,199,.18); }
html[data-font-scale="90"] body { font-size:12.6px; }
html[data-font-scale="100"] body { font-size:14px; }
html[data-font-scale="110"] body { font-size:15.4px; }
.btn-primary { background:linear-gradient(135deg,var(--primary),var(--primary-dark)); }
.sidebar { transition:width .24s cubic-bezier(.2,.7,.2,1), padding .24s ease, background .2s ease; }
.main-area { transition:margin-right .24s cubic-bezier(.2,.7,.2,1); }
.sidebar-group { margin:3px 0 7px; }
.sidebar-group-toggle { width:100%; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:9px 11px 5px; border:0; background:transparent; color:#8290a8; text-align:right; font:inherit; font-size:10px; font-weight:700; cursor:pointer; }
.sidebar-group-toggle svg { width:14px; height:14px; flex:0 0 14px; fill:none; stroke:currentColor; stroke-width:1.8; transition:transform .2s ease; }
.sidebar-group-toggle[aria-expanded="false"] svg { transform:rotate(90deg); }
.sidebar-group-items { overflow:hidden; transition:max-height .22s ease,opacity .16s ease; }
.sidebar-group-items .nav-link { margin-inline:4px; }
.category-child-row { padding-inline-start:42px; }
.product-delete-blocked { align-self:center; font-size:10px; white-space:nowrap; }
.table-actions form { display:inline-flex; margin:0; }
.interface-text-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.interface-text-field { display:flex; flex-direction:column; gap:6px; min-width:0; font-size:11px; font-weight:600; color:var(--ink); }
.interface-text-field small { display:block; margin-top:3px; color:var(--muted); font-weight:400; line-height:1.7; }
.interface-text-field textarea { min-height:64px; font-size:11px; line-height:1.8; }
.settings-subtitle { margin:18px 0 10px; padding-top:13px; border-top:1px solid var(--border); font-size:12px; font-weight:700; color:var(--ink); }
.backup-panel { min-width:0; }
.backup-badge { padding:5px 10px; border-radius:20px; background:#e8f7f0; color:#168259; font-size:10px; font-weight:700; }
.backup-note { margin:13px 0; padding:10px 12px; border-radius:10px; background:#fff8e9; color:#76571b; font-size:10px; line-height:1.9; }
.app-confirm-dialog { width:min(440px,calc(100vw - 32px)); border:1px solid var(--border); border-radius:18px; padding:0; color:var(--ink); background:var(--surface); box-shadow:0 24px 80px rgba(15,23,42,.3); }
.app-confirm-dialog::backdrop { background:rgba(15,23,42,.48); backdrop-filter:blur(3px); }
.app-confirm-dialog form { padding:24px; }
.app-confirm-dialog .confirm-icon { width:38px; height:38px; display:grid; place-items:center; border-radius:12px; background:var(--primary-soft); color:var(--primary); font-size:20px; font-weight:800; }
.app-confirm-dialog h2 { margin:14px 0 7px; color:var(--ink); font-size:16px; font-weight:800; }
.app-confirm-dialog p { margin:0; color:var(--muted); font-size:12px; line-height:1.9; }
.confirm-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:22px; }
.backup-panel .compact-row { gap:12px; }
html[data-theme="dark"] { --bg:#0b1220; --surface:#131c2e; --surface-2:#18223a; }
html[data-theme="dark"] .sidebar { background:#111b2e; border-left-color:#26334b; color:var(--ink); }
html[data-theme="dark"] .sidebar .brand,
html[data-theme="dark"] .sidebar .user-name { color:var(--ink); }
html[data-theme="dark"] .sidebar .brand small,
html[data-theme="dark"] .sidebar .user-name small { color:#93a1bb; }
html[data-theme="dark"] .sidebar .nav-caption,
html[data-theme="dark"] .sidebar-group-toggle { color:#91a0bb; }
html[data-theme="dark"] .sidebar .nav-link { color:#bcc8dc; }
html[data-theme="dark"] .sidebar .nav-link:hover { background:#1b2941; color:#dbeafe; }
html[data-theme="dark"] .sidebar .nav-link.active { background:#1b2a47; color:#c8d7ff; box-shadow:inset -3px 0 var(--primary); }
html[data-theme="dark"] .sidebar-bottom { border-top-color:#26334b; }
html[data-theme="dark"] .sidebar .icon-button { color:#bcc8dc; }
html[data-theme="dark"] .woo-connection-form .sensitive-field { background:#211b31; border-color:#493b68; }
html[data-theme="dark"] .woo-connection-form .sensitive-field .form-label { color:#d5c4ff; }
html[data-theme="dark"] .woo-connection-form .sensitive-field .form-control { background:#0f1729; color:var(--ink); }
html[data-theme="dark"] .backup-badge { background:#15382e; color:#9de6c9; }
html[data-theme="dark"] .backup-note { background:#302719; color:#ffdb91; }
html[data-theme="dark"] .app-confirm-dialog { background:var(--surface); color:var(--ink); }
html[data-theme="dark"] .app-confirm-dialog h2 { color:var(--ink); }
html[data-theme="dark"] .form-card .form-grid .form-field .form-control,
html[data-theme="dark"] .form-card .form-grid .form-field .form-select,
html[data-theme="dark"] .document-editor .form-grid .form-control,
html[data-theme="dark"] .document-editor .form-grid .form-select { background:#0f1729; color:var(--ink); border-color:#2c3a57; }
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light { background-color:var(--surface-2)!important; color:var(--ink)!important; }
@media (min-width:901px) {
  html.sidebar-collapsed .sidebar-group-toggle { min-height:8px; height:8px; padding:0; overflow:hidden; }
  html.sidebar-collapsed .sidebar-group-toggle span,
  html.sidebar-collapsed .sidebar-group-toggle svg { display:none; }
  html.sidebar-collapsed .sidebar-group-items { max-height:none!important; opacity:1!important; }
}
@media (max-width:700px) { .interface-text-grid { grid-template-columns:1fr; } }
@media (prefers-reduced-motion:reduce) { .sidebar,.main-area,.sidebar-group-items,.sidebar-group-toggle svg { transition:none!important; } }

/* Product catalogue rows follow the supplied reference: framed items, linked
   12px names, and a quiet category path directly below each name. */
html[data-product-title-color="blue"] { --product-title-color:#155bd3; }
html[data-product-title-color="indigo"] { --product-title-color:#5947b8; }
html[data-product-title-color="teal"] { --product-title-color:#087b72; }
html[data-product-title-color="charcoal"] { --product-title-color:#334155; }
/* Keep one clean frame around the catalogue; draw only single internal grid lines. */
.table-responsive:has(> #product-table) { overflow-x:auto; border:1px solid #e4e7eb; border-radius:var(--radius-sm, 8px); }
#product-table.product-catalog-table { border-collapse:separate!important; border-spacing:0; border:0!important; margin-bottom:0!important; }
#product-table thead th {
  background:#f0f2f4!important;
  border:0!important;
  border-bottom:1px solid #e4e7eb!important;
}
#product-table thead th:not(:last-child) { border-inline-end:1px solid #e4e7eb!important; }
#product-table thead th:first-child { border-start-start-radius:7px; }
#product-table thead th:last-child { border-start-end-radius:7px; }
#product-table tbody tr { filter:none; }
#product-table tbody tr td {
  background:#fff!important;
  border:0!important;
  border-bottom:1px solid #e6e8eb!important;
  border-radius:0!important;
  padding-block:11px;
}
/* Restore vertical separators between columns without drawing over the outer frame. */
#product-table tbody tr td:not(:last-child) { border-inline-end:1px solid #e6e8eb!important; }
#product-table tbody tr:nth-child(even) td { background:#f6f6f6!important; }
#product-table tbody tr:last-child td { border-bottom:0!important; }
#product-table tbody tr:last-child td:first-child { border-end-start-radius:7px!important; }
#product-table tbody tr:last-child td:last-child { border-end-end-radius:7px!important; }
.product-name-link { display:inline-block; color:var(--product-title-color); font-size:12px; font-weight:700; line-height:1.7; text-decoration:none; }
a.product-name-link:hover { color:var(--product-title-color); text-decoration:underline; text-underline-offset:3px; }
.product-category-path { display:block; margin-top:2px; color:var(--muted); font-size:10px; font-weight:400; line-height:1.65; }
.product-delete-icon { width:29px; height:29px; display:inline-grid; place-items:center; border:1px solid transparent; border-radius:5px; background:transparent; color:#89919b; cursor:pointer; }
.product-delete-icon svg { width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.product-delete-icon:hover:not(.is-disabled) { background:#f1f3f5; border-color:#e1e5e9; color:#58616d; }
.product-delete-icon.is-disabled { opacity:.45; cursor:not-allowed; }
.product-muted-label { color:#969da6; font-size:11px; }
.badge-status.neutral { color:#9299a2; background:#f0f1f2; }
.product-list-tools { align-items:center; gap:12px; }
.product-filter-form { display:grid; flex:1 1 auto; min-width:0; grid-template-columns:minmax(205px,1.5fr) repeat(3,minmax(130px,1fr)) auto; align-items:center; gap:8px; }
.product-filter-form .form-control, .product-filter-form .form-select { min-width:0; max-width:none; height:38px; border-radius:5px; }
.document-filter-form { display:grid; flex:0 1 540px; width:min(100%,540px); grid-template-columns:minmax(0,1.6fr) minmax(0,1fr); gap:8px; }
.document-filter-form .form-control, .document-filter-form .form-select { min-width:0; max-width:none; }
.product-category-toggle { display:flex; align-items:center; gap:7px; white-space:nowrap; color:var(--muted); font-size:11px; cursor:pointer; }
.product-category-toggle input { accent-color:var(--primary); }
.visually-hidden { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }
.category-row-actions { display:flex; align-items:center; gap:7px; margin-inline-start:auto; }
.category-row-actions form { margin:0; }
.category-delete-icon { width:29px; height:29px; display:grid; place-items:center; border:1px solid transparent; border-radius:5px; background:transparent; color:#89919b; cursor:pointer; }
.category-delete-icon:hover { color:#58616d; background:#f1f3f5; border-color:#e1e5e9; }
.category-delete-icon svg { width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.category-tree-row.level-2 { padding-inline-start:24px; }
.category-tree-row.level-3 { padding-inline-start:48px; }
html[data-theme="dark"][data-product-title-color="blue"] { --product-title-color:#83adff; }
html[data-theme="dark"][data-product-title-color="indigo"] { --product-title-color:#b5a8ff; }
html[data-theme="dark"][data-product-title-color="teal"] { --product-title-color:#6ad9cf; }
html[data-theme="dark"][data-product-title-color="charcoal"] { --product-title-color:#d1d9e6; }
html[data-theme="dark"] .table-responsive:has(> #product-table) { border-color:#405169; }
html[data-theme="dark"] #product-table thead th { background:#334257!important; border-color:#405169!important; }
html[data-theme="dark"] #product-table thead th:not(:last-child) { border-inline-end-color:#405169!important; }
html[data-theme="dark"] #product-table tbody tr td { background:#263548!important; border-color:#39495d!important; }
html[data-theme="dark"] #product-table tbody tr td:not(:last-child) { border-inline-end-color:#39495d!important; }
html[data-theme="dark"] #product-table tbody tr:nth-child(even) td { background:#2d3b4e!important; }
html[data-theme="dark"] .product-delete-icon, html[data-theme="dark"] .category-delete-icon { background:transparent; border-color:transparent; color:#a2aab6; }
html[data-theme="dark"] .product-delete-icon:hover:not(.is-disabled), html[data-theme="dark"] .category-delete-icon:hover { background:#202b3c; border-color:#354256; color:#d0d6df; }
html[data-theme="dark"] .badge-status.neutral { color:#b0b6c0; background:#283243; }
html[data-theme="dark"] .product-muted-label { color:#a0a7b2; }

.settings-shortcut-panel { grid-column:1/-1; border-color:var(--border); background:linear-gradient(135deg,var(--surface),var(--surface-2)); }
.settings-shortcut-icon { width:38px; height:38px; display:grid; place-items:center; border-radius:10px; color:var(--primary); background:#edf1ff; }
.settings-shortcut-panel .panel-heading { margin-bottom:14px; }
.payment-progress { display:flex; flex-direction:column; align-items:flex-start; gap:3px; }
.payment-progress > b { color:var(--ink); font-size:14px; }
.payment-progress small { color:var(--muted); font-size:10px; }
.balance-popup-trigger { border:0; padding:0; background:transparent; color:var(--muted); font:inherit; font-size:10px; text-align:start; cursor:pointer; }
.balance-popup-trigger:hover { color:var(--primary); text-decoration:underline; }
.invoice-profit { color:#16745d; }
.invoice-profit.is-loss { color:#a94b45; }
.debtor-dialog { width:min(520px,calc(100% - 28px)); max-width:520px; padding:0; border:1px solid var(--border); border-radius:12px; background:var(--surface); color:var(--ink); box-shadow:0 24px 64px rgba(15,23,42,.24); }
.debtor-dialog::backdrop { background:rgba(15,23,42,.42); backdrop-filter:blur(2px); }
.debtor-dialog-inner { padding:20px; }
.debtor-dialog-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:18px; }
.debtor-dialog-heading h2 { margin:0; font-size:16px; }
.debtor-dialog-heading p { margin:5px 0 0; color:var(--muted); font-size:11px; }
.debtor-dialog-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.debtor-dialog-item { padding:11px; border:1px solid var(--border); border-radius:7px; background:var(--surface-2); }
.debtor-dialog-item span { display:block; margin-bottom:4px; color:var(--muted); font-size:10px; }
.debtor-dialog-item b { font-size:12px; }
.debtor-dialog-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
html[data-theme="dark"] .settings-shortcut-icon { background:#273253; color:#adbcff; }

/* Skeleton loading for workspace tabs and live search menus. */
.app-tab-host { position:relative; overflow:hidden; }
.app-tab-panel { position:relative; z-index:1; }
.app-tab-skeleton { position:absolute; inset:0; z-index:5; overflow:hidden; padding:24px 28px; background:var(--bg); }
.app-tab-skeleton[hidden] { display:none; }
.app-skeleton-inner { max-width:1500px; margin:0 auto; }
.app-skeleton-heading { display:flex; flex-direction:column; gap:10px; margin:0 0 22px; }
.app-skeleton-line,.app-skeleton-card,.search-skeleton-bar,.history-skeleton-block { background:linear-gradient(100deg,var(--surface-2) 20%,var(--border) 38%,var(--surface-2) 56%); background-size:220% 100%; animation:skeleton-shimmer 1.25s ease-in-out infinite; }
.app-skeleton-line { display:block; height:11px; border-radius:6px; }
.app-skeleton-line.is-title { width:min(34%,260px); height:25px; }
.app-skeleton-line.is-subtitle { width:min(52%,420px); height:12px; }
.app-skeleton-cards { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:16px; }
.app-skeleton-card { height:98px; border:1px solid var(--border); border-radius:11px; }
.app-skeleton-panel { display:grid; gap:15px; padding:18px; border:1px solid var(--border); border-radius:12px; background:var(--surface); }
.app-skeleton-line.is-section { width:180px; height:17px; margin-bottom:2px; }
.app-skeleton-line.is-row { width:100%; height:37px; border-radius:6px; }
.search-skeleton-row { display:grid; grid-template-columns:100px 1fr; align-items:center; gap:10px; padding:9px 10px; }
.search-skeleton-bar { display:block; height:11px; border-radius:6px; }
.search-skeleton-bar.is-short { width:68%; }
.history-skeleton { display:grid; gap:10px; }
.history-skeleton-row { display:grid; grid-template-columns:1fr 100px 140px; gap:12px; align-items:center; padding:10px; border:1px solid var(--border); border-radius:7px; }
.history-skeleton-block { height:12px; border-radius:6px; }
@keyframes skeleton-shimmer { to { background-position-x:-220%; } }
@media(max-width:800px) { .app-tab-skeleton { padding:16px; } .app-skeleton-cards { grid-template-columns:repeat(2,minmax(0,1fr)); } .history-skeleton-row { grid-template-columns:1fr 70px; } .history-skeleton-row .history-skeleton-block:last-child { display:none; } }
@media(prefers-reduced-motion:reduce) { .app-skeleton-line,.app-skeleton-card,.search-skeleton-bar,.history-skeleton-block { animation:none; } }

/* Refined dark palette: layered slate surfaces and consistent controls. */
html[data-theme="dark"] {
  --bg:#1d2938;
  --surface:#263447;
  --surface-2:#2e3d52;
  --border:#3b4c61;
  --ink:#e7edf4;
  --muted:#b0bdcb;
  --navy:#202d3e;
  --primary-soft:rgba(124,151,232,.18);
  --primary-dark:#a6bbff;
  --ring:0 0 0 3px rgba(124,151,232,.24);
  --shadow-sm:0 1px 2px rgba(4,10,18,.12),0 4px 12px rgba(4,10,18,.1);
  --shadow-md:0 6px 20px rgba(4,10,18,.22);
  color-scheme:dark;
}
html[data-theme="dark"] body,
html[data-theme="dark"] .main-area,
html[data-theme="dark"] .content-wrap,
html[data-theme="dark"] .app-tab-host { background-color:var(--bg)!important; color:var(--ink); }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .app-tab-host,
html[data-theme="dark"] .app-tab-panel { background-color:var(--bg)!important; }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .cashbox-card,
html[data-theme="dark"] .exchange-rate-card,
html[data-theme="dark"] .exchange-rate-section,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .column-chooser-menu,
html[data-theme="dark"] .purchase-history-dialog,
html[data-theme="dark"] .debtor-dialog,
html[data-theme="dark"] .app-confirm-dialog { background-color:var(--surface)!important; border-color:var(--border)!important; color:var(--ink)!important; }
html[data-theme="dark"] .panel-heading,
html[data-theme="dark"] .form-actions,
html[data-theme="dark"] .panel .table-responsive,
html[data-theme="dark"] .table-responsive,
html[data-theme="dark"] .cashbox-balance,
html[data-theme="dark"] .cash-summary>div,
html[data-theme="dark"] .doc-header>div,
html[data-theme="dark"] .doc-summary>span,
html[data-theme="dark"] .payment-section,
html[data-theme="dark"] .document-editor .payment-section,
html[data-theme="dark"] .debtor-dialog-item { border-color:var(--border)!important; }
html[data-theme="dark"] .form-card .form-grid>.form-field,
html[data-theme="dark"] .document-editor .form-grid>.form-field,
html[data-theme="dark"] .document-lines .form-grid>.form-field { background:var(--surface)!important; border-color:var(--border)!important; }
html[data-theme="dark"] .form-label,
html[data-theme="dark"] label.form-label { color:var(--ink)!important; }
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="url"] {
  background-color:var(--surface-2)!important;
  border-color:var(--border)!important;
  color:var(--ink)!important;
}
html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] input::placeholder { color:var(--muted)!important; opacity:.82; }
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus { border-color:var(--primary)!important; }
html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control[readonly],
html[data-theme="dark"] .form-select:disabled { background-color:var(--surface)!important; color:var(--muted)!important; }
html[data-theme="dark"] .editable-grid-table tbody tr:nth-child(even),
html[data-theme="dark"] .editable-grid-table tbody tr:hover,
html[data-theme="dark"] .editable-grid-table tbody td.line-amount,
html[data-theme="dark"] .document-editor .payment-section { background-color:var(--surface-2)!important; }
html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-danger,
html[data-theme="dark"] .column-chooser summary,
html[data-theme="dark"] .app-tab-tools button { background-color:var(--surface-2)!important; border-color:var(--border)!important; color:var(--ink)!important; }
html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .btn-outline-primary:hover,
html[data-theme="dark"] .column-chooser summary:hover,
html[data-theme="dark"] .app-tab-tools button:hover:not(:disabled) { background-color:#384960!important; }
html[data-theme="dark"] .btn-outline-primary:hover { color:#d9e4ff!important; border-color:#7187aa!important; }
html[data-theme="dark"] .btn-outline-danger { color:#efb7ba!important; border-color:#76565f!important; }
html[data-theme="dark"] .btn-outline-danger:hover { background-color:#443640!important; border-color:#a07179!important; }
html[data-theme="dark"] .btn-primary { color:#fff!important; }
html[data-theme="dark"] .table-responsive { background-color:var(--surface)!important; }
html[data-theme="dark"] .app-table,
html[data-theme="dark"] .app-table thead th { --bs-table-bg:var(--surface); background-color:var(--surface-2); border-color:var(--border); color:var(--ink); }
html[data-theme="dark"] .app-table tbody td { color:var(--ink)!important; border-color:var(--border)!important; }
html[data-theme="dark"] .app-table tbody tr:hover td { background-color:#34445a!important; }
html[data-theme="dark"] .sidebar { background:linear-gradient(180deg,#223146 0%,#1c2a3d 100%)!important; }
html[data-theme="dark"] .sidebar .nav-link:hover { background:#34465d; }
html[data-theme="dark"] .sidebar .nav-link.active { background:#30435e; }
html[data-theme="dark"] .woo-connection-form .sensitive-field { background:#34364a!important; border-color:#50566b!important; }
html[data-theme="dark"] .woo-connection-form .sensitive-field .form-control { background-color:var(--surface-2)!important; }
html[data-theme="dark"] .table-responsive:has(> #product-table) { border-color:#405169; }
html[data-theme="dark"] #product-table thead th { background:#334257!important; border-color:#405169!important; }
html[data-theme="dark"] #product-table thead th:not(:last-child) { border-inline-end-color:#405169!important; }
html[data-theme="dark"] #product-table tbody tr td { background:#263548!important; border-color:#39495d!important; }
html[data-theme="dark"] #product-table tbody tr td:not(:last-child) { border-inline-end-color:#39495d!important; }
html[data-theme="dark"] #product-table tbody tr:nth-child(even) td { background:#2d3b4e!important; }
html[data-theme="dark"] #product-table tbody tr:hover td { background:#35465b!important; }
html[data-theme="dark"] .stat-card.is-key { background:linear-gradient(135deg,#2c3b4f,#373b4a)!important; border-color:#4b596d!important; box-shadow:inset 3px 0 #a9878a,var(--shadow-sm); }
html[data-theme="dark"] .stat-card.is-key strong { color:#f0e3e5!important; }
html[data-theme="dark"] .key-metric { background:#34445a!important; border-color:#4a5c75!important; }
html[data-theme="dark"] .key-metric em { color:#c2d0ed!important; }
html[data-theme="dark"] .key-metric b { color:var(--ink)!important; }
html[data-theme="dark"] .app-tab-skeleton { background:var(--bg)!important; }
html[data-theme="dark"] .barcode-label { background:var(--surface-2)!important; border-color:var(--border)!important; color:var(--ink); }
html[data-theme="dark"] .barcode-product-name,
html[data-theme="dark"] .barcode-item-code { color:var(--ink); }
html[data-theme="dark"] .panel-heading { border-bottom-color:var(--border)!important; }
html[data-theme="dark"] hr { border-color:var(--border)!important; opacity:1; }
html[data-theme="dark"] .app-tab-bar { background:var(--surface)!important; border-color:var(--border)!important; }
html[data-theme="dark"] .app-tab { background:var(--surface-2)!important; border-color:var(--border)!important; color:var(--muted)!important; }
html[data-theme="dark"] .app-tab.is-active { background:var(--surface)!important; color:var(--ink)!important; }
@media (max-width:1100px) { .product-filter-form { grid-template-columns:repeat(2,minmax(0,1fr)); } .product-category-toggle { min-height:38px; } }
@media (max-width:600px) { .product-filter-form { width:100%; grid-template-columns:1fr; } .debtor-dialog-grid { grid-template-columns:1fr; } }
@media (max-width:480px) { .document-filter-form { width:100%; grid-template-columns:1fr; } }

/* ===== Overall polish: softer surfaces, clearer hierarchy ===== */
.panel, .stat-card, .form-card { box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px rgba(15, 23, 42, .04); }
.btn-primary {
  background: linear-gradient(135deg, #3b5bdb, #4c6ef5);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(59, 91, 219, .25);
}
.btn-primary:hover { filter: brightness(1.05); }
.page-heading h1 { letter-spacing: -.2px; }
.app-table thead th { font-size: 11px; letter-spacing: .2px; }

/* Compact dashboard metrics and a balanced masonry flow for the dashboard panels. */
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { min-height: 102px; padding: 12px 14px; display: flex; flex-direction: column; justify-content: space-between; border-radius: 12px; }
.stat-top { gap: 8px; font-size: 11px; line-height: 1.5; }
.stat-icon { width: 31px; height: 31px; flex: 0 0 31px; border-radius: 9px; }
.stat-icon .ico { width: 17px; height: 17px; }
.stat-card strong { margin: 4px 0 0; font-size: clamp(16px, 1.15vw, 19px); line-height: 1.45; overflow-wrap: anywhere; }
.stat-card small { font-size: 10px; line-height: 1.5; }
.stat-card.is-key { border-color: #f3c6c6; background: linear-gradient(145deg, #fff, #fff4f3); box-shadow: inset 3px 0 #e57268, 0 4px 14px rgba(180, 35, 24, .06); }
.stat-card.is-key strong { color: #a92a21; font-size: clamp(16px, 1.15vw, 19px); }
.dashboard-masonry { display: block; columns: 2 370px; column-gap: 16px; direction: rtl; }
.dashboard-masonry > .panel { display: inline-block; width: 100%; min-width: 0; margin: 0 0 16px; vertical-align: top; break-inside: avoid; }
.dashboard-masonry .chart-panel { min-height: 0; }
@media (min-width: 1500px) { .stats-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { min-height: 96px; padding: 10px 11px; }
  .dashboard-masonry { columns: 1; }
}
@media (max-width: 380px) { .stats-grid { grid-template-columns: 1fr; } }

/* Explicit controls for the saved WooCommerce connection. */
.woo-connection-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.woo-connection-actions form { margin: 0; }
.woo-connection-actions .btn-outline-danger { border-color: #f1b8b8; color: #b42318; background: #fff8f7; }
.woo-connection-actions .btn-outline-danger:hover { border-color: #dc6d65; color: #8f1d17; background: #fff0ee; }
html[data-theme="dark"] .woo-connection-actions .btn-outline-danger { border-color: #744144; color: #ffb4ad; background: #2a171a; }
@media (max-width: 520px) { .woo-connection-card .panel-heading { align-items: flex-start; flex-direction: column; } .woo-connection-actions { width: 100%; } }


/* Container for each form field */
.form-grid .form-field {
  position: relative;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 8px 10px 4px;
  margin-top: 8px;
  background-color: #fff;
}

/* Label positioned on the top border */
.form-grid .form-field label {
  position: absolute;
  top: -9px;
  right: 10px; /* Adjust to 'left' if using LTR layout */
  background-color: #fff;
  padding: 0 5px;
  font-size: 11px;
  color: #888;
  z-index: 1;
}

/* Inner input/select styling */
.form-grid .form-field input,
.form-grid .form-field select,
.form-grid .form-field textarea {
  border: none !important;
  outline: none !important;
  width: 100%;
  background-color: transparent !important;
  box-shadow: none !important;
  height: auto;
  min-height: unset;
  padding: 4px 0;
}

/* اصلاح ارتفاع فیلد جستجوی تامین‌کننده */
.product-search input#id_contact-search {
    height: 40px !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    box-sizing: border-box;
}
/* اصلاح نبود حاشیه در فیلدهای فرم بخش پرداخت */
.form-grid .form-field input,
.form-grid .form-field select {
    border: 1px solid #d1d5db !important;
    padding: 0.5rem !important;
    border-radius: 0.375rem !important;
    appearance: auto !important; /* برای نمایش فلش در select و استایل پیش‌فرض */
    -webkit-appearance: auto !important;
}

/* استایل پیشنهادی برای حالت فوکوس جهت بهبود تجربه کاربری */
.form-grid .form-field input:focus,
.form-grid .form-field select:focus {
    outline: 2px solid #3b82f6 !important;
    border-color: transparent !important;
}
/* اصلاح نبود حاشیه در فیلدهای فرم بخش پرداخت */
.form-grid .form-field input,
.form-grid .form-field select {
    border: 1px solid #d1d5db !important;
    padding: 0.5rem !important;
    border-radius: 0.375rem !important;
    appearance: auto !important; /* برای نمایش فلش در select و استایل پیش‌فرض */
    -webkit-appearance: auto !important;
}

/* استایل پیشنهادی برای حالت فوکوس جهت بهبود تجربه کاربری */
.form-grid .form-field input:focus,
.form-grid .form-field select:focus {
    outline: 2px solid #3b82f6 !important;
    border-color: transparent !important;
}

/* Product three-dot menu and movement history */
.product-actions-menu{position:relative;display:inline-block}
.product-actions-menu>summary{list-style:none;cursor:pointer}
.product-actions-menu>summary::-webkit-details-marker{display:none}
.product-actions-popover{position:absolute;inset-inline-end:0;top:calc(100% + 4px);z-index:30;min-width:150px;background:var(--bs-body-bg,#fff);border:1px solid rgba(100,110,140,.25);border-radius:10px;box-shadow:0 8px 24px rgba(20,30,60,.16);padding:6px;display:flex;flex-direction:column;gap:2px}
.product-actions-popover button{font:inherit;text-align:right;border:0;background:transparent;color:inherit;padding:8px 10px;border-radius:7px;cursor:pointer;white-space:nowrap}
.product-actions-popover button:hover{background:rgba(52,78,155,.1)}
.movement-summary{display:flex;flex-wrap:wrap;gap:8px 22px;padding:10px 12px;border-radius:9px;background:rgba(52,78,155,.07);margin-bottom:6px}
.movement-heading{font-size:14px;font-weight:700;margin:16px 0 6px}

/* Product list: search stays visible beside the filter icon instead of living inside the filter popover. */
.product-list-tools .product-search-form { flex:1 1 260px; max-width:420px; margin:0; }
.product-list-tools .product-search-form .form-control { width:100%; height:40px; border-radius:10px; }
.product-list-tools .filter-toggle-wrap { margin-bottom:0; }
@media (max-width:600px) { .product-list-tools .product-search-form { max-width:none; width:100%; } }
