:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --pending: #f59e0b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

body.hero-bg {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #0b0f14;
}

.hero-photo {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: linear-gradient(180deg, rgba(11, 20, 38, 0.5) 0%, rgba(11, 20, 38, 0.25) 40%, rgba(11, 20, 38, 0.8) 100%), url('/toco-tower.webp');
  background-size: cover, cover;
  background-position: center, center 22%;
  background-repeat: no-repeat, no-repeat;
  z-index: -1;
}

.hero-bg .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
}

.hero-bg .card {
  border: none;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.lang-switch {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 14px;
}
.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}
.lang-btn svg { width: 100%; height: 100%; display: block; }
.lang-btn:hover { border-color: var(--primary); }
.lang-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.logo-badge .logo-divider { width: 1px; height: 34px; background: var(--border); }
nav.topbar .brand .logo-divider { width: 1px; height: 24px; background: var(--border); }

.container.wide {
  max-width: 1400px;
}

.table-wrap {
  overflow-x: auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 24px 0 12px; }
.subtitle { color: var(--muted); font-size: 0.9rem; margin: 0 0 20px; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin: 16px 0 6px;
}

input[type="text"], input[type="tel"], input[type="date"], input[type="password"], input[type="email"], select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

button, .btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button:hover, .btn:hover { background: var(--primary-dark); }
button:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-block { width: 100%; margin-top: 24px; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: #fca5a5; cursor: not-allowed; }

.toolbar { display: flex; justify-content: flex-end; margin: 16px 0 10px; }

.edit-cell {
  white-space: nowrap;
}
.edit-cell button + button {
  margin-left: 6px;
}

.photo-cell {
  white-space: nowrap;
  text-align: center;
}
.id-photo-thumb {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 0 auto 4px;
}
.photo-placeholder {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}
.photo-upload-btn {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}
.photo-upload-btn:hover {
  color: var(--primary-dark);
}
.photo-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.photo-remove-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.78rem;
  color: var(--danger);
  cursor: pointer;
  text-decoration: underline;
}
.photo-remove-btn:hover {
  color: #b91c1c;
}

th input[type="checkbox"], td input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.success-icon { font-size: 2.5rem; text-align: center; margin-bottom: 8px; }

.info-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}
.info-box div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.92rem; }
.info-box .label { color: var(--muted); }

nav.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}
nav.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
nav.topbar .brand-logo { height: 40px; width: auto; display: block; }

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 0;
}
.page-header .logo-divider { width: 1px; height: 34px; background: var(--border); }
.page-header .brand-logo { height: 56px; width: auto; display: block; }
nav.topbar a { color: var(--text); text-decoration: none; margin-left: 18px; font-size: 0.9rem; }
nav.topbar a.active { color: var(--primary); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.issued { background: #dcfce7; color: #166534; }
.badge.returned { background: #e2e8f0; color: #475569; }

.pending-row { background: #fffbeb; }
.pending-row.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: #fde68a; } 100% { background: #fffbeb; } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.compact-input {
  width: 120px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.issue-btn { padding: 6px 12px; font-size: 0.85rem; }
.return-form { display: inline-block; margin-left: 10px; }

.search-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
.search-form .field { display: flex; flex-direction: column; }
.search-form label { margin: 0 0 4px; }
.search-form input { padding: 8px 10px; }

.empty-state { color: var(--muted); text-align: center; padding: 30px 0; }

.card-code { font-family: "SFMono-Regular", Consolas, monospace; font-weight: 700; }

.gift-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; white-space: nowrap; cursor: pointer; }
.gift-toggle input[disabled] { cursor: not-allowed; }
.gift-note { font-size: 0.72rem; color: var(--muted); margin-top: 2px; white-space: nowrap; }

.permission-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 16px; }
.permission-item { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 0.88rem; margin: 0; }
.permission-item input { width: 15px; height: 15px; }

.permission-form .permission-list, .reset-form { margin: 0 0 8px; }
.reset-form { display: flex; gap: 6px; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; }
.reset-form input { padding: 6px 8px; }
