:root {
  --navy: #0c2a44;
  --navy-soft: #173b59;
  --sage: #8ba377;
  --sage-dark: #6f875a;
  --cream: #f7f2ec;
  --bg: #f4f5f6;
  --white: #ffffff;
  --text: #263746;
  --muted: #6b7780;
  --line: #e2dbd2;
  --danger: #a8423a;
  --ok-bg: #edf4e8;
  --ok-text: #4d6a3c;
  --err-bg: #fbecea;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
}

h1, h2 {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--navy);
  font-weight: 500;
  line-height: 1.15;
}

a { color: var(--navy); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- estructura ---------- */
.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  background: var(--navy);
  color: white;
  padding: 26px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  margin-bottom: 26px;
}

.brand strong { display: block; font-size: 16px; }
.brand small { display: block; font-size: 12px; opacity: .7; }

.brand-mark {
  width: 42px; height: 42px;
  border: 2px solid var(--sage);
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 900; font-size: 15px; letter-spacing: -1px;
  color: var(--sage);
  flex: none;
}

.side-nav a {
  display: flex;
  gap: 10px;
  align-items: center;
  color: rgba(255,255,255,.82);
  padding: 10px 12px;
  border-radius: 9px;
  margin-bottom: 2px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.side-nav a:hover, .side-nav a.active {
  background: rgba(255,255,255,.1);
  color: white;
}

.side-nav hr {
  border: 0;
  border-top: 1px solid rgba(255,255,255,.14);
  margin: 12px 4px;
}

.logout { margin-top: auto; padding-top: 18px; }
.logout .btn { width: 100%; color: white; border-color: rgba(255,255,255,.3); }

.content {
  padding: 40px 48px 120px;
  max-width: 1080px;
  width: 100%;
}

.mobile-bar { display: none; }

/* ---------- encabezados y avisos ---------- */
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 34px; margin-bottom: 6px; }
.page-head p { color: var(--muted); max-width: 640px; }

.flash {
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-weight: 600;
}
.flash ul { margin: 8px 0 0 20px; font-weight: 400; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--danger); }

.notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid var(--sage);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 24px;
}
.notice small { color: var(--muted); }

/* ---------- tarjetas del inicio ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(12,42,68,.08); }
.card-icon { font-size: 26px; display: block; margin-bottom: 10px; }
.card h2 { font-size: 20px; margin-bottom: 6px; }
.card p { color: var(--muted); font-size: 14px; }

.badge {
  position: absolute; top: 16px; right: 16px;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
}
.badge-on { background: var(--ok-bg); color: var(--ok-text); }
.badge-off { background: #eceef0; color: var(--muted); }

/* ---------- formularios ---------- */
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
}
.panel.narrow { max-width: 520px; }

.field { margin-bottom: 22px; }
.field-compact { margin-bottom: 12px; }

label, .label, legend {
  display: block;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
  font-size: 15px;
}
legend small { font-weight: 400; color: var(--muted); }
.req { color: var(--danger); }

input[type=text], input[type=email], input[type=url], input[type=password], textarea {
  width: 100%;
  border: 1px solid #d3d9de;
  border-radius: 10px;
  padding: 12px 13px;
  font: inherit;
  color: var(--text);
  background: white;
}
textarea { resize: vertical; line-height: 1.55; min-height: 96px; }

input:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(139,163,119,.25);
}

.help { font-size: 13px; color: var(--muted); margin-top: 5px; }
.help.warn { color: #8a5a12; }
.counter { font-size: 12px; color: var(--muted); text-align: right; margin-top: 3px; }
.counter.near { color: var(--danger); font-weight: 700; }

/* interruptor visible/oculto */
.field-toggle {
  background: var(--cream);
  border-radius: 12px;
  padding: 14px 16px;
}
.switch {
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; margin: 0;
}
.switch input { position: absolute; opacity: 0; }
.switch-ui {
  width: 44px; height: 26px; border-radius: 999px;
  background: #c9ced3; position: relative; flex: none;
  transition: background .15s;
}
.switch-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: white;
  transition: transform .15s;
}
.switch input:checked + .switch-ui { background: var(--sage-dark); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { box-shadow: 0 0 0 3px rgba(139,163,119,.35); }

/* imágenes */
.image-box {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: start;
  background: var(--cream);
  border-radius: 14px;
  padding: 16px;
}
.image-preview {
  width: 200px; height: 160px;
  border-radius: 10px;
  background: #e3e0dc;
  display: grid; place-items: center;
  color: var(--muted); font-size: 13px;
  overflow: hidden;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.file-btn { position: relative; overflow: hidden; margin: 0; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-name { font-size: 13px; color: var(--ok-text); font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 0; }

/* listas */
fieldset.list {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
fieldset.list legend { padding: 0 6px; }
.list-rows { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 12px; }
.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  background: #fafafa;
  border: 1px solid #eceae6;
  border-radius: 12px;
  padding: 10px;
}
.list-row-fields .field-compact:last-child { margin-bottom: 0; }
.list-row-tools { display: flex; flex-direction: column; gap: 4px; }
.list-row-tools button {
  width: 34px; height: 34px;
  border: 1px solid #d3d9de; border-radius: 8px;
  background: white; color: var(--navy);
  font-size: 15px; cursor: pointer;
}
.list-row-tools button.danger { color: var(--danger); }
.list-row-tools button:hover { background: var(--cream); }

/* botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--navy);
  font: inherit; font-weight: 700; font-size: 15px;
  cursor: pointer; text-decoration: none;
}
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-soft); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-secondary { background: white; color: var(--navy); }
.btn-secondary:hover { background: var(--cream); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.link-button {
  background: none; border: 0; font: inherit; color: var(--danger);
  font-weight: 700; padding: 12px 4px; cursor: pointer;
}

.actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 26px; }
.sticky-actions {
  position: sticky; bottom: 0;
  background: linear-gradient(rgba(255,255,255,0), white 30%);
  padding: 22px 0 6px;
  margin-bottom: -6px;
}

/* historial */
.history { list-style: none; }
.history li {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.history li:last-child { border-bottom: 0; }
.history small { display: block; color: var(--muted); }

/* login */
.login-page {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 20px;
  background: var(--navy);
}
.login-card {
  background: white;
  width: 100%; max-width: 400px;
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 26px; margin-bottom: 12px; }
.login-card p { margin-bottom: 20px; color: var(--muted); }
.brand-center { color: var(--navy); margin-bottom: 26px; }
.brand-center small { color: var(--muted); opacity: 1; }

/* ---------- celular ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }

  .mobile-bar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 20;
    background: var(--navy); color: white;
    padding: 10px 14px;
  }
  .mobile-bar .brand { margin: 0; flex: 1; }
  .mobile-bar .brand-mark { width: 34px; height: 34px; font-size: 13px; }
  .mobile-bar .btn-ghost { color: white; border-color: rgba(255,255,255,.3); }

  .mobile-menu summary {
    list-style: none; cursor: pointer;
    padding: 8px 12px; border-radius: 9px;
    border: 1px solid rgba(255,255,255,.3);
    font-weight: 700; font-size: 14px;
  }
  .mobile-menu summary::-webkit-details-marker { display: none; }
  .mobile-menu nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: white;
    box-shadow: 0 16px 30px rgba(0,0,0,.18);
    max-height: 75vh; overflow-y: auto;
    padding: 8px 14px 14px;
  }
  .mobile-menu nav a {
    display: block; padding: 12px 4px;
    border-bottom: 1px solid #eee;
    text-decoration: none; font-weight: 600; color: var(--navy);
  }

  .content { padding: 22px 14px 110px; }
  .page-head h1 { font-size: 27px; }
  .panel { padding: 18px 14px; border-radius: 14px; }
  .image-box { grid-template-columns: 1fr; }
  .image-preview { width: 100%; height: 200px; }
  .notice { flex-direction: column; align-items: flex-start; }
  .actions .btn { flex: 1; }
  fieldset.list { padding: 12px 10px; }
  input[type=text], input[type=email], input[type=url], input[type=password], textarea { font-size: 16px; }
}
