:root {
  color-scheme: light;
  --primary: #0f4c81;
  --secondary: #2a9d8f;
  --bg: #f5f7fb;
  --text: #1f2937;
  --card: #ffffff;
  --border: #e5e7eb;
  --sidebar-width: 220px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  position: relative;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  color: white;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header-content { display: flex; align-items: center; gap: 18px; }
.app-logo { display: block; width: 220px; height: auto; max-height: 58px; object-fit: contain; }
.app-subtitle {
  position: absolute;
  left: 50%;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.95;
  transform: translateX(-50%);
  white-space: nowrap;
}
.header-user { display: flex; flex-direction: column; align-items: flex-end; font-size: 14px; line-height: 1.35; }
.header-user-name, .header-user-role { display: block; }
.header-user-name { font-weight: 600; }
.header-user-role { margin-top: 2px; font-size: 12px; opacity: 0.85; }
.mobile-menu-toggle {
  display: none;
  padding: 7px 10px;
  color: white;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.app-sidebar {
  width: var(--sidebar-width);
  background: #f3f4f6;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0;
}

.sidebar-nav { margin: 0; padding: 0; list-style: none; }
.nav-section { margin-bottom: 20px; }
.nav-title { margin: 0 0 10px 0; padding: 0 20px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: #6b7280; }
.nav-section ul { margin: 0; padding: 0; list-style: none; }
.nav-section li { margin: 0; }
.nav-link {
  display: block;
  padding: 10px 20px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}
.nav-link:hover { background: rgba(15, 76, 129, 0.08); border-left-color: var(--primary); }
.nav-link.logout { color: #dc2626; }

.nav-toggle {
  width: 100%;
  text-align: left;
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.nav-toggle:hover {
  background: rgba(15, 76, 129, 0.08);
}

.nav-details > summary { list-style: none; }
.nav-details > summary::-webkit-details-marker { display: none; }
.nav-details[open] .toggle-icon { transform: rotate(180deg); }
.nav-details[open] .nav-submenu { max-height: 500px; }

.toggle-icon {
  display: inline-block;
  transition: transform 0.3s ease;
  font-size: 12px;
}

.nav-toggle.open .toggle-icon {
  transform: rotate(180deg);
}

.nav-submenu {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-submenu.open {
  max-height: 500px;
}

.nav-submenu li { margin: 0; }
.nav-submenu .nav-link {
  padding-left: 40px;
  font-size: 13px;
}

.nav-group-label {
  padding: 10px 40px 4px;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
}

.nav-submenu .nav-link.nav-nested-link {
  padding-left: 58px;
}


.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
}

.page-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.app-footer {
  background: #f3f4f6;
  border-top: 1px solid var(--border);
  padding: 20px 30px;
  text-align: center;
  font-size: 12px;
  color: #6b7280;
  margin: 0;
}

.page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-title { margin: 0; font-size: 28px; color: var(--primary); }

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.search-bar button {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-new {
  background: #dc2626;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}

.btn-new:hover { background: #991b1b; }

.card {
  background: var(--card);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.login-logo {
  display: block;
  width: min(210px, 70%);
  height: auto;
  margin: 0 auto 30px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

thead { background: #f9fafb; }
th {
  padding: 14px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

tr:hover { background: #f9fafb; }

.status-activo { color: #059669; font-weight: 600; }
.status-inactivo { color: #dc2626; font-weight: 600; }

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0;
  border: none;
  cursor: pointer;
}

.btn-icon::before { font-size: 16px; line-height: 1; }
.btn-edit::before { content: '✏'; }
.btn-view::before { content: '👁'; }
.btn-delete::before { content: '🗑'; }

.btn-edit { background: #dbeafe; color: #0284c7; }
.btn-delete { background: #fee2e2; color: #dc2626; }
.btn-view { background: #e0e7ff; color: #4f46e5; }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.pagination a, .pagination span {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--primary);
  cursor: pointer;
}

.pagination a:hover { background: var(--bg); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

.alert {
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  border-left: 4px solid;
}

.alert-success { background: #dcfce7; border-left-color: #059669; color: #166534; }
.alert-danger { background: #fee2e2; border-left-color: #dc2626; color: #991b1b; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 1024px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .app-header { position: relative; display: block; padding: 14px 64px 14px 16px; }
  .header-content { flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
  .app-logo { width: 130px; max-height: 42px; }
  .app-subtitle { position: static; align-self: stretch; font-size: 11px; line-height: 1.25; text-align: center; transform: none; white-space: normal; }
  .mobile-menu-toggle { position: absolute; top: 14px; right: 16px; display: inline-flex; align-items: center; justify-content: center; }
  .header-user { align-items: flex-start; margin-top: 8px; font-size: 12px; }

  .app-body { position: relative; overflow: hidden; }
  .app-sidebar {
    position: absolute;
    z-index: 10;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(280px, 85vw);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.18);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
  }
  .app-sidebar.is-open { transform: translateX(0); }
  .app-main { padding: 20px 16px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .search-bar { flex-direction: column; }
  .search-bar button { width: 100%; }
  .card { padding: 16px; }
}

label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

label > span {
  display: inline;
  margin-left: 2px;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.1);
}

.btn {
  display: inline-block;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  font-size: 14px;
}

.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: #e5e7eb;
  color: var(--text);
  padding: 10px 20px;
  font-size: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  grid-column: 1 / -1;
  margin-top: 20px;
}

.btn-back, .btn-cancel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #334155;
  background: #f8fafc;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.btn-back::before { content: '←'; font-size: 18px; line-height: 1; }
.btn-back:hover, .btn-cancel:hover { background: #e2e8f0; }

.consumo-waiting {
  padding: 16px 20px;
  border: 1px solid #93c5fd;
  border-left: 4px solid #0284c7;
  background: #eff6ff;
  color: #075985;
  margin-bottom: 20px;
}
