/* =========================================
   SAJA v2 — Modern Design System
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --primary:       #4f46e5;
  --primary-dark:  #3730a3;
  --primary-mid:   #6366f1;
  --primary-light: #eef2ff;
  --primary-glow:  rgba(79,70,229,0.15);

  /* Accent */
  --accent:        #06b6d4;
  --accent-light:  #ecfeff;

  /* Semantic */
  --success:       #10b981;
  --success-light: #d1fae5;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --info:          #3b82f6;
  --info-light:    #dbeafe;
  --purple:        #8b5cf6;
  --purple-light:  #ede9fe;
  --orange:        #f97316;
  --orange-light:  #ffedd5;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Layout */
  --sidebar-w: 268px;
  --header-h:  64px;

  /* Radii */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Shadows */
  --shadow-xs: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.14), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-primary: 0 8px 24px rgba(79,70,229,0.3);

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow:   0.4s cubic-bezier(0.4,0,0.2,1);

  /* Z-indices */
  --z-sidebar:  1000;
  --z-header:   100;
  --z-dropdown: 500;
  --z-modal:    2000;
  --z-toast:    9999;
}

/* ===========================
   BASE
   =========================== */
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f2ff;
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ===========================
   LAYOUT
   =========================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===========================
   SIDEBAR
   =========================== */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(175deg, #1e1b4b 0%, #312e81 60%, #3730a3 100%);
  color: white;
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--t-slow);
  overflow: hidden;
  box-shadow: 4px 0 24px rgba(49,46,129,0.35);
}

/* Noise texture overlay */
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.4;
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.sidebar-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #818cf8, #4f46e5);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79,70,229,0.5);
}

.sidebar-title { font-size: 1.2rem; font-weight: 800; letter-spacing: 1.5px; }
.sidebar-subtitle { font-size: 0.68rem; color: rgba(255,255,255,0.5); margin-top: 0.1rem; letter-spacing: 0.3px; }

.sidebar-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  margin: 0 1rem;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  position: relative;
}

.nav-section { margin-bottom: 0.25rem; }

.nav-section-title {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 1rem 1.25rem 0.3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  transition: all var(--t-fast);
  color: rgba(255,255,255,0.6);
  font-size: 0.845rem;
  font-weight: 500;
  user-select: none;
  position: relative;
  border-radius: 0;
  margin: 1px 0.5rem;
  border-radius: var(--r-sm);
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
  transform: translateX(2px);
}

.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #818cf8;
}

.nav-item .nav-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.sidebar-footer {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  position: relative;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.6rem;
  border-radius: var(--r);
  transition: background var(--t-fast);
}

.user-info:hover { background: rgba(255,255,255,0.08); }

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,70,229,0.4);
}

.user-name { font-size: 0.85rem; font-weight: 600; color: white; }
.user-role { font-size: 0.68rem; color: rgba(255,255,255,0.45); text-transform: capitalize; }

/* ===========================
   MAIN CONTENT
   =========================== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #f0f2ff;
}

/* ===========================
   HEADER
   =========================== */
.page-header {
  height: var(--header-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(79,70,229,0.08);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  gap: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 0.3rem;
  border: none;
  background: transparent;
}

.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--gray-600); border-radius: 2px;
  transition: all 0.3s;
}

.page-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.2px;
}

.page-breadcrumb {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.05rem;
}

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }

/* ===========================
   PAGE BODY
   =========================== */
.page-body {
  flex: 1;
  padding: 1.5rem;
  animation: pageFadeIn 0.3s ease-out;
}

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

/* ===========================
   CARDS
   =========================== */
.card {
  background: white;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: cardSlideIn 0.25s ease-out both;
}

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

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(to right, rgba(79,70,229,0.03), transparent);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.2px;
}

.card-actions { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.card-body { padding: 1.25rem; }

/* ===========================
   KPI CARDS
   =========================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: white;
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
  overflow: hidden;
  border: none;
  transition: transform var(--t-normal), box-shadow var(--t-normal);
  animation: cardSlideIn 0.3s ease-out both;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.kpi-card.success::before { background: var(--success); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-card.danger::before  { background: var(--danger); }
.kpi-card.info::before    { background: var(--info); }
.kpi-card.purple::before  { background: var(--purple); }
.kpi-card.accent::before  { background: var(--accent); }

.kpi-card::after {
  content: '';
  position: absolute;
  bottom: -20px;
  right: -10px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--primary-light);
  opacity: 0.6;
}

.kpi-card.success::after { background: var(--success-light); }
.kpi-card.warning::after { background: var(--warning-light); }
.kpi-card.danger::after  { background: var(--danger-light); }
.kpi-card.info::after    { background: var(--info-light); }
.kpi-card.purple::after  { background: var(--purple-light); }

.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.kpi-label { font-size: 0.7rem; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.8px; }
.kpi-value { font-size: 1.65rem; font-weight: 800; color: var(--gray-900); letter-spacing: -0.5px; position: relative; z-index: 1; }
.kpi-sub   { font-size: 0.72rem; color: var(--gray-400); position: relative; z-index: 1; }

/* ===========================
   TABLES
   =========================== */
.table-wrapper { overflow-x: auto; border-radius: var(--r); }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

thead th {
  background: var(--gray-50);
  padding: 0.65rem 0.875rem;
  text-align: left;
  font-weight: 700;
  color: var(--gray-500);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 2px solid var(--gray-100);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

tbody td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
  transition: background var(--t-fast);
}

tbody tr {
  animation: rowFadeIn 0.2s ease-out both;
}

tbody tr:hover td { background: var(--primary-light); }
tbody tr:last-child td { border-bottom: none; }

@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.table-empty {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--gray-400);
}
.table-empty .empty-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.6; }
.table-empty p { font-size: 0.9rem; }

/* ===========================
   BUTTONS
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.575rem 1.1rem;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.1px;
  position: relative;
  overflow: hidden;
  font-family: inherit;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity var(--t-fast);
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-mid), var(--primary-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-primary);
}

.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); }

.btn-success {
  background: linear-gradient(135deg, #34d399, #059669);
  color: white;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}
.btn-success:hover:not(:disabled) { transform: translateY(-1px); }

.btn-danger {
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: white;
  box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}
.btn-danger:hover:not(:disabled) { transform: translateY(-1px); }

.btn-warning {
  background: linear-gradient(135deg, #fcd34d, #d97706);
  color: white;
  box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}
.btn-warning:hover:not(:disabled) { transform: translateY(-1px); }

.btn-info {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: white;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.btn-accent {
  background: linear-gradient(135deg, #22d3ee, #0891b2);
  color: white;
  box-shadow: 0 2px 8px rgba(6,182,212,0.3);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-800); }

.btn-sm  { padding: 0.35rem 0.7rem; font-size: 0.775rem; }
.btn-lg  { padding: 0.8rem 1.6rem; font-size: 0.95rem; }
.btn-xl  { padding: 1rem 2rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; border-radius: var(--r-sm); }

/* ===========================
   BADGES
   =========================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-danger   { background: var(--danger-light); color: var(--danger); }
.badge-info     { background: var(--info-light); color: var(--info); }
.badge-secondary{ background: var(--gray-100); color: var(--gray-600); }
.badge-primary  { background: var(--primary-light); color: var(--primary); }
.badge-purple   { background: var(--purple-light); color: var(--purple); }
.badge-accent   { background: var(--accent-light); color: var(--accent); }
.badge-orange   { background: var(--orange-light); color: var(--orange); }

/* ===========================
   FORMS
   =========================== */
.form-row { display: flex; gap: 0.875rem; flex-wrap: wrap; }
.form-col  { flex: 1; min-width: 180px; }
.form-col-2{ flex: 2; min-width: 280px; }
.form-col-3{ flex: 3; min-width: 320px; }

.form-group { margin-bottom: 0.9rem; }

.form-group label {
  display: block;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  letter-spacing: 0.1px;
}

.form-group label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  color: var(--gray-800);
  background: white;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: white;
}

.form-control:disabled,
.form-control[readonly] {
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: not-allowed;
  border-style: dashed;
}

.form-control.auto-gen {
  background: #f8f9ff;
  color: var(--primary-dark);
  font-weight: 600;
  font-family: 'Courier New', monospace;
  border-color: var(--primary-light);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint  { font-size: 0.72rem; color: var(--gray-400); margin-top: 0.25rem; }
.form-error { font-size: 0.72rem; color: var(--danger); margin-top: 0.25rem; display: flex; align-items: center; gap: 0.25rem; }

/* Checkbox + Switch */
.checkbox-group { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.checkbox-group input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.switch-label {
  display: flex; align-items: center; gap: 0.6rem;
  cursor: pointer; font-size: 0.875rem; font-weight: 500;
}

/* File input styling */
.file-drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--r);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--gray-50);
}

.file-drop-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-drop-zone .drop-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.file-drop-zone p { color: var(--gray-500); font-size: 0.875rem; }
.file-drop-zone input[type=file] { display: none; }

/* ===========================
   FILTERS BAR
   =========================== */
.filters-bar {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.875rem 1rem;
  background: var(--gray-50);
  border-radius: var(--r);
  border: 1px solid var(--gray-100);
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}

.search-input input { padding-left: 2.4rem; }

.search-input .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 0.9rem;
  pointer-events: none;
}

/* ===========================
   TABS
   =========================== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.tab {
  padding: 0.65rem 1rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--t-fast);
  letter-spacing: 0.1px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab:hover { color: var(--primary); background: var(--primary-light); border-radius: 6px 6px 0 0; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

.tab-panel { animation: tabFadeIn 0.2s ease-out; }

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

/* ===========================
   MODAL
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 60px rgba(0,0,0,0.3);
  transform: scale(0.94) translateY(10px);
  transition: transform var(--t-slow);
}

.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-lg  { max-width: 860px; }
.modal-xl  { max-width: 1100px; }
.modal-xxl { max-width: 1300px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(to right, var(--primary-light), white);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  color: var(--gray-800);
  letter-spacing: -0.2px;
}

.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: var(--gray-100);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 1rem;
  color: var(--gray-500);
  transition: all var(--t-fast);
  font-family: inherit;
}

.modal-close:hover { background: var(--danger-light); color: var(--danger); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--gray-50);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* ===========================
   ALERTS
   =========================== */
.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--r-sm);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  border-left: 4px solid;
}

.alert-success { background: var(--success-light); color: #065f46; border-color: var(--success); }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: var(--warning); }
.alert-error   { background: var(--danger-light);  color: #991b1b; border-color: var(--danger); }
.alert-info    { background: var(--info-light);    color: #1e40af; border-color: var(--info); }

/* ===========================
   TOAST
   =========================== */
#toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  background: var(--gray-900);
  color: white;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 280px;
  max-width: 400px;
  animation: toastSlide 0.35s cubic-bezier(0.4,0,0.2,1);
}

@keyframes toastSlide {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.success { background: linear-gradient(135deg, #10b981, #059669); }
.toast.error   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toast.info    { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-msg  { flex: 1; line-height: 1.4; }

/* ===========================
   LOADING / SKELETON
   =========================== */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 2.5rem auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-row { height: 52px; margin-bottom: 2px; }

/* ===========================
   PT CARDS (Productos Terminados)
   =========================== */
.pt-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
  padding: 0.25rem;
}

.pt-card {
  background: white;
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--t-normal), box-shadow var(--t-normal);
  position: relative;
  overflow: hidden;
  border: 1.5px solid transparent;
  animation: cardSlideIn 0.25s ease-out both;
}

.pt-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.pt-card.jab::before { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.pt-card.acc::before { background: linear-gradient(90deg, #34d399, #10b981); }
.pt-card.liq::before { background: linear-gradient(90deg, #60a5fa, #3b82f6); }

.pt-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.pt-card-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  display: inline-block;
  margin-bottom: 0.6rem;
  letter-spacing: 0.3px;
  font-family: 'Courier New', monospace;
}

.pt-card.jab .pt-card-badge { color: var(--warning); background: var(--warning-light); }
.pt-card.acc .pt-card-badge { color: var(--success); background: var(--success-light); }
.pt-card.liq .pt-card-badge { color: var(--info); background: var(--info-light); }

.pt-card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.pt-card-sub {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.pt-card-footer {
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pt-card-price {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--success);
}

/* ===========================
   INSUMOS CARD (list style)
   =========================== */
.insumo-card {
  background: white;
  border-radius: var(--r);
  border: 1.5px solid var(--gray-100);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  cursor: pointer;
  transition: all var(--t-fast);
  margin-bottom: 0.375rem;
}

.insumo-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateX(4px);
}

.insumo-card-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.insumo-card-clave {
  font-size: 0.7rem;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

/* ===========================
   DETAIL TABLE
   =========================== */
.detail-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.detail-table th {
  background: var(--gray-50);
  padding: 0.55rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--gray-100);
}
.detail-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}
.detail-table td input,
.detail-table td select {
  padding: 0.35rem 0.5rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.8rem;
  width: 100%;
  font-family: inherit;
  transition: border-color var(--t-fast);
}
.detail-table td input:focus,
.detail-table td select:focus { outline: none; border-color: var(--primary); }

/* ===========================
   INFO GRID
   =========================== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}

.info-item .info-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-item .info-value {
  font-size: 0.9rem;
  color: var(--gray-800);
  font-weight: 500;
  margin-top: 0.1rem;
}

/* ===========================
   SECTION DIVIDER
   =========================== */
.section-divider {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===========================
   GRID HELPERS
   =========================== */
.two-col-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.three-col-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.four-col-grid  { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }

/* ===========================
   PAGINATION
   =========================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-100);
}

.page-btn {
  padding: 0.35rem 0.65rem;
  border: 1.5px solid var(--gray-200);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--gray-600);
  transition: all var(--t-fast);
  font-family: inherit;
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===========================
   STATUS COLORS
   =========================== */
.status-borrador    { color: var(--gray-500); }
.status-emitida, .status-liberada { color: var(--info); }
.status-confirmada, .status-finalizada, .status-pagado { color: var(--success); }
.status-parcial, .status-en_proceso { color: var(--warning); }
.status-cancelada, .status-vencido  { color: var(--danger); }

/* ===========================
   KANBAN / PIPELINE
   =========================== */
.kanban-board { display: flex; gap: 0.875rem; overflow-x: auto; padding-bottom: 1rem; }
.kanban-col {
  flex: 0 0 230px;
  background: var(--gray-50);
  border-radius: var(--r-lg);
  padding: 0.75rem;
  border: 1.5px solid var(--gray-100);
}
.kanban-col-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kanban-col-header .col-count {
  background: var(--gray-200);
  border-radius: 99px;
  padding: 0.1rem 0.5rem;
  font-size: 0.68rem;
}
.kanban-card {
  background: white;
  border-radius: var(--r);
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  border-left: 3px solid var(--primary);
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ===========================
   PRODUCTION / OP STYLES
   =========================== */
.op-header-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.op-folio {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.op-meta-item { font-size: 0.8rem; opacity: 0.85; }
.op-meta-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.6; }

/* BOM sections */
.bom-section {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r);
  margin-bottom: 1rem;
  overflow: hidden;
}

.bom-section-header {
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-bottom: 1.5px solid var(--gray-200);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===========================
   LÍNEAS DE PRODUCCIÓN
   =========================== */
.lineas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.linea-card {
  background: white;
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--primary);
  transition: transform var(--t-normal), box-shadow var(--t-normal);
  cursor: pointer;
}

.linea-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.linea-card.disponible { border-top-color: var(--success); }
.linea-card.ocupada    { border-top-color: var(--warning); }
.linea-card.inactiva   { border-top-color: var(--gray-300); opacity: 0.7; }

.linea-cargas {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin: 0.5rem 0;
}

/* ===========================
   FILE UPLOAD LIST
   =========================== */
.file-list { display: flex; flex-direction: column; gap: 0.4rem; }

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.875rem;
  background: var(--gray-50);
  border-radius: var(--r-sm);
  border: 1px solid var(--gray-100);
  font-size: 0.8rem;
  transition: background var(--t-fast);
}

.file-item:hover { background: var(--primary-light); }
.file-item-icon { font-size: 1.1rem; flex-shrink: 0; }
.file-item-name { flex: 1; font-weight: 500; color: var(--gray-700); }
.file-item-size { color: var(--gray-400); font-size: 0.72rem; }

/* ===========================
   HISTORICO TABLE
   =========================== */
.historico-card {
  background: var(--gray-50);
  border-radius: var(--r);
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--primary);
  font-size: 0.875rem;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 30px rgba(0,0,0,0.3); }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .two-col-grid, .three-col-grid, .four-col-grid { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .search-input { max-width: none; }
  .pt-cards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-body { padding: 1rem; }
  .modal { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 96vh; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* ===========================
   SIDEBAR OVERLAY
   =========================== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: calc(var(--z-sidebar) - 1);
}
.sidebar-overlay.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===========================
   PRINT
   =========================== */
@media print {
  .sidebar, .page-header, .btn, .filters-bar, #toast-container { display: none !important; }
  .main-content { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
