:root {
  --primary: #3b0707;
  --secondary: #711414;
  --accent: #ffc400;
  --accent-soft: #fff0b8;
  --bg: #f7f2ec;
  --card: #ffffff;
  --text: #24100c;
  --muted: #7c625a;
  --line: #e6d8cf;
  --green: #167a45;
  --amber: #a96500;
  --red: #b42318;
  --shadow: 0 10px 30px rgba(59, 7, 7, .10);
}
html[data-theme="dark"] {
  --primary: #ffc400;
  --secondary: #ffd65a;
  --accent: #ffc400;
  --accent-soft: #3a2b00;
  --bg: #130707;
  --card: #211111;
  --text: #f8eee9;
  --muted: #c8aaa0;
  --line: #4a241f;
  --green: #39d98a;
  --amber: #ffb340;
  --red: #ff6b5e;
  --shadow: 0 14px 36px rgba(0, 0, 0, .38);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Inter", Arial, sans-serif;
  background:
    radial-gradient(circle at 100% 0, rgba(255, 196, 0, .08), transparent 32%),
    linear-gradient(180deg, #fbf8f3 0%, var(--bg) 100%);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}
html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 100% 0, rgba(255, 196, 0, .12), transparent 34%),
    radial-gradient(circle at 0 100%, rgba(113, 20, 20, .35), transparent 45%),
    linear-gradient(180deg, #1b0909 0%, var(--bg) 100%);
}
a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px;
  background: linear-gradient(180deg, #081a33 0%, #0c2344 60%, #0a1d38 100%);
  color: #fff;
  padding: 26px 16px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.06);
}
.brand {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: .3px;
  line-height: 1.1;
  padding: 0 10px;
}
.brand::before {
  content: "";
  display: block;
  width: 34px;
  height: 5px;
  border-radius: 99px;
  background: var(--accent);
  margin-bottom: 12px;
}
.brand span {
  color: #9fb3cc;
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.2px;
  margin-top: 7px;
}
.nav {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,196,0,.45) transparent;
}
.nav::-webkit-scrollbar { width: 7px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,196,0,.45); border-radius: 99px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav a { flex: 0 0 auto; }
.nav a {
  color: #c9d7e8;
  padding: 10px 12px;
  border-radius: 9px;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active {
  background: rgba(242, 169, 0, .13);
  color: #ffd36b;
  border-left-color: var(--accent);
  font-weight: 700;
}
.sidebar .foot {
  position: static;
  flex: 0 0 auto;
  margin-top: 14px;
  padding-top: 12px;
  font-size: 11px;
  color: #8fa4bf;
  line-height: 1.6;
  border-top: 1px solid rgba(255,255,255,.08);
}
.main { flex: 1; padding: 30px 36px 64px; max-width: 1560px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.topbar-title { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.mobile-menu, .sidebar-backdrop { display: none; }
h1 { font-size: 27px; margin: 0; color: var(--primary); letter-spacing: -.4px; }
h2 { font-size: 18px; color: var(--primary); margin: 26px 0 12px; }
h3 { color: var(--primary); }
.sub { color: var(--muted); margin-top: 5px; font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 18px 0; }
.card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.card { padding: 17px 18px; }
.card .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }
.card .value { font-size: 26px; font-weight: 800; margin-top: 7px; color: var(--primary); letter-spacing: -.5px; }
.card .small { font-size: 12px; color: var(--muted); margin-top: 4px; }
.panel { padding: 20px; margin: 16px 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.badge.green { background: #e5f6ec; color: var(--green); }
.badge.amber { background: #fff1d6; color: var(--amber); }
.badge.red { background: #fde7e5; color: var(--red); }
.badge.gray { background: #e9eef5; color: var(--muted); }
.badge.blue { background: #e2edfb; color: var(--secondary); }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); }
.table-scroll {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 270px);
    overflow: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 12px;
    scroll-behavior: smooth;
}
.table-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 4px 0 10px;
}
.table-tools input {
    flex: 1 1 340px;
    max-width: 520px;
}
.table-scroll table { width: 100%; min-width: 1350px; table-layout: auto; }
.table-scroll th, .table-scroll td { white-space: normal; }
.table-scroll th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--card);
    box-shadow: 0 1px 0 var(--line);
}
.table-scroll td:first-child, .table-scroll th:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--card);
}
.table-scroll td.row-number { color: var(--muted); font-weight: 700; text-align: right; min-width: 44px; }
.table-scroll td:nth-child(2) { min-width: 250px; max-width: 340px; }
.table-scroll td:nth-child(3) { min-width: 150px; }
.table-scroll td:nth-child(4) { min-width: 260px; }
.table-scroll td:nth-child(n+7) { white-space: nowrap; }

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b2545 0%, #13315c 55%, #0b2545 100%);
    padding: 24px;
}
.login-card {
    width: min(420px, 100%);
    background: var(--card);
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}
.login-brand { margin-bottom: 18px; }
.login-card h1 { margin: 0 0 6px; font-size: 26px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); background: #f8fafd; font-weight: 800; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfcff; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
button, .btn {
  border: 0; border-radius: 9px; padding: 10px 15px; background: var(--primary); color: #fff;
  font-weight: 700; cursor: pointer; font-size: 13px; display: inline-block;
  transition: transform .12s ease, background .12s ease;
}
button:hover, .btn:hover { background: var(--secondary); text-decoration: none; color: #fff; transform: translateY(-1px); }
button.accent { background: var(--accent); color: var(--primary); }
button.accent:hover { background: #ffbf1f; }
button.danger { background: var(--red); }
button.ghost, .btn.ghost { background: #e9eef5; color: var(--primary); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242, 169, 0, .16);
}
input[type=checkbox] { width: auto; }
label { font-size: 11px; color: var(--muted); font-weight: 700; display: block; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.flash { padding: 12px 15px; border-radius: 10px; margin-bottom: 12px; border: 1px solid; font-weight: 600; }
.flash.success { background: #e5f6ec; border-color: #b7dfc7; color: #145c34; }
.flash.error { background: #fde7e5; border-color: #f3b7b0; color: #8a1c0b; }
.warning { background: #fff8e1; border: 1px solid #f3d27a; color: #6b4e00; padding: 13px; border-radius: 10px; margin: 12px 0; }
.notice { background: #eaf2fb; border: 1px solid #c3d7f0; color: #163a63; padding: 13px; border-radius: 10px; margin: 12px 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gallery img { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.gallery .caption { font-size: 12px; color: var(--muted); margin-top: 6px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 7px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details { margin: 8px 0; }
summary { cursor: pointer; font-weight: 700; color: var(--secondary); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input { width: auto; min-width: 130px; }
.hero {
  background:
    radial-gradient(circle at 88% 18%, rgba(242, 169, 0, .28), transparent 34%),
    linear-gradient(120deg, #081a33, #12345f);
  color: #fff; padding: 26px 28px; border-radius: 16px;
  box-shadow: var(--shadow);
}
.hero h2 { color: #fff; margin: 0 0 7px; font-size: 24px; }
.hero p { color: #c9d7e8; margin: 0; max-width: 760px; }
.hero .kicker { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase; margin-bottom: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 10px; }
.section-head h2 { margin: 0; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.stat-strip .item { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; }
.stat-strip .item strong { display: block; font-size: 20px; color: var(--primary); }
.stat-strip .item span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
@media (max-width: 860px) {
  body.menu-open { overflow: hidden; }
  body { overflow-x: hidden; }
  .layout { display: block; min-height: 100vh; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    width: min(84vw, 300px);
    height: 100dvh;
    padding: 22px 16px 18px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    overflow: hidden;
    box-shadow: 14px 0 40px rgba(0,0,0,.45);
  }
  .sidebar.open { transform: translateX(0); }
  .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .sidebar .foot { position: static; margin-top: 12px; }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0,0,0,.58);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .main { width: 100%; padding: 16px 14px 42px; }
  .topbar { flex-direction: column; gap: 12px; margin-bottom: 16px; }
  .topbar-title { align-items: center; width: 100%; }
  .mobile-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 10px;
    background: var(--accent);
    color: #2a0505;
    font-size: 20px;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(0,0,0,.2);
  }
  h1 { font-size: 22px; line-height: 1.2; }
  .actions { width: 100%; align-items: stretch; }
  .actions > form, .actions > button, .actions > a { flex: 1 1 auto; }
  .actions button { width: 100%; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .panel { padding: 15px; margin: 12px 0; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .table-wrap, .table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .row { align-items: stretch; }
}

/* Identidad ZYTRON: rojo profundo, blanco y amarillo del logo. */
.sidebar {
  background: linear-gradient(180deg, #250404 0%, #3b0707 58%, #1c0303 100%);
  border-right-color: rgba(255, 196, 0, .16);
}
.brand-with-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-with-logo .brand-logo {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 196, 0, .45);
  box-shadow: 0 0 0 3px rgba(255, 196, 0, .08);
  flex: 0 0 auto;
}
.brand-with-logo > div { min-width: 0; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-logo {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(255, 196, 0, .45);
}
html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .item {
  background: var(--card);
  border-color: var(--line);
}
html[data-theme="dark"] .panel { box-shadow: var(--shadow); }
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: #180b0b;
  color: var(--text);
  border-color: var(--line);
}
html[data-theme="dark"] .btn.ghost {
  color: var(--text);
  border-color: var(--line);
  background: #2a1514;
}
html[data-theme="dark"] .btn.ghost:hover { background: #3a1c19; }
html[data-theme="dark"] th {
  background: #2a1514;
  color: var(--text);
}
html[data-theme="dark"] tr:nth-child(even) td { background: rgba(255, 196, 0, .025); }
html[data-theme="dark"] .flash.success { background: #123522; color: #a7f3c8; }
html[data-theme="dark"] .flash.error { background: #3d1111; color: #ffc2bb; }
html[data-theme="dark"] .badge.blue { background: #2b1a12; color: #ffd65a; }
html[data-theme="dark"] .badge.gray { background: #2a2523; color: #d8c7bd; }
html[data-theme="dark"] .badge.green { background: #103a25; color: #6ff0ae; }
html[data-theme="dark"] .badge.amber { background: #3b2a08; color: #ffd166; }
html[data-theme="dark"] .badge.red { background: #3d1111; color: #ff9c92; }
html[data-theme="dark"] .table-scroll th,
html[data-theme="dark"] .table-scroll td:first-child { background: #211111; }
html[data-theme="dark"] a { color: #ffd65a; }
html[data-theme="dark"] .topbar .sub,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .small { color: var(--muted); }
html[data-theme="dark"] .stat-strip .item strong,
html[data-theme="dark"] .card .value { color: #fff8f2; }
html[data-theme="dark"] .notice { background: #2a1c08; border-color: #5c4614; color: #ffe4a3; }
.login-body {
  background:
    radial-gradient(circle at 75% 15%, rgba(255, 196, 0, .12), transparent 30%),
    radial-gradient(circle at 20% 80%, rgba(113, 20, 20, .55), transparent 45%),
    #130707;
}
.login-card { background: #211111; color: #f8eee9; border: 1px solid #4a241f; }
.login-card h1 { color: #fff8f2; }
.login-card .field label { color: #c8aaa0; }
/* Botones de accion: rojo profundo con texto blanco (mejor contraste). */
button.accent, .btn.accent {
  background: #8f1d1d;
  color: #ffffff;
  border: 1px solid #6b1010;
  box-shadow: 0 4px 14px rgba(143, 29, 29, .22);
}
button.accent:hover, .btn.accent:hover {
  background: #b32626;
  color: #ffffff;
  border-color: #8f1d1d;
}
html[data-theme="dark"] button.accent,
html[data-theme="dark"] .btn.accent {
  background: #b32626;
  color: #ffffff;
  border-color: #ff8a7a;
}
html[data-theme="dark"] button.accent:hover,
html[data-theme="dark"] .btn.accent:hover { background: #d13a3a; }
/* Correcciones de contraste del modo noche. */
html[data-theme="dark"] .stat-strip .item,
html[data-theme="dark"] .stat-strip .item:not(.hero),
html[data-theme="dark"] .grid3 > .item,
html[data-theme="dark"] .grid2 > .panel,
html[data-theme="dark"] .table-tools,
html[data-theme="dark"] .table-scroll {
  background: var(--card);
  color: var(--text);
  border-color: var(--line);
}
html[data-theme="dark"] .stat-strip .item strong,
html[data-theme="dark"] .stat-strip .item .value,
html[data-theme="dark"] .grid3 > .item strong,
html[data-theme="dark"] .grid3 > .item h1,
html[data-theme="dark"] .grid3 > .item h2,
html[data-theme="dark"] .grid3 > .item h3 {
  color: #fff8f2;
}
html[data-theme="dark"] .grid3 > .item span,
html[data-theme="dark"] .stat-strip .item span {
  color: var(--muted);
}
html[data-theme="dark"] tr:hover td { background: #2a1514; }
html[data-theme="dark"] .gallery img,
html[data-theme="dark"] .photo img { background: #211111; }
html[data-theme="dark"] .warning {
  background: #3a2a08;
  border-color: #7a5a14;
  color: #ffe6a3;
}
html[data-theme="dark"] .flash.success { border-color: #1e5b39; }
html[data-theme="dark"] .flash.error { border-color: #6b2222; }
html[data-theme="dark"] button:not(.accent):not(.ghost),
html[data-theme="dark"] .btn:not(.accent):not(.ghost) {
  background: #8f1d1d;
  color: #ffffff;
  border-color: #b32626;
}
html[data-theme="dark"] button:not(.accent):not(.ghost):hover,
html[data-theme="dark"] .btn:not(.accent):not(.ghost):hover {
  background: #b32626;
  color: #ffffff;
}
html[data-theme="dark"] select,
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="file"],
html[data-theme="dark"] textarea {
  background: #180b0b;
  color: var(--text);
  border-color: var(--line);
}
html[data-theme="dark"] .table-tools input::placeholder,
html[data-theme="dark"] input::placeholder { color: #9d7e74; }
html[data-theme="dark"] .table-scroll th { background: #2a1514; color: #fff8f2; }
html[data-theme="dark"] .table-scroll td { border-color: var(--line); }
html[data-theme="dark"] .table-scroll td:first-child { background: #211111; }
html[data-theme="dark"] .kv dt { color: var(--muted); }
html[data-theme="dark"] .kv dd { color: var(--text); }
html[data-theme="dark"] button.ghost {
  background: #2a1514;
  color: #fff8f2;
  border: 1px solid var(--line);
}
html[data-theme="dark"] button.ghost:hover {
  background: #3a1c19;
  color: #ffffff;
}
.card .value { overflow-wrap: anywhere; word-break: break-word; line-height: 1.18; }
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel { color: var(--text); }
html[data-theme="dark"] .topbar h1,
html[data-theme="dark"] .topbar .sub { color: var(--text); }
html[data-theme="dark"] .topbar .sub { color: var(--muted); }
