/* ProcMaster — visual refresh (professional style, teal/green theme)
   Extracted from inline <style> and refined to match QuoteMaster's clean design language.
   Colors: teal/green (#00796b) to differentiate from QuoteMaster's navy blue (#1a3a6b). */

:root {
  --primary:       #00796b;
  --primary-light:  #26a69a;
  --primary-dark:   #004d40;
  --primary-pale:   #e0f2f1;
  --accent:         #ff6f00;
  --accent-light:   #fff3e0;
  --gold:           #c8952a;
  --gold-light:     #fff8e8;
  --border:         #dde2ea;
  --line:           #eceff4;
  --bg:             #f5f7fa;
  --white:          #ffffff;
  --text:           #1a2a3a;
  --text-muted:     #6b7a90;
  --green:          #1a7a4a;
  --green-bg:       #e8f7ef;
  --red:            #c62828;
  --red-bg:         #fbe6e5;
  --shadow-sm: 0 1px 2px rgba(0,121,107,.06), 0 1px 3px rgba(0,121,107,.04);
  --shadow:    0 2px 8px rgba(0,121,107,.06), 0 1px 3px rgba(0,121,107,.04);
  --shadow-lg: 0 8px 24px rgba(0,121,107,.08), 0 2px 6px rgba(0,121,107,.04);
  --radius:    10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body,
body button,
body input,
body select,
body textarea {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { font-size: 14px; color: var(--text); background: var(--bg); min-height: 100vh; }


/* ── HEADER ──────────────────────────────────────────────────────────── */
.header {
  background: var(--primary);
  color: white;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  position: sticky;
  top: 0;
  z-index: 200;
}
.header-logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-logo span { color: #80cbc4; }

.nav-tabs {
  display: flex;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
  flex-shrink: 1;
  min-width: 0;
  scrollbar-width: thin;
}
.nav-tab {
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,.75);
  transition: background .12s, color .12s;
  border: 1px solid transparent;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-tab:hover { color: white; background: rgba(255,255,255,.1); }
.nav-tab.active {
  background: rgba(255,255,255,.16);
  color: white;
  border-color: transparent;
}
.nav-tab.hidden { display: none !important; }

.header-right { display: flex; align-items: center; gap: 10px; direction: rtl; }
.header-badge, .user-pill {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  direction: rtl;
  unicode-bidi: embed;
}
.user-pill { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-select {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 5px 10px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  min-width: 108px;
  outline: none;
}
.auth-select option { color: #111; }
.logout-btn {
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1);
  padding: 4px 10px;
  color: white;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: background .12s;
}
.logout-btn:hover { background: rgba(255,255,255,.2); }
.hidden { display: none !important; }


/* ── SCREENS ─────────────────────────────────────────────────────────── */
.screen {
  display: none;
  padding: 18px 22px;
  overflow: auto;
  background: var(--bg);
  min-height: calc(100vh - 50px);
}
.screen.active { display: block; }


/* ── MANAGEMENT TABS & PANES ─────────────────────────────────────────── */
.management-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-group { display: flex; gap: 3px; padding: 4px 6px; border-radius: var(--radius); }
.tab-group.group-catalog  { background: #d4edda; border: 1px solid #8fcbaa; }
.tab-group.group-suppliers { background: #cde0f7; border: 1px solid #a8c8e8; }
.tab-group.group-admin    { background: #fcedc8; border: 1px solid #e0cc8a; }
.management-tab {
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  transition: background .12s, color .12s;
  font-family: inherit;
  white-space: nowrap;
}
.management-tab:hover { background: rgba(0,0,0,.06); }
.management-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.management-pane { display: none; }
.management-pane.active { display: block; }
.report-pane { display: none; }
.report-pane.active { display: block; }

.inv-kpi-grid { display: flex; flex-direction: column; gap: 8px; }
.inv-kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
  transition: border-color .12s;
}
.inv-kpi-card:hover { border-color: var(--primary); cursor: pointer; }
.inv-kpi-card.kpi-large { padding: 14px 10px; border-width: 2px; }
.inv-kpi-icon { font-size: 16px; margin-bottom: 2px; }
.inv-kpi-card.kpi-large .inv-kpi-icon { font-size: 22px; margin-bottom: 4px; }
.inv-kpi-label { font-size: 10px; font-weight: 700; color: var(--text-muted); margin-bottom: 1px; letter-spacing: .3px; }
.inv-kpi-card.kpi-large .inv-kpi-label { font-size: 11px; margin-bottom: 2px; }
.inv-kpi-value { font-size: 16px; font-weight: 900; color: var(--primary-dark); }
.inv-kpi-card.kpi-large .inv-kpi-value { font-size: 22px; }
.report-kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 140px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.report-kpi-label { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.report-kpi-value { font-size: 22px; font-weight: 900; color: var(--primary); }


/* ── LOGIN OVERLAY ───────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,20,18,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.login-overlay.open { display: flex; pointer-events: auto; }
.login-card {
  width: min(460px, 96vw);
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.login-head {
  padding: 28px 28px 24px;
  background: var(--primary);
  color: white;
}
.login-head h2 { font-size: 24px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 6px; }
.login-head p { font-size: 13px; opacity: .85; line-height: 1.6; }
.login-body { padding: 24px 28px 28px; display: grid; gap: 14px; }
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.login-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.login-field input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(0,121,107,.14);
}
.login-error { min-height: 18px; font-size: 12px; color: var(--red); font-weight: 700; }
.login-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.tfa-digit {
  width: 46px;
  height: 54px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.tfa-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,121,107,.18);
  background: var(--white);
}
.tfa-digit.filled { border-color: var(--primary-light); background: var(--primary-pale); }


/* ── BUTTONS ─────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-family: inherit;
  box-shadow: none;
}
.btn:hover { transform: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: white; border: 1px solid var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--white); color: var(--primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--primary-pale); border-color: var(--primary-light); }
.btn-danger { background: var(--white); color: var(--red); border: 1px solid var(--border); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-save { background: var(--white); color: var(--green); border: 1px solid var(--border); }
.btn-save:hover { background: var(--green-bg); border-color: var(--green); }
.btn-accent { background: var(--accent); color: white; border: 1px solid var(--accent); }
.btn-accent:hover { background: #e65100; border-color: #e65100; }
.btn-lg { padding: 10px 24px; font-size: 14px; border-radius: var(--radius); }


/* ── ADMIN TOOLBAR + TABLE ───────────────────────────────────────────── */
.admin-shell { display: grid; gap: 16px; }
.admin-toolbar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 4px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.admin-toolbar-title { font-size: 16px; font-weight: 800; color: var(--primary); white-space: nowrap; margin-left: 20px; }
.admin-toolbar .btn { font-size: 11px; padding: 4px 10px; }
.admin-search {
  min-width: 200px;
  max-width: 300px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  outline: none;
  text-align: right;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.admin-search:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(0,121,107,.12);
}
.admin-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sales-kpis { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 14px; }
.sales-kpi {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.sales-kpi .icon { font-size: 22px; margin-bottom: 6px; }
.sales-kpi .lbl  { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 700; }
.sales-kpi .val  { font-size: 28px; color: var(--primary); font-weight: 900; line-height: 1.1; }
.sales-kpi .sub  { font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.sales-kpi-accent {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  border: none;
}
.sales-kpi-accent .lbl, .sales-kpi-accent .sub { color: rgba(255,255,255,.75); }
.sales-kpi-accent .val { color: white; }
.sales-kpi-warn { background: linear-gradient(135deg, #fff8e8 0%, #fff3d0 100%); border: 1px solid var(--gold); }
.sales-kpi-warn .val { color: var(--gold); }
@media (max-width: 1200px) { .sales-kpis { grid-template-columns: repeat(3, minmax(180px, 1fr)); } }
@media (max-width: 760px) { .sales-kpis { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; } .sales-kpi .val { font-size: 22px; } }
#screen-dashboard .auth-select { background: white; color: #333; border: 1px solid var(--border); }

.admin-table-wrap { overflow: auto; max-height: calc(100vh - 220px); }
.admin-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.admin-table th, .admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: 13px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-table th {
  background: #f5f7fa;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
.admin-table tr:hover { background: #fafbfd; }
.admin-table td.td-clickable { cursor: pointer; color: var(--primary); transition: color .12s; }
.admin-table td.td-clickable:hover { text-decoration: underline; color: var(--primary-dark); }
.admin-toolbar .spacer { flex: 1; }
.empty-admin { padding: 40px 20px; color: #98a2b3; font-weight: 700; text-align: center; }
@keyframes rowIn { from { opacity: 0; transform: translateY(3px) } to { opacity: 1; transform: translateY(0) } }
.admin-table tbody tr { animation: rowIn .12s ease forwards; }
.row-actions { display: flex; gap: 6px; justify-content: flex-start; }
tr.inactive-row { background: #fff0f0 !important; }
tr.inactive-row:hover { background: #ffe0e0 !important; }
tr.inactive-row td { color: #999; }

.edit-btn {
  background: none;
  border: 1px solid var(--primary-light);
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  transition: background .12s, color .12s;
}
.edit-btn:hover { background: var(--primary); color: white; }
.del-btn {
  background: none;
  border: 1px solid #e0a0a0;
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 11px;
  color: var(--red);
  font-weight: 600;
  transition: background .12s, color .12s;
  margin-inline-start: 4px;
}
.del-btn:hover { background: var(--red); color: white; }


/* ── MODALS ──────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,20,18,.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 20px 0;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; pointer-events: auto; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 820px;
  max-height: 92vh;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}
.modal-wide { width: 960px; }
#prModalOverlay .modal-wide { width: 1100px; max-height: 95vh; }
#prModalOverlay .form-grid-3col { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px 12px; }
#prModalOverlay .form-grid-3col .half { grid-column: span 2; }
#prModalOverlay .form-grid-3col label {
  display: block; font-size: 11px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 4px; text-transform: none; letter-spacing: 0;
}
#prModalOverlay .form-grid-3col input,
#prModalOverlay .form-grid-3col select,
#prModalOverlay .form-grid-3col textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; outline: none; background: var(--white);
  text-align: right; font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
#prModalOverlay .form-grid-3col input:focus,
#prModalOverlay .form-grid-3col select:focus,
#prModalOverlay .form-grid-3col textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(0,121,107,.12);
}
#prModalOverlay .pr-items-scroll { max-height: 340px; min-height: 260px; overflow-y: auto; }
#prModalOverlay .pr-items-scroll::-webkit-scrollbar { width: 6px; }
#prModalOverlay .pr-items-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.modal-header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  border-radius: 14px 14px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: none;
}
.modal-header h2 { font-size: 16px; font-weight: 700; letter-spacing: 0; }
.close-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  font-family: inherit;
}
.close-btn:hover { background: rgba(255,255,255,.28); }
.modal-body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: #b0bec5; border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: #78909c; }

.po-guide-highlight {
  background: #fff8e1 !important;
  border-color: #ff9800 !important;
  box-shadow: 0 0 0 3px rgba(255,152,0,0.25) !important;
  transition: all .3s ease;
}
.po-guide-highlight:focus { box-shadow: 0 0 0 4px rgba(255,152,0,0.4) !important; }
@keyframes guideGlow {
  0%   { box-shadow: 0 0 0 3px rgba(255,152,0,0.25); }
  50%  { box-shadow: 0 0 0 6px rgba(255,152,0,0.15); }
  100% { box-shadow: 0 0 0 3px rgba(255,152,0,0.25); }
}
.po-guide-highlight { animation: guideGlow 2s ease-in-out infinite; }

.modal-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-shrink: 0;
}
.modal-subtitle { font-size: 12px; color: var(--text-muted); opacity: .8; margin-top: 2px; }
.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  flex-shrink: 0;
}
.modal-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .12s, background .12s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.modal-tab:hover { color: var(--primary); background: var(--primary-pale); }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.modal-tab-content { display: none; }
.modal-tab-content.active { display: block; }


/* ── FORM GRID ───────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: none;
  letter-spacing: 0;
}
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  background: var(--white);
  text-align: right;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(0,121,107,.12);
}
.form-grid textarea { min-height: 60px; resize: vertical; }
.form-section-title {
  grid-column: 1/-1;
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  border-bottom: 1px solid var(--primary-pale);
  padding-bottom: 5px;
  margin-top: 6px;
}


/* ── STATUS BADGES ───────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 8px;
  min-width: 54px;
  text-align: center;
  white-space: nowrap;
}
.badge-draft     { background: #f0f2f5; color: #6b7a90; }
.badge-pending   { background: #fff8e1; color: #f9a825; }
.badge-approved  { background: var(--green-bg); color: var(--green); }
.badge-rejected  { background: var(--red-bg); color: var(--red); }
.badge-sent      { background: #e3f2fd; color: #1565c0; }
.badge-closed    { background: #f0f2f5; color: #455a64; }
.badge-confirmed { background: #e3f2fd; color: #1565c0; }
.badge-partial   { background: var(--accent-light); color: #e65100; }
.badge-received  { background: var(--green-bg); color: var(--green); }
.badge-match-ok  { background: var(--green-bg); color: var(--green); font-size: 14px; }
.badge-match-fail { background: var(--red-bg); color: var(--red); font-size: 14px; }
.match-indicator { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; }
.match-indicator .match-icon { font-size: 16px; }
.badge-active   { background: var(--green-bg); color: var(--green); }
.badge-inactive { background: #f0f0f0; color: #999; }


/* ── URGENCY BADGES ──────────────────────────────────────────────────── */
.urgency-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 8px;
  min-width: 40px;
  text-align: center;
  white-space: nowrap;
}
.urgency-low      { background: #f0f2f5; color: #6b7a90; }
.urgency-normal   { background: #e3f2fd; color: #1565c0; }
.urgency-high     { background: var(--accent-light); color: #e65100; }
.urgency-critical { background: var(--red-bg); color: var(--red); }


/* ── RATING STARS ────────────────────────────────────────────────────── */
.rating-stars { color: #f9a825; font-size: 13px; letter-spacing: 1px; }


/* ── STATUS CHIPS (filter) ───────────────────────────────────────────── */
.status-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 0; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background .12s, color .12s, border-color .12s;
  background: var(--bg);
  color: var(--text-muted);
  user-select: none;
}
.status-chip:hover { background: var(--primary-pale); color: var(--primary); border-color: var(--primary); }
.status-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.status-chip.chip-draft.active    { background: #78909c; border-color: #78909c; }
.status-chip.chip-pending.active  { background: #f9a825; border-color: #f9a825; }
.status-chip.chip-approved.active { background: #1a7a4a; border-color: #1a7a4a; }
.status-chip.chip-rejected.active { background: #c62828; border-color: #c62828; }
.status-chip.chip-sent.active     { background: #1565c0; border-color: #1565c0; }
.chip-count {
  font-size: 10px;
  background: rgba(0,0,0,.06);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
}
.status-chip.active .chip-count { background: rgba(255,255,255,.25); }
.status-chip:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }


/* ── TOAST ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--primary);
  color: white;
  padding: 11px 28px;
  border-radius: 28px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-success { background: var(--green); }
.toast.toast-error   { background: var(--red); }
.toast.toast-warning { background: #856404; }
.toast.toast-info    { background: #1565c0; }


/* ── PLACEHOLDER / DASHBOARD ─────────────────────────────────────────── */
.placeholder-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-muted);
  gap: 12px;
}
.placeholder-screen .icon { font-size: 52px; opacity: .3; }
.placeholder-screen p     { font-size: 18px; font-weight: 700; }
.placeholder-screen small { font-size: 13px; }


/* ── APPROVAL TIMELINE ──────────────────────────────────────────────── */
.approval-timeline { list-style: none; padding: 0; margin: 8px 0; }
.approval-timeline li {
  position: relative;
  padding: 10px 40px 10px 16px;
  border-right: 2px solid var(--border);
  margin-right: 12px;
  margin-bottom: 4px;
}
.approval-timeline li:last-child { border-right-color: transparent; }
.approval-timeline li::before {
  content: '';
  position: absolute;
  right: -8px;
  top: 12px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
}
.approval-timeline li.step-approved::before { background: var(--green); border-color: var(--green); }
.approval-timeline li.step-approved { border-right-color: var(--green); }
.approval-timeline li.step-rejected::before { background: var(--red); border-color: var(--red); }
.approval-timeline li.step-rejected { border-right-color: var(--red); }
.approval-timeline li.step-pending::before { background: #f9a825; border-color: #f9a825; animation: pulse 1.5s infinite; }
.approval-timeline li.step-pending { border-right-color: #f9a825; }
.approval-timeline li.step-cancelled::before { background: #ccc; border-color: #ccc; }
.approval-timeline .step-title   { font-size: 13px; font-weight: 700; color: var(--text); }
.approval-timeline .step-meta    { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.approval-timeline .step-comment { font-size: 12px; color: var(--primary); margin-top: 3px; font-style: italic; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .5 } }
.badge-pending_approval { background: #fff8e1; color: #f9a825; }


/* ── PR ITEMS TABLE ──────────────────────────────────────────────────── */
.items-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.items-table th {
  background: var(--primary-pale);
  color: var(--primary);
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}
.items-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.items-table input, .items-table select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 12px;
  outline: none;
  text-align: right;
  font-family: inherit;
  transition: border-color .12s;
}
.items-table input:focus, .items-table select:focus { border-color: var(--primary-light); }
.items-table .remove-item-btn { background: none; border: none; color: var(--red); cursor: pointer; font-size: 14px; padding: 2px 6px; }
.items-total-row td { font-weight: 800; background: #f0f7f6; border-top: 2px solid var(--primary); }


/* ── AUTOCOMPLETE ────────────────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  background: var(--white);
  border: 1px solid var(--primary-light);
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item { padding: 6px 10px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.autocomplete-item:hover { background: var(--primary-pale); }
.autocomplete-item .item-sku { font-weight: 700; color: var(--primary); margin-inline-start: 8px; }


/* ── PAYMENT STATUS BADGES ──────────────────────────────────────────── */
.badge-paid   { background: var(--green-bg); color: var(--green); }
.badge-unpaid { background: #f0f2f5; color: #6b7a90; }
.badge-overdue { background: var(--red-bg); color: var(--red); }


/* ── PAYMENT REPORT ─────────────────────────────────────────────────── */
.payment-summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.payment-summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.payment-summary-card .card-value { font-size: 22px; font-weight: 900; color: var(--primary); margin-bottom: 2px; }
.payment-summary-card .card-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.payment-summary-card.card-danger  .card-value { color: var(--red); }
.payment-summary-card.card-warning .card-value { color: #f9a825; }
.payment-summary-card.card-success .card-value { color: var(--green); }
.payment-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.payment-filter-bar label { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-inline-start: 4px; }
.payment-filter-bar select, .payment-filter-bar input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color .12s;
}
.payment-filter-bar select:focus, .payment-filter-bar input:focus { border-color: var(--primary-light); }
.row-overdue { background: #fff5f5 !important; }
.row-overdue:hover { background: #ffe8e8 !important; }


/* ── PAYMENT HISTORY (in modal) ─────────────────────────────────────── */
.payment-history-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.payment-history-table th {
  background: var(--primary-pale);
  color: var(--primary);
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}
.payment-history-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; }


/* ── RTL HELPERS ─────────────────────────────────────────────────────── */
.ltr-num { direction: ltr; text-align: right; unicode-bidi: embed; }


/* ── SCROLLBAR ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: #f0f2f8; }
::-webkit-scrollbar-thumb { background: #a0b0b8; border-radius: 3px; }


/* ── CATEGORY FILTER ─────────────────────────────────────────────────── */
.filter-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
  min-width: 140px;
  font-family: inherit;
  transition: border-color .12s;
}
.filter-select:focus { border-color: var(--primary-light); }


/* ── ACCESSIBILITY ───────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.skip-to-content {
  position: absolute; top: -100px; right: 0;
  background: var(--primary); color: #fff;
  padding: 12px 24px; font-size: 14px; font-weight: 700;
  z-index: 100000; border-radius: 0 0 0 8px;
  text-decoration: none; transition: top .2s;
}
.skip-to-content:focus { top: 0; }
*:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
.nav-tab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.a11y-widget { position: fixed; bottom: 20px; left: 20px; z-index: 99999; font-family: 'Segoe UI', Tahoma, sans-serif; }
.a11y-toggle {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--white); color: var(--primary);
  border: 2px solid var(--primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: background .12s, transform .12s;
}
.a11y-toggle:hover { background: var(--primary); color: #fff; transform: scale(1.05); }
.a11y-toggle:focus-visible { outline: 3px solid #000; outline-offset: 3px; }
.a11y-panel {
  position: absolute; bottom: 58px; left: 0; width: 280px;
  background: var(--white); border-radius: 14px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden; direction: rtl;
}
.a11y-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: var(--primary); color: #fff;
  font-weight: 700; font-size: 15px;
}
.a11y-close {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px;
}
.a11y-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 4px; }
.a11y-option {
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--text);
}
.a11y-option:last-of-type { border-bottom: none; }
.a11y-btn-group { display: flex; gap: 4px; }
.a11y-btn-group button {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); cursor: pointer; font-size: 13px; font-weight: 600;
  font-family: inherit; transition: background .12s;
}
.a11y-btn-group button:hover { background: var(--primary-pale); }
.a11y-btn-group button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.a11y-switch-label {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; cursor: pointer; gap: 8px;
}
.a11y-switch-label input { position: absolute; opacity: 0; width: 0; height: 0; }
.a11y-switch {
  position: relative; width: 40px; height: 22px;
  background: #cbd5e1; border-radius: 11px;
  transition: background .2s; flex-shrink: 0;
}
.a11y-switch::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; background: #fff;
  border-radius: 50%; transition: transform .2s;
}
.a11y-switch-label input:checked + .a11y-switch { background: var(--primary); }
.a11y-switch-label input:checked + .a11y-switch::after { transform: translateX(-18px); }
.a11y-switch-label input:focus-visible + .a11y-switch { outline: 2px solid var(--primary); outline-offset: 2px; }
.a11y-statement-link {
  display: block; text-align: center; padding: 10px;
  font-size: 12px; color: var(--primary); text-decoration: none;
  border-top: 1px solid var(--line);
}
.a11y-statement-link:hover { text-decoration: underline; }
.a11y-statement-link:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

body.a11y-high-contrast { filter: contrast(1.4); }
body.a11y-high-contrast * { border-color: #000 !important; }
body.a11y-no-motion, body.a11y-no-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
body.a11y-highlight-links a {
  outline: 2px solid #f59e0b !important;
  outline-offset: 2px;
  text-decoration: underline !important;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ── DASHBOARD ───────────────────────────────────────────────────────── */
.sales-kpi.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.sales-kpi.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.dash-quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dash-quick-actions .btn { font-size: 13px; padding: 8px 16px; border-radius: var(--radius); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.dash-inv-alerts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.dash-inv-alert {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.dash-inv-alert:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.dash-inv-alert .alert-val { font-size: 28px; font-weight: 900; }
.dash-inv-alert .alert-lbl { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-top: 4px; }
@media (max-width: 768px) {
  .dash-inv-alerts { grid-template-columns: 1fr; }
  .dash-quick-actions { flex-direction: column; }
}


/* ── Document Comments ───────────────────────────────────────────────── */
.comments-section { margin-top: 16px; border-top: 1px solid var(--primary-pale); padding-top: 12px; }
.comments-section h3 { font-size: 14px; font-weight: 800; color: var(--primary); margin-bottom: 10px; }
.comments-thread {
  max-height: 260px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 2px; margin-bottom: 10px;
}
.comment-bubble {
  max-width: 80%; padding: 8px 12px;
  border-radius: 12px; font-size: 12.5px;
  line-height: 1.5; position: relative; word-wrap: break-word;
}
.comment-bubble.mine  { align-self: flex-end; background: var(--primary-pale); border-bottom-left-radius: 12px; border-bottom-right-radius: 4px; }
.comment-bubble.other { align-self: flex-start; background: #f0f2f5; border-bottom-right-radius: 12px; border-bottom-left-radius: 4px; }
.comment-meta {
  font-size: 10.5px; color: var(--text-muted); margin-bottom: 2px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.comment-meta .comment-name { font-weight: 700; }
.comment-text { color: var(--text); }
.comment-delete-btn { background: none; border: none; color: #c00; cursor: pointer; font-size: 11px; padding: 0 2px; opacity: 0.5; }
.comment-delete-btn:hover { opacity: 1; }
.comments-input-row { display: flex; gap: 8px; align-items: flex-end; }
.comments-input-row textarea {
  flex: 1; resize: none; min-height: 36px; max-height: 80px;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-family: inherit;
}
.comments-input-row button { white-space: nowrap; }
.comments-empty { text-align: center; color: var(--text-muted); padding: 16px; font-size: 12px; }

.stage-box { display: inline-block; width: 32px; height: 32px; border-radius: var(--radius-sm); position: relative; cursor: default; transition: transform .15s; }
.stage-box:hover { transform: scale(1.15); }
.stage-done      { background: #4caf50; }
.stage-current   { background: #ff9800; cursor: pointer; }
.stage-pending   { background: #e0e0e0; }
.stage-cancelled { background: #f44336; }
.stage-tooltip {
  display: none; position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%);
  background: #333; color: white; padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; white-space: nowrap; z-index: 100; pointer-events: none;
}
.stage-tooltip::after {
  content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 5px solid transparent; border-top-color: #333;
}
.stage-current:hover .stage-tooltip { display: block; }

.pagination-bar { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; direction: ltr; }
.pagination-bar button { padding: 4px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--white); cursor: pointer; font-size: 12px; transition: background .12s; }
.pagination-bar button:disabled { opacity: 0.4; cursor: default; }
.pagination-bar button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-bar .page-info { font-size: 12px; color: var(--text-muted); }


/* ── RESPONSIVE — Tablet ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  body { font-size: 13px; }
  .header { padding: 0 12px; }
  .header-logo { font-size: 16px; }
  .nav-tab { padding: 4px 10px; font-size: 11px; }
  .screen { padding: 14px 14px; }
  .admin-toolbar { padding: 6px 10px; }
  .admin-search { min-width: 180px; max-width: 280px; }
  .admin-table th, .admin-table td { padding: 7px 6px; font-size: 12px; }
  .modal { width: 90vw; max-width: 820px; }
  .modal-wide { width: 94vw; max-width: 960px; }
  #prModalOverlay .modal-wide { width: 96vw; max-width: 1000px; }
  .form-grid { gap: 6px; }
  .sales-kpis { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .payment-summary-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .inv-kpi-grid { flex-direction: column; }
  #invKpiSidebar { width: 180px; }
  .dash-inv-alerts { grid-template-columns: repeat(2, 1fr); }
}


/* ── MOBILE ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header { padding: 0 10px; height: 48px; gap: 4px; }
  .header-logo { font-size: 16px; }
  .nav-tabs { gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-shrink: 1; min-width: 0; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab { padding: 4px 8px; font-size: 10px; white-space: nowrap; flex-shrink: 0; }
  .header-right { gap: 4px; }
  .user-pill { max-width: 90px; font-size: 10px; padding: 3px 7px; }
  .auth-select { font-size: 10px; min-width: 80px; padding: 4px 6px; }
  .logout-btn { font-size: 10px; padding: 3px 7px; }
  .screen { padding: 10px 8px; }
  .admin-toolbar { padding: 6px 8px; gap: 6px; flex-wrap: wrap; }
  .admin-search { min-width: 0; max-width: none; width: 100%; }
  .admin-table th, .admin-table td { padding: 6px 4px; font-size: 11px; }
  .modal { width: 96vw !important; max-width: none; }
  .modal-wide { width: 96vw !important; }
  .form-grid { grid-template-columns: 1fr !important; }
  .form-grid.three { grid-template-columns: 1fr !important; }
  #prModalOverlay .form-grid-3col { grid-template-columns: 1fr !important; }
  #prModalOverlay .form-grid-3col .half { grid-column: span 1; }
  .login-card { width: 96vw; }
  .login-head { padding: 20px 18px; }
  .login-head h2 { font-size: 22px; }
  .login-body { padding: 18px 16px; }
  .toast { max-width: 90vw; font-size: 12px; padding: 8px 16px; }
  .status-chips { flex-wrap: wrap; gap: 4px; }
  .status-chip { padding: 3px 8px; font-size: 11px; }
  .items-table { font-size: 11px; }
  .btn { font-size: 12px; padding: 6px 10px; }
  .modal-content { width: 98vw; max-width: 98vw; margin: 5px auto; padding: 10px; }
}

@media (max-width: 480px) {
  .header { height: 44px; }
  .header-logo { font-size: 14px; }
  .nav-tab { padding: 3px 6px; font-size: 9px; }
  .screen { min-height: calc(100vh - 44px); padding: 8px 6px; }
  .modal { width: 98vw !important; max-width: none; border-radius: 8px; }
  .modal-header { padding: 8px 12px; }
  .modal-header h2 { font-size: 13px; }
  .modal-body { padding: 10px 12px; }
  .modal-footer { padding: 8px 12px; }
  .sales-kpis { grid-template-columns: 1fr !important; gap: 6px; }
  .sales-kpi .val { font-size: 20px; }
  .sales-kpi { padding: 12px 14px; }
  #invKpiSidebar { display: none; }
  .inv-kpi-card { padding: 6px; }
  .inv-kpi-value { font-size: 14px; }
  .payment-summary-cards { grid-template-columns: 1fr; }
  .admin-toolbar { flex-direction: column; align-items: stretch; }
  .admin-toolbar-title { margin-inline-start: 0; text-align: center; }
  .btn { font-size: 11px; padding: 4px 10px; }
  .btn-lg { padding: 8px 16px; font-size: 12px; }
  .login-head h2 { font-size: 20px; }
  .login-body { padding: 14px 12px; gap: 10px; }
  .tfa-digit { width: 38px; height: 44px; font-size: 20px; }
}
