:root {
  --accent: #0f172a;
  --accent-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --danger: #b91c1c;
  --danger-light: #fef2f2;
  --amber: #92400e;
  --amber-light: #fffbeb;
  --blue: #1d4ed8;
  --blue-light: #eff6ff;
  --green: #15803d;
  --green-light: #f0fdf4;
  --radius: 8px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

button { font-family: inherit; }
button:disabled { cursor: wait; opacity: .6; }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.hint.center { text-align: center; }

.link-btn {
  background: none; border: none; color: var(--muted);
  text-decoration: underline; font-size: 12px; cursor: pointer; padding: 0;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
}
.btn-primary:hover { background: #1e293b; }

.btn-secondary {
  width: 100%;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 14px 0 6px;
  text-transform: uppercase;
}

input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #94a3b8; box-shadow: 0 0 0 3px var(--accent-soft); }

.logo-badge {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; margin: 0 auto 14px;
  letter-spacing: 0.02em;
}
.logo-badge.small { width: 32px; height: 32px; font-size: 12px; margin: 0; border-radius: 7px; }

/* ---------- Login ---------- */
.login-card {
  width: 100%; max-width: 360px; background: var(--card-bg);
  border-radius: var(--radius); border: 1px solid var(--border);
  padding: 32px 28px; text-align: center;
}
.login-card h1 { font-size: 17px; margin: 0 0 4px; font-weight: 600; }
.login-card .subtitle { margin: 0 0 20px; color: var(--muted); font-size: 12.5px; }
.login-card .field-label { text-align: left; }
.login-card input { text-align: left; }
.login-error {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: var(--danger);
  font-size: 12px;
  margin: 12px 0 0;
  padding: 9px 10px;
  text-align: left;
}
.success-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--green-light); color: var(--green);
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; margin: 4px auto 14px;
}
.sent-text { font-size: 13px; margin: 0; }
.sent-text strong { color: var(--text); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 14px; font-weight: 600; font-size: 13.5px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 10px; }

.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: none; text-align: left; cursor: pointer;
  padding: 9px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--muted);
  margin-bottom: 1px;
}
.nav-item .nav-icon { font-size: 10px; width: 22px; text-align: center; font-weight: 700; letter-spacing: -.02em; color: #94a3b8; }
.nav-item:hover { background: #f8fafc; color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .nav-icon { color: var(--text); }

.sidebar-footer { border-top: 1px solid var(--border); padding: 14px 18px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-info strong { font-size: 12.5px; font-weight: 600; }
.user-info span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 15px 28px;
  border-bottom: 1px solid var(--border); background: #fff; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 15px; margin: 0; flex: 1; font-weight: 600; }
.topbar-link { font-size: 12px; color: var(--muted); font-weight: 500; text-decoration: none; }
.topbar-link:hover { color: var(--text); text-decoration: underline; }
.menu-toggle { display: none; background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text); }

.content { padding: 24px 28px 48px; max-width: 1100px; width: 100%; }

/* ---------- Shared widgets ---------- */
.section-header { margin-bottom: 18px; }
.section-header h2 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.section-header p { margin: 0; color: var(--muted); font-size: 12.5px; }

.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.card h3 { font-size: 13px; margin: 0 0 12px; font-weight: 600; }

.subsection-title { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 0 0 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.stat-card .stat-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .stat-value { font-size: 20px; font-weight: 700; margin: 6px 0 2px; }
.stat-card .stat-sub { font-size: 11.5px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; border: 1px solid transparent;
}
.badge-green { background: var(--green-light); color: var(--green); border-color: #bbf7d0; }
.badge-amber { background: var(--amber-light); color: var(--amber); border-color: #fde68a; }
.badge-blue { background: var(--blue-light); color: var(--blue); border-color: #bfdbfe; }
.badge-gray { background: #f1f5f9; color: var(--muted); border-color: var(--border); }
.badge-red { background: var(--danger-light); color: var(--danger); border-color: #fecaca; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid #f1f5f9; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .toggle-label { font-size: 13px; font-weight: 500; }
.toggle-row .toggle-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .15s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 14px; width: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }

.btn-outline {
  border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 6px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text);
}
.btn-outline:hover { background: #f8fafc; }
.btn-outline-green { border-color: #bbf7d0; color: var(--green); }
.btn-outline-danger { border-color: #fecaca; color: var(--danger); }

.actions-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 11px; font-size: 12px; font-weight: 500;
  background: #fff; cursor: pointer; color: var(--muted);
}
.chip.active { background: var(--accent-soft); border-color: #cbd5e1; color: var(--text); }

/* Dashboard chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar-track { width: 100%; display: flex; align-items: flex-end; height: 110px; }
.bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 3px; opacity: .85; }
.bar-col .bar-day { font-size: 10.5px; color: var(--muted); }

/* Products grid (admin) */
.admin-products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.admin-product-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: #fff; }
.admin-product-card .thumb {
  width: 100%; aspect-ratio: 16/10; border-radius: 6px; background: var(--accent-soft); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em;
}
.admin-product-card .name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.admin-product-card .price { color: var(--text); font-weight: 600; font-size: 13.5px; }
.admin-product-card .stock { color: var(--muted); font-size: 11.5px; margin-bottom: 10px; }
.admin-product-card .row-actions { display: flex; gap: 6px; }
.product-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

/* Live donation feed (Painel) */
.feed-list { display: flex; flex-direction: column; gap: 12px; max-height: 320px; overflow-y: auto; }
.feed-item { display: flex; gap: 10px; }
.feed-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--text);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11.5px; flex-shrink: 0;
}
.feed-body { flex: 1; min-width: 0; }
.feed-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.feed-amount { color: var(--text); font-weight: 600; }
.feed-message { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }
.feed-time { font-size: 11px; color: #94a3b8; margin-top: 2px; }

input[type="range"] { width: 100%; accent-color: var(--accent); margin: 6px 0 4px; }

/* Polls */
.poll-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; background: #fff; }
.poll-card .poll-question { font-weight: 600; font-size: 13px; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.poll-option { margin-bottom: 10px; }
.poll-option-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.poll-bar-track { background: #f1f5f9; border-radius: 999px; height: 6px; overflow: hidden; }
.poll-bar-fill { background: var(--accent); height: 100%; border-radius: 999px; opacity: .85; }

/* Overlay preview */
.overlay-preview {
  background: #0f172a;
  border-radius: var(--radius); padding: 40px 24px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
  min-height: 160px;
}
.overlay-toast {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 10px;
  padding: 14px 18px; display: flex; gap: 12px; align-items: center; color: #fff; max-width: 340px;
}
.overlay-toast .icon {
  width: 36px; height: 36px; border-radius: 8px; background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; color: #fff;
}
.overlay-toast .title { font-weight: 600; font-size: 13px; }
.overlay-toast .amount { color: #86efac; font-weight: 600; font-size: 13px; }
.overlay-toast .msg { font-size: 12px; color: #cbd5e1; margin-top: 2px; }

.url-field { display: flex; gap: 8px; }
.url-field input { flex: 1; font-size: 12px; color: var(--muted); background: #f8fafc; }

/* Sounds */
.sound-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.sound-row:last-child { border-bottom: none; }
.sound-row .sound-icon { width: 32px; height: 32px; border-radius: 7px; background: var(--accent-soft); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.sound-row .sound-info { flex: 1; min-width: 0; }
.sound-row .sound-name { font-weight: 600; font-size: 13px; }
.sound-row .sound-meta { font-size: 11.5px; color: var(--muted); }

/* Filters */
.filters-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters-row select, .filters-row input { width: auto; min-width: 130px; }

/* About */
.about-list { list-style: none; padding: 0; margin: 0; }
.about-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.about-list li:last-child { border-bottom: none; }
.about-list li span:first-child { color: var(--muted); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13px; }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; width: min(320px, calc(100vw - 32px));
}
.toast {
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--card-bg);
  padding: 12px 14px; font-size: 12.5px; box-shadow: 0 6px 18px rgba(15,23,42,.08);
  display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in .15s ease-out;
}
.toast-success { border-color: #bbf7d0; background: var(--green-light); color: #14532d; }
.toast-error { border-color: #fecaca; background: var(--danger-light); color: #7f1d1d; }
.toast-message { flex: 1; word-break: break-word; }
.toast-close { background: none; border: none; cursor: pointer; color: inherit; opacity: .6; font-size: 13px; line-height: 1; padding: 0; }
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 90;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal-box {
  background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border);
  width: 100%; max-width: 420px; padding: 20px 22px 22px; box-shadow: 0 20px 40px rgba(15,23,42,.18);
}
.modal-box h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 600; }
.modal-box .modal-desc { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.modal-error {
  background: var(--danger-light); border: 1px solid #fecaca; border-radius: 6px; color: var(--danger);
  font-size: 12px; padding: 9px 10px; margin-top: 12px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { width: auto; margin-top: 0; }
.modal-box .field-label:first-of-type { margin-top: 0; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { position: fixed; left: -260px; z-index: 20; transition: left .2s; box-shadow: 0 0 0 9999px rgba(0,0,0,0); }
  .sidebar.open { left: 0; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
  .menu-toggle { display: block; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 14px 16px; }
}
