:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --line: #dce3ee;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --blue: #2563eb;
  --green: #16a34a;
  --emerald: #047857;
  --amber: #f59e0b;
  --orange: #f97316;
  --red: #dc2626;
  --shadow: 0 14px 40px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
label { display: grid; gap: 7px; font-weight: 700; color: #334155; }

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(140deg, rgba(15, 118, 110, .12), transparent 34%),
    linear-gradient(40deg, rgba(245, 158, 11, .12), transparent 44%),
    var(--bg);
}
.login-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.splash-logo-img {
  display: block;
  width: min(190px, 80%);
  height: auto;
  margin: 0 auto 18px;
}
.brand-logo {
  display: block;
  width: 74px;
  height: auto;
  max-height: 44px;
  object-fit: contain;
}
.login-card h1 { margin: 0 0 6px; font-size: 30px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.stack { display: grid; gap: 14px; }
.checkline { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.checkline input { width: 18px; height: 18px; }
.danger-check {
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
}
.muted-link { display: block; margin-top: 18px; color: var(--muted); text-align: center; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 34px);
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-nav a { padding: 9px 10px; border-radius: 8px; color: #334155; font-weight: 700; }
.admin-nav a:hover { background: #eef6f5; color: var(--primary-dark); }

.app-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 16px 92px;
}
.admin-main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 30px clamp(22px, 3.2vw, 56px) 48px;
}
.hero-panel, .panel, .client-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.hero-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px;
  background: linear-gradient(135deg, #0f766e, #155e75);
  color: #fff;
}
.hero-panel h1, .section-head h1 { margin: 2px 0 4px; }
.hero-panel p { margin: 0; color: rgba(255,255,255,.82); }
.eyebrow { color: var(--amber); font-weight: 900; text-transform: uppercase; font-size: 12px; }
.goal-ring {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#f59e0b var(--progress), rgba(255,255,255,.22) 0);
  position: relative;
}
.goal-ring::after { content: ""; position: absolute; inset: 10px; background: #0f766e; border-radius: 50%; }
.goal-ring strong, .goal-ring span { z-index: 1; grid-area: 1 / 1; }
.goal-ring span { margin-top: 38px; font-size: 12px; color: rgba(255,255,255,.8); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.admin-metrics { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.metric-card {
  padding: 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-left: 5px solid var(--primary);
}
.metric-card span { display: block; color: var(--muted); font-weight: 700; font-size: 13px; }
.metric-card strong { display: block; margin-top: 6px; font-size: 30px; }
.accent-blue { border-left-color: var(--blue); }
.accent-green { border-left-color: var(--green); }
.accent-emerald { border-left-color: var(--emerald); }
.accent-amber, .accent-yellow { border-left-color: var(--amber); }
.accent-orange { border-left-color: var(--orange); }
.accent-red { border-left-color: var(--red); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}
.panel { padding: 18px; margin: 14px 0; }
.panel h2 { margin: 0 0 14px; font-size: 20px; }
.filter-bar, .form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  margin: 12px 0;
}
.admin-filter { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
  color: #1e293b;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-secondary { background: #eef6f5; color: var(--primary-dark); border-color: #b7ded9; }
.btn-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.btn-whatsapp { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-block { width: 100%; }
.install-btn { padding: 8px 12px; border-radius: 8px; border: 0; background: #ecfeff; color: #155e75; font-weight: 900; }

.client-list, .notice-list { display: grid; gap: 12px; }
.client-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}
.client-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.client-card h2, .notice-card h2 { margin: 4px 0; font-size: 18px; }
.client-card p { margin: 0; color: var(--muted); }
.client-code { color: var(--muted); font-weight: 900; font-size: 12px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}
.status-pendente { background: #fff; border-color: #e2e8f0; }
.status-mensagem-enviada { background: #eff6ff; border-color: #bfdbfe; }
.status-respondeu { background: #ecfdf5; border-color: #bbf7d0; }
.status-voltou-na-loja { background: #d1fae5; border-color: #34d399; }
.status-nao-respondeu { background: #fffbeb; border-color: #fde68a; }
.status-sem-resposta { background: #fff7ed; border-color: #fed7aa; }
.status-sem-telefone { background: #fef2f2; border-color: #fecaca; }
.card-actions, .inline-form, .quick-note, .row-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.confirm-send-form { margin: 0; }
.quick-note input, .inline-form input { flex: 1; }
.client-detail { padding: 20px; }
.client-detail h1 { margin: 4px 0; }
.detail-phone { color: var(--muted); margin: 0 0 12px; }

.timeline { display: grid; gap: 10px; }
.timeline article, .notice-card, .notice-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.timeline span, .notice-card span, .muted, .read-label { color: var(--muted); font-size: 13px; }
.notice-card.is-unread, .notice-row.is-unread { border-color: #f59e0b; background: #fffbeb; }
.notice-row { display: flex; justify-content: space-between; gap: 10px; }
.empty-state { padding: 24px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  backdrop-filter: blur(16px);
}
.bottom-nav a { text-align: center; padding: 10px 6px; border-radius: 8px; color: #334155; font-weight: 900; font-size: 13px; }
.bottom-nav a:hover { background: #eef6f5; color: var(--primary); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #475569; font-size: 12px; text-transform: uppercase; }
.progress { width: 120px; height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--primary); }
.password-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.password-grid span { padding: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
.image-preview {
  display: grid;
  gap: 10px;
  align-items: start;
}
.image-preview img {
  width: min(260px, 100%);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.toast, .alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-weight: 800;
}
.toast { position: fixed; right: 16px; top: 76px; z-index: 40; box-shadow: var(--shadow); }
.toast-success, .alert-success { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.toast-error, .alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

@media (min-width: 720px) {
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: 2fr 1fr auto; }
}

@media (min-width: 1024px) {
  .admin-topbar {
    min-height: 76px;
    padding-left: clamp(28px, 3vw, 56px);
    padding-right: clamp(28px, 3vw, 56px);
  }

  .admin-shell .brand-logo {
    width: 86px;
    max-height: 54px;
  }

  .admin-main .section-head {
    margin-top: 8px;
    margin-bottom: 18px;
  }

  .admin-main .section-head h1 {
    font-size: 36px;
  }

  .admin-main .filter-bar {
    grid-template-columns: minmax(260px, 1.25fr) minmax(220px, .9fr) minmax(220px, .8fr) minmax(180px, .7fr) minmax(180px, .7fr) minmax(150px, .5fr);
    gap: 14px;
    margin: 14px 0 18px;
  }

  .admin-main input,
  .admin-main select,
  .admin-main .btn {
    min-height: 52px;
  }

  .admin-main .metric-grid {
    gap: 14px;
  }

  .admin-main .metric-card {
    min-height: 112px;
    padding: 20px;
  }

  .admin-main .metric-card strong {
    font-size: 36px;
  }

  .admin-main .panel {
    padding: 24px 28px;
    margin-top: 18px;
  }

  .admin-main .panel h2 {
    font-size: 24px;
  }

  .admin-main table {
    min-width: 100%;
    font-size: 15px;
  }

  .admin-main th,
  .admin-main td {
    padding: 15px 14px;
  }

  .admin-main .progress {
    width: 180px;
    height: 12px;
  }
}

@media (max-width: 620px) {
  .admin-nav { overflow-x: auto; flex-wrap: nowrap; width: 100%; }
  .admin-topbar { align-items: flex-start; flex-direction: column; }
  .hero-panel { align-items: flex-start; }
  .goal-ring { width: 82px; height: 82px; flex-basis: 82px; }
  .card-actions, .inline-form, .quick-note, .row-form { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
}
