:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --text: #20231f;
  --muted: #6d7469;
  --line: #dfe3da;
  --primary: #25683a;
  --primary-dark: #184929;
  --accent: #d9a441;
  --danger: #b42318;
  --ok: #1f7a4d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.topbar {
  min-height: 64px;
  padding: 10px 18px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: white;
  color: var(--primary);
  font-weight: 900;
}
.brand-mark .app-logo { width: 100%; height: 100%; object-fit: contain; }
.app-logo[hidden] { display: none; }
.public-logo { display: block; max-width: 220px; max-height: 90px; object-fit: contain; margin: 0 auto 10px; }
.display-logo { width: auto; max-width: 120px; height: 58px; object-fit: contain; }
.brand small { display: block; opacity: .8; font-size: 12px; }
.nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nav a, .ghost {
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12);
  color: white;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px; }
.narrow { max-width: 520px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(24, 38, 25, .06);
}
.section-title { margin: 0 0 12px; font-size: 20px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
label { font-weight: 650; font-size: 13px; color: var(--text); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: white;
  color: var(--text);
}
textarea { min-height: 84px; resize: vertical; }
.btn {
  border: 0;
  border-radius: 7px;
  padding: 11px 14px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn.secondary { background: #ecf0e8; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.big { min-height: 72px; font-size: 20px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.stat { text-align: center; }
.stat strong { font-size: 36px; color: var(--primary); display: block; }
.turn-number { font-size: clamp(54px, 12vw, 136px); font-weight: 950; color: var(--primary); line-height: 1; }
.queue { display: flex; flex-wrap: wrap; gap: 7px; min-height: 32px; }
.pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: #eef4eb;
  border: 1px solid var(--line);
  font-weight: 750;
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(145deg, #f7f7f4, #e9efe6);
}
.client-page {
  min-height: 100vh;
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
}
.client-header, .client-footer { background: white; color: var(--text); padding: 24px; text-align: center; }
.client-main { flex: 1; display: grid; place-items: center; padding: 28px; }
.sector-card { color: var(--text); text-align: center; cursor: pointer; }
.sector-letter {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #edf5ec;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 54px;
  font-weight: 950;
  margin: 14px auto;
}
.sector-panel[data-sector="minorista"] .sector-letter { background: color-mix(in srgb, var(--accent) 18%, white); color: var(--accent); }
.display-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.display-header, .display-footer { background: var(--primary); color: white; padding: 18px 24px; }
.display-main { flex: 1; padding: 24px; display: grid; gap: 18px; align-content: start; }
.display-card { min-height: 320px; display: grid; place-items: center; text-align: center; }
.promo-slot img, .promo-slot video { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; background: #111; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: #f0f3ed; font-size: 13px; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #1d2b1f;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  z-index: 50;
}
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.logo-preview { min-height: 92px; border: 1px dashed var(--line); display: grid; place-items: center; padding: 10px; border-radius: 7px; }
.logo-preview img { max-width: 220px; max-height: 90px; object-fit: contain; }
.theme-editor input[type="color"] { height: 46px; padding: 4px; cursor: pointer; }
.form-status { min-height: 20px; margin: 10px 0 0; font-weight: 700; color: var(--ok); }
.form-status.error { color: var(--danger); }
.printing-guide { gap: 22px; }
.printing-guide section { border-top: 1px solid var(--line); padding-top: 14px; }
.printing-guide h3 { margin: 0 0 8px; }
.command-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.command-row code { display: block; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); overflow-wrap: anywhere; }
.guide-steps { margin: 12px 0 18px; padding-left: 24px; }
.guide-steps li { margin: 8px 0; }
.print-warning { margin: 0; padding: 12px; border: 1px solid var(--accent); border-radius: 7px; background: color-mix(in srgb, var(--accent) 10%, white); }
.tab-panel[hidden] { display: none; }
.hide { display: none !important; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .wrap { padding: 14px; }
  .display-main { padding: 14px; }
  .command-row { grid-template-columns: 1fr; }
}

@media print {
  body * { visibility: hidden; }
  #ticket-print, #ticket-print * { visibility: visible; }
  #ticket-print {
    position: absolute;
    left: 0;
    top: 0;
    width: 72mm;
    padding: 4mm;
    color: #000;
    background: #fff;
    text-align: center;
  }
}
