/* ==========================================================================
   GarmentERP — Design Tokens
   ========================================================================== */
:root {
  /* Bootstrap 5 default palette */
  --blue-50:  #e7f1ff;
  --blue-100: #cfe2ff;
  --blue-500: #3d8bfd;
  --blue-600: #0d6efd;
  --blue-700: #0a58ca;
  --blue-900: #052c65;

  --indigo-500: #7952f2;
  --indigo-600: #6610f2;
  --indigo-700: #5209b5;

  --gray-25:  #fcfcfd;
  --gray-50:  #f8f9fa;
  --gray-100: #e9ecef;
  --gray-200: #dee2e6;
  --gray-300: #ced4da;
  --gray-400: #adb5bd;
  --gray-500: #6c757d;
  --gray-600: #495057;
  --gray-700: #343a40;
  --gray-800: #212529;
  --gray-900: #1a1d20;

  --white: #ffffff;

  --green-500: #198754;
  --green-100: #d1e7dd;
  --amber-500: #ffc107;
  --amber-100: #fff3cd;
  --red-500:   #dc3545;
  --red-100:   #f8d7da;
  --gold:      #d4af37;

  /* Semantic (light mode) */
  --bg-app: var(--gray-50);
  --bg-surface: var(--white);
  --bg-surface-alt: var(--gray-25);
  --border-color: var(--gray-200);
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --sidebar-bg: #212529;
  --sidebar-bg-alt: #2b3035;
  --sidebar-text: #adb5bd;
  --sidebar-text-active: #ffffff;

  --shadow-sm: 0 .125rem .25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 .5rem 1rem rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
  --shadow-card-hover: 0 .5rem 1rem rgba(0, 0, 0, 0.15);

  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-pill: 50rem;

  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 84px;
  --topbar-h: 68px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode overrides */
body.dark-mode {
  --bg-app: #1a1d20;
  --bg-surface: #212529;
  --bg-surface-alt: #2b3035;
  --border-color: #343a40;
  --text-primary: #f8f9fa;
  --text-secondary: #ced4da;
  --text-muted: #adb5bd;
  --sidebar-bg: #16181b;
  --sidebar-bg-alt: #1a1d20;
  --shadow-md: 0 .5rem 1rem rgba(0,0,0,0.4);
  --shadow-lg: 0 1rem 3rem rgba(0,0,0,0.5);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-display);
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--blue-100); color: var(--blue-700); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-weight: 400; font-size: 0.8em; }
.text-amber { color: var(--amber-500); }
.text-gold { color: var(--gold); }

:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   ROLE VISIBILITY
   ========================================================================== */
.admin-only {
  display: flex;
}
.employee-only {
  display: none;
}

/* Non-page elements (sidebar nav items, labels, topbar bits): fully toggle
   with role. :not(.page) is essential here - without it these rules also
   match page <section>s, and being !important they'd force EVERY page of
   the active role to display:flex at once (regardless of .active), which
   is what caused pages to render stacked on top of each other. */
body.employee-mode .admin-only:not(.page) {
  display: none !important;
}
body.employee-mode .employee-only:not(.page) {
  display: flex !important;
}
body.admin-mode .employee-only:not(.page) {
  display: none !important;
}
body.admin-mode .admin-only:not(.page) {
  display: flex !important;
}

/* Page sections: visibility is owned by .page / .page.active (see below).
   Only force-hide pages belonging to the wrong role, as a safety net in
   case a page from the other role is ever left with a stray .active class.
   Never force-show here - that would bypass the active/inactive state. */
body.employee-mode .page.admin-only {
  display: none !important;
}
body.admin-mode .page.employee-only {
  display: none !important;
}

body.employee-mode .nav-section-label:not(.employee-only) {
  display: none !important;
}

/* ==========================================================================
   HIDE SEARCH AND DARK MODE IN ALL MODES
   ========================================================================== */
.topbar-search,
#darkModeToggle {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 8px; }
body.dark-mode ::-webkit-scrollbar-thumb { background: #2a3555; }

/* ==========================================================================
   Loading Overlay
   ========================================================================== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--gray-900);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  transition: opacity 0.5s var(--ease), visibility 0.5s var(--ease);
}
.loading-overlay.fade-out { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-ring {
  width: 52px; height: 52px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--blue-500);
  animation: spin 0.9s linear infinite;
}
.loading-overlay p { color: var(--gray-400); font-size: 0.9rem; letter-spacing: 0.02em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  position: relative;
  overflow: hidden;
}
.login-bg { position: relative; overflow: hidden; display: flex; align-items: center; }
.login-bg-svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.stitch-motif { animation: dashMove 12s linear infinite; }
@keyframes dashMove { to { stroke-dashoffset: -400; } }

.login-bg::after {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08), transparent 60%);
  pointer-events: none;
}

/* Left-panel brand showcase */
.login-showcase {
  position: relative;
  z-index: 2;
  color: #fff;
  width: 100%;
  max-width: 460px;
  padding: 0 clamp(24px, 6vw, 72px);
  animation: fadeSlideUp 0.7s var(--ease);
}
.showcase-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  backdrop-filter: blur(6px);
  margin-bottom: 22px;
}
.login-showcase h2 {
  font-size: clamp(1.6rem, 2.4vw, 2.3rem);
  font-weight: 700; line-height: 1.28; letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.login-showcase > p {
  font-size: 0.95rem; line-height: 1.65;
  color: rgba(255, 255, 255, 0.72);
  max-width: 400px;
  margin-bottom: 44px;
}

/* Simple floating dashboard visual */
.showcase-visual { position: relative; max-width: 380px; }
.visual-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.35);
}
.visual-card-main { padding: 20px 22px 22px; }
.visual-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 22px; }
.visual-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); }
.visual-card-title {
  margin-left: 8px; font-size: 0.72rem; font-weight: 600;
  color: rgba(255, 255, 255, 0.55); letter-spacing: 0.02em;
}
.visual-bars { display: flex; align-items: flex-end; gap: 10px; height: 84px; }
.visual-bars span {
  flex: 1;
  height: var(--h);
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.35));
  animation: barGrow 1s var(--ease) backwards;
}
.visual-bars span:nth-child(1) { animation-delay: 0.05s; }
.visual-bars span:nth-child(2) { animation-delay: 0.1s; }
.visual-bars span:nth-child(3) { animation-delay: 0.15s; }
.visual-bars span:nth-child(4) { animation-delay: 0.2s; }
.visual-bars span:nth-child(5) { animation-delay: 0.25s; }
.visual-bars span:nth-child(6) { animation-delay: 0.3s; }
.visual-bars span:nth-child(7) { animation-delay: 0.35s; }
@keyframes barGrow { from { transform: scaleY(0); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }

.visual-card-float {
  position: absolute;
  right: -18px; bottom: -26px;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: rgba(20, 30, 60, 0.55);
}
.visual-card-float i {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: rgba(52, 211, 153, 0.2);
  color: #6ee7b7;
  font-size: 0.85rem;
}
.visual-card-float strong { display: block; font-size: 1.05rem; font-weight: 700; line-height: 1.1; }
.visual-card-float span { font-size: 0.7rem; color: rgba(255, 255, 255, 0.6); }

@media (max-height: 780px) {
  .login-showcase > p { margin-bottom: 32px; }
}

.login-panel {
  display: flex; align-items: center; justify-content: center;
  background: var(--white);
  padding: 40px;
}
.login-card {
  width: 100%; max-width: 400px;
  animation: fadeSlideUp 0.7s var(--ease);
}
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(24px);} to { opacity: 1; transform: translateY(0);} }

.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 34px; }
.login-logo {
  width: 52px; height: 52px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--blue-600), var(--indigo-600));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; box-shadow: var(--shadow-md);
}
.login-brand h1 { font-size: 1.4rem; font-weight: 700; color: var(--gray-900); }
.login-brand h1 span { color: var(--blue-600); }
.login-tagline { font-size: 0.78rem; color: var(--gray-500); font-weight: 500; letter-spacing: 0.03em; text-transform: uppercase; }

.login-form { display: flex; flex-direction: column; gap: 18px; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 0.82rem; font-weight: 600; color: var(--gray-700); }
.input-wrap {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 12px 14px; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  background: var(--gray-25);
}
.input-wrap:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 4px var(--blue-100); background: #fff; }
.input-wrap i { color: var(--gray-400); font-size: 0.9rem; }
.input-wrap input { border: none; outline: none; background: transparent; flex: 1; font-size: 0.92rem; color: var(--gray-900); }
.pw-toggle { color: var(--gray-400); padding: 2px; }
.pw-toggle:hover { color: var(--blue-600); }

.field-row { display: flex; align-items: center; justify-content: space-between; }
.checkbox-wrap { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--gray-600); cursor: pointer; }
.checkbox-wrap input { display: none; }
.checkbox-box { width: 18px; height: 18px; border: 1.5px solid var(--gray-300); border-radius: 5px; position: relative; transition: all 0.2s var(--ease); flex-shrink: 0; }
.checkbox-wrap input:checked + .checkbox-box { background: var(--blue-600); border-color: var(--blue-600); }
.checkbox-wrap input:checked + .checkbox-box::after {
  content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
  color: #fff; font-size: 10px; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.forgot-link { font-size: 0.84rem; color: var(--blue-600); font-weight: 600; }
.forgot-link:hover { text-decoration: underline; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue-600); border: 1px solid var(--blue-600);
  color: #fff; font-weight: 400; font-size: 0.9rem;
  padding: 10px 18px; border-radius: var(--radius-md);
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-primary:active { background: var(--blue-900); border-color: var(--blue-900); }
.btn-primary:focus-visible { box-shadow: 0 0 0 0.25rem rgba(13,110,253,0.35); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--red-500); border: 1px solid var(--red-500); color: #fff; font-weight: 400; font-size: 0.9rem;
  padding: 10px 18px; border-radius: var(--radius-md);
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn-danger:hover { background: #bb2d3b; border-color: #b02a37; }
.btn-danger:active { background: #b02a37; border-color: #a52834; }
.btn-danger:focus-visible { box-shadow: 0 0 0 0.25rem rgba(220,53,69,0.35); }
.btn-signin { width: 100%; padding: 11px; margin-top: 4px; }

/* Button ripple */
.ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.5); transform: scale(0); animation: ripple-anim 0.6s linear; pointer-events: none; }
@keyframes ripple-anim { to { transform: scale(3); opacity: 0; } }

.login-divider { display: flex; align-items: center; gap: 12px; margin: 6px 0; color: var(--gray-400); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }
.login-hint { font-size: 0.8rem; color: var(--gray-500); line-height: 1.5; text-align: center; }
.login-footer { text-align: center; margin-top: 32px; font-size: 0.76rem; color: var(--gray-400); }

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  transition: width 0.28s var(--ease);
  z-index: 40;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-head { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,0.06); position: relative; }
.sidebar-logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--blue-500), var(--indigo-500)); display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.sidebar-brand-text { display: flex; flex-direction: column; overflow: hidden; white-space: nowrap; }
.sidebar-brand-text strong { color: #fff; font-size: 0.98rem; font-weight: 700; }
.sidebar-brand-text span { font-size: 0.68rem; color: var(--sidebar-text); letter-spacing: 0.04em; }
.sidebar.collapsed .sidebar-brand-text { opacity: 0; width: 0; }
.sidebar-collapse-btn { margin-left: auto; color: var(--sidebar-text); width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; transition: background 0.2s; }
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.08); }
.sidebar.collapsed .sidebar-collapse-btn { transform: rotate(180deg); position: absolute; right: -13px; top: 26px; background: var(--blue-600); color: #fff; box-shadow: var(--shadow-md); }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 12px 20px; }
.nav-section-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: #5b6690; font-weight: 700; padding: 16px 12px 8px; white-space: nowrap; }
.sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 6px 0 0; overflow: hidden; }

.nav-item {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
  color: var(--sidebar-text); font-size: 0.865rem; font-weight: 500;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
  white-space: nowrap; position: relative;
}
.nav-item i { width: 18px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--blue-600); color: #fff; }
.nav-item.nav-logout { color: #f87171; margin-top: 10px; }
.nav-item.nav-logout:hover { background: rgba(248,113,113,0.1); }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(10,14,30,0.5); z-index: 39; }
.sidebar-overlay.show { display: block; animation: fadeIn 0.2s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Main column --- */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; z-index: 30;
}
.mobile-menu-btn { display: none; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 1rem;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
  position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--gray-100); color: var(--blue-600); }
body.dark-mode .icon-btn:hover { background: var(--bg-surface-alt); }

/* Search input - hidden in all modes */
.topbar-search {
  display: none !important;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.badge-dot {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 3px;
  background: var(--red-500); color: #fff; font-size: 0.6rem; font-weight: 700;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-surface);
}

.dropdown-wrap { position: relative; }
.dropdown-panel {
  position: absolute; top: calc(100% + 10px); right: 0; width: 320px;
  max-width: calc(100vw - 24px);
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: all 0.2s var(--ease); z-index: 50; overflow: hidden;
}
.dropdown-panel.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-panel-right { width: 220px; padding: 8px; }
.dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border-color); font-weight: 600; font-size: 0.88rem; }
.dropdown-head a { font-size: 0.78rem; color: var(--blue-600); font-weight: 600; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border-color); transition: background 0.15s; cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--gray-50); }
body.dark-mode .notif-item:hover { background: var(--bg-surface-alt); }
.notif-item.unread { background: var(--blue-50); }
body.dark-mode .notif-item.unread { background: rgba(13, 110, 253,0.08); }
.notif-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.85rem; }
.notif-text strong { display: block; font-size: 0.83rem; margin-bottom: 2px; }
.notif-text span { font-size: 0.76rem; color: var(--text-muted); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: var(--radius-pill); transition: background 0.18s; }
.user-chip:hover { background: var(--gray-100); }
body.dark-mode .user-chip:hover { background: var(--bg-surface-alt); }
.user-chip img { width: 32px; height: 32px; border-radius: 50%; }
.user-chip-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.user-chip-text strong { font-size: 0.82rem; }
.user-chip-text span { font-size: 0.72rem; color: var(--text-muted); }
.user-chip > i { font-size: 0.7rem; color: var(--text-muted); }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 8px; font-size: 0.85rem; }
.dropdown-item:hover { background: var(--gray-100); }
body.dark-mode .dropdown-item:hover { background: var(--bg-surface-alt); }
.dropdown-item i { width: 16px; color: var(--text-muted); }

/* Breadcrumb */
.breadcrumb-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 26px; border-bottom: 1px solid var(--border-color); }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); }
.breadcrumb .sep { font-size: 0.6rem; }
.breadcrumb #breadcrumbCurrent { color: var(--text-primary); font-weight: 600; }
.breadcrumb-date { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }

/* Page content */
.page-content { flex: 1; min-width: 0; padding: 26px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page { display: none; animation: fadeSlideUp 0.4s var(--ease); }
.page.active { display: block; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-secondary); font-size: 0.9rem; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.page-header-dark {
  background: #212529; border: 1px solid #343a40; border-radius: var(--radius-lg);
  padding: 20px 24px; margin-bottom: 24px;
}
.page-header-dark.page-header { margin-bottom: 24px; }
.page-header-dark h1, .page-header-dark p { color: #fff; }
.page-header-dark p { color: #adb5bd; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--radius-md);
  background: transparent; border: 1px solid var(--gray-500);
  font-size: 0.85rem; font-weight: 400; color: var(--gray-600);
  transition: all 0.15s var(--ease);
}
.btn-ghost:hover { border-color: var(--gray-600); color: #fff; background: var(--gray-600); }
body.dark-mode .btn-ghost:hover { background: var(--bg-surface-alt); color: var(--text-primary); }
.link-btn { font-size: 0.8rem; font-weight: 600; color: var(--blue-600); display: inline-flex; align-items: center; gap: 6px; }
.link-btn:hover { text-decoration: underline; }

/* ==========================================================================
   KPI CARDS
   ========================================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 18px; margin-bottom: 24px; }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-exec { grid-template-columns: repeat(4, 1fr); }

.kpi-card {
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 18px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s var(--ease);
  animation: fadeSlideUp 0.5s var(--ease) backwards;
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; font-size: 1.05rem; }
.kpi-label { font-size: 0.76rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 6px; }
.kpi-value { font-size: 1.55rem; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }
.kpi-delta { font-size: 0.76rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--green-500); }
.kpi-delta.down { color: var(--red-500); }
.kpi-progress { height: 5px; border-radius: 4px; background: var(--gray-100); margin-top: 12px; overflow: hidden; }
body.dark-mode .kpi-progress { background: var(--bg-surface-alt); }
.kpi-progress-bar { height: 100%; border-radius: 4px; width: 0; transition: width 1.2s var(--ease) 0.2s; }

/* Exec (dark) KPI variant */
.panel-dark, .kpi-card-exec { background: #212529; border: 1px solid #343a40; color: #fff; }
.panel.panel-dark { background: #212529; border: 1px solid #343a40; color: #fff; }
.kpi-card-exec .kpi-label { color: #adb5bd; }
.kpi-card-exec .kpi-value { color: #fff; }

/* ==========================================================================
   PANELS / GRIDS
   ========================================================================== */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-2col > * { min-width: 0; }
.panel {
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
  animation: fadeSlideUp 0.5s var(--ease) backwards;
}
.grid-2col .panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.panel-head h3 { font-size: 0.98rem; font-weight: 700; }
.panel-tabs { display: flex; gap: 6px; background: var(--gray-100); padding: 3px; border-radius: var(--radius-pill); }
body.dark-mode .panel-tabs { background: var(--bg-surface-alt); }
.chip { padding: 5px 13px; border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); transition: all 0.2s; }
.chip.active { background: var(--bg-surface); color: var(--blue-600); box-shadow: var(--shadow-sm); }

.legend-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; justify-content: center; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 0.78rem; color: var(--text-secondary); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.dept-bars { display: flex; flex-direction: column; gap: 16px; }
.dept-bar-row { display: flex; flex-direction: column; gap: 6px; }
.dept-bar-label { display: flex; justify-content: space-between; font-size: 0.83rem; font-weight: 600; }
.dept-bar-track { height: 9px; background: var(--gray-100); border-radius: 6px; overflow: hidden; }
body.dark-mode .dept-bar-track { background: var(--bg-surface-alt); }
.dept-bar-fill { height: 100%; border-radius: 6px; width: 0; transition: width 1s var(--ease); }

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; min-width: 560px; --bs-table-striped-bg: rgba(0,0,0,0.02); }
.data-table tbody tr:nth-of-type(odd) { background-color: var(--bs-table-striped-bg); }
.data-table thead th {
  text-align: left; padding: 11px 14px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); border-bottom: 1.5px solid var(--border-color); white-space: nowrap; font-weight: 700;
}
.data-table tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border-color); color: var(--text-primary); white-space: nowrap; }
.data-table tbody tr { transition: background 0.15s var(--ease); }
.data-table tbody tr:hover { background: var(--gray-50); }
body.dark-mode .data-table tbody tr:hover { background: var(--bg-surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table-dark thead th { color: #adb5bd; border-color: #343a40; }
.data-table-dark tbody td { border-color: #343a40; color: #dfe6fb; }
.data-table-dark tbody tr:hover { background: rgba(255,255,255,0.04); }

.cell-main { display: flex; align-items: center; gap: 10px; }
.cell-avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--blue-100); color: var(--blue-700); display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; flex-shrink: 0; }
.cell-sub { color: var(--text-muted); font-size: 0.75rem; }

.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: var(--radius-pill); font-size: 0.72rem; font-weight: 600; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-green { background: var(--green-100); color: #0a3622; }
.status-amber { background: var(--amber-100); color: #664d03; }
.status-red { background: var(--red-100); color: #58151c; }
.status-blue { background: var(--blue-100); color: #052c65; }
.status-gray { background: var(--gray-100); color: var(--gray-600); }

.row-actions { display: flex; gap: 6px; }
.row-actions button { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all 0.15s; font-size: 0.8rem; }
.row-actions button:hover { background: var(--blue-50); color: var(--blue-600); }
.row-actions button.danger:hover { background: var(--red-100); color: var(--red-500); }

.mini-progress { width: 90px; height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 10px; }
body.dark-mode .mini-progress { background: var(--bg-surface-alt); }
.mini-progress-fill { display: block; height: 100%; border-radius: 4px; background: var(--blue-500); min-width: 3px; }
.mini-progress-fill.good { background: var(--green-500); }
.mini-progress-fill.warn { background: var(--amber-500); }
.mini-progress-fill.bad { background: var(--red-500); }
.mini-progress-label { font-weight: 600; font-variant-numeric: tabular-nums; }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-search { display: flex; align-items: center; gap: 8px; background: var(--gray-50); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 8px 12px; flex: 1; max-width: 320px; }
body.dark-mode .toolbar-search { background: var(--bg-surface-alt); }
.toolbar-search i { color: var(--text-muted); font-size: 0.8rem; }
.toolbar-search input { border: none; background: transparent; outline: none; font-size: 0.83rem; flex: 1; color: var(--text-primary); }
.toolbar-filters { display: flex; gap: 8px; align-items: center; }
.toolbar-filters select { padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); background: var(--bg-surface); font-size: 0.82rem; color: var(--text-primary); }

.table-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 0.8rem; color: var(--text-muted); flex-wrap: wrap; gap: 10px; }
.pagination { display: flex; gap: 6px; }
.pagination button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-color); font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.pagination button.active { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.pagination button:hover:not(.active) { background: var(--gray-100); }

/* ==========================================================================
   TABS
   ========================================================================== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; overflow-x: auto; }
.tabs-compact { border-bottom: none; margin-bottom: 0; }
.tab {
  padding: 9px 16px; font-size: 0.85rem; font-weight: 400; color: var(--blue-600);
  border: 1px solid transparent; border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  white-space: nowrap; position: relative; top: 1px; transition: all 0.15s var(--ease);
}
.tab:hover { border-color: var(--gray-100) var(--gray-100) var(--border-color); background: var(--gray-50); }
.tab.active { color: var(--text-primary); background: var(--bg-surface); border-color: var(--border-color) var(--border-color) var(--bg-surface); font-weight: 600; }

/* ==========================================================================
   MISC MODULE COMPONENTS
   ========================================================================== */
/* Roll / warehouse / bank cards */
.roll-grid, .warehouse-grid, .bank-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.roll-card, .warehouse-card, .bank-card {
  background: var(--bg-surface-alt); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 16px; transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.roll-card:hover, .warehouse-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.roll-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.roll-swatch { width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--bg-surface); box-shadow: 0 0 0 1px var(--border-color); }
.roll-card h4 { font-size: 0.88rem; margin-bottom: 4px; }
.roll-card .barcode-txt { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); letter-spacing: 0.05em; }
.roll-meta { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); margin-top: 10px; }

.warehouse-card h4 { font-size: 0.9rem; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.warehouse-card .wh-fill { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }

.bank-card { display: flex; flex-direction: column; gap: 8px; }
.bank-card .bank-name { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }
.bank-card .bank-balance { font-size: 1.25rem; font-weight: 700; }

/* Operator cards */
.operator-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.operator-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-md); transition: box-shadow 0.2s; }
.operator-card:hover { box-shadow: var(--shadow-sm); }
.operator-avatar { width: 40px; height: 40px; border-radius: 50%; }
.operator-info { flex: 1; min-width: 0; }
.operator-info strong { display: block; font-size: 0.83rem; }
.operator-info span { font-size: 0.72rem; color: var(--text-muted); }
.operator-eff { font-weight: 700; font-size: 0.9rem; }

/* Process flow (finishing) */
.process-flow { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.flow-step { flex: 1; min-width: 160px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 16px; text-align: center; position: relative; }
.flow-step i { width: 44px; height: 44px; border-radius: 12px; background: var(--blue-50); color: var(--blue-600); display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; font-size: 1.1rem; }
body.dark-mode .flow-step i { background: rgba(13, 110, 253,0.15); }
.flow-step h4 { font-size: 0.85rem; margin-bottom: 4px; }
.flow-step span { font-size: 0.72rem; color: var(--text-muted); }
.flow-step:not(:last-child)::after { content: '\f105'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; right: -18px; top: 50%; transform: translateY(-50%); color: var(--gray-300); display: none; }
@media (min-width: 900px) { .flow-step:not(:last-child)::after { display: block; } }

/* Calendar */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-cell { aspect-ratio: 1; border-radius: 10px; background: var(--bg-surface-alt); border: 1px solid var(--border-color); padding: 8px; display: flex; flex-direction: column; font-size: 0.75rem; transition: box-shadow 0.15s; }
.calendar-cell:hover { box-shadow: var(--shadow-sm); }
.calendar-cell .cal-day { font-weight: 700; margin-bottom: 4px; }
.calendar-cell .cal-load { margin-top: auto; font-size: 0.65rem; padding: 3px 6px; border-radius: 5px; text-align: center; font-weight: 700; }
.calendar-cell.faded { opacity: 0.35; }

/* Timeline (dispatch) */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border-color); }
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -30px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--blue-600); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.6rem; box-shadow: 0 0 0 4px var(--blue-100); }
body.dark-mode .timeline-dot { box-shadow: 0 0 0 4px rgba(13, 110, 253,0.2); }
.timeline-item.done .timeline-dot { background: var(--green-500); box-shadow: 0 0 0 4px var(--green-100); }
.timeline-item h4 { font-size: 0.86rem; margin-bottom: 2px; }
.timeline-item span { font-size: 0.75rem; color: var(--text-muted); }

/* Live lines (director) */
.live-lines { display: flex; flex-direction: column; gap: 14px; }
.live-line-row { display: flex; align-items: center; gap: 12px; }
.live-line-row .pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green-500); flex-shrink: 0; animation: pulseDot 1.4s infinite; }
@keyframes pulseDot { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5);} 50% { box-shadow: 0 0 0 6px rgba(16,185,129,0);} }
.live-line-row .line-name { width: 90px; font-size: 0.82rem; font-weight: 600; flex-shrink: 0; color: #dfe6fb; }
.live-line-row .line-track { flex: 1; height: 8px; background: rgba(255,255,255,0.08); border-radius: 5px; overflow: hidden; }
.live-line-row .line-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--blue-500), var(--indigo-500)); }
.live-line-row .line-pct { width: 42px; text-align: right; font-size: 0.8rem; font-weight: 700; color: #fff; font-family: var(--font-mono); }

/* Report grid */
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.report-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 20px; transition: transform 0.2s, box-shadow 0.2s; }
.report-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.report-card-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; font-size: 1.1rem; background: var(--blue-50); color: var(--blue-600); }
body.dark-mode .report-card-icon { background: rgba(13, 110, 253,0.15); }
.report-card h4 { font-size: 0.95rem; margin-bottom: 6px; }
.report-card p { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; min-height: 34px; }
.report-card-actions { display: flex; gap: 8px; }
.report-card-actions button { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border-color); font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 5px; transition: all 0.15s; }
.report-card-actions button:hover { background: var(--blue-50); border-color: var(--blue-500); color: var(--blue-600); }

/* Settings */
.settings-layout { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
.settings-nav { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav-item { text-align: left; padding: 11px 14px; border-radius: 9px; font-size: 0.84rem; font-weight: 600; color: var(--text-secondary); }
.settings-nav-item:hover { background: var(--gray-100); }
body.dark-mode .settings-nav-item:hover { background: var(--bg-surface-alt); }
.settings-nav-item.active { background: var(--blue-50); color: var(--blue-600); }
body.dark-mode .settings-nav-item.active { background: rgba(13, 110, 253,0.15); }
.settings-content { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 26px; }
.settings-content h3 { font-size: 1.05rem; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); }
.form-field input, .form-field select, .form-field textarea {
  padding: 8px 12px; border-radius: var(--radius-md); border: 1px solid var(--gray-400);
  background: var(--bg-surface); color: var(--text-primary); font-size: 0.9rem; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 0.25rem rgba(13,110,253,0.25); }
.settings-save-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border-color); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row strong { display: block; font-size: 0.87rem; }
.toggle-row span { font-size: 0.78rem; color: var(--text-muted); }
.switch { position: relative; width: 44px; height: 24px; background: var(--gray-200); border-radius: 999px; flex-shrink: 0; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); box-shadow: var(--shadow-sm); }
.switch.on { background: var(--blue-600); }
.switch.on::after { transform: translateX(20px); }

/* Theme swatch selection */
.theme-swatches { display: flex; gap: 14px; flex-wrap: wrap; }
.theme-swatch { width: 90px; text-align: center; cursor: pointer; }
.theme-swatch .swatch-preview { height: 56px; border-radius: 10px; border: 2px solid transparent; margin-bottom: 6px; transition: border-color 0.2s; }
.theme-swatch.selected .swatch-preview { border-color: var(--blue-600); }
.theme-swatch span { font-size: 0.75rem; color: var(--text-secondary); }

/* Accordion */
.accordion-item { border: 1px solid var(--border-color); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; }
.accordion-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 0.87rem; font-weight: 600; background: var(--bg-surface-alt); }
.accordion-head i { transition: transform 0.2s; color: var(--text-muted); }
.accordion-item.open .accordion-head i { transform: rotate(180deg); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.25s var(--ease); font-size: 0.82rem; color: var(--text-secondary); }
.accordion-item.open .accordion-body { max-height: 200px; }
.accordion-body-inner { padding: 14px 16px; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; }
.activity-item { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border-color); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; flex-shrink: 0; }
.activity-text strong { font-size: 0.82rem; }
.activity-text p { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.activity-text time { font-size: 0.7rem; color: var(--text-muted); }

/* ==========================================================================
   TOASTS
   ========================================================================== */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 999; }
.toast {
  display: flex; align-items: center; gap: 12px; background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 12px 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  min-width: 280px; animation: toastIn 0.35s var(--ease);
  font-size: 0.85rem;
}
.toast.success { border-left: 4px solid var(--green-500); }
.toast.error { border-left: 4px solid var(--red-500); }
.toast.info { border-left: 4px solid var(--blue-500); }
.toast i { font-size: 1rem; }
.toast.success i { color: var(--green-500); }
.toast.error i { color: var(--red-500); }
.toast.info i { color: var(--blue-500); }
.toast.hide { animation: toastOut 0.3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px);} to { opacity: 1; transform: translateX(0);} }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px);} }

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; opacity: 0; visibility: hidden; transition: opacity 0.15s linear; padding: 20px; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-box { background: var(--bg-surface); border: 1px solid rgba(0,0,0,0.2); border-radius: var(--radius-md); width: 100%; max-width: 460px; box-shadow: var(--shadow-lg); transform: translateY(-30px); transition: transform 0.2s ease-out; max-height: 86vh; display: flex; flex-direction: column; }
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.modal-head h3 { font-size: 1.1rem; font-weight: 500; }
.modal-body { padding: 20px; overflow-y: auto; }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.app-footer { display: flex; align-items: center; justify-content: space-between; padding: 16px 26px; border-top: 1px solid var(--border-color); font-size: 0.78rem; color: var(--text-muted); flex-wrap: wrap; gap: 10px; }
.app-footer-links { display: flex; gap: 18px; align-items: center; }
.app-footer-links a:hover { color: var(--blue-600); }
.version-tag { background: var(--gray-100); padding: 3px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; }
body.dark-mode .version-tag { background: var(--bg-surface-alt); }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .report-grid { grid-template-columns: repeat(2, 1fr); }
  .roll-grid, .warehouse-grid, .bank-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1080px) {
  .grid-2col { grid-template-columns: 1fr; }
  .operator-cards { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -100%; top: 0; height: 100vh; box-shadow: var(--shadow-lg); }
  .sidebar.mobile-open { left: 0; }
  .sidebar.collapsed { width: var(--sidebar-w); }
  .mobile-menu-btn { display: flex; }
  .kpi-grid, .kpi-grid-4, .kpi-grid-exec { grid-template-columns: repeat(2, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-bg { display: none; }
}
@media (max-width: 640px) {
  .kpi-grid, .kpi-grid-4, .kpi-grid-exec { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .roll-grid, .warehouse-grid, .bank-cards { grid-template-columns: 1fr; }
  /* Hide search on mobile - already hidden globally */
  .page-content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .breadcrumb-bar { padding: 10px 14px; }
  .page-header { flex-direction: column; }
  .user-chip-text { display: none; }
}

/* ==========================================================================
   PRO UI POLISH
   Bootstrap 5 supplies the responsive foundation; these refinements keep the
   ERP feeling intentional while preserving the existing component API.
   ========================================================================== */
:root {
  --bs-primary: #2563eb;
  --bs-primary-rgb: 37, 99, 235;
  --bg-app: #f4f7fb;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f8fafc;
  --border-color: #e5eaf2;
  --text-primary: #172033;
  --text-secondary: #5d6b82;
  --text-muted: #8793a7;
  --sidebar-bg: #101827;
  --sidebar-bg-alt: #172235;
  --sidebar-text: #aab6c9;
  --sidebar-text-active: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
  --radius-sm: 0.55rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --topbar-h: 72px;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 88% -10%, rgba(37, 99, 235, 0.07), transparent 28rem),
    var(--bg-app);
  font-size: 0.9rem;
}

/* One deliberate scroll surface for the signed-in app. This prevents the
   browser viewport, main column and sidebar from all scrolling independently. */
.app-shell {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  position: relative;
  top: auto;
  height: 100dvh;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), transparent 26%),
    var(--sidebar-bg);
}

.sidebar-head {
  min-height: 84px;
  padding: 20px;
  background: rgba(255,255,255,0.015);
}

.sidebar-logo,
.login-logo {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.sidebar-nav {
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
}

.nav-section-label {
  color: #71809b;
  padding-top: 20px;
}

.nav-item {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  color: #aebbd0;
}

.nav-item:hover {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.08);
}

.nav-item.active {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  box-shadow: 0 7px 18px rgba(37, 99, 235, 0.25);
}

.main-col {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  background: rgba(255, 255, 255, 0.88);
  border-bottom-color: rgba(226, 232, 240, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.breadcrumb-bar {
  flex-shrink: 0;
  background: rgba(248, 250, 252, 0.72);
}

.page-content {
  max-width: none;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px clamp(18px, 3vw, 40px) 34px;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.page-header {
  align-items: center;
  margin-bottom: 26px;
}

.page-header h1 {
  color: #111827;
  font-size: clamp(1.35rem, 1.8vw, 1.75rem);
  letter-spacing: -0.035em;
}

.page-header p {
  color: #64748b;
  margin-bottom: 0;
}

.page-header-actions {
  align-items: center;
}

.btn-primary,
.btn-ghost {
  min-height: 40px;
  border-radius: 0.65rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.btn-primary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #2563eb;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.18);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  border-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.24);
}

.btn-ghost {
  border-color: #d9e1ec;
  background: rgba(255, 255, 255, 0.7);
  color: #475569;
}

.btn-ghost:hover {
  background: #eef4ff;
  border-color: #b7cdfc;
  color: #1d4ed8;
}

.kpi-grid {
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card,
.panel,
.report-card,
.settings-nav,
.settings-content {
  border-color: #e3e9f2;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.035);
}

.kpi-card {
  padding: 20px;
  background: linear-gradient(145deg, #fff, #fbfdff);
}

.kpi-card::after {
  content: '';
  position: absolute;
  right: -26px;
  bottom: -36px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.045);
}

.kpi-card:hover,
.panel:hover,
.report-card:hover {
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.kpi-icon {
  border-radius: 0.8rem;
}

.kpi-value {
  color: #111827;
  font-size: 1.7rem;
  letter-spacing: -0.04em;
}

.panel {
  padding: 22px;
  margin-bottom: 20px;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head h3 {
  color: #1e293b;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.grid-2col {
  gap: 20px;
  margin-bottom: 20px;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.data-table {
  min-width: 0;
}

.data-table thead th {
  background: #f8fafc;
  color: #64748b;
}

.data-table tbody td {
  padding-top: 14px;
  padding-bottom: 14px;
}

.data-table tbody tr:hover {
  background: #f5f8ff;
}

.tabs {
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  color: #64748b;
  font-weight: 600;
}

.tab.active {
  color: #1d4ed8;
  box-shadow: inset 0 -2px 0 #2563eb;
}

.toolbar-search,
.toolbar-filters select,
.form-field input,
.form-field select,
.form-field textarea {
  border-color: #dbe3ef;
  border-radius: 0.65rem;
}

.toolbar-search {
  background: #f8fafc;
}

.activity-feed {
  max-height: none;
  overflow: visible;
}

.app-footer {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.58);
  padding: 14px clamp(18px, 3vw, 40px);
}

.login-page {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow-y: auto;
  background: #fff;
}

.login-panel {
  background:
    radial-gradient(circle at 10% 10%, rgba(37, 99, 235, 0.04), transparent 18rem),
    #fff;
  padding: clamp(24px, 5vw, 64px);
}

.login-card {
  max-width: 430px;
}

.login-brand {
  margin-bottom: 30px;
}

.input-wrap {
  min-height: 48px;
  border-radius: 0.7rem;
  background: #f8fafc;
  border-color: #dbe3ef;
}

.input-wrap:focus-within {
  background: #fff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.12);
}

.role-btn {
  border-radius: 0.75rem;
  background: #fff;
}

.role-btn.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.toast-container {
  right: clamp(14px, 2vw, 24px);
  bottom: clamp(14px, 2vw, 24px);
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    height: 100dvh;
  }

  .page-content {
    padding-top: 22px;
  }
}

@media (max-width: 640px) {
  .page-content {
    padding: 20px 14px 28px;
  }

  .panel {
    padding: 16px;
  }

  .page-header-actions {
    width: 100%;
  }

  .page-header-actions > * {
    flex: 1;
  }

  .app-footer {
    padding: 12px 14px;
  }
}

/* ==========================================================================
   FINAL LAYOUT + CHART PASS
   ========================================================================== */
.login-page {
  overflow: hidden;
  align-content: center;
}

.login-panel {
  align-items: flex-start;
  padding: 60px 40px 0;
}

.login-brand {
  margin-bottom: clamp(16px, 3vh, 30px);
}

.login-form {
  gap: clamp(10px, 1.8vh, 18px);
}

.login-footer {
  margin-top: clamp(12px, 2.5vh, 28px);
}

.panel > canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  border-radius: 0.85rem;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.72), rgba(255, 255, 255, 0.25));
}

.chart-viewport {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: 0.85rem;
}

.chart-viewport canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
}

.dashboard-page .kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.dashboard-page > .grid-2col > .panel {
  min-height: 318px;
}

.dashboard-page > .grid-2col > .panel .panel-head {
  padding-bottom: 14px;
  border-bottom: 1px solid #edf1f6;
}

.dashboard-page .panel-tabs {
  border: 1px solid #e2e8f0;
}

.director-header {
  background:
    linear-gradient(135deg, #ffffff 0%, #f5f8ff 100%);
  border: 1px solid #e1e8f3;
  border-left: 4px solid #2563eb;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.05);
}

.director-header h1 {
  color: #172033;
}

.director-page .kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.director-page .panel {
  min-height: 260px;
}

.director-page .panel-head {
  padding-bottom: 14px;
  border-bottom: 1px solid #edf1f6;
}

.director-page .panel-head h3 {
  color: #1e293b;
}

.director-page .live-lines {
  gap: 17px;
  padding-top: 4px;
}

.director-page .live-line-row .line-name,
.director-page .live-line-row .line-pct {
  color: #334155;
}

.director-page .live-line-row .line-track {
  background: #e8eef7;
}

.director-page .data-table thead th {
  background: #f8fafc;
}

.inventory-page > .panel:last-child,
.cutting-page > .panel:last-child,
.director-delayed-panel {
  width: 100%;
}

.inventory-page > .panel:last-child .data-table,
.cutting-page > .panel:last-child .data-table,
.director-delayed-panel .data-table {
  font-size: 0.8rem;
}

.inventory-page > .panel:last-child .data-table th,
.inventory-page > .panel:last-child .data-table td,
.cutting-page > .panel:last-child .data-table th,
.cutting-page > .panel:last-child .data-table td,
.director-delayed-panel .data-table th,
.director-delayed-panel .data-table td {
  padding-left: 9px;
  padding-right: 9px;
}

.inventory-page > .panel:last-child .mini-progress,
.cutting-page > .panel:last-child .mini-progress {
  width: 72px;
  margin-right: 6px;
}

.inventory-page > .panel:last-child .row-actions,
.cutting-page > .panel:last-child .row-actions {
  gap: 2px;
}

.inventory-page > .panel:last-child .row-actions button,
.cutting-page > .panel:last-child .row-actions button {
  width: 26px;
  height: 26px;
  font-size: 0.72rem;
}

/* The three-line mobile trigger is intentionally removed. On small screens
   the sidebar becomes a compact icon rail so navigation stays available. */
.mobile-menu-btn {
  display: none !important;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 76px;
    height: 100dvh;
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .sidebar-head {
    justify-content: center;
    padding: 18px 10px;
  }

  #sidebar .sidebar-brand-text,
  #sidebar .sidebar-collapse-btn,
  #sidebar .nav-section-label,
  #sidebar .nav-item span {
    display: none !important;
  }

  .sidebar-nav {
    padding: 14px 10px 20px;
  }

  .sidebar .nav-item {
    justify-content: center;
    min-height: 42px;
    padding: 10px 8px;
  }

  .sidebar-overlay {
    display: none !important;
  }

  .main-col {
    width: calc(100% - 76px);
    margin-left: 76px;
  }
}

@media (max-height: 720px) {
  .login-panel {
    padding-top: 60px;
    padding-bottom: 0;
  }

  .login-brand {
    margin-bottom: 14px;
  }

  .login-logo {
    width: 44px;
    height: 44px;
  }

  .login-brand h1 {
    font-size: 1.2rem;
  }

  .login-form {
    gap: 9px;
  }

  .role-btn {
    padding: 8px 10px !important;
  }

  .input-wrap {
    min-height: 42px;
    padding-block: 9px;
  }

  .login-footer {
    margin-top: 10px;
  }
}

/* ==========================================================================
   EXTRA-SMALL PHONES (<=480px)
   ========================================================================== */
@media (max-width: 480px) {
  .topbar { padding: 0 12px; gap: 8px; height: 60px; }
  .icon-btn { width: 34px; height: 34px; font-size: 0.9rem; }
  .breadcrumb-bar { padding: 8px 12px; }
  .page-content { padding: 16px 12px 24px; }
  .page-header h1 { font-size: 1.15rem; }

  /* Anchor dropdowns to the viewport instead of a fixed 320px panel so
     they can never run off the left edge on narrow phones. */
  .dropdown-panel {
    position: fixed; top: 60px; right: 8px; left: 8px;
    width: auto; max-width: none;
  }
  .dropdown-panel-right { left: auto; right: 8px; width: 200px; }

  .sidebar { width: 60px !important; }
  .main-col { width: calc(100% - 60px) !important; margin-left: 60px !important; }
  .sidebar .nav-item { min-height: 38px; padding: 8px 6px; }

  .kpi-card { padding: 14px; }
  .kpi-icon { width: 34px; height: 34px; font-size: 0.9rem; }
  .kpi-value { font-size: 1.3rem; }
  .panel { padding: 14px; }

  .login-panel { padding: 32px 18px 0; }
  .login-card { max-width: 100%; }
  .login-logo { width: 42px; height: 42px; font-size: 1.15rem; }
  .login-brand h1 { font-size: 1.15rem; }

  .modal-box { max-width: 100%; }
  .task-card, .shift-card, .flow-step { padding: 12px; }
}

@media (max-height: 560px) {
  .login-panel {
    align-items: flex-start;
    padding-top: 60px;
    padding-bottom: 0;
  }

  .login-brand {
    margin-bottom: 10px;
  }

  .login-tagline,
  .login-footer {
    display: none;
  }
}