:root {
  --primary:      #16a34a;
  --primary-dark: #15803d;
  --primary-light:#dcfce7;
  --danger:       #ef4444;
  --danger-light: #fee2e2;
  --text:         #111827;
  --muted:        #6b7280;
  --border:       #e5e7eb;
  --bg:           #f9fafb;
  --white:        #ffffff;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.12);
  --radius:       12px;
  --h-header:     56px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --h-header-total: calc(var(--h-header) + var(--safe-top));
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }

/* ── Header ─────────────────────────────────────────────────── */
.cfg-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--h-header-total);
  padding-top: var(--safe-top);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.cfg-header h1 { font-size: 18px; font-weight: 700; }

.btn-back {
  background: rgba(255,255,255,0.18);
  border: none;
  border-radius: 10px;
  padding: 6px 14px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn-back:hover { background: rgba(255,255,255,0.28); }

/* ── Main ───────────────────────────────────────────────────── */
.cfg-main {
  margin-top: var(--h-header-total);
  padding: 16px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Sections ───────────────────────────────────────────────── */
.cfg-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  padding-bottom: 4px;
  border-bottom: 2px solid var(--primary-light);
  display: inline-block;
}

.btn-add-vendor {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-add-vendor:active { background: var(--primary); color: white; }

/* ── Logo area ───────────────────────────────────────────────── */
.logo-area {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo-preview {
  position: relative;
  width: 90px; height: 90px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  border: 2px dashed var(--border);
  background: var(--bg);
  flex-shrink: 0;
  transition: border-color 0.2s;
}
.logo-preview:hover { border-color: var(--primary); }
.logo-preview.has-logo { border-style: solid; border-color: var(--primary); }

.logo-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.logo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.40);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  color: white;
  font-weight: 600;
}
.logo-overlay span:first-child { font-size: 22px; }
.logo-preview.has-logo .logo-overlay { opacity: 0; transition: opacity 0.2s; }
.logo-preview.has-logo:hover .logo-overlay { opacity: 1; }

.logo-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.logo-hint small { font-size: 11px; }

/* ── Campos ─────────────────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field-group input,
.field-group select {
  height: 48px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.field-group input:focus,
.field-group select:focus { border-color: var(--primary); }

/* ── Botões ─────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  height: 50px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.88; }

.btn-danger {
  width: 100%;
  height: 44px;
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

/* ── Lista de vendedores ─────────────────────────────────────── */
.vendor-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.vendor-item:last-child { border-bottom: none; }

.vendor-avatar-cfg {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.vendor-item.inativo .vendor-avatar-cfg { background: var(--muted); }

.vendor-item-info { flex: 1; min-width: 0; }

.vendor-item-nome {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vendor-status {
  font-size: 12px;
  margin-top: 2px;
}
.vendor-status.ativo   { color: var(--primary); }
.vendor-status.inativo { color: var(--muted); }

.btn-edit-vendor {
  width: 44px; height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-edit-vendor:active { background: var(--primary-light); border-color: var(--primary); }

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

/* ── Painel ─────────────────────────────────────────────────── */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.panel-overlay.open { opacity: 1; pointer-events: auto; }

.panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
}
.panel-overlay.open .panel { transform: translateY(0); }

.panel::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--white);
  z-index: 10;
}
.panel-header h2 { font-size: 18px; font-weight: 700; }

.btn-close {
  background: var(--bg);
  border: none;
  border-radius: 50%;
  width: 44px; height: 44px;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}

.form-fields {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-error {
  font-size: 14px;
  color: var(--danger);
  font-weight: 500;
  min-height: 18px;
  text-align: center;
}

/* ── Suporte ────────────────────────────────────────────────── */
.cfg-support { gap: 12px; }
.support-desc { font-size: 14px; color: var(--muted); line-height: 1.5; }
.btn-support {
  display: flex; align-items: center; justify-content: center;
  height: 48px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-support:active { background: var(--primary); color: white; }
.btn-support-email {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.btn-support-email:active { background: var(--border); color: var(--text); }

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(17,24,39,0.85);
  backdrop-filter: blur(8px);
  color: white;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
