/* ============================================================================
   LA MADRE · DESIGN SYSTEM COMPARTILHADO
   Uma fonte de verdade para as 5 telas do painel. Estilos específicos de
   cada tela ficam no <style> da própria página.
   Desenvolvido pela Glai · glai.ia
   ========================================================================== */

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

:root {
  --bg:        #0c0a07;
  --bg-1:      #14110c;
  --bg-2:      #1c1812;
  --bg-3:      #241e16;
  --border:    #2a221a;
  --border-2:  #3a3024;
  --ink:       #f4ede0;
  --ink-2:     #a39885;
  --ink-3:     #6b6354;
  --ink-4:     #443d33;

  --copper:      #c8a35c;
  --copper-2:    #d8b878;
  --copper-soft: rgba(200, 163, 92, 0.12);
  --copper-line: rgba(200, 163, 92, 0.28);

  --ok:        #8fa572;
  --warn:      #c89352;
  --lost:      #a05c52;

  --lume:      #c8ff00; /* verde Glai — usado só na assinatura da agência */

  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans:  'Geist', system-ui, -apple-system, sans-serif;
  --mono:  'Geist Mono', ui-monospace, Menlo, monospace;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;

  --sidebar-w: 248px;
  --tabbar-h: 64px;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* textura quente de fundo */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 20% 10%, rgba(200,163,92,0.04), transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(200,163,92,0.03), transparent 50%);
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
button:disabled { opacity: .55; cursor: default; }

:focus-visible {
  outline: 2px solid var(--copper-line);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ============ CASCA ============ */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}
@media (min-width: 880px) {
  .shell { grid-template-columns: var(--sidebar-w) 1fr; }
}

/* ============ SIDEBAR (desktop) ============ */
.sidebar {
  display: none;
  border-right: 1px solid var(--border);
  padding: 28px 20px 24px;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, #0e0b08, #0a0805);
}
@media (min-width: 880px) { .sidebar { display: flex; } }

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand-mark em { color: var(--copper); font-style: italic; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 10px 10px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 400;
  font-size: 14.5px;
  transition: color .15s ease, background .15s ease;
}
.nav a:hover { color: var(--ink); background: var(--bg-1); }
.nav a.active {
  color: var(--ink);
  background: var(--bg-2);
  box-shadow: inset 2px 0 0 var(--copper);
}
.nav a .ico { width: 16px; height: 16px; flex-shrink: 0; color: var(--ink-3); }
.nav a.active .ico { color: var(--copper); }

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-4);
  flex-shrink: 0;
}
.status-dot.on  { background: var(--ok);   box-shadow: 0 0 0 3px rgba(143,165,114,0.15); }
.status-dot.off { background: var(--lost); box-shadow: 0 0 0 3px rgba(160,92,82,0.15); }

.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-style: italic;
  color: var(--copper);
  font-size: 16px;
  flex-shrink: 0;
}
.who-meta { line-height: 1.25; min-width: 0; }
.who-meta strong { color: var(--ink); font-weight: 500; font-size: 13.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-meta span { color: var(--ink-3); font-size: 12px; }

/* ============ ASSINATURA GLAI ============ */
.glai-lockup {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  transition: color .15s ease;
}
.glai-lockup strong { font-weight: 500; color: var(--ink-3); letter-spacing: 0.18em; transition: color .15s ease; }
.glai-lockup .glai-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--lume);
  box-shadow: 0 0 6px rgba(200,255,0,0.45);
  flex-shrink: 0;
}
.glai-lockup:hover { color: var(--ink-3); }
.glai-lockup:hover strong { color: var(--lume); }

.glai-foot-mobile {
  display: flex;
  justify-content: center;
  padding: 28px 0 4px;
}
@media (min-width: 880px) { .glai-foot-mobile { display: none; } }

/* ============ MAIN ============ */
.main {
  min-width: 0;
  padding: 20px 20px calc(var(--tabbar-h) + 32px);
}
@media (min-width: 880px)  { .main { padding: 28px 48px 56px; } }
@media (min-width: 1280px) { .main { padding: 36px 64px 72px; } }

/* ============ TOPO MOBILE ============ */
.mobile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  margin-bottom: 4px;
}
@media (min-width: 880px) { .mobile-top { display: none; } }
.mobile-top .brand-mark { font-size: 24px; }
.mobile-top .status-pill { font-size: 10px; }

/* ============ CABEÇALHO DE PÁGINA ============ */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.greeting { display: flex; flex-direction: column; gap: 4px; }
.greeting .hi {
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.greeting .hi em { color: var(--copper); font-style: italic; }
.greeting .when {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
@media (min-width: 880px) { .greeting .hi { font-size: 34px; } }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============ BOTÕES ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--bg-1);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { color: var(--ink); border-color: var(--copper-line); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--copper); color: #1a1408; border-color: var(--copper); font-weight: 600; }
.btn-primary:hover { background: var(--copper-2); border-color: var(--copper-2); color: #1a1408; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-1); border-color: var(--border); }
.btn-danger { color: var(--lost); border-color: var(--lost); background: rgba(160,92,82,0.08); }
.btn-danger:hover { background: rgba(160,92,82,0.16); color: var(--lost); border-color: var(--lost); }
.btn-wa { background: #1ea566; color: #fff; border-color: #1ea566; }
.btn-wa:hover { background: #25b974; border-color: #25b974; color: #fff; }
.btn-grande { padding: 13px 18px; font-size: 14px; width: 100%; }

/* ============ FILTRO DE BARBEIRO ============ */
.filtro-barbeiro { display: none; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filtro-barbeiro.visivel { display: flex; }
.filtro-btn {
  padding: 7px 14px;
  border: 1px solid var(--border-2);
  border-radius: 20px;
  background: var(--bg-1);
  color: var(--ink-2);
  font-size: 13px;
  transition: all .15s;
}
.filtro-btn:hover { border-color: var(--copper-line); color: var(--ink); }
.filtro-btn.ativo { background: var(--copper); color: #1a1408; border-color: var(--copper); font-weight: 600; }

/* ============ TÍTULO DE SEÇÃO ============ */
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 18px;
}
.section-title h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.section-title h2 em { color: var(--copper); font-style: italic; }
.section-title .more {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.section-title a.more:hover { color: var(--copper); }

/* ============ CAMPOS ============ */
.field {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  width: 100%;
  transition: border-color .15s ease;
}
.field:focus { outline: none; border-color: var(--copper-line); }
.field::placeholder { color: var(--ink-4); }
textarea.field { min-height: 110px; resize: vertical; line-height: 1.5; }

/* toggle */
.toggle-wrap { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-wrap input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; margin: 0; z-index: 1; }
.toggle-track { display: block; width: 36px; height: 20px; background: var(--border-2); border-radius: 10px; transition: background .2s; }
.toggle-wrap input:checked ~ .toggle-track { background: var(--copper); }
.toggle-knob { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: #fff; border-radius: 50%; transition: transform .2s; pointer-events: none; }
.toggle-wrap input:checked ~ .toggle-knob { transform: translateX(16px); }

/* ============ TAB BAR (mobile) ============ */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: rgba(12, 10, 7, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 880px) { .tabbar { display: none; } }
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-3);
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 4px;
  border-top: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.tabbar a .ico { width: 20px; height: 20px; }
.tabbar a.active { color: var(--copper); border-top-color: var(--copper); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.modal h3 { font-family: var(--serif); font-style: italic; font-size: 24px; font-weight: 400; margin: 0; color: var(--ink); }
.modal h3 em { color: var(--copper); font-style: italic; }
.modal label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: block;
  margin-bottom: 6px;
}
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }

/* ============ FOLHA INFERIOR (mobile) ============ */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.sheet-overlay.open { opacity: 1; pointer-events: all; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 95;
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-bottom: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform .25s cubic-bezier(.32,.72,.35,1);
  max-height: 82vh;
  overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet-alca {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--border-2);
  margin: 0 auto 16px;
}
@media (min-width: 880px) {
  .sheet {
    left: 50%; right: auto; bottom: 50%;
    transform: translate(-50%, 50%) scale(.97);
    opacity: 0;
    pointer-events: none;
    width: 440px;
    border-radius: var(--r-lg);
    border-bottom: 1px solid var(--border-2);
  }
  .sheet.open { transform: translate(-50%, 50%) scale(1); opacity: 1; pointer-events: all; }
  .sheet-alca { display: none; }
}

/* ============ ESTADOS ============ */
.aguardando { opacity: 0; transition: opacity .25s ease; }
.carregado  { opacity: 1; }

@keyframes shimmer { 0%,100% { opacity: .4; } 50% { opacity: .75; } }
.skeleton { background: var(--bg-2); border-radius: var(--r); animation: shimmer 1.5s ease-in-out infinite; }

.estado-vazio, .estado-erro {
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px;
}
.estado-vazio em, .estado-erro em {
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  color: var(--ink-4);
  display: block;
  margin-bottom: 10px;
  font-weight: 400;
}
.estado-erro em { color: var(--lost); opacity: .8; }
.estado-erro .btn { margin-top: 16px; }

/* ============ TOAST ============ */
.lm-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 200;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  padding: 11px 18px;
  font-size: 13.5px;
  color: var(--ink);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: min(92vw, 460px);
  text-align: center;
}
@media (min-width: 880px) { .lm-toast { bottom: 28px; } }
.lm-toast.show { opacity: 1; transform: translate(-50%, 0); }
.lm-toast.ok   { border-color: rgba(143,165,114,0.5); }
.lm-toast.erro { border-color: rgba(160,92,82,0.6); }

/* ============ TELA DE PIN ============ */
.lm-lock {
  position: fixed; inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lm-lock::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 20% 10%, rgba(200,163,92,0.05), transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(200,163,92,0.04), transparent 50%);
  pointer-events: none;
}
.lm-lock-box {
  position: relative;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}
.lm-lock-box .brand-mark { font-size: 40px; }
.lm-lock-box .sub {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: -10px;
}
.lm-lock-box .field {
  text-align: center;
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.4em;
  padding: 14px;
}
.lm-lock-box .erro-pin { color: var(--lost); font-size: 12.5px; min-height: 18px; }
@keyframes lockshake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }
.lm-lock-box.tremeu { animation: lockshake .3s ease; }
.lm-lock .glai-lockup { margin-top: 22px; }

/* ============ UTILITÁRIOS ============ */
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.serif-i { font-family: var(--serif); font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
