:root {
  --brand: #604404;
  --brand-dark: #4a3203;
  --ink: #2c2c2c;
  --muted: #6b7280;
  --line: #e5e3e3;
  --surface: #ffffff;
  --canvas: #f8f7f7;
  --soft: #fdf8f0;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
img { max-width: 100%; }

.container { width: min(100% - 32px, 980px); margin: 0 auto; padding: 28px 0 48px; }
.container-sm { width: min(100% - 32px, 540px); margin: 0 auto; padding: 28px 0 48px; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card { background: var(--surface); border: 1px solid rgba(229, 227, 227, .7); border-radius: 16px; box-shadow: 0 2px 10px rgba(30, 24, 10, .055); padding: 24px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.wrap { flex-wrap: wrap; }
.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)); }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .74rem; }
.uppercase { text-transform: uppercase; letter-spacing: .08em; }
.title { margin: 0 0 6px; font-size: 1.7rem; line-height: 1.15; }
.subtitle { margin: 0; color: var(--muted); }
.section-title { margin: 0 0 14px; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.hidden { display: none !important; }

.btn { border: 1px solid transparent; border-radius: 10px; padding: 11px 16px; background: white; color: var(--ink); font-weight: 650; transition: .18s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { border-color: var(--line); }
.btn-danger { color: var(--red); border-color: #fecaca; background: #fff7f7; }
.btn-success { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.btn-block { width: 100%; }
.btn-lg { min-height: 50px; font-size: 1.04rem; }
.back { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .9rem; margin-bottom: 22px; }

.field label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.input { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); padding: 12px 14px; outline: 0; transition: .18s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(96, 68, 4, .1); }
textarea.input { min-height: 125px; resize: vertical; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 14px; text-align: left; font-weight: 600; min-height: 48px; }
.choice.active { background: var(--brand); border-color: var(--brand); color: white; }
.choice[data-kind="baixa"] { color: var(--green); background: #f0fdf4; }
.choice[data-kind="media"] { color: var(--amber); background: #fffbeb; }
.choice[data-kind="alta"], .choice[data-kind="muito_alta"] { color: var(--red); background: #fef2f2; }
.choice.active[data-kind] { border-width: 2px; background: white; }

.alert { border-radius: 10px; padding: 12px 14px; font-size: .9rem; }
.alert-error { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: .75rem; font-weight: 700; background: var(--soft); color: var(--muted); }
.badge-baixa { background: #f0fdf4; color: var(--green); }
.badge-media { background: #fffbeb; color: var(--amber); }
.badge-alta, .badge-muito_alta { background: #fef2f2; color: var(--red); }
.badge-gestor { background: #f3e8ff; color: #7e22ce; }

.logo-box { width: 52px; height: 52px; border-radius: 13px; background: var(--brand); color: white; display: grid; place-items: center; font-weight: 900; letter-spacing: -.04em; }
.brand-logo { width: 110px; height: 110px; border: 5px solid var(--brand); border-radius: 24px; display: grid; place-items: center; margin: 0 auto 18px; color: var(--brand); font-size: 2.2rem; font-weight: 950; }
.photo-preview { width: 100%; max-height: 280px; object-fit: cover; border: 1px solid var(--line); border-radius: 12px; margin-top: 14px; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 92px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: #2c2c2c; color: white; padding: 18px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sidebar .logo-box { width: 50px; height: 50px; margin-bottom: 12px; }
.nav-link { width: 72px; color: #d1d5db; border-radius: 10px; padding: 9px 4px; text-align: center; font-size: .69rem; border: 0; background: transparent; }
.nav-link:hover, .nav-link.active { color: white; background: var(--brand); }
.nav-spacer { flex: 1; }
.admin-main { min-width: 0; }
.admin-header { background: white; border-bottom: 1px solid var(--line); padding: 20px 28px; }
.admin-content { padding: 26px 28px 46px; width: min(100%, 1200px); margin: auto; }
.summary { background: white; border-radius: 14px; padding: 20px; border: 1px solid var(--line); }
.summary strong { display: block; margin-top: 5px; font-size: 2rem; }
.ticket-list { display: flex; flex-direction: column; gap: 12px; }
.ticket { display: block; background: white; border: 1px solid var(--line); border-radius: 14px; padding: 18px; transition: .18s; }
.ticket:hover { border-color: rgba(96, 68, 4, .45); box-shadow: 0 5px 18px rgba(30, 24, 10, .07); }
.ticket p { margin: 7px 0 14px; color: var(--muted); }
.ticket-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }

.timeline { position: relative; padding-left: 5px; }
.timeline-item { display: grid; grid-template-columns: 18px 1fr; gap: 12px; min-height: 72px; position: relative; }
.timeline-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); margin-top: 3px; z-index: 1; }
.timeline-dot.done { background: var(--green); }
.timeline-dot.current { background: var(--brand); }
.timeline-line { position: absolute; left: 6px; top: 17px; bottom: -3px; width: 2px; background: var(--line); }
.timeline-content p { margin: 4px 0; }
.note { background: var(--soft); border-radius: 9px; padding: 9px 11px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; border-bottom: 1px solid #f0eeee; padding: 11px 8px; }
th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px; }
.qr-card { background: white; border: 4px solid #1f2937; border-radius: 18px; padding: 20px; text-align: center; }
.qr-card img { width: 170px; height: 170px; image-rendering: pixelated; }
.chart { width: 100%; height: 260px; display: block; }

.modal { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .72); display: grid; place-items: center; padding: 18px; }
.modal-panel { width: min(100%, 820px); max-height: 95vh; overflow: auto; background: white; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head, .modal-foot { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-foot { border: 0; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.modal-body { padding: 20px; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; background: var(--soft); border-bottom: 1px solid var(--line); }
.editor-toolbar .btn.active { background: var(--brand); color: white; }
.editor-canvas-wrap { padding: 20px; background: var(--canvas); overflow: auto; text-align: center; }
#photo-editor-canvas { max-width: 100%; border-radius: 9px; box-shadow: 0 2px 10px rgba(0,0,0,.14); touch-action: none; }

@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4, .choice-grid { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 20; width: 100%; height: auto; flex-direction: row; overflow-x: auto; padding: 9px 10px; }
  .sidebar .logo-box { width: 42px; height: 42px; margin: 0; flex: 0 0 auto; }
  .nav-link { flex: 0 0 68px; }
  .nav-spacer { display: none; }
  .admin-header, .admin-content { padding-left: 16px; padding-right: 16px; }
  .row-between.mobile-stack { align-items: stretch; flex-direction: column; }
}

@media print {
  .print-hide, .sidebar, .admin-header { display: none !important; }
  .admin-shell { display: block; }
  .admin-content { padding: 0; }
  .qr-grid { grid-template-columns: repeat(3, 1fr); }
  .qr-card { break-inside: avoid; box-shadow: none; }
}
