/* SEL Center - Site-wide readability + dynamic UX layer
   Shared across every page. No database changes required. */

:root {
  --sel-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sel-text: #172033;
  --sel-text-strong: #0f172a;
  --sel-text-muted: #526173;
  --sel-border: #dfe4ea;
  --sel-focus: rgba(185, 28, 28, .16);
  --sel-sidebar-collapsed: 78px;
}

html { font-size: 16px; }
body {
  font-family: var(--sel-font) !important;
  font-size: 15px;
  line-height: 1.55;
  color: var(--sel-text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Stronger, easier-to-read hierarchy */
h1,h2,h3,h4,h5,h6,strong,b { color: inherit; }
p,small,.muted { line-height: 1.55; }
.muted, .page-title p, .view-toolbar p, .admin-topbar p, .portal-topbar p,
.brand p, .stock, .cat, .sidebar-brand span, .sidebar-user span,
.portal-help small, .welcome-visual span { color: var(--sel-text-muted); }

.page-title h2 { font-size: clamp(1.55rem, 2vw, 1.9rem); letter-spacing: -.025em; }
.card-head h3, .section-title, .ticket-group h3 { font-size: 15px; }
.module-card h3, .product-card h4 { font-size: 15px; }
.module-card p, .cart-empty, .empty { font-size: 13.5px; }

/* Forms */
.field label {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #344054 !important;
}
.field input,.field select,.field textarea,.search-input,.compact-control,.date-control input,
input.form-input, select, textarea {
  font-size: 14px !important;
}
.field input,.field select,.field textarea,.search-input {
  min-height: 44px;
}
textarea { line-height: 1.55; }
::placeholder { color: #8a96a6 !important; opacity: 1; }

/* Buttons + controls */
.btn, button, .tab, .admin-tab, .action-btn { font-family: var(--sel-font); }
.btn { font-size: 14px !important; min-height: 42px; }
.tab,.admin-tab { font-size: 13px !important; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible {
  outline: 3px solid var(--sel-focus) !important;
  outline-offset: 2px;
}

/* Sidebar readability */
.side-link {
  font-size: 14px !important;
  line-height: 1.35;
  min-height: 42px;
  padding-top: 11px !important;
  padding-bottom: 11px !important;
}
.side-link i { font-size: 15px !important; }
.sidebar-label { font-size: 11px !important; letter-spacing: .11em; }
.sidebar-brand strong,.sidebar-user strong { font-size: 14.5px !important; }
.sidebar-brand span,.sidebar-user span { font-size: 12px !important; }

/* Top bars */
.admin-topbar h1,.portal-topbar h1 { font-size: 20px !important; letter-spacing: -.02em; }
.admin-topbar p,.portal-topbar p { font-size: 12.5px !important; }
.topbar-user,.user-pill { font-size: 12.5px !important; }

/* Tables are one of the most-used accountant/admin surfaces */
.table, table { font-size: 13px !important; }
.table th, table th {
  font-size: 12.5px !important;
  font-weight: 800 !important;
  color: #475467 !important;
  letter-spacing: .01em;
}
.table td,table td { line-height: 1.45; }
.table-wrap { position: relative; scrollbar-gutter: stable; }
.table-wrap .table thead th, .table-wrap table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: inset 0 -1px var(--sel-border);
}

/* Click-to-sort table headings */
th.ui-sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 28px !important;
  position: sticky;
}
th.ui-sortable::after {
  content: "↕";
  position: absolute;
  right: 10px;
  color: #98a2b3;
  font-size: 11px;
  opacity: .75;
}
th.ui-sortable[data-sort-dir="asc"]::after { content: "↑"; color: #b91c1c; opacity: 1; }
th.ui-sortable[data-sort-dir="desc"]::after { content: "↓"; color: #b91c1c; opacity: 1; }
.ui-table-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 0;
  color: #667085;
  font-size: 12px;
  font-weight: 600;
}

/* Global live header tools */
.ui-live-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #475467;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.app-header .ui-live-meta,
.pos-header .ui-live-meta,
header[style*="background"] .ui-live-meta {
  color: inherit;
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.10);
}
.ui-live-meta i { color: #b91c1c; }
.app-header .ui-live-meta i,.pos-header .ui-live-meta i { color: currentColor; }

.ui-command-btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #344054;
  min-height: 36px;
  border-radius: 10px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.ui-command-btn kbd {
  font: inherit;
  font-size: 10px;
  padding: 2px 5px;
  border: 1px solid #d0d5dd;
  border-bottom-width: 2px;
  border-radius: 5px;
  color: #667085;
  background: #f9fafb;
}

/* Sidebar collapse on desktop */
.ui-sidebar-collapse {
  position: absolute;
  top: 83px;
  right: -15px;
  width: 30px;
  height: 30px;
  border: 1px solid #dfe3e8;
  border-radius: 50%;
  background: #fff;
  color: #344054;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(15,23,42,.12);
  z-index: 70;
}
body.ui-sidebar-collapsed .admin-sidebar,
body.ui-sidebar-collapsed .portal-sidebar { width: var(--sel-sidebar-collapsed) !important; }
body.ui-sidebar-collapsed .admin-content,
body.ui-sidebar-collapsed .portal-content { margin-left: var(--sel-sidebar-collapsed) !important; }
body.ui-sidebar-collapsed .sidebar-brand > div:last-child,
body.ui-sidebar-collapsed .sidebar-user > div:last-child,
body.ui-sidebar-collapsed .side-link span,
body.ui-sidebar-collapsed .sidebar-label { display: none !important; }
body.ui-sidebar-collapsed .sidebar-brand,
body.ui-sidebar-collapsed .sidebar-user,
body.ui-sidebar-collapsed .side-link { justify-content: center; }
body.ui-sidebar-collapsed .sidebar-user { margin-left: 12px; margin-right: 12px; padding-left: 0; padding-right: 0; }
body.ui-sidebar-collapsed .side-link { padding-left: 10px !important; padding-right: 10px !important; }
body.ui-sidebar-collapsed .side-link i { width: auto !important; margin: 0 !important; }
body.ui-sidebar-collapsed .ui-sidebar-collapse i { transform: rotate(180deg); }
.admin-sidebar,.portal-sidebar,.admin-content,.portal-content { transition: width .22s ease, margin-left .22s ease, transform .22s ease; }

.ui-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.48);
  backdrop-filter: blur(2px);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.ui-sidebar-backdrop.open { opacity: 1; visibility: visible; }

/* Command palette */
.ui-command-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: start center;
  padding: min(12vh, 110px) 18px 30px;
  background: rgba(15,23,42,.48);
  backdrop-filter: blur(7px);
}
.ui-command-overlay.hidden { display: none !important; }
.ui-command {
  width: min(620px, 100%);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(15,23,42,.28);
}
.ui-command-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
}
.ui-command-search i { color: #98a2b3; }
.ui-command-search input {
  width: 100%;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  font-size: 15px !important;
  min-height: 34px;
  background: transparent !important;
}
.ui-command-list { max-height: min(55vh, 440px); overflow: auto; padding: 8px; }
.ui-command-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: #1d2939;
  border-radius: 10px;
  min-height: 46px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  cursor: pointer;
}
.ui-command-item:hover,.ui-command-item.active { background: #fef2f2; color: #991b1b; }
.ui-command-item i { width: 24px; text-align: center; }
.ui-command-item span { display: flex; flex-direction: column; }
.ui-command-item strong { font-size: 13px; }
.ui-command-item small { font-size: 11px; color: #667085; }
.ui-command-empty { padding: 28px 16px; text-align: center; color: #667085; font-size: 13px; }
.ui-command-footer { border-top: 1px solid #e5e7eb; padding: 9px 12px; display: flex; justify-content: space-between; color: #98a2b3; font-size: 10.5px; }

/* Toasts - automatically mirror application alerts */
.ui-toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 3500;
  width: min(380px, calc(100vw - 36px));
  display: grid;
  gap: 9px;
  pointer-events: none;
}
.ui-toast {
  pointer-events: auto;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #059669;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 16px 45px rgba(15,23,42,.16);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: uiToastIn .26s ease both;
}
.ui-toast.error { border-left-color: #dc2626; }
.ui-toast.info { border-left-color: #2563eb; }
.ui-toast i { margin-top: 2px; color: #059669; }
.ui-toast.error i { color: #dc2626; }
.ui-toast.info i { color: #2563eb; }
.ui-toast strong { display: block; font-size: 12.5px; margin-bottom: 2px; }
.ui-toast p { margin: 0; font-size: 12px; color: #475467; line-height: 1.45; }
@keyframes uiToastIn { from { opacity:0; transform:translateY(10px) translateX(8px) } to { opacity:1; transform:none } }

/* Page transition indicator */
.ui-page-progress {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 5000;
  height: 3px;
  width: 0;
  opacity: 0;
  background: linear-gradient(90deg,#7f1d1d,#ef4444);
  box-shadow: 0 0 12px rgba(239,68,68,.45);
  transition: width .32s ease, opacity .2s ease;
}
.ui-page-progress.active { width: 78%; opacity: 1; }
.ui-page-progress.done { width: 100%; opacity: 0; }

/* Better hover/tactile feedback */
.product-card,.module-card,.card,.metric-cell,.stat,.portal-help>div { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.product-card:hover,.module-card:hover { transform: translateY(-2px); }
.action-btn[title] { position: relative; }

/* Responsive */
@media (max-width: 1100px) {
  .ui-live-meta .ui-live-date { display:none; }
  .ui-command-btn kbd { display:none; }
}
@media (max-width: 820px) {
  body.ui-sidebar-collapsed .admin-sidebar,body.ui-sidebar-collapsed .portal-sidebar { width: 264px !important; }
  body.ui-sidebar-collapsed .portal-sidebar { width: 248px !important; }
  body.ui-sidebar-collapsed .admin-content,body.ui-sidebar-collapsed .portal-content { margin-left: 0 !important; }
  body.ui-sidebar-collapsed .sidebar-brand > div:last-child,
  body.ui-sidebar-collapsed .sidebar-user > div:last-child,
  body.ui-sidebar-collapsed .side-link span,
  body.ui-sidebar-collapsed .sidebar-label { display: block !important; }
  body.ui-sidebar-collapsed .sidebar-brand,body.ui-sidebar-collapsed .sidebar-user,body.ui-sidebar-collapsed .side-link { justify-content: flex-start; }
  .ui-sidebar-collapse { display:none; }
  .ui-live-meta { margin-left:auto; }
  .ui-command-btn { display:none; }
  .admin-topbar p,.portal-topbar p { display:none; }
}
@media (max-width: 540px) {
  body { font-size:14px; }
  .ui-live-meta { display:none; }
  .table,.table th,.table td,table,table th,table td { font-size:12.5px !important; }
  .field label { font-size:12.5px !important; }
  .btn { font-size:13.5px !important; }
  .ui-toast-stack { right:10px; bottom:10px; width:calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior:auto !important; animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
}

/* Preserve strong contrast inside dark sidebars/hero surfaces. */
.admin-sidebar .sidebar-brand span,.admin-sidebar .sidebar-user span,
.portal-sidebar .sidebar-brand span,.portal-sidebar .sidebar-user span { color:#9ca3af !important; }
.welcome-visual span { color:#c4c9d2 !important; }
.app-header .brand p { color:rgba(255,255,255,.82) !important; }
