* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f5;
  color: #333;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
}

.header p {
  font-size: 14px;
  color: #666;
  margin: 4px 0 0;
}

.section {
  margin-bottom: 28px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
  color: #1a1a1a;
}

.upload-area {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-area:hover {
  background: #fff;
  border-color: #0066cc;
}

.upload-area input[type="file"] {
  display: none;
}

.file-input-label {
  cursor: pointer;
  color: #0066cc;
  font-weight: 600;
  display: block;
  font-size: 15px;
}

.uploaded-files {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.file-badge {
  background: #e3f2fd;
  color: #0066cc;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #bbdefb;
}

.maintenance-section {
  background: #fafafa;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid #e0e0e0;
}

.btn-primary {
  background: #0066cc;
  color: white;
  border: 1px solid #0066cc;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #0052a3;
  border-color: #0052a3;
}

.btn-secondary {
  background: white;
  color: #333;
  border: 1px solid #ccc;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: #0066cc;
  color: #0066cc;
}

.btn-danger {
  background: #ffebee;
  color: #d32f2f;
  border: 1px solid #ffcdd2;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #fff;
  border-color: #d32f2f;
}

.row-delete-btn {
  background: transparent;
  color: #d32f2f;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s;
}

.row-delete-btn:hover {
  background: #ffebee;
  color: #b71c1c;
}

input[type="text"],
input[type="date"],
input[type="datetime-local"],
select {
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  color: #333;
  font-family: inherit;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
select:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.alert {
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  border-left: 3px solid;
  display: block;
}

.alert.danger {
  background: #ffebee;
  color: #d32f2f;
  border-left-color: #d32f2f;
}

.alert.warning {
  background: #fff3e0;
  color: #f57c00;
  border-left-color: #f57c00;
}

.alert.success {
  background: #e8f5e9;
  color: #388e3c;
  border-left-color: #388e3c;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: white;
  padding: 16px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #e0e0e0;
}

.stat-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #0066cc;
}

.tab-group {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  gap: 0;
  margin-bottom: 16px;
  background: white;
  border-radius: 8px 8px 0 0;
}

.tab {
  padding: 12px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-weight: 500;
}

.tab:hover {
  color: #0066cc;
}

.tab.active {
  color: #0066cc;
  border-bottom-color: #0066cc;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.data-grid {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
}

th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid #e0e0e0;
  color: #333;
}

tr:hover td {
  background: #f9f9f9;
}

tr:last-child td {
  border-bottom: none;
}

.editable-cell {
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.editable-cell:hover {
  background: #e3f2fd;
  color: #0066cc;
}

.highlight-danger {
  background: #ffcdd2;
  color: #d32f2f;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
}

.highlight-warning {
  background: #ffe0b2;
  color: #f57c00;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
}

.highlight-success {
  background: #c8e6c9;
  color: #388e3c;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 14px;
}

.edit-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.edit-modal.show {
  display: flex;
}

.edit-modal-content {
  background: white;
  padding: 24px;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.edit-modal-header {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1a1a1a;
}

.edit-modal-body {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.edit-field {
  display: flex;
  flex-direction: column;
}

.edit-field label {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  font-weight: 500;
}

.edit-field input,
.edit-field select {
  width: 100%;
}

.edit-modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.maintenance-item {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  margin-bottom: 12px;
  align-items: center;
}

.maintenance-item:last-child {
  margin-bottom: 0;
}

/* ============================================
   ADMIN THEME — body.dark-theme (sidebar dark + contenido claro)
   Paleta inspirada en mockup "Glance": slate + naranja
   ============================================ */

body.dark-theme {
  --bg-app:        #EEF2F7;
  --bg-sidebar:    #2A3F54;
  --bg-sidebar-hd: #1F2D3D;
  --bg-card:       #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-input:      #F8FAFC;
  --bg-elevated:   #FFFFFF;
  --border:        #E2E8F0;
  --border-soft:   #EDF1F5;
  --text:          #1F2937;
  --text-soft:     #4B5563;
  --text-muted:    #8492A6;
  --accent:        #F39C12;
  --accent-hover:  #E08E0B;
  --accent-soft:   rgba(243,156,18,0.12);
  --danger:        #E84B6F;
  --warning:       #F39C12;
  --success:       #27AE60;

  /* Sidebar-only (porque el sidebar es oscuro y el resto es claro) */
  --sb-text:        #C9D2DD;
  --sb-text-active: #FFFFFF;
  --sb-text-muted:  #7A8FA0;

  background: var(--bg-app);
  color: var(--text);
}

body.dark-theme .app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar (oscuro) */
body.dark-theme .sidebar {
  background: var(--bg-sidebar);
  padding: 0 12px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  color: var(--sb-text);
}

/* Header del logo: ligeramente más oscuro para resaltar la marca */
body.dark-theme .sidebar-logo {
  background: #ffffff;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 4px 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

body.dark-theme .sidebar-logo img {
  width: 100%;
  height: auto;
  max-height: 42px;
  object-fit: contain;
  display: block;
}

body.dark-theme .sidebar-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sb-text-muted);
  padding: 8px 12px 10px;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

body.dark-theme .sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.dark-theme .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 6px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

body.dark-theme .nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #ffffff;
}

body.dark-theme .nav-item.active {
  background: var(--accent);
  color: var(--sb-text-active);
  border-left-color: #C77C0C;
  box-shadow: 0 2px 6px rgba(243,156,18,0.35);
}

body.dark-theme .nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

body.dark-theme .sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

body.dark-theme .sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
}

body.dark-theme .sidebar-footer a:hover {
  background: rgba(255,255,255,0.05);
  color: var(--accent);
}

/* Main content & topbar */
body.dark-theme .main-content {
  padding: 24px 32px 40px;
  max-width: none;
  min-width: 0;
}

body.dark-theme .topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-soft);
}

body.dark-theme .topbar h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

body.dark-theme .topbar p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

body.dark-theme .module-view { display: none; }
body.dark-theme .module-view.active { display: block; }

/* Hide legacy elements when in dark theme */
body.dark-theme .topnav,
body.dark-theme .container > .header { display: none; }

/* Sections become cards (blanco) */
body.dark-theme .section {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(15,30,55,0.04);
}

body.dark-theme .section-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

/* Buttons */
body.dark-theme .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
body.dark-theme .btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

body.dark-theme .btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-soft);
}
body.dark-theme .btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

body.dark-theme .btn-danger {
  background: rgba(239,83,80,0.12);
  border-color: rgba(239,83,80,0.4);
  color: var(--danger);
}
body.dark-theme .btn-danger:hover {
  background: rgba(239,83,80,0.18);
  border-color: var(--danger);
}

body.dark-theme .row-delete-btn { color: var(--danger); }
body.dark-theme .row-delete-btn:hover {
  background: rgba(239,83,80,0.15);
  color: #ff7a78;
}

/* Inputs */
body.dark-theme input[type="text"],
body.dark-theme input[type="date"],
body.dark-theme input[type="datetime-local"],
body.dark-theme input[type="number"],
body.dark-theme select,
body.dark-theme textarea {
  background: var(--bg-input);
  border-color: var(--border);
  color: var(--text);
}

body.dark-theme input::placeholder { color: var(--text-muted); }

body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(243,156,18,0.18);
}

body.dark-theme select option { background: #FFFFFF; color: var(--text); }

/* File upload area */
body.dark-theme .upload-area {
  background: var(--bg-input);
  border-color: var(--border);
}
body.dark-theme .upload-area:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
}
body.dark-theme .file-input-label { color: var(--accent); }

body.dark-theme .file-badge {
  background: rgba(243,156,18,0.12);
  border-color: rgba(243,156,18,0.3);
  color: #B66E07;
}

body.dark-theme .maintenance-section {
  background: var(--bg-input);
  border-color: var(--border);
}

/* Stat cards (blancos sobre fondo claro) */
body.dark-theme .stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  text-align: left;
  padding: 18px 20px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15,30,55,0.04);
}
body.dark-theme .stat-label {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
body.dark-theme .stat-value {
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
}

/* Tables */
body.dark-theme .data-grid {
  background: var(--bg-card);
  border-color: var(--border-soft);
}
body.dark-theme thead {
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-soft);
}
body.dark-theme th {
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
body.dark-theme td {
  color: var(--text);
  border-bottom: 1px solid var(--border-soft);
}
body.dark-theme tr:hover td { background: #F8FAFC; }

body.dark-theme .empty-state { color: var(--text-muted); }

/* Publish bar */
body.dark-theme .publish-bar {
  background: var(--bg-input);
  border-color: var(--border);
}
body.dark-theme .publish-status { color: var(--text-muted); }
body.dark-theme .publish-status.ok { color: var(--success); }
body.dark-theme .publish-status.error { color: var(--danger); }

/* Edit modal in dark */
body.dark-theme .edit-modal-content {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
body.dark-theme .edit-modal-header { color: var(--text); }
body.dark-theme .edit-field label { color: var(--text-muted); }

/* Alerts (sobre fondo claro) */
body.dark-theme .alert.danger  { background: rgba(232,75,111,0.10); color: #B22942; border-left-color: var(--danger); }
body.dark-theme .alert.warning { background: rgba(243,156,18,0.12); color: #8C5A04; border-left-color: var(--warning); }
body.dark-theme .alert.success { background: rgba(39,174,96,0.10);  color: #1B7B43; border-left-color: var(--success); }

/* Container override */
body.dark-theme .container {
  max-width: none;
  margin: 0;
  padding: 0;
}

/* Scrollbar */
body.dark-theme ::-webkit-scrollbar { width: 10px; height: 10px; }
body.dark-theme ::-webkit-scrollbar-track { background: transparent; }
body.dark-theme ::-webkit-scrollbar-thumb { background: #C7D0DC; border-radius: 6px; }
body.dark-theme ::-webkit-scrollbar-thumb:hover { background: #A8B3C4; }
body.dark-theme .sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }
body.dark-theme .sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* Responsive sidebar collapse on narrow screens */
@media (max-width: 900px) {
  body.dark-theme .app-layout { grid-template-columns: 1fr; }
  body.dark-theme .sidebar { position: relative; height: auto; }
}
