:root {
  color-scheme: dark;
  --primary: #f27a1a;
  --primary-hover: #ff8b2e;
  --primary-soft: rgba(242, 122, 26, 0.14);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.15);

  --bg-main: #0b0f19;
  --bg-panel: rgba(17, 24, 39, 0.85);
  --bg-card: rgba(30, 41, 59, 0.65);
  --bg-input: rgba(15, 23, 42, 0.9);
  --bg-dropdown: #131b2e;
  --bg-dropdown-trigger: #111827;
  --border-color: rgba(148, 163, 184, 0.16);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-main: #f1f5f9;
  --bg-panel: rgba(255, 255, 255, 0.92);
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --bg-dropdown: #ffffff;
  --bg-dropdown-trigger: #ffffff;
  --border-color: rgba(15, 23, 42, 0.1);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 99px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(242, 122, 26, 0.65);
}

body {
  font-family: "Cairo", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(circle at 12% 15%, rgba(242, 122, 26, 0.09), transparent 32%),
    radial-gradient(circle at 88% 82%, rgba(59, 130, 246, 0.08), transparent 35%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  direction: rtl;
}

code, pre {
  font-family: "JetBrains Mono", monospace;
  direction: ltr;
  unicode-bidi: embed;
}

.hidden {
  display: none !important;
}

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

iconify-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.18em;
  line-height: 1;
  font-size: 1.2em;
  flex-shrink: 0;
}

.nav-icon iconify-icon {
  font-size: 1.35rem;
}

.stat-icon iconify-icon {
  font-size: 1.75rem;
}

.brand-logo-icon iconify-icon {
  font-size: 1.65rem;
}

.page-header h1 iconify-icon,
.card-header h3 iconify-icon,
.modal-header h2 iconify-icon {
  color: var(--primary);
  margin-left: 0.35rem;
  font-size: 1.25em;
}

/* ========================================================================= */
/* Auth Overlay                                                              */
/* ========================================================================= */
.auth-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 1.25rem;
  overflow: hidden;
  isolation: isolate;
}

.auth-ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(75px);
  pointer-events: none;
  z-index: -1;
  opacity: 0.55;
}

.auth-orb-1 {
  width: 360px;
  height: 360px;
  top: -90px;
  right: max(8%, calc(50% - 340px));
  background: radial-gradient(circle, rgba(242, 122, 26, 0.34) 0%, rgba(255, 82, 0, 0.08) 65%, transparent 100%);
}

.auth-orb-2 {
  width: 340px;
  height: 340px;
  bottom: -90px;
  left: max(8%, calc(50% - 340px));
  background: radial-gradient(circle, rgba(59, 130, 246, 0.24) 0%, rgba(16, 185, 129, 0.07) 65%, transparent 100%);
}

html[data-theme="light"] .auth-ambient-orb {
  opacity: 0.38;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  border-radius: 24px;
  padding: 1.65rem 2.15rem 1.85rem;
  background: linear-gradient(165deg, rgba(23, 32, 51, 0.92) 0%, rgba(13, 19, 33, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 24px 60px -12px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(242, 122, 26, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

html[data-theme="light"] .auth-card {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.98) 100%);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow:
    0 20px 50px -12px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(242, 122, 26, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, rgba(242, 122, 26, 0.85), transparent);
  pointer-events: none;
}

.auth-card-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 1.15rem;
  margin-bottom: 1.35rem;
  border-bottom: 1px solid var(--border-color);
}

.auth-security-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.72rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border-color);
}

.auth-security-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  flex-shrink: 0;
}

.auth-top-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.btn-auth-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-auth-theme:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  transform: translateY(-1px);
}

.brand-logo-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f27a1a, #ff5200);
  color: #fff;
  font-weight: 800;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(242, 122, 26, 0.35);
  flex-shrink: 0;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.45rem;
  margin-bottom: 1.65rem;
}

.brand-logo-ring {
  padding: 6px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(242, 122, 26, 0.22), rgba(242, 122, 26, 0.04));
  border: 1px solid rgba(242, 122, 26, 0.28);
  margin-bottom: 0.35rem;
  box-shadow: 0 10px 28px -6px rgba(242, 122, 26, 0.3);
}

.auth-brand .brand-logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 1.75rem;
}

.auth-brand .brand-logo-icon iconify-icon {
  font-size: 1.9rem;
}

.auth-brand h1 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
  background: linear-gradient(135deg, var(--text-main) 30%, #f27a1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-brand p {
  font-size: 0.86rem;
  color: var(--text-muted);
  max-width: 340px;
  line-height: 1.5;
}

.auth-form .form-group {
  margin-bottom: 1.15rem;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 0.9rem;
  color: var(--text-muted);
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  pointer-events: none;
  transition: color 0.18s ease;
  z-index: 2;
}

.auth-input-wrap:focus-within .auth-input-icon {
  color: var(--primary);
}

.auth-input-wrap input {
  width: 100%;
  padding-left: 2.65rem !important;
  padding-right: 0.95rem !important;
  height: 46px;
  border-radius: 13px;
  font-size: 0.92rem;
  text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.auth-input-wrap input#loginPassword {
  padding-right: 2.75rem !important;
}

.auth-pw-toggle {
  position: absolute;
  right: 0.55rem;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.16s ease, background-color 0.16s ease;
  z-index: 2;
}

.auth-pw-toggle:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.auth-submit-btn {
  margin-top: 0.45rem;
  height: 48px;
  border-radius: 13px;
  font-size: 0.96rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f27a1a 0%, #ff5200 100%);
  box-shadow: 0 10px 24px -6px rgba(242, 122, 26, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.auth-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -6px rgba(242, 122, 26, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  filter: brightness(1.04);
}

.auth-footer {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.auth-footer iconify-icon {
  color: var(--success);
  font-size: 1.1rem;
}

/* ========================================================================= */
/* Main App Shell                                                            */
/* ========================================================================= */
.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  border-left: 1px solid var(--border-color);
  z-index: 20;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: right;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(242, 122, 26, 0.35);
}

.nav-counter {
  margin-right: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  min-width: 24px;
  height: 22px;
  padding: 0 0.5rem;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

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

.user-mini-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  background: var(--bg-card);
  padding: 0.55rem 0.7rem;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  transition: border-color 0.2s ease;
}

.user-mini-card:hover {
  border-color: rgba(242, 122, 26, 0.35);
}

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  overflow: hidden;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.user-profile-trigger:hover {
  background: var(--primary-soft);
}

.user-profile-trigger:hover .user-info strong {
  color: var(--primary);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(242, 122, 26, 0.25);
}

.user-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.user-info strong {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.user-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-logout {
  color: #f87171 !important;
  background: rgba(239, 68, 68, 0.14) !important;
  border-color: rgba(239, 68, 68, 0.32) !important;
  font-size: 1.15rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: var(--danger) !important;
  color: #ffffff !important;
  border-color: var(--danger) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.42);
}

.profile-summary-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--primary-soft);
  border: 1px solid rgba(242, 122, 26, 0.3);
  border-radius: 14px;
  margin-bottom: 1.25rem;
}

.profile-modal-avatar {
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
}

/* ========================================================================= */
/* Topbar & Content                                                          */
/* ========================================================================= */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.75rem;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar-right, .topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.workspace-selector-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.workspace-selector-box label {
  margin-bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.proxy-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.95rem;
  border-radius: 99px;
  background: var(--bg-dropdown-trigger);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-green {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.content-container {
  padding: 1.75rem;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease;
}

.tab-pane.active {
  display: block;
}

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

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ========================================================================= */
/* Stats & Cards                                                             */
/* ========================================================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bg-orange { background: var(--primary-soft); color: var(--primary); }
.bg-green { background: var(--success-soft); color: var(--success); }
.bg-red { background: var(--danger-soft); color: var(--danger); }
.bg-blue { background: var(--info-soft); color: var(--info); }

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-orange { color: var(--primary) !important; }

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 1.25rem;
}

.stacked-tables-grid {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.stacked-tables-grid > .card {
  margin-bottom: 0;
}

/* Table Product Cell with Thumbnail */
.table-product-cell {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 260px;
}

.table-product-thumb {
  width: 46px;
  height: 58px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.table-product-thumb:hover {
  transform: scale(1.06);
  border-color: var(--primary);
}

.table-product-thumb-placeholder {
  width: 46px;
  height: 58px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.table-product-info {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  min-width: 0;
}

.table-product-title {
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.15s;
}

.table-product-title:hover {
  color: var(--primary);
}

.table-product-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.log-thumbs-stack {
  display: inline-flex;
  align-items: center;
}

.log-thumbs-stack img {
  width: 34px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #ffffff;
  border: 2px solid var(--bg-dropdown);
  margin-left: -8px;
  cursor: pointer;
  transition: transform 0.18s ease, z-index 0.18s;
  position: relative;
}

.log-thumbs-stack img:hover {
  transform: translateY(-2px) scale(1.08);
  z-index: 3;
  border-color: var(--primary);
}

.card {
  border-radius: 16px;
  padding: 1.35rem;
  margin-bottom: 1.25rem;
}

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

.card-header h3 {
  font-size: 1.08rem;
  font-weight: 700;
}

/* ========================================================================= */
/* Forms, Inputs & Buttons                                                   */
/* ========================================================================= */
.form-group {
  margin-bottom: 1.1rem;
}

.form-row {
  display: flex;
  gap: 1.15rem;
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
  min-width: 250px;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
textarea,
.select-modern {
  width: 100%;
  min-width: 210px;
  padding: 0.7rem 0.95rem;
  border-radius: 11px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:not([type="radio"]):not([type="checkbox"]):focus, textarea:focus, .select-modern:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(242, 122, 26, 0.16);
}

/* ========================================================================= */
/* Interactive Field Validation (:user-invalid / :user-valid + :has())       */
/* ========================================================================= */
.field-error {
  display: none;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.42rem;
  padding: 0.38rem 0.65rem;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #f87171;
  font-size: 0.81rem;
  font-weight: 600;
  animation: fadeIn 0.18s ease;
}

html[data-theme="light"] .field-error {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
}

.field-error iconify-icon {
  font-size: 1.05rem;
  color: var(--danger);
  flex-shrink: 0;
}

input:user-invalid,
textarea:user-invalid,
input.user-invalid-fallback,
textarea.user-invalid-fallback,
input.is-invalid,
textarea.is-invalid {
  border-color: var(--danger) !important;
  background-color: rgba(239, 68, 68, 0.05);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16) !important;
}

input:user-valid:not([type="checkbox"]):not([type="radio"]),
textarea:user-valid,
input.user-valid-fallback:not([type="checkbox"]):not([type="radio"]),
textarea.user-valid-fallback,
input.is-valid:not([type="checkbox"]):not([type="radio"]),
textarea.is-valid {
  border-color: rgba(16, 185, 129, 0.65);
}

/* Style parent .form-group using :has() + fallback class */
.form-group:has(:user-invalid) > label,
.form-group:has(.is-invalid) > label,
.form-group.has-error-fallback > label {
  color: #f87171;
}

html[data-theme="light"] .form-group:has(:user-invalid) > label,
html[data-theme="light"] .form-group:has(.is-invalid) > label,
html[data-theme="light"] .form-group.has-error-fallback > label {
  color: #dc2626;
}

.form-group:has(:user-invalid) .field-error,
.form-group:has(.is-invalid) .field-error,
.form-group.has-error-fallback .field-error {
  display: flex;
}

/* Customizable <select> (appearance: base-select) + Custom Dropdown UI */
.select-modern,
.select-modern::picker(select) {
  appearance: base-select;
}

.select-modern::picker(select) {
  font-family: inherit;
  background-color: var(--bg-dropdown) !important;
  backdrop-filter: none !important;
  border: 1px solid rgba(242, 122, 26, 0.45);
  border-radius: 14px;
  padding: 0.45rem;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.75);
  color: var(--text-main);
}

.select-modern::picker-icon {
  color: var(--primary);
  transition: transform 0.2s ease;
}

.select-modern:open::picker-icon {
  transform: rotate(180deg);
}

.select-modern option {
  padding: 0.6rem 0.85rem;
  border-radius: 9px;
  color: var(--text-main);
  background-color: var(--bg-dropdown);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.select-modern option:hover,
.select-modern option:focus {
  background-color: var(--primary-soft);
  color: var(--primary);
}

.select-modern option:checked {
  background-color: rgba(242, 122, 26, 0.18);
  color: var(--primary);
}

.select-modern option::checkmark {
  color: var(--primary);
  font-weight: 800;
}

/* Universal Custom Select Component */
.custom-select-wrapper {
  position: relative;
  width: 100%;
  min-width: 220px;
  user-select: none;
  z-index: 20;
}

.custom-select-wrapper.open {
  z-index: 99999 !important;
}

/* Elevate parent stacking contexts (created by backdrop-filter on .glass-panel) when a dropdown inside is open */
.filters-bar:has(.custom-select-wrapper.open),
.glass-panel:has(.custom-select-wrapper.open),
.card:has(.custom-select-wrapper.open),
.form-row:has(.custom-select-wrapper.open),
.form-group:has(.custom-select-wrapper.open),
.filter-item:has(.custom-select-wrapper.open),
.has-open-select {
  position: relative;
  z-index: 9000 !important;
}

.workspace-selector-box .custom-select-wrapper {
  min-width: 340px;
  width: 340px;
}

.workspace-selector-box .custom-select-trigger {
  padding: 0.72rem 1.15rem;
  font-size: 0.94rem;
}

.custom-select-native-hidden {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.68rem 1.05rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-dropdown-trigger);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: right;
}

.custom-select-trigger:hover {
  border-color: rgba(242, 122, 26, 0.65);
  background-color: var(--bg-dropdown);
}

.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(242, 122, 26, 0.2);
  background-color: var(--bg-dropdown);
}

.custom-select-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.custom-select-arrow {
  color: var(--primary);
  font-size: 1.3rem;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-select-wrapper.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background-color: #131b2e !important;
  backdrop-filter: none !important;
  border: 1.5px solid rgba(242, 122, 26, 0.55);
  border-radius: 14px;
  padding: 0.5rem;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  z-index: 99999 !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

html[data-theme="light"] .custom-select-menu {
  background-color: #ffffff !important;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.custom-select-wrapper.open .custom-select-menu {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto;
  animation: fadeIn 0.14s ease;
}

.modal-body .custom-select-menu {
  top: auto;
  bottom: calc(100% + 8px);
}

.custom-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.62rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.custom-select-option + .custom-select-option {
  margin-top: 2px;
}

.custom-select-option:hover {
  background: var(--primary-soft);
  color: var(--primary);
  padding-right: 1.05rem;
}

.custom-select-option.selected {
  background: linear-gradient(135deg, rgba(242, 122, 26, 0.22), rgba(242, 122, 26, 0.08));
  color: var(--primary);
  border: 1px solid rgba(242, 122, 26, 0.3);
}

.custom-select-check {
  color: var(--primary);
  font-size: 1.15rem;
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.15s ease;
}

.custom-select-option.selected .custom-select-check {
  opacity: 1;
  transform: scale(1);
}

small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.radio-cards-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-input);
  cursor: pointer;
  opacity: 0.75;
  transition: all 0.2s ease;
  user-select: none;
}

.radio-card:hover {
  opacity: 0.95;
  border-color: rgba(242, 122, 26, 0.4);
}

.radio-card input[type="radio"] {
  width: 18px;
  height: 18px;
  margin-top: 0.15rem;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.radio-card.active,
.radio-card:has(input:checked) {
  opacity: 1;
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(242, 122, 26, 0.14);
}

.radio-card:not(.active):not(:has(input:checked)) {
  border-color: var(--border-color);
  background: var(--bg-input);
  box-shadow: none;
}

.radio-card strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 0.15rem;
}

.radio-card.active strong,
.radio-card:has(input:checked) strong {
  color: var(--primary);
}

.label-with-samples {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.sample-links {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-chip {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid rgba(242, 122, 26, 0.35);
  border-radius: 99px;
  padding: 0.2rem 0.7rem;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.scrape-options-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  font-weight: 500;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1.2rem;
  border-radius: 11px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #f27a1a, #e05a00);
  color: #fff;
  box-shadow: 0 4px 14px rgba(242, 122, 26, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ff8b2e, #f27a1a);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

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

.btn-ghost:hover {
  color: var(--text-main);
  background: var(--bg-card);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  border-radius: 9px;
}

.btn-lg {
  padding: 0.8rem 1.65rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-orange { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* ========================================================================= */
/* Products Cards Grid                                                       */
/* ========================================================================= */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 14px;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-item.search-box {
  flex: 2;
  min-width: 260px;
}

.filter-item {
  flex: 1;
  min-width: 170px;
}

/* Bulk Selection & Manual Webhook Sync Bar */
.bulk-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 0.85rem 1.15rem;
  border-radius: 14px;
  margin-bottom: 1.25rem;
  border: 1.5px solid var(--border-color);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.bulk-selection-bar.has-selection {
  border-color: rgba(242, 122, 26, 0.55);
  background: linear-gradient(135deg, rgba(242, 122, 26, 0.12), var(--bg-panel));
  box-shadow: 0 10px 28px rgba(242, 122, 26, 0.14);
}

.bulk-selection-right {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.bulk-select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.bulk-select-all-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.bulk-selection-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.products-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.2rem;
}

.product-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.product-card:hover {
  transform: translateY(-3px);
  border-color: rgba(242, 122, 26, 0.45);
}

.product-card.selected,
.product-card:has(.product-card-checkbox:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(242, 122, 26, 0.22), 0 12px 28px rgba(0, 0, 0, 0.35);
}

.product-img-wrap {
  position: relative;
  height: 220px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-img-wrap img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.product-badges-top {
  position: absolute;
  top: 10px;
  right: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 3;
}

.product-select-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.86);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  color: #f8fafc;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: all 0.18s ease;
}

.product-select-pill:hover {
  background: rgba(15, 23, 42, 0.96);
  border-color: var(--primary);
}

.product-card.selected .product-select-pill,
.product-select-pill:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.product-select-pill input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #fff;
  cursor: pointer;
}

.product-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}

.product-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.product-title {
  font-size: 0.96rem;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3rem;
}

.product-price-box {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 0.2rem;
}

.price-current {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
}

.price-old {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: line-through;
}

.variants-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.size-chip {
  font-size: 0.74rem;
  padding: 0.12rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
}

.size-chip.out {
  opacity: 0.45;
  text-decoration: line-through;
  border-color: var(--danger);
}

.product-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 0.9rem;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.12);
}

.product-btn-detail {
  flex: 1;
  height: 38px;
  padding: 0 0.75rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  gap: 0.4rem;
  white-space: nowrap;
}

.product-btn-detail iconify-icon {
  font-size: 1.2rem;
  vertical-align: middle;
}

.product-action-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.product-action-icon iconify-icon {
  font-size: 1.2rem;
}

.btn-action-webhook,
.btn-webhook-solid {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.32);
  background: rgba(16, 185, 129, 0.1);
}

.btn-action-webhook:hover,
.btn-webhook-solid:hover {
  color: #fff;
  background: #059669;
  border-color: #059669;
  transform: translateY(-1px);
}

.btn-action-refresh {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.08);
}

.btn-action-refresh:hover {
  color: #fff;
  background: #0284c7;
  border-color: #0284c7;
  transform: translateY(-1px);
}

.btn-action-external {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.08);
}

.btn-action-external:hover {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* ========================================================================= */
/* Workspaces Cards                                                          */
/* ========================================================================= */
.workspaces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.ws-card {
  border-radius: 16px;
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.api-key-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.api-key-box code {
  flex: 1;
  font-size: 0.82rem;
  color: var(--primary);
  overflow-x: auto;
}

/* ========================================================================= */
/* Tables                                                                    */
/* ========================================================================= */
.table-responsive {
  overflow-x: auto;
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

.modern-table th {
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.empty-cell {
  text-align: center !important;
  padding: 2rem !important;
  color: var(--text-muted);
}

/* ========================================================================= */
/* Native <dialog> Modals (Following modern-web-guidance light-dismiss)      */
/* ========================================================================= */
dialog.modal-dialog {
  margin: auto;
  width: 92%;
  max-width: 600px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-panel);
  color: var(--text-main);
  padding: 0;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65);
  overflow: visible;
}

dialog.modal-dialog.modal-lg {
  max-width: 680px;
}

dialog.modal-dialog.modal-xl {
  max-width: 1080px;
  overflow: hidden;
}

dialog.modal-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-content {
  display: flex;
  flex-direction: column;
  max-height: 95vh;
}

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

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
}

.btn-close {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
}

.modal-body {
  padding: 1.2rem 1.45rem;
  overflow: visible;
}

dialog.modal-dialog.modal-xl .modal-body {
  overflow-y: auto;
}

.modal-body .form-group {
  margin-bottom: 0.85rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-color);
  margin-top: 0.75rem;
}

/* Product Detail Modal Layout */
.detail-top-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.detail-gallery-main {
  background: #fff;
  border-radius: 14px;
  height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  margin-bottom: 0.65rem;
}

.detail-gallery-main img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.detail-thumbs {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

.detail-thumbs img {
  width: 56px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  background: #fff;
}

.detail-thumbs img.active {
  border-color: var(--primary);
}

.group-options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.75rem 0 1.25rem;
}

.group-opt-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  cursor: pointer;
  transition: all 0.2s;
}

.group-opt-card.current {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.group-opt-card img {
  width: 36px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: #fff;
}

/* API Docs & Code */
.api-endpoints-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0;
}

.api-ep-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.95rem;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.method-badge {
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.75rem;
  font-family: "JetBrains Mono", monospace;
}

.method-badge.get { background: var(--info-soft); color: var(--info); }
.method-badge.post { background: var(--success-soft); color: var(--success); }

.code-example-box {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
}

.code-example-box pre {
  overflow-x: auto;
  color: #e2e8f0;
  font-size: 0.84rem;
}

/* Progress & Toasts */
.progress-bar-wrap {
  height: 6px;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar-fill.indeterminate {
  width: 45%;
  height: 100%;
  background: var(--primary);
  animation: slideProgress 1.2s infinite ease-in-out;
}

@keyframes slideProgress {
  0% { transform: translateX(120%); }
  100% { transform: translateX(-220%); }
}

/* ========================================================================= */
/* Prominent Modern Alerts & Floating Toasts (Top Layer Popover)             */
/* ========================================================================= */
.toast-container,
.toast-container:popover-open {
  position: fixed !important;
  inset: 24px auto auto 24px !important;
  top: 24px !important;
  left: 24px !important;
  right: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  color: inherit;
  box-shadow: none !important;
  overflow: visible !important;
  z-index: 2147483647 !important;
  display: flex !important;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
  width: calc(100vw - 48px);
  pointer-events: none;
}

.toast-container:empty {
  display: none !important;
}

.toast {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background-color: #131b2e !important;
  border: 1.5px solid rgba(148, 163, 184, 0.25);
  border-right: 4.5px solid var(--success);
  color: var(--text-main);
  padding: 0.95rem 1.1rem 1.15rem;
  border-radius: 16px;
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
  animation: toastSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="light"] .toast {
  background-color: #ffffff !important;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.24), 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.toast.toast-closing {
  animation: toastSlideOut 0.22s ease forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(-28px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateX(-28px) scale(0.95);
  }
}

.toast-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
  background: var(--success-soft);
  color: var(--success);
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 0.2rem;
  color: var(--text-main);
}

.toast-message {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.45;
  word-break: break-word;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 8px;
  font-size: 1.2rem;
  line-height: 1;
  transition: color 0.18s, background 0.18s;
}

.toast-close:hover {
  color: var(--text-main);
  background: rgba(148, 163, 184, 0.14);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 3.5px;
  width: 100%;
  background: var(--success);
  transform-origin: right;
  animation: toastCountdown 4.5s linear forwards;
}

@keyframes toastCountdown {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Toast Variants */
.toast.toast-success {
  border-right-color: var(--success);
}
.toast.toast-success .toast-icon-badge {
  background: var(--success-soft);
  color: var(--success);
}
.toast.toast-success .toast-progress {
  background: var(--success);
}

.toast.toast-danger {
  border-right-color: var(--danger);
}
.toast.toast-danger .toast-icon-badge {
  background: var(--danger-soft);
  color: var(--danger);
}
.toast.toast-danger .toast-title {
  color: #f87171;
}
html[data-theme="light"] .toast.toast-danger .toast-title {
  color: #dc2626;
}
.toast.toast-danger .toast-progress {
  background: var(--danger);
}

.toast.toast-warning {
  border-right-color: var(--primary);
}
.toast.toast-warning .toast-icon-badge {
  background: var(--primary-soft);
  color: var(--primary);
}
.toast.toast-warning .toast-progress {
  background: var(--primary);
}

.toast.toast-info {
  border-right-color: var(--info);
}
.toast.toast-info .toast-icon-badge {
  background: var(--info-soft);
  color: var(--info);
}
.toast.toast-info .toast-progress {
  background: var(--info);
}

/* Inline Alert Banners (.alert) */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  border-radius: 14px;
  margin-bottom: 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-right-width: 4px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  animation: alertPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes alertPopIn {
  0% { opacity: 0; transform: translateY(-6px) scale(0.98); }
  60% { transform: translateY(2px) scale(1.005); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.alert-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 0.18rem;
}

.alert-text {
  font-size: 0.86rem;
  line-height: 1.5;
  opacity: 0.95;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.38);
  border-right-color: var(--danger);
}

html[data-theme="light"] .alert-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
  border-right-color: var(--danger);
}

.alert-danger .alert-icon {
  background: rgba(239, 68, 68, 0.22);
  color: var(--danger);
}

.alert-success {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.38);
  border-right-color: var(--success);
}

html[data-theme="light"] .alert-success {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
  border-right-color: var(--success);
}

.alert-success .alert-icon {
  background: rgba(16, 185, 129, 0.22);
  color: var(--success);
}

.alert-warning {
  background: rgba(242, 122, 26, 0.14);
  color: #fdba74;
  border-color: rgba(242, 122, 26, 0.38);
  border-right-color: var(--primary);
}

html[data-theme="light"] .alert-warning {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
  border-right-color: var(--primary);
}

.alert-warning .alert-icon {
  background: rgba(242, 122, 26, 0.22);
  color: var(--primary);
}

.proxy-info-banner {
  background: var(--primary-soft);
  border: 1px solid rgba(242, 122, 26, 0.3);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.25rem 0;
}

.pagination-bar {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 1.5rem;
}

/* ========================================================================= */
/* Tracking History Table Selection & Per-Row Actions                        */
/* ========================================================================= */
.tracking-bulk-bar {
  margin: 0 0 1rem 0;
  background: rgba(15, 23, 42, 0.35);
}

html[data-theme="light"] .tracking-bulk-bar {
  background: rgba(241, 245, 249, 0.75);
}

.table-select-th,
.table-select-cell {
  width: 42px;
  text-align: center;
  padding-left: 0.5rem !important;
  padding-right: 0.75rem !important;
}

.table-checkbox {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}

.modern-table tbody tr.table-row-selected {
  background: rgba(242, 122, 26, 0.11) !important;
}

.modern-table tbody tr.table-row-selected td:first-child {
  box-shadow: inset -3px 0 0 var(--primary);
}

.table-actions-th {
  text-align: left;
  white-space: nowrap;
}

.table-actions-cell {
  white-space: nowrap;
}

.table-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-table-retrack {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.32);
  padding: 0.34rem 0.72rem;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 9px;
  gap: 0.35rem;
  white-space: nowrap;
}

.btn-table-retrack:hover:not(:disabled) {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
  transform: translateY(-1px);
}

html[data-theme="light"] .btn-table-retrack {
  background: rgba(2, 132, 199, 0.1);
  color: #0369a1;
  border-color: rgba(2, 132, 199, 0.28);
}

html[data-theme="light"] .btn-table-retrack:hover:not(:disabled) {
  background: #0284c7;
  color: #fff;
}

.btn-action-detail {
  color: var(--primary);
  border-color: rgba(242, 122, 26, 0.3);
  background: rgba(242, 122, 26, 0.09);
}

.btn-action-detail:hover {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* =========================================================================
   Role-Based Permissions & Multi-Project User Management UI
   ========================================================================= */
.nav-label-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
  gap: 0.15rem;
}

.admin-only-nav-note {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.28);
  padding: 0.08rem 0.42rem;
  border-radius: 6px;
}

.nav-item.nav-item-disabled {
  opacity: 0.62;
  cursor: not-allowed;
  border-style: dashed;
}

.nav-item.nav-item-disabled:hover {
  background: rgba(245, 158, 11, 0.06);
  color: var(--text-muted);
}

.admin-only-inline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  margin-right: 0.35rem;
  white-space: nowrap;
}

.admin-lock-notice {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
  padding: 0.5rem 0.75rem;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.1);
  border: 1px dashed rgba(245, 158, 11, 0.38);
}

html[data-theme="light"] .admin-lock-notice {
  color: #b45309;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(217, 119, 6, 0.35);
}

.btn-admin-locked,
button.btn-admin-locked:disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.25);
}

.check-row.disabled-lock-row {
  opacity: 0.65;
  cursor: not-allowed;
}

.ws-admin-locked-row {
  border-style: dashed !important;
  opacity: 0.85;
}

.usr-ws-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.usr-ws-header label {
  margin-bottom: 0 !important;
}

.usr-ws-all-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(242, 122, 26, 0.1);
  border: 1px solid rgba(242, 122, 26, 0.28);
  padding: 0.28rem 0.68rem;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.usr-ws-all-toggle input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.usr-workspaces-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 0.5rem;
  max-height: 210px;
  overflow-y: auto;
  padding: 0.65rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border);
}

html[data-theme="light"] .usr-workspaces-checklist {
  background: rgba(241, 245, 249, 0.75);
}

.usr-ws-check-card {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.usr-ws-check-card:hover {
  border-color: rgba(242, 122, 26, 0.5);
}

.usr-ws-check-card.checked {
  border-color: var(--primary);
  background: rgba(242, 122, 26, 0.11);
}

.usr-ws-check-card input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.usr-ws-card-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.usr-ws-card-info strong {
  font-size: 0.84rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usr-ws-card-info small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.user-projects-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* =========================================================================
   Settings & Proxies Full-Width 2-Tab Switcher
   ========================================================================= */
.settings-subtabs-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  padding: 0.5rem;
  border-radius: 16px;
  margin-bottom: 1.35rem;
}

.settings-subtab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-subtab-btn iconify-icon {
  font-size: 1.35rem;
}

.settings-subtab-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.settings-subtab-btn.active {
  background: linear-gradient(135deg, rgba(242, 122, 26, 0.2), rgba(242, 122, 26, 0.08));
  color: var(--primary);
  border-color: rgba(242, 122, 26, 0.45);
  box-shadow: 0 4px 16px rgba(242, 122, 26, 0.14);
}

.subtab-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 0.55rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--primary);
  color: #fff;
}

.settings-subtab-pane {
  display: none;
  width: 100%;
  animation: fadeIn 0.2s ease;
}

.settings-subtab-pane.active {
  display: block;
}

.full-width-card {
  width: 100%;
}

.settings-checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.settings-checks-grid .form-group {
  margin-bottom: 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
}

/* =========================================================================
   Guide & Documentation Tab (#tab-guide) — Full-Width Cards & Tables
   ========================================================================= */
.guide-subtabs-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  padding: 0.45rem;
  border-radius: 16px;
  margin-bottom: 1.35rem;
}

.guide-section-block {
  width: 100%;
  margin-bottom: 1.35rem;
  animation: fadeIn 0.2s ease;
}

.guide-intro-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.15rem 1.3rem;
  margin-bottom: 1.25rem;
}

.guide-intro-box p {
  font-size: 0.94rem;
  color: var(--text-main);
  margin-bottom: 0.9rem;
}

.guide-url-anatomy {
  background: rgba(242, 122, 26, 0.08);
  border: 1px dashed rgba(242, 122, 26, 0.4);
  border-radius: 12px;
  padding: 0.95rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.url-anatomy-title {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--primary);
}

.url-anatomy-code {
  background: #090d16;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  direction: ltr;
  text-align: left;
}

.url-anatomy-code code {
  font-size: 0.9rem;
  color: #cbd5e1;
}

.url-highlight-cid {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  padding: 0.12rem 0.5rem;
  border-radius: 6px;
  margin: 0 0.2rem;
}

.url-anatomy-legend {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.guide-table th,
.guide-table td {
  vertical-align: top;
  padding: 0.95rem 1rem;
  line-height: 1.65;
}

.guide-code-pill {
  display: inline-block;
  padding: 0.22rem 0.65rem;
  border-radius: 8px;
  background: rgba(242, 122, 26, 0.14);
  border: 1px solid rgba(242, 122, 26, 0.35);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
}

.guide-btn-preview {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.8rem;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
}

.guide-btn-preview.primary {
  background: rgba(242, 122, 26, 0.15);
  color: var(--primary);
  border-color: rgba(242, 122, 26, 0.4);
}

.guide-btn-preview.info {
  background: rgba(56, 189, 248, 0.13);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.guide-btn-preview.webhook {
  background: rgba(16, 185, 129, 0.13);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.35);
}

.guide-btn-preview.secondary {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-main);
  border-color: rgba(148, 163, 184, 0.28);
}

/* =========================================================================
   Header Language Toggle Button & LTR (English) Support
   ========================================================================= */
.btn-lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 38px;
  padding: 0 0.85rem;
  border-radius: 11px;
  background: var(--bg-dropdown-trigger);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-lang-toggle iconify-icon {
  font-size: 1.15rem;
  color: var(--primary);
}

.btn-lang-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  transform: translateY(-1px);
}

.lang-toggle-code {
  letter-spacing: 0.04em;
}

html[dir="ltr"] body {
  direction: ltr;
}

html[dir="ltr"] .sidebar {
  border-left: none;
  border-right: 1px solid var(--border-color);
}

html[dir="ltr"] .nav-item,
html[dir="ltr"] .custom-select-trigger,
html[dir="ltr"] .modern-table th,
html[dir="ltr"] .modern-table td {
  text-align: left;
}

html[dir="ltr"] .nav-counter {
  margin-right: 0;
  margin-left: auto;
}

html[dir="ltr"] .page-header h1 iconify-icon,
html[dir="ltr"] .card-header h3 iconify-icon,
html[dir="ltr"] .modal-header h2 iconify-icon {
  margin-left: 0;
  margin-right: 0.35rem;
}

/* =========================================================================
   Mobile Navigation Drawer & Responsive Design System
   (Dynamic viewport units dvh/dvw, clamp() typography, aspect-ratio, @container)
   ========================================================================= */
body,
.auth-screen,
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
}

.page-header h1 {
  font-size: clamp(1.18rem, 0.98rem + 1vw, 1.5rem);
}

.stat-value {
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem);
}

.table-product-thumb {
  aspect-ratio: 46 / 58;
}

.detail-thumbs img {
  aspect-ratio: 4 / 5;
}

.group-opt-card img {
  aspect-ratio: 3 / 4;
}

/* Sticky Table Headers & Container Queries */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-inline-size: 100%;
  container-type: inline-size;
}

.modern-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

@container (width < 600px) {
  .modern-table th,
  .modern-table td {
    padding: 0.6rem 0.65rem;
    font-size: 0.81rem;
  }
  .table-product-cell {
    min-width: 210px;
    gap: 0.6rem;
  }
  .table-product-thumb,
  .table-product-thumb-placeholder {
    width: 38px;
    height: 48px;
  }
}

/* Mobile Menu Button, Sidebar Close Button & Backdrop (Hidden on Desktop) */
.mobile-menu-btn,
.sidebar-close-btn {
  display: none;
  flex-shrink: 0;
}

.mobile-menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--primary-soft);
  border-color: rgba(242, 122, 26, 0.35);
  color: var(--primary);
  font-size: 1.35rem;
}

.mobile-menu-btn:hover {
  background: var(--primary);
  color: #fff;
}

.sidebar-close-btn {
  margin-right: auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--text-muted);
}

html[dir="ltr"] .sidebar-close-btn {
  margin-right: 0;
  margin-left: auto;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 20, 0.68);
  backdrop-filter: blur(4px);
  z-index: 990;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

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

/* Flexible Grid Minimums to Prevent Horizontal Overflow on Small Screens */
.products-cards-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.workspaces-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
}

.two-col-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
}

.settings-checks-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

/* =========================================================================
   Tablet & Mobile Breakpoint (<= 1024px) — Off-Canvas Drawer Navigation
   ========================================================================= */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-menu-btn,
  .sidebar-close-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: min(300px, 85dvw);
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    overflow-y: auto;
    background: var(--bg-dropdown) !important;
    box-shadow: -16px 0 45px rgba(0, 0, 0, 0.65);
    transform: translateX(105%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  html[dir="ltr"] .sidebar {
    right: auto;
    left: 0;
    box-shadow: 16px 0 45px rgba(0, 0, 0, 0.65);
    transform: translateX(-105%);
  }

  .sidebar.mobile-open,
  html[dir="ltr"] .sidebar.mobile-open {
    transform: translateX(0);
  }

  .topbar {
    padding: 0.75rem 1.15rem;
    gap: 0.75rem;
  }

  .workspace-selector-box .custom-select-wrapper {
    min-width: 240px;
    width: 260px;
  }

  .content-container {
    padding: 1.25rem;
  }

  .detail-top-grid {
    grid-template-columns: 260px 1fr;
    gap: 1.15rem;
  }

  .guide-subtabs-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =========================================================================
   Mobile Phones Breakpoint (<= 768px)
   ========================================================================= */
@media (max-width: 768px) {
  /* Auth Login Card */
  .auth-screen {
    padding: 1rem;
  }

  .auth-card {
    padding: 1.5rem 1.25rem;
    border-radius: 16px;
  }

  .auth-brand {
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .auth-brand h1 {
    font-size: 1.12rem;
  }

  /* Topbar Layout on Mobile */
  .topbar {
    padding: 0.65rem 0.85rem;
    gap: 0.6rem;
  }

  .topbar-right {
    flex: 1 1 100%;
    order: 2;
    gap: 0.55rem;
  }

  /* Put Hamburger + Quick Controls neatly accessible */
  .workspace-selector-box {
    flex: 1;
    min-width: 0;
    gap: 0.45rem;
  }

  .workspace-selector-box label {
    display: none;
  }

  .workspace-selector-box .custom-select-wrapper {
    width: 100% !important;
    min-width: 0 !important;
  }

  .workspace-selector-box .custom-select-trigger {
    padding: 0.58rem 0.85rem;
    font-size: 0.86rem;
  }

  .topbar-left {
    width: 100%;
    order: 1;
    justify-content: flex-end;
    gap: 0.45rem;
  }

  .proxy-pill {
    flex: 1;
    min-width: 0;
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
  }

  .proxy-pill #topbarProxyText {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Main Container & Cards */
  .content-container {
    padding: 0.95rem 0.75rem 2rem;
  }

  .card {
    padding: 1rem 0.9rem;
    border-radius: 14px;
    margin-bottom: 1rem;
  }

  .card-header {
    gap: 0.55rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.65rem;
  }

  .card-header h3 {
    font-size: 0.98rem;
  }

  /* Page Header & Action Buttons */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
    margin-bottom: 1.1rem;
  }

  .page-header p {
    font-size: 0.84rem;
  }

  .header-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .header-actions .btn {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 140px;
    padding: 0.58rem 0.75rem;
    font-size: 0.82rem;
    text-align: center;
  }

  /* Stats Grid: 2x2 Compact Grid on Mobile */
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin-bottom: 1.1rem;
  }

  .stat-card {
    padding: 0.85rem;
    gap: 0.65rem;
    border-radius: 14px;
    flex-direction: column;
    align-items: flex-start;
  }

  .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
  }

  .stat-icon iconify-icon {
    font-size: 1.4rem;
  }

  .stat-label {
    font-size: 0.78rem;
  }

  .stat-sub {
    font-size: 0.72rem;
  }

  /* Forms & Inputs */
  .form-row {
    flex-direction: column;
    gap: 0.85rem;
  }

  .flex-1 {
    min-width: 100%;
  }

  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="url"],
  input[type="number"],
  textarea,
  .select-modern,
  .custom-select-wrapper {
    min-width: 0;
  }

  .scrape-options-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .scrape-options-bar .btn-lg {
    width: 100%;
  }

  /* Filters Bar & Bulk Selection Bar */
  .filters-bar {
    padding: 0.85rem;
    gap: 0.6rem;
  }

  .filter-item,
  .filter-item.search-box {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .filters-bar > .btn {
    flex: 1 1 calc(50% - 0.35rem);
  }

  .bulk-selection-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.8rem 0.85rem;
    gap: 0.75rem;
  }

  .bulk-selection-right {
    justify-content: space-between;
    width: 100%;
  }

  .bulk-selection-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }

  .bulk-selection-actions .btn {
    width: 100%;
    white-space: normal;
    line-height: 1.35;
    padding: 0.55rem 0.75rem;
    text-align: center;
  }

  /* Products Cards & Workspaces Grid */
  .products-cards-grid,
  .workspaces-grid,
  .two-col-grid {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .product-img-wrap {
    height: 195px;
  }

  .api-key-box {
    flex-wrap: wrap;
  }

  .api-key-box code {
    width: 100%;
    flex: 1 1 100%;
    padding-bottom: 0.25rem;
  }

  /* Settings & Guide Subtabs */
  .settings-subtabs-bar,
  .guide-subtabs-bar {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding: 0.4rem;
  }

  .settings-subtab-btn {
    padding: 0.68rem 0.85rem;
    font-size: 0.86rem;
    justify-content: flex-start;
  }

  .guide-intro-box {
    padding: 0.85rem 0.9rem;
  }

  .guide-url-anatomy {
    padding: 0.75rem 0.85rem;
  }

  /* Modals (<dialog>) on Mobile */
  dialog.modal-dialog,
  dialog.modal-dialog.modal-lg,
  dialog.modal-dialog.modal-xl {
    width: min(96dvw, 100%);
    max-width: 96dvw;
    border-radius: 16px;
    margin: auto;
  }

  .modal-content {
    max-height: 92vh;
    max-height: 92dvh;
  }

  .modal-header {
    padding: 0.85rem 1rem;
    gap: 0.5rem;
  }

  .modal-header h2 {
    font-size: 0.98rem;
    line-height: 1.35;
  }

  .modal-body {
    padding: 0.95rem 1rem;
    overflow-y: auto;
    max-height: calc(92dvh - 64px);
  }

  .modal-body .custom-select-menu {
    top: calc(100% + 6px);
    bottom: auto;
  }

  .modal-footer {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    flex: 1 1 auto;
  }

  /* Product Detail Modal on Mobile */
  .detail-top-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .detail-gallery-main {
    height: 230px;
  }

  .group-opt-card {
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 140px;
  }

  /* Toasts on Mobile */
  .toast-container,
  .toast-container:popover-open {
    inset: 12px 12px auto 12px !important;
    top: 12px !important;
    left: 12px !important;
    right: 12px !important;
    width: calc(100dvw - 24px) !important;
    max-width: none !important;
  }

  .toast {
    padding: 0.8rem 0.9rem 0.95rem;
    border-radius: 14px;
  }
}

/* =========================================================================
   Small Mobile Phones Breakpoint (<= 420px)
   ========================================================================= */
@media (max-width: 420px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    flex-direction: row;
    align-items: center;
  }

  .header-actions .btn {
    flex: 1 1 100%;
  }

  .group-opt-card {
    flex: 1 1 100%;
  }
}


