:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #027a48;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #111827;
  color: #fff;
  padding: 20px 14px;
}

.brand {
  display: grid;
  gap: 4px;
  padding: 4px 8px 24px;
}

.brand strong {
  font-size: 20px;
}

.brand span {
  color: #b8c0ce;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d6dce7;
  padding: 11px 12px;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: #223047;
  color: #fff;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 28px;
}

h2 {
  font-size: 19px;
  margin-bottom: 12px;
}

p {
  color: var(--muted);
}

.status-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  white-space: nowrap;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: start;
}

.catalog-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.catalog-sidebar {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.catalog-list {
  display: grid;
  gap: 8px;
}

.catalog-list-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.catalog-list-item:hover,
.catalog-list-item.active {
  border-color: var(--accent);
  background: #ecfdf3;
}

.catalog-list-item span,
.catalog-list-item small {
  color: var(--muted);
  font-size: 12px;
}

.catalog-workspace {
  min-width: 0;
}

.catalog-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.catalog-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.catalog-tabs button {
  border: 0;
  border-radius: 7px;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.catalog-tabs button:hover,
.catalog-tabs button.active {
  background: #0f766e;
  color: #fff;
}

.create-catalog-form {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat,
.panel,
.empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 16px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 26px;
  margin-top: 5px;
}

.panel {
  padding: 18px;
}

.panel.compact {
  align-self: start;
}

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

.between {
  justify-content: space-between;
}

.stack {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 13px;
  font-weight: 700;
  text-decoration: none;
}

.button:hover {
  background: var(--accent-strong);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.button.secondary {
  background: #eef4f3;
  color: var(--accent-strong);
}

.button.ghost {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid #b7d7d3;
}

.button.danger {
  background: #fee4e2;
  color: #b42318;
}

.button.danger:hover {
  background: #fecdca;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f7;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #dcfae6;
  color: var(--ok);
}

.badge.warn {
  background: #fef0c7;
  color: var(--warn);
}

.badge.danger {
  background: #fee4e2;
  color: var(--danger);
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.design-preview {
  position: relative;
  width: 100%;
  max-width: 860px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f7;
}

.design-canvas {
  position: relative;
  transform-origin: top left;
}

.design-canvas.dragging-field {
  cursor: grabbing;
}

.design-canvas img {
  display: block;
  width: 100%;
  height: auto;
}

.design-field {
  position: absolute;
  border: 1px dashed rgba(15, 118, 110, .8);
  background: rgba(15, 118, 110, .08);
  color: #101828;
  padding: 3px;
  overflow: hidden;
  font-weight: 800;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: box-shadow .15s ease, background .15s ease;
}

.design-field:hover,
.design-field.dragging {
  background: rgba(15, 118, 110, .16);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.design-field.dragging {
  cursor: grabbing;
  z-index: 5;
}

.design-field.qr {
  display: grid;
  place-items: center;
  background: #fff;
  border-style: solid;
  font-size: 12px !important;
}

.generated-design-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.generated-design-panel h3,
.generated-design-panel p {
  margin: 0;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.theme-card {
  display: grid;
  gap: 6px;
  justify-items: start;
  min-height: 94px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--soft), color-mix(in srgb, var(--accent) 32%, white));
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
}

.theme-card small {
  font-weight: 800;
}

.theme-swatch {
  width: 100%;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--band), var(--accent), var(--glow));
}

.generated-preview-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f7;
  padding: 16px;
}

.generated-preview {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 43%);
  gap: 14px;
  width: min(560px, 100%);
  aspect-ratio: 2.35 / 1;
  min-height: 220px;
  padding: 22px;
  overflow: hidden;
  border: 2px solid rgba(17, 24, 39, .22);
  border-radius: 20px;
  background: var(--soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55), 0 12px 28px rgba(16,24,40,.18);
}

.generated-preview::before {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: -1;
  border: 2px dashed color-mix(in srgb, var(--accent) 75%, transparent);
  border-radius: 13px;
}

.generated-preview::after {
  content: "";
  position: absolute;
  width: 220px;
  aspect-ratio: 1;
  right: -70px;
  top: -110px;
  z-index: -2;
  border-radius: 999px;
  background: var(--glow);
  opacity: .62;
}

.generated-preview .preview-ribbon {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 34px;
  background: linear-gradient(180deg, var(--band), var(--accent));
}

.generated-preview section {
  min-width: 0;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding-left: 28px;
}

.preview-kicker {
  width: max-content;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--band);
  color: white;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.generated-preview h3 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-size: 30px;
  line-height: .92;
  text-transform: uppercase;
}

.preview-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-codes strong {
  padding: 8px 10px;
  border: 1px solid rgba(17,24,39,.16);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 22px;
}

.generated-preview aside {
  display: grid;
  align-content: space-between;
  justify-items: center;
  text-align: center;
  font-weight: 900;
}

.preview-qr {
  display: grid;
  place-items: center;
  width: min(100%, 168px);
  aspect-ratio: 1;
  border: 1px solid rgba(17,24,39,.24);
  border-radius: 10px;
  background: white;
  color: #111827;
}

.theme-preview-noche {
  background: radial-gradient(circle at 18% 10%, rgba(56,189,248,.22), transparent 34%), linear-gradient(135deg, #111827, #10221f 54%, #06251f);
}

.theme-preview-fiesta {
  background: linear-gradient(135deg, #fff7df, #fde68a 52%, #fef3c7);
}

.theme-preview-coral {
  background: linear-gradient(135deg, #fff1f2, #fed7aa 52%, #dbeafe);
}

.theme-preview-clasico {
  background: linear-gradient(135deg, #ffffff, #fef3c7 50%, #fee2e2);
}

.field-list {
  display: grid;
  gap: 12px;
}

.table-tools input {
  max-width: 360px;
}

.field-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #f5f7fb;
}

.login-card {
  width: min(420px, 100%);
}

.empty {
  padding: 28px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  background: #101828;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(16, 24, 40, .25);
  z-index: 50;
  max-width: min(720px, calc(100vw - 24px));
  text-align: center;
}

.toast.error {
  background: #b42318;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, .42);
}

.modal {
  width: min(780px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 22px 70px rgba(16, 24, 40, .28);
}

.sale-ticket {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.workflow-step > strong {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #0f766e;
  color: white;
}

.workflow-step p {
  margin: 4px 0 0;
  font-size: 13px;
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid.two,
  .catalog-layout,
  .stats,
  .form-grid,
  .workflow {
    grid-template-columns: 1fr;
  }

  .catalog-sidebar {
    position: static;
    max-height: none;
  }

  .catalog-header {
    display: grid;
  }

  .catalog-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}

.choice-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.choice-group legend {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
  padding: 0 6px;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  font-weight: 700;
}

.choice input {
  width: auto;
}

.soft-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}


#app:has(.login-screen) {
  display: block;
  min-height: 100vh;
}

.login-screen {
  width: 100%;
}

.login-card {
  margin: 0 auto;
}

.table-scroll { width: 100%; overflow-x: auto; }
.table-scroll table { min-width: 980px; }
.code-editor { min-height: 480px; resize: vertical; font-family: Consolas, "Courier New", monospace; font-size: 12px; line-height: 1.5; tab-size: 2; }
.color-settings { display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)); gap: 10px; }
.color-setting { display: grid; gap: 7px; }
.color-setting input[type="color"] { width: 100%; height: 44px; padding: 3px; cursor: pointer; }
@media (max-width: 760px) { .color-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); } }