html {
  --radius: 10px;
}

/* Modo oscuro (predeterminado): acentos verdes */
html[data-theme="dark"],
html:not([data-theme]) {
  color-scheme: dark;
  --bg: #0a0f0c;
  --panel: #121a15;
  --muted: #8ea896;
  --text: #e8f5ef;
  --accent: #34d399;
  --accent-dim: #059669;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --accent-soft-strong: rgba(52, 211, 153, 0.22);
  --accent-muted: #6ee7b7;
  --danger: #f87171;
  --danger-text: #fecaca;
  --ok: #4ade80;
  --border: #1e3328;
  --input-bg: #0d1611;
  --row-hover: rgba(255, 255, 255, 0.03);
  --subnav-hover: rgba(52, 211, 153, 0.06);
}

/* Modo claro: verdes sobre fondo claro */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #ecf6ef;
  --panel: #ffffff;
  --muted: #64748b;
  --text: #0f2918;
  --accent: #15803d;
  --accent-dim: #166534;
  --accent-soft: rgba(22, 163, 74, 0.1);
  --accent-soft-strong: rgba(22, 163, 74, 0.18);
  --accent-muted: #166534;
  --danger: #dc2626;
  --danger-text: #991b1b;
  --ok: #16a34a;
  --border: #b8e4c8;
  --input-bg: #f7fbf8;
  --row-hover: rgba(22, 163, 74, 0.06);
  --subnav-hover: rgba(22, 163, 74, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.theme-toggle-wrap {
  position: fixed;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 200;
}
.theme-toggle {
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}
html[data-theme="dark"] .theme-toggle,
html:not([data-theme]) .theme-toggle {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
.theme-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent-dim);
  text-decoration: none;
}

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

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  letter-spacing: 0.02em;
  color: var(--text);
}

.nav-section {
  margin-top: 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}
.nav a span:not(.nav-icon) {
  flex: 1;
  min-width: 0;
}
.nav a:hover { background: var(--accent-soft); text-decoration: none; }
.nav a.active { background: var(--accent-soft-strong); color: var(--text); font-weight: 600; }

.nav-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  opacity: 0.92;
  color: var(--muted);
}
.nav a.active .nav-icon,
.nav a:hover .nav-icon {
  color: var(--accent-muted);
  opacity: 1;
}
.nav-icon svg {
  display: block;
}

main {
  padding: 1.5rem 2rem;
  max-width: 1200px;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
  font-weight: 650;
}

.flash {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.flash.ok { background: rgba(74, 222, 128, 0.12); border: 1px solid rgba(74, 222, 128, 0.35); }
.flash.err { background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.35); }

.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-primary { background: var(--accent); border-color: var(--accent-dim); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { background: rgba(248, 113, 113, 0.15); border-color: rgba(248, 113, 113, 0.45); color: var(--danger-text); }
html[data-theme="light"] .btn-danger { color: #b91c1c; }
.btn-ghost { background: transparent; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.55rem 0.65rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--row-hover); }

form.std .row { margin-bottom: 0.85rem; }
form.std label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
form.std input[type="text"],
form.std input[type="email"],
form.std input[type="password"],
form.std input[type="number"],
form.std select,
form.std textarea {
  width: 100%;
  max-width: 520px;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}
form.std textarea { min-height: 80px; resize: vertical; }
form.std .check { display: flex; align-items: center; gap: 0.5rem; }
form.std .check input { width: auto; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
}

.pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  color: var(--muted);
}

.subnav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.subnav a {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.88rem;
}
.subnav a:hover { background: var(--subnav-hover); text-decoration: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  main { padding-top: 2.75rem; }
  .login-wrap { padding-top: 3.25rem; }
}

/* Salón — mapa de mesas */
.salon-toolbar {
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.salon-filtro {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.salon-filtro select {
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
}
.salon-leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.leyenda-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.leyenda-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
html[data-theme="dark"] .leyenda-dot,
html:not([data-theme]) .leyenda-dot {
  border-color: rgba(255, 255, 255, 0.12);
}
.salon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.mesa-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 140px;
}
.mesa-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.mesa-card__codigo { font-size: 1.1rem; }
.mesa-card__badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.mesa-card__nombre { font-size: 0.9rem; color: var(--muted); }
.mesa-card__meta { font-size: 0.8rem; color: var(--muted); }
.mesa-card__actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.mesa-card__alt {
  margin: 0;
  font-size: 0.85rem;
}
.mesa-card__nuevo summary {
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--accent);
  list-style: none;
}
.mesa-card__nuevo summary::-webkit-details-marker { display: none; }
.mesa-card__form {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}
.mesa-card__form .row { margin-bottom: 0.55rem; }
.mesa-card__form .row label { font-size: 0.75rem; }
.mesa-card--libre {
  border-left: 4px solid var(--ok);
}
.mesa-card--libre .mesa-card__badge {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--ok);
}
html[data-theme="light"] .mesa-card--libre .mesa-card__badge {
  color: #15803d;
}
.mesa-card--ocupada {
  border-left: 4px solid #f0b429;
}
.mesa-card--ocupada .mesa-card__badge {
  background: rgba(240, 180, 41, 0.15);
  border-color: rgba(240, 180, 41, 0.4);
  color: #d4a017;
}
.mesa-card--limpiar {
  border-left: 4px solid #c9a227;
}
.mesa-card--limpiar .mesa-card__badge {
  background: rgba(201, 162, 39, 0.15);
  border-color: rgba(201, 162, 39, 0.4);
  color: #b8860b;
}
.mesa-card--reservada {
  border-left: 4px solid var(--accent);
}
.mesa-card--reservada .mesa-card__badge {
  background: var(--accent-soft);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--accent-muted);
}
html[data-theme="light"] .mesa-card--reservada .mesa-card__badge {
  border-color: rgba(22, 163, 74, 0.35);
}
.mesa-card--off {
  border-left: 4px solid var(--muted);
  opacity: 0.85;
}
.mesa-card--off .mesa-card__badge {
  background: rgba(139, 155, 180, 0.1);
  color: var(--muted);
}
.leyenda-dot.mesa-card--libre { background: rgba(74, 222, 128, 0.5); }
.leyenda-dot.mesa-card--ocupada { background: rgba(240, 180, 41, 0.55); }
.leyenda-dot.mesa-card--limpiar { background: rgba(201, 162, 39, 0.55); }
.leyenda-dot.mesa-card--reservada { background: rgba(52, 211, 153, 0.55); }
html[data-theme="light"] .leyenda-dot.mesa-card--reservada { background: rgba(22, 163, 74, 0.45); }
.leyenda-dot.mesa-card--off { background: rgba(139, 155, 180, 0.4); }
