/* ks-qr-dinamico — paleta blanco/negro/grises. Sin border-radius. Sin sombras. */

:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;
  --text: #18181b;
  --text-strong: #000000;

  --transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  border-radius: 0 !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}
h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 16px; }
p { margin: 0; }

a { color: var(--text-strong); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--text-muted); }

button { font-family: inherit; cursor: pointer; }

/* Layout app: sidebar + main */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  padding: 4px 8px 16px;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar a, .sidebar button.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  background: transparent;
  border: 0;
  font-size: 14px;
  text-align: left;
  transition: var(--transition);
}
.sidebar a:hover, .sidebar button.nav-item:hover { background: var(--bg-muted); }
.sidebar a.active { background: var(--text-strong); color: var(--bg); }
.sidebar a.active svg { color: var(--bg); }
.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.main {
  padding: 32px 48px 64px;
  max-width: 1280px;
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.page-header h1 { letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* Card */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  background: var(--text-strong);
  color: var(--bg);
  border: 1px solid var(--text-strong);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover:not(:disabled) { opacity: 0.85; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-secondary {
  background: var(--bg);
  color: var(--text-strong);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-muted); opacity: 1; }
.btn-ghost {
  background: transparent;
  color: var(--text-strong);
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-muted); opacity: 1; }

.btn-icon {
  padding: 8px;
  width: 32px;
  height: 32px;
}

.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Inputs */
.input, .select, .textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  outline: none;
  transition: var(--transition);
  line-height: 1.4;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--text-strong);
  box-shadow: 0 0 0 1px var(--text-strong);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--bg-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}
.input::placeholder { color: var(--text-subtle); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.field-hint { font-size: 12px; color: var(--text-muted); }
.field-error {
  font-size: 12px;
  color: var(--text-strong);
  font-weight: 500;
  border-left: 2px solid var(--text-strong);
  padding-left: 8px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Checkbox / toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.toggle input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.toggle input[type="checkbox"]:checked {
  background: var(--text-strong);
  border-color: var(--text-strong);
}
.toggle input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.toggle input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 1px var(--text-strong);
}

/* Active/inactive switch (looks like a real switch but mono) */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: var(--transition);
}
.switch-track::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: var(--text-strong);
  transition: var(--transition);
}
.switch input:checked + .switch-track {
  background: var(--text-strong);
  border-color: var(--text-strong);
}
.switch input:checked + .switch-track::before {
  background: var(--bg);
  transform: translateX(16px);
}
.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 1px var(--text-strong);
}

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); }
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table thead th {
  text-align: left;
  font-weight: 500;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg-subtle); }

/* Toolbar de listas */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .search {
  flex: 1;
  min-width: 240px;
  position: relative;
}
.toolbar .search .input { padding-left: 36px; }
.toolbar .search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}

/* Modal / dialog */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.dialog-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.dialog {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  transform: translateY(8px);
  transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.dialog-backdrop.open .dialog {
  transform: translateY(0);
}
.dialog-lg { max-width: 720px; }
.dialog-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.dialog-header h3 { font-size: 16px; }
.dialog-body { padding: 20px 24px; }
.dialog-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--text-strong);
  color: var(--bg);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  min-width: 260px;
  max-width: 360px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1),
              transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.empty .empty-title { font-size: 14px; color: var(--text); }

/* Spinner monocromo */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.6s linear infinite;
}
.spinner-lg { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  padding: 24px;
}
.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-brand {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

/* Slug pill / mono code */
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.slug-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.strong { color: var(--text-strong); font-weight: 500; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  color: var(--text-muted);
}
.tag-on { color: var(--text-strong); border-color: var(--text-strong); }
.tag-off { color: var(--text-subtle); border-color: var(--border-strong); }

/* QR preview box */
.qr-preview {
  border: 1px solid var(--border);
  padding: 16px;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.qr-preview img, .qr-preview svg { display: block; max-width: 100%; height: auto; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.stat {
  border: 1px solid var(--border);
  padding: 16px;
  background: var(--bg);
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}
.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Bar chart minimalista (CSS) */
.bar-chart { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 40px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.bar-row .bar {
  height: 8px;
  background: var(--bg-muted);
  position: relative;
}
.bar-row .bar > span {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--text-strong);
}
.bar-row .bar-count { text-align: right; color: var(--text-muted); }

.day-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 80px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.day-bars .day {
  flex: 1;
  background: var(--text-strong);
  min-height: 1px;
  position: relative;
}
.day-bars .day:hover { opacity: 0.7; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Skeleton */
.skeleton {
  background: var(--bg-muted);
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* Visually hidden */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible global */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px var(--text-strong);
}

/* Small screens */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; }
  .sidebar-nav { flex-direction: row; flex: 1; flex-wrap: wrap; }
  .sidebar-footer { display: none; }
  .main { padding: 24px 16px; }
  .field-row { grid-template-columns: 1fr; }
}
