/* ==========================================================================
   Hawaii Papaya Order Management System - FHD 1920x1080 Optimized CSS
   ========================================================================== */

:root {
  /* Color Palette - Premium Slate & Emerald Accent */
  --bg-main: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #1c2742;
  --bg-input: #1a233a;
  --bg-input-focus: #243050;
  --bg-table-header: #0e1526;
  --bg-row-alt: #10182b;
  --bg-row-hover: #19243c;
  --bg-row-selected: #1d3557;

  --border-color: #23304d;
  --border-focus: #3b82f6;
  --border-subtle: #192338;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0b0f19;

  /* Status Colors */
  --color-ok: #10b981;        /* Emerald (0 remaining) */
  --color-ok-bg: rgba(16, 185, 129, 0.15);
  --color-ok-border: rgba(16, 185, 129, 0.4);

  --color-surplus: #38bdf8;   /* Sky Blue (>0 remaining) */
  --color-surplus-bg: rgba(56, 189, 248, 0.15);
  --color-surplus-border: rgba(56, 189, 248, 0.4);

  --color-shortage: #f43f5e;  /* Rose/Crimson (<0 shortage) */
  --color-shortage-bg: rgba(244, 63, 94, 0.15);
  --color-shortage-border: rgba(244, 63, 94, 0.4);

  --color-accent: #f59e0b;    /* Amber */
  --color-brand: #6366f1;     /* Indigo */
  --color-brand-hover: #4f46e5;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "BIZ UDPGothic", "Hiragino Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.app-header {
  background: linear-gradient(180deg, #162038 0%, #0f172a 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-logo {
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  background: var(--bg-input);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.35rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  background: var(--color-brand);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ==========================================================================
   Main Content Layout (FHD 1920x1080 Optimized)
   ========================================================================== */

.app-main {
  flex: 1;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 100%;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

.tab-content.active {
  display: flex;
}

/* ==========================================================================
   Multi-Product Switcher Tab Bar
   ========================================================================== */

.product-tabs-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.product-tab-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 0 0.5rem;
  white-space: nowrap;
}

.product-tab-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.product-tab-item:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
}

.product-tab-item.active {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

/* ==========================================================================
   Shipment Selection & Actions Bar
   ========================================================================== */

.control-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.shipment-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.selector-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.shipment-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  min-width: 260px;
}

.shipment-select:focus {
  border-color: var(--border-focus);
}

.date-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.date-filter-input {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.date-filter-input:focus {
  border-color: var(--border-focus);
}

.btn-calendar-trigger {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-calendar-trigger:hover {
  background: var(--bg-card-hover);
  border-color: #38bdf8;
  transform: scale(1.05);
}

/* Custom Glassmorphism Calendar Popup */
.calendar-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
  width: 290px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.15);
  animation: fadeIn 0.15s ease;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.cal-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.cal-nav-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cal-nav-btn:hover {
  color: #fff;
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.cal-day-cell:hover:not(.cal-empty) {
  background: rgba(255, 255, 255, 0.08);
}

.cal-day-cell.cal-empty {
  cursor: default;
  opacity: 0.2;
}

.cal-day-cell.cal-today {
  border-color: #60a5fa;
  font-weight: 700;
}

.cal-day-cell.cal-selected {
  background: rgba(56, 189, 248, 0.25) !important;
  border-color: #38bdf8 !important;
  color: #fff !important;
  font-weight: 700;
}

.cal-day-cell.cal-has-data {
  background: rgba(30, 41, 59, 0.8);
  font-weight: 600;
  color: #f1f5f9;
}

.cal-day-cell.cal-has-data:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.5);
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  position: absolute;
  bottom: 3px;
}

.cal-dot-confirmed {
  background: var(--color-ok);
  box-shadow: 0 0 5px var(--color-ok);
}

.cal-dot-open {
  background: #38bdf8;
  box-shadow: 0 0 5px #38bdf8;
}

.cal-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.shipment-meta-bar {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  animation: fadeIn 0.2s ease;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.meta-label {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  border-color: #6366f1;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}

/* Export Format Group (Split button with Combobox) */
.export-format-group {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.25);
  border: 1px solid #10b981;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-export-main {
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0.4rem 0.75rem !important;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.export-format-select {
  background: #065f46;
  color: #ecfdf5;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.35rem 0.5rem;
  font-size: 0.775rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.export-format-select:hover {
  background: #047857;
}

.export-format-select:focus {
  background: #064e3b;
}

.export-format-select option {
  background: #0f172a;
  color: #f8fafc;
}

/* Adobe Acrobat PDF Mode (Softer Light Red Theme) */
.export-format-group.format-pdf {
  border-color: #fb7185;
  box-shadow: 0 2px 5px rgba(251, 113, 133, 0.35);
}

.export-format-group.format-pdf .btn-export-main {
  background: linear-gradient(135deg, #fb7185 0%, #e11d48 100%) !important;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.export-format-group.format-pdf .btn-export-main:hover {
  background: linear-gradient(135deg, #fda4af 0%, #f43f5e 100%) !important;
  box-shadow: 0 4px 10px rgba(251, 113, 133, 0.45) !important;
}

.export-format-group.format-pdf .export-format-select {
  background: #be123c;
  color: #fff1f2;
  border-left-color: rgba(255, 255, 255, 0.25);
}

.export-format-group.format-pdf .export-format-select:hover {
  background: #e11d48;
}

.export-format-group.format-pdf .export-format-select:focus {
  background: #9f1239;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-outline:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
}

.btn-sampling-active {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #f59e0b !important;
  border-color: rgba(245, 158, 11, 0.6) !important;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
  font-weight: 700 !important;
}

.btn-sampling-active:hover {
  background: rgba(245, 158, 11, 0.25) !important;
  border-color: #f59e0b !important;
}

/* ==========================================================================
   Real-Time Stock Clearance / Residual Balance Bar
   ========================================================================== */

.stock-balance-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.6rem 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stock-balance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.4rem;
}

.stock-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stock-overall-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.badge-ok {
  background: var(--color-ok-bg);
  color: var(--color-ok);
  border: 1px solid var(--color-ok-border);
}

.badge-surplus {
  background: var(--color-surplus-bg);
  color: var(--color-surplus);
  border: 1px solid var(--color-surplus-border);
}

.badge-shortage {
  background: var(--color-shortage-bg);
  color: var(--color-shortage);
  border: 1px solid var(--color-shortage-border);
}

.variant-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
}

.variant-stat-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.variant-stat-card:hover {
  border-color: var(--border-focus);
}

.variant-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.variant-card-counts {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.variant-card-balance {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 0.1rem;
  padding-top: 0.2rem;
  border-top: 1px dashed var(--border-subtle);
}

.balance-num {
  font-size: 1rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

.balance-ok { color: var(--color-ok); }
.balance-surplus { color: var(--color-surplus); }
.balance-shortage { color: var(--color-shortage); }

.balance-label {
  font-size: 0.65rem;
  font-weight: 600;
}

/* ==========================================================================
   Spreadsheet Order Allocation Grid (FHD 1920x1080 & Sticky Optimized)
   ========================================================================== */

.grid-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.grid-toolbar {
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.grid-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.grid-search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  outline: none;
  min-width: 180px;
}

.grid-search-input:focus {
  border-color: var(--border-focus);
}

.grid-filter-carrier {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}

/* Handling customer filter toggle */
.filter-handling-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  background: var(--bg-input);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.filter-handling-wrap input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--color-brand);
}

.grid-hints {
  font-size: 0.725rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.kbd {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.675rem;
  color: var(--text-secondary);
}

.table-scroll-container {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 275px);
  position: relative;
}

.alloc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.alloc-table th,
.alloc-table td {
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.25rem 0.35rem;
  text-align: center;
  white-space: nowrap;
}

/* Sticky Header on vertical scroll */
.alloc-table thead th {
  background: var(--bg-table-header);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 2px solid var(--border-color);
}

/* Sticky Left Columns for Code & Name */
.alloc-table th.th-sticky-code {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 25;
  background: var(--bg-table-header);
  width: 50px;
}

.alloc-table th.th-sticky-name {
  position: sticky;
  left: 50px;
  top: 0;
  z-index: 25;
  background: var(--bg-table-header);
  width: 120px;
  text-align: left;
}

.alloc-table td.td-sticky-code {
  position: sticky;
  left: 0;
  z-index: 15;
  background: #131b2e;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.alloc-table td.td-sticky-name {
  position: sticky;
  left: 50px;
  z-index: 15;
  background: #131b2e;
  text-align: left;
  font-weight: 600;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alloc-table tbody tr {
  background: var(--bg-card);
  transition: background-color 0.1s ease;
}

.alloc-table tbody tr:nth-child(even) {
  background: var(--bg-row-alt);
}

.alloc-table tbody tr:nth-child(even) td.td-sticky-code,
.alloc-table tbody tr:nth-child(even) td.td-sticky-name {
  background: #10182b;
}

.alloc-table tbody tr:hover {
  background: var(--bg-row-hover);
}

.alloc-table tbody tr:hover td.td-sticky-code,
.alloc-table tbody tr:hover td.td-sticky-name {
  background: #19243c;
}

.alloc-table tbody tr.row-active {
  background: var(--bg-row-selected);
}

.alloc-table tbody tr.row-active td.td-sticky-code,
.alloc-table tbody tr.row-active td.td-sticky-name {
  background: #1d3557;
}

/* Non-handling row visual tone */
.alloc-table tbody tr.row-non-handling {
  opacity: 0.45;
}

/* Grid Input Cells (Compact for FHD 1920) */
.cell-input {
  width: 100%;
  min-width: 44px;
  max-width: 60px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 0.2rem 0.15rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.1s ease;
}

.cell-input:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.cell-input.modified {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
}

.cell-input-text {
  text-align: left;
  font-family: var(--font-family);
  font-size: 0.775rem;
  font-weight: 400;
  min-width: 75px;
  max-width: 110px;
}

.cell-select {
  text-align: left;
  font-family: var(--font-family);
  font-size: 0.775rem;
  font-weight: 500;
  min-width: 90px;
  max-width: 130px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.cell-select option {
  background: #1e293b;
  color: var(--text-primary);
}

/* Inactive & Invalid Carrier Styling */
.cell-carrier-invalid,
select.cell-carrier.cell-carrier-invalid {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.18) !important;
  color: #fca5a5 !important;
  font-weight: 700 !important;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4) !important;
}

.m-card-badge-carrier.carrier-invalid {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #fca5a5 !important;
  border-color: rgba(239, 68, 68, 0.6) !important;
  font-weight: 700 !important;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.35) !important;
}

option.opt-disabled-warning {
  color: #f87171 !important;
  background-color: #1e1b2e !important;
  font-weight: 700 !important;
}

option.opt-disabled {
  color: #64748b !important;
  background-color: #0f172a !important;
  font-style: italic;
}

.cell-calc {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}

.cell-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #38bdf8;
  text-align: right;
  padding-right: 0.5rem;
}

/* Sticky Footer Total Row */
.alloc-table tfoot tr {
  background: var(--bg-table-header);
  position: sticky;
  bottom: 0;
  z-index: 20;
}

.alloc-table tfoot td {
  border-top: 2px solid var(--border-color);
  font-weight: 800;
  font-size: 0.825rem;
  color: var(--text-primary);
}

.tfoot-sticky-label {
  position: sticky;
  left: 0;
  bottom: 0;
  z-index: 25;
  background: var(--bg-table-header);
  text-align: left;
  padding-left: 0.6rem;
}

/* ==========================================================================
   Modals & Toast
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-backdrop.show {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  background: var(--bg-table-header);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-label {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  font-weight: 500;
  animation: slideIn 0.2s ease-out forwards;
}

.toast-success { border-left: 4px solid var(--color-ok); }
.toast-error { border-left: 4px solid var(--color-shortage); }
.toast-info { border-left: 4px solid var(--color-surplus); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.master-subtabs {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.subtab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.subtab-btn.active {
  background: var(--bg-input);
  color: var(--text-primary);
  border-bottom: 2px solid var(--color-brand);
}

.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ==========================================================================
   Mobile-Optimized & Dual-View (Cards & Table) Styles
   ========================================================================== */

/* View Mode Switcher in Header / Toolbar */
.view-toggle-wrap {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.btn-view-mode {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.35rem 0.65rem;
  font-size: 0.775rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.btn-view-mode.active {
  background: var(--color-brand);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Mobile Sticky Stock Balance Chips */
.mobile-sticky-balance {
  display: none; /* Shown in mobile card view */
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.6rem 0.85rem;
  margin: -0.5rem -0.5rem 0.75rem -0.5rem;
}

.mobile-balance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.mobile-balance-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mobile-chips-scroll {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}

.mobile-chip {
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: 0.725rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mobile-chip-ok { border-color: var(--color-ok-border); background: var(--color-ok-bg); color: var(--color-ok); }
.mobile-chip-surplus { border-color: var(--color-surplus-border); background: var(--color-surplus-bg); color: var(--color-surplus); }
.mobile-chip-shortage { border-color: var(--color-shortage-border); background: var(--color-shortage-bg); color: var(--color-shortage); }

/* Mobile Quick Filter & Progress Bar */
.mobile-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.mobile-filter-chips {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  scrollbar-width: none;
}

.mobile-filter-chips::-webkit-scrollbar {
  display: none;
}

.m-filter-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.m-filter-chip.active {
  background: var(--color-brand);
  border-color: var(--color-brand-hover);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.m-filter-chip .chip-count {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.05rem 0.3rem;
  border-radius: 9999px;
  font-size: 0.65rem;
}

.m-btn-toggle-all {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.m-btn-toggle-all:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Mobile Customer Cards Grid (Accordion & Collapsible) */
.mobile-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 5.5rem; /* Room for bottom action bar */
}

.mobile-customer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.mobile-customer-card.has-order {
  border-left: 4px solid var(--color-ok);
  background: linear-gradient(180deg, rgba(19, 27, 46, 0.95) 0%, rgba(16, 24, 43, 0.95) 100%);
}

.mobile-customer-card:focus-within {
  border-color: var(--border-focus);
}

/* Accordion Header (Clickable) */
.m-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 0.5rem;
}

.mobile-customer-card.is-expanded .m-card-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.45rem;
  margin-bottom: 0.55rem;
}

.m-card-cust-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex-grow: 1;
}

.m-card-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.m-card-code {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
}

.m-card-subinfo {
  font-size: 0.725rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.m-card-badge-carrier {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.m-card-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: right;
}

.m-card-toggle-icon {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-customer-card.is-expanded .m-card-toggle-icon {
  transform: rotate(180deg);
  color: var(--color-brand);
}

/* Accordion Body (Hidden when collapsed) */
.m-card-body {
  display: none;
}

.mobile-customer-card.is-expanded .m-card-body {
  display: block;
  animation: fadeInDown 0.15s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.m-card-remarks {
  font-size: 0.75rem;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  border-left: 2px solid #f59e0b;
}

/* Variant Rows in Mobile Card */
.m-card-variant-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.m-variant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.55rem;
  gap: 0.4rem;
}

.m-variant-row.active-qty {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
}

.m-var-label {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.m-var-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.m-var-price {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Stepper Control for Quantity [-] [ Qty ] [+] */
.m-stepper-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.m-btn-step {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.1s ease;
}

.m-btn-step:active {
  background: var(--color-brand);
  transform: scale(0.92);
}

.m-btn-step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.m-input-qty {
  width: 48px;
  height: 32px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--color-ok);
  padding: 0 0.2rem;
}

.m-input-qty:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  outline: none;
}

.m-input-qty.zero-val {
  color: var(--text-muted);
}

/* Mobile Card Footer (Subtotal & Remarks input) */
.m-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.775rem;
}

.m-card-total-qty {
  font-weight: 700;
  color: var(--color-ok);
  font-size: 0.875rem;
}

.m-card-total-amount {
  color: var(--text-primary);
  font-weight: 600;
}

/* Mobile Floating Bottom Action Bar */
.mobile-bottom-bar {
  display: none; /* Shown on mobile or mobile view mode */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 250;
  background: rgba(11, 15, 25, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem env(safe-area-inset-bottom, 0.5rem) 0.75rem;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.5);
}

.mobile-bottom-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 0.4rem;
  max-width: 600px;
  margin: 0 auto;
}

.btn-mobile-act {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.3rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.7rem;
  font-weight: 600;
  gap: 0.2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 48px;
}

.btn-mobile-act .icon {
  font-size: 1.1rem;
  line-height: 1;
}

.btn-mobile-act.primary {
  background: var(--color-brand);
  border-color: var(--color-brand-hover);
  color: #ffffff;
}

.btn-mobile-act.highlight {
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.8);
  border-color: #818cf8;
  animation: pulseSave 1.5s infinite;
}

@keyframes pulseSave {
  0%, 100% { box-shadow: 0 0 8px rgba(99, 102, 241, 0.6); }
  50% { box-shadow: 0 0 16px rgba(99, 102, 241, 1); }
}

.btn-mobile-act:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Numeric Keypad Touch Modal for Mobile */
.keypad-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 350;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1rem 1rem env(safe-area-inset-bottom, 1rem) 1rem;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.7);
  transform: translateY(100%);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.keypad-modal.show {
  transform: translateY(0);
}

.keypad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.keypad-target-info {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.keypad-display {
  background: var(--bg-input);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  font-size: 1.75rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--color-ok);
  text-align: right;
  margin-bottom: 0.75rem;
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.btn-keypad {
  height: 52px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-keypad:active {
  background: var(--color-brand);
}

.btn-keypad-action {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
}

.btn-keypad-done {
  background: var(--color-ok);
  border-color: var(--color-ok);
  color: #0b0f19;
  font-size: 1rem;
  grid-column: span 2;
}

/* Responsive Adaptive Rules */
@media (max-width: 900px) {
  .app-header {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .desktop-only-controls {
    display: none !important;
  }

  .mobile-bottom-bar {
    display: block;
  }

  .mobile-sticky-balance {
    display: block;
  }

  .table-scroll-container {
    display: none; /* In mobile viewport, use cards layout by default */
  }

  .mobile-cards-grid {
    display: flex;
  }
}

/* ==========================================================================
   ⚙️ Settings Modal & RBAC Access Control Styling
   ========================================================================== */

/* User Role Badge in Header */
.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.badge-role-admin {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge-role-user {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.btn-header-setting {
  padding: 0.35rem 0.75rem;
  font-size: 0.825rem;
  border-color: rgba(148, 163, 184, 0.3);
}

.btn-header-setting:hover {
  border-color: var(--primary);
  color: #fff;
}

/* Settings Sub-Navigation Tabs */
.setting-nav-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem 0;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.4);
}

.setting-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.setting-tab-btn:hover {
  color: var(--text-primary);
}

.setting-tab-btn.active {
  color: #818cf8;
  border-bottom-color: var(--primary);
}

/* Settings Sections */
.setting-section-content {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.setting-section-content.active {
  display: flex;
}

.setting-card {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.setting-info {
  flex: 1;
}

.setting-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.45;
}

.setting-sub-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(148, 163, 184, 0.15);
}

/* Modern Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: 0.25s ease;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #f8fafc;
  transition: 0.25s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* Permissions Matrix Table */
.setting-perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  margin-top: 0.5rem;
}

.setting-perm-table th,
.setting-perm-table td {
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.setting-perm-table th {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-primary);
  font-weight: 700;
}

.setting-perm-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Test Result Banner */
.setting-test-result {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 0.25rem;
}

.setting-test-result.success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.setting-test-result.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* Role-Based Element Visibility & Protection */
[data-role-required="admin"].role-hidden {
  display: none !important;
}

[data-role-required="admin"].role-disabled {
  opacity: 0.35 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  filter: grayscale(0.8);
}
