:root {
  --primary: #1a237e;
  --primary-light: #283593;
  --secondary: #37474f;
  --accent: #ff6f00;
  --success: #2e7d32;
  --danger: #c62828;
  --warning: #f57f17;
  --info: #0277bd;
  --light: #f5f5f5;
  --dark: #212121;
  --white: #ffffff;
  --border: #e0e0e0;
  --sidebar-w: 250px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 14px; color: var(--dark); background: var(--light); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #ffffff 0%, #ffd9b8 100%);
  color: var(--dark); overflow-y: auto; z-index: 1000;
  transition: transform .3s;
}
.sidebar-logo {
  padding: 16px 20px; font-size: 18px; font-weight: 700;
  border-bottom: 1px solid rgba(0,0,0,.12);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo i { color: var(--accent); font-size: 22px; }
.sidebar-nav { list-style: none; padding: 8px 0; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(0,0,0,.82);
  transition: background .2s; font-size: 13px;
}
.sidebar-nav li a:hover, .sidebar-nav li a.active {
  background: rgba(0,0,0,.10); color: var(--dark); text-decoration: none;
}
.sidebar-nav li a.nav-link-accent, .sidebar-nav li a.nav-link-accent:hover { color: var(--accent); }
.sidebar-nav li a.nav-link-success, .sidebar-nav li a.nav-link-success:hover { color: var(--success); }
.sidebar-nav li a.nav-link-primary, .sidebar-nav li a.nav-link-primary:hover { color: var(--primary); }
.sidebar-nav li a.nav-link-celeste, .sidebar-nav li a.nav-link-celeste:hover { color: #29b6f6; }
.sidebar-nav li a.nav-link-dashboard, .sidebar-nav li a.nav-link-dashboard:hover { color: var(--accent); font-weight: 700; }
.sidebar-nav li a.nav-link-dashboard i { color: #c62828; }
.sidebar-nav li a.nav-link-series, .sidebar-nav li a.nav-link-series:hover { color: var(--primary); }
.sidebar-nav li a.nav-link-series i { color: #29b6f6; }
.sidebar-nav li a.nav-link-bold { font-weight: 700; }
.sidebar-nav li a i { width: 20px; text-align: center; }
.nav-section {
  padding: 10px 20px 4px; font-size: 11px; text-transform: uppercase;
  color: rgba(0,0,0,.55); letter-spacing: 1px; margin-top: 4px; font-weight: 700;
}
.submenu { list-style: none; display: none; background: rgba(0,0,0,.08); }
.submenu.open { display: block; }
.submenu li a { padding-left: 50px; font-size: 12px; }
.nav-toggle { cursor: pointer; }
.nav-toggle::after { content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900; margin-left: auto; font-size: 10px; transition: transform .2s; }
.nav-toggle.open::after { transform: rotate(180deg); }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h); background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 999;
}
.topbar-info { font-size: 13px; color: var(--secondary); }
.topbar-info strong { color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-actions a { color: var(--secondary); font-size: 14px; }
.topbar-actions a:hover { color: var(--danger); text-decoration: none; }

/* ===== NOTIFICATION BADGES ===== */
.notif-badge {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.notif-badge .count {
  position: absolute; top: -6px; right: -8px;
  background: var(--danger); color: var(--white);
  border-radius: 50%; min-width: 18px; height: 18px;
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.notif-badge .count.zero { display: none; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w); margin-top: var(--topbar-h);
  padding: 24px; min-height: calc(100vh - var(--topbar-h));
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.page-header h1 { font-size: 22px; color: var(--primary); font-weight: 600; }

/* ===== CARDS ===== */
.card {
  background: var(--white); border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1); margin-bottom: 20px;
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px; color: var(--primary);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.stat-card {
  background: var(--white); border-radius: 8px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  display: flex; align-items: center; gap: 16px; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); text-decoration: none; }
.stat-icon {
  width: 50px; height: 50px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--white);
}
.stat-icon.bg-primary { background: var(--primary); }
.stat-icon.bg-success { background: var(--success); }
.stat-icon.bg-warning { background: var(--warning); }
.stat-icon.bg-danger { background: var(--danger); }
.stat-icon.bg-info { background: var(--info); }
.stat-icon.bg-accent { background: var(--accent); }
.stat-icon.bg-secondary { background: var(--secondary); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--dark); }
.stat-label { font-size: 12px; color: #757575; }

/* ===== TABLES ===== */
.table-container { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table thead th {
  background: var(--primary); color: var(--white);
  padding: 10px 12px; text-align: left; font-weight: 600;
  position: sticky; top: 0; white-space: nowrap;
}
.data-table tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: #e8eaf6; }
.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table tbody tr:nth-child(even):hover { background: #e8eaf6; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 13px; color: var(--secondary); }
.form-control {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 14px; transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,35,126,.15); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 60px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-inline { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: 4px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .2s, transform .1s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-light); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #1b5e20; color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b71c1c; color: var(--white); }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-info { background: var(--info); color: var(--white); }
.btn-info:hover { background: #01579b; color: var(--white); }
.btn-secondary { background: #757575; color: var(--white); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-outline-primary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: var(--white); }

/* ===== BADGES (Purchase order states) ===== */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.badge-P { background: #bdbdbd; color: #424242; }
.badge-A { background: #fff9c4; color: #f57f17; }
.badge-B { background: #ffcdd2; color: #c62828; }
.badge-C { background: #c8e6c9; color: #2e7d32; }
.badge-R { background: #bbdefb; color: #0277bd; }
.badge-F { background: #b2dfdb; color: #00695c; }
.badge-W { background: #a5d6a7; color: #1b5e20; }
.badge-O { background: #e0e0e0; color: #424242; }
.badge-E { background: #fff9c4; color: #f57f17; }
.badge-S { background: #ffcdd2; color: #c62828; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 2000;
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--white); border-radius: 8px; width: 90%; max-width: 600px;
  max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 16px; color: var(--primary);
}
.modal-close { cursor: pointer; font-size: 20px; color: #999; background: none; border: none; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: url('/img/fondo-login.jpg') center center / cover no-repeat fixed;
}
.login-card {
  background: var(--white); border-radius: 12px; padding: 40px;
  width: 100%; max-width: 400px; box-shadow: 0 8px 40px rgba(0,0,0,.3);
  text-align: center;
}
.login-card h1 { color: var(--primary); margin-bottom: 8px; font-size: 28px; }
.login-card .subtitle { color: #757575; margin-bottom: 30px; font-size: 13px; }
.login-logo { display: block; max-width: 380px; width: 100%; height: auto; margin: 0 auto 32px; }
.login-card .form-group { text-align: left; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-top: 10px; }
.login-error { background: #ffebee; color: var(--danger); padding: 10px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.login-footer { margin-top: 24px; font-size: 11px; color: #999; }
.password-toggle { position: relative; }
.password-toggle .toggle-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: #999;
}

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 70px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: 6px; color: var(--white);
  font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: slideIn .3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-celeste { color: #29b6f6; }
.text-muted { color: #999; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.hidden { display: none; }
.w-100 { width: 100%; }

.alert { padding: 12px 16px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.alert-danger { background: #ffebee; color: var(--danger); border: 1px solid #ffcdd2; }
.alert-success { background: #e8f5e9; color: var(--success); border: 1px solid #c8e6c9; }
.alert-warning { background: #fff8e1; color: #e65100; border: 1px solid #ffecb3; }

.search-box { position: relative; }
.search-box input { padding-left: 36px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #999; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
