:root{
  --bg:#fbfaf4;
  --card:#ffffff;
  --card-2:#fffdfa;
  --text:#3e3150;
  --muted:#7d7390;
  --line:rgba(197,113,233,.16);
  --line-strong:rgba(197,113,233,.24);

  --primary:#C571E9;
  --primary2:#AE57D5;

  --accent1:#E9C571;
  --accent2:#D1E971;
  --accent3:#71E9C5;
  --accent4:#71D1E9;
  --accent5:#C571E9;

  --primary-ink:#6d3487;
  --accent1-ink:#6b5620;
  --accent2-ink:#576819;
  --accent3-ink:#1d6b5a;
  --accent4-ink:#205e72;

  --nav:#7B4AA6;
  --nav2:#5D357F;
  --nav3:#4A2A66;

  --shadow: 0 18px 45px rgba(197,113,233,.10);
  --shadow2: 0 10px 25px rgba(197,113,233,.08);

  --r-lg:18px;
  --r-md:14px;
  --r-sm:12px;

  --sidebar-w: 290px;
  --sidebar-w-md: 262px;

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

*{box-sizing:border-box}
html,body{height:100%}

html{
  -webkit-text-size-adjust:100%;
}

body{
  margin:0;
  font-family:var(--font);
  color:var(--text);
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(197,113,233,.11), transparent 55%),
    radial-gradient(900px 500px at 85% -15%, rgba(113,209,233,.10), transparent 60%),
    linear-gradient(180deg, #fffdf8 0%, var(--bg) 100%);
}

a{color:inherit;text-decoration:none}
code{
  background:rgba(62,49,80,.06);
  padding:2px 6px;
  border-radius:8px;
}

img{
  max-width:100%;
  height:auto;
}

.layout{
  display:grid;
  grid-template-columns: minmax(250px, var(--sidebar-w)) minmax(0, 1fr);
  min-height:100vh;
}

@media (max-width: 1280px){
  .layout{
    grid-template-columns: minmax(232px, var(--sidebar-w-md)) minmax(0, 1fr);
  }
}

/* Sidebar */
.sidebar{
  position:sticky;
  top:0;
  height:100vh;
  min-height:100vh;
  overflow:auto;
  padding:18px 14px 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,0) 22%),
    linear-gradient(180deg, var(--nav) 0%, var(--nav2) 52%, var(--nav3) 100%);
  color:#F8F5FF;
  border-right: 1px solid rgba(255,255,255,.10);
  scrollbar-width:thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}

.sidebar::-webkit-scrollbar{
  width:10px;
}
.sidebar::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.16);
  border-radius:999px;
  border:2px solid transparent;
  background-clip:padding-box;
}
.sidebar::-webkit-scrollbar-track{
  background:transparent;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding:10px;
}

.brand-mark{
  width:44px;
  height:44px;
  border-radius:16px;
  display:grid;
  place-items:center;
  background: linear-gradient(135deg, rgba(233,197,113,.34), rgba(255,255,255,.16));
  border:1px solid rgba(255,255,255,.18);
  box-shadow: 0 12px 22px rgba(0,0,0,.18);
  overflow:hidden;
}

.brand-title{
  font-weight:900;
  letter-spacing:-.02em;
  color:#fff;
}

.brand-sub{
  font-size:12px;
  opacity:.84;
  margin-top:3px;
  color:rgba(255,255,255,.82);
}

.clinic-switch{
  margin:12px 10px 14px;
  padding:12px;
  border-radius: var(--r-lg);
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 14px 28px rgba(0,0,0,.16);
  backdrop-filter: blur(8px);
}

.clinic-label{
  display:block;
  font-size:12px;
  opacity:.9;
  margin-bottom:8px;
  color:rgba(255,255,255,.86);
}

.clinic-select{
  width:100%;
  padding:10px 12px;
  border-radius: 12px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.14);
  color:#fff;
  outline:none;
  font-weight:800;
}

.clinic-select:focus{
  border-color: rgba(233,197,113,.55);
  box-shadow: 0 0 0 4px rgba(233,197,113,.14);
}

.clinic-select option{
  color:#0F172A;
}

.clinic-hint{
  margin-top:8px;
  font-size:12px;
  opacity:.82;
  color:rgba(255,255,255,.78);
}

.nav{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:0 10px;
}

.nav-link{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px 10px;
  border-radius: 14px;
  border:1px solid transparent;
  color:#F8F5FF;
  transition: background .16s ease, transform .10s ease, border-color .16s ease, box-shadow .16s ease;
  min-height:48px;
}

.nav-link:hover{
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.08);
}

.nav-link.is-active{
  background: linear-gradient(135deg, rgba(233,197,113,.22), rgba(197,113,233,.16));
  border-color: rgba(233,197,113,.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.nav-ico{
  width:28px;
  height:28px;
  display:grid;
  place-items:center;
  color:#fff;
  flex:0 0 auto;
}

.nav-txt{
  font-weight:900;
  font-size:14px;
  min-width:0;
}

.sidebar-footer{
  margin-top:18px;
  padding:10px;
  border-top:1px solid rgba(255,255,255,.10);
}

.muted{
  font-size:12px;
  opacity:.82;
  margin-top:10px;
  padding-left:10px;
}

/* Main */
.main{
  min-width:0;
  padding:22px 18px 96px;
}

.container{
  max-width:1180px;
  margin:0 auto;
  min-width:0;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:18px;
  min-width:0;
}

.top-left{
  display:flex;
  flex-direction:column;
  gap:8px;
  min-width:0;
}

.chip{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding:8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.84);
  border:1px solid var(--line);
  box-shadow: var(--shadow2);
  font-size:12px;
  font-weight:900;
  color:var(--text);
  max-width:100%;
}

.chip .dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background:var(--primary);
}

.chip .sep{
  opacity:.55;
}

.title{
  margin:0;
  font-size:28px;
  font-weight:950;
  letter-spacing:-.03em;
  color:var(--text);
}

.subtitle{
  margin:0;
  color:var(--muted);
  font-weight:650;
}

.top-right{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.icon-btn{
  width:42px;
  height:42px;
  border-radius:16px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow2);
  display:grid;
  place-items:center;
  cursor:pointer;
  position:relative;
  color:var(--primary-ink);
}

.icon-btn .badge{
  position:absolute;
  top:9px;
  right:10px;
  width:9px;
  height:9px;
  border-radius:99px;
  background:#EF4444;
  border:2px solid #fff;
}

.avatar{
  width:42px;
  height:42px;
  border-radius:999px;
  border:1px solid var(--line);
  background: linear-gradient(135deg, rgba(233,197,113,.26), rgba(197,113,233,.16));
  box-shadow: var(--shadow2);
}

.grid{
  display:grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr);
  gap:14px;
  min-width:0;
}

.card{
  background: rgba(255,255,255,.90);
  border:1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding:16px;
  min-width:0;
}

.card-h{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  min-width:0;
}

.card h3{
  margin:0;
  font-size:14px;
  letter-spacing:-.01em;
}

.mt8{margin-top:8px}
.m0{margin:0}

.pill{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  background: rgba(113,209,233,.16);
  border:1px solid rgba(113,209,233,.24);
  color:var(--accent4-ink);
  font-weight:950;
  font-size:12px;
}

.brand-logo-img{
  height:32px;
  width:auto;
  display:block;
  border-radius:12px;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 12px;
  border-radius: 14px;
  font-weight:950;
  cursor:pointer;
  border:1px solid var(--line);
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow2);
  transition: transform .08s ease, box-shadow .16s ease, border-color .16s ease;
  color:var(--text);
}

.btn:hover{
  transform: translateY(-1px);
}

.btn-primary{
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color:#fff;
  border-color: rgba(197,113,233,.28);
}

.btn-soft{
  background: rgba(255,255,255,.82);
  color:var(--primary-ink);
}

.next-card{
  display:flex;
  gap:12px;
  align-items:center;
  padding:14px;
  border-radius: var(--r-lg);
  border:1px dashed rgba(197,113,233,.28);
  background: linear-gradient(135deg, rgba(233,197,113,.10), rgba(197,113,233,.06));
  margin-top:12px;
}

.next-ico{
  width:38px;
  height:38px;
  border-radius:16px;
  display:grid;
  place-items:center;
  background: rgba(255,255,255,.92);
  border:1px solid rgba(197,113,233,.18);
  box-shadow: var(--shadow2);
  color:var(--primary-ink);
}

.next-title{
  font-weight:950;
}

.next-desc{
  margin-top:4px;
  color:var(--muted);
  font-weight:700;
  font-size:13px;
}

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}

.mini-grid{
  margin-top:14px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}

.mini{
  border:1px solid var(--line);
  background: rgba(255,255,255,.90);
  border-radius: 16px;
  padding:12px;
  box-shadow: var(--shadow2);
  min-width:0;
}

.mini-k{
  font-size:12px;
  color:var(--muted);
  font-weight:850;
}

.mini-v{
  margin-top:4px;
  font-weight:950;
  color:var(--text);
}

.kpis{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
  margin-top:12px;
}

.kpi{
  padding:14px;
  border-radius: var(--r-lg);
  border:1px solid var(--line);
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow2);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  min-width:0;
}

.kpi-n{
  font-size:28px;
  font-weight:950;
  letter-spacing:-.03em;
  color:var(--text);
}

.kpi-l{
  font-size:12px;
  color:var(--muted);
  font-weight:900;
  margin-top:2px;
}

.kpi-ico{
  width:40px;
  height:40px;
  border-radius:16px;
  display:grid;
  place-items:center;
  border:1px solid var(--line);
  background: rgba(233,197,113,.10);
  color: var(--primary-ink);
}

.mt16{margin-top:16px}

.list{
  margin:10px 0 0;
  padding-left:18px;
  color:var(--text);
}

.list li{
  margin:8px 0;
  line-height:1.5;
}

/* Auth */
.auth-body{
  display:grid;
  place-items:center;
  min-height:100vh;
}

.auth-wrap{
  width:min(520px, 92vw);
}

.auth-card{
  background: rgba(255,255,255,.90);
  border:1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-brand{
  display:flex;
  gap:12px;
  align-items:center;
}

.alert{
  margin-top:12px;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid rgba(233,197,113,.28);
  background: rgba(233,197,113,.14);
  color:var(--accent1-ink);
  font-weight:850;
}

.auth-title{
  margin:14px 0 0;
  font-size:24px;
  font-weight:950;
  color:var(--text);
}

.auth-sub{
  margin:8px 0 0;
  color:var(--muted);
  font-weight:700;
}

.auth-form{
  margin-top:14px;
  display:grid;
  gap:12px;
}

.field span{
  display:block;
  font-size:12px;
  color:var(--muted);
  font-weight:900;
  margin-bottom:6px;
}

.field input{
  width:100%;
  padding:12px 12px;
  border-radius: 14px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.96);
  outline:none;
  font-weight:800;
  color:var(--text);
}

.field input:focus{
  border-color: rgba(197,113,233,.36);
  box-shadow: 0 0 0 4px rgba(197,113,233,.10);
}

.hint{
  margin-top:10px;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}

/* ===========================
   Bootnav + Drawer (Mais)
   =========================== */

.bottom-nav{ display:none; }
.mnav-overlay{ display:none; }
.mnav-drawer{ display:none; }

@media (max-width: 980px){
  .layout{
    grid-template-columns: 1fr;
  }

  .sidebar{
    display:none;
  }

  .grid{
    grid-template-columns: 1fr;
  }

  .main{
    padding-bottom: 112px;
  }

  .bottom-nav{
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 9000;
    display: flex;
    gap: 6px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.90);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
  }

  .bottom-link{
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 6px;
    border-radius: 16px;
    border: 1px solid transparent;
    background: transparent;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    min-width:0;
  }

  .bottom-btn{
    appearance: none;
    border: 0;
    cursor: pointer;
    font: inherit;
  }

  .bottom-link.is-active{
    background: linear-gradient(135deg, rgba(233,197,113,.16), rgba(197,113,233,.10));
    border-color: rgba(197,113,233,.16);
  }

  .bottom-ico{
    color: var(--primary-ink);
    display:grid;
    place-items:center;
  }

  .bottom-txt{
    font-size:12px;
    font-weight:950;
    color:var(--text);
    text-align:center;
  }

  .mnav-overlay{
    display:block;
    position: fixed;
    inset: 0;
    z-index: 9500;
    background: rgba(62,49,80,.42);
    backdrop-filter: blur(10px);
  }

  .mnav-overlay[hidden]{ display:none; }

  .mnav-drawer{
    display:flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(92vw, 420px);
    z-index: 9600;
    background: rgba(255,255,255,.98);
    border-left: 1px solid var(--line);
    border-radius: 22px 0 0 22px;
    box-shadow: -18px 0 45px rgba(62,49,80,.18);
    overflow: hidden;
  }

  .mnav-drawer[hidden]{ display:none; }

  .mnav-top{
    flex: 0 0 auto;
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fffdfa 0%, #fff 100%);
  }

  .mnav-brand{
    display:flex;
    align-items:center;
    gap:10px;
    min-width:0;
    border-radius: 12px;
  }

  .mnav-mark{
    width: 36px;
    height: 36px;
    display:grid;
    place-items:center;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(233,197,113,.18), rgba(197,113,233,.14));
    color:var(--primary-ink);
    border:1px solid var(--line);
  }

  .mnav-title{
    font-weight: 950;
    letter-spacing: -.02em;
    color:var(--text);
  }

  .mnav-sub{
    font-size: 12px;
    opacity: .76;
    color:var(--muted);
  }

  .mnav-close{
    width: 40px;
    height: 40px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.94);
    cursor: pointer;
    color:var(--primary-ink);
  }

  .mnav-body{
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px 14px;
  }

  .mnav-footer{
    flex: 0 0 auto;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,.96);
    font-size: 12px;
    opacity: .75;
    color:var(--muted);
  }

  .mnav-clinic{
    padding: 8px 0 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
  }

  .mnav-clinic-label{
    display:block;
    font-size:12px;
    opacity:.78;
    margin-bottom:6px;
    color:var(--muted);
  }

  .mnav-clinic-select{
    width:100%;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.96);
    outline: none;
    font-weight: 900;
    color:var(--text);
  }

  .mnav-clinic-select:focus{
    border-color: rgba(197,113,233,.36);
    box-shadow: 0 0 0 4px rgba(197,113,233,.10);
  }

  .mnav-clinic-hint{
    margin-top:6px;
    font-size:12px;
    opacity:.74;
    color:var(--muted);
  }

  .mnav-grid{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 4px 0 14px;
  }

  .mnav-card{
    display:flex;
    align-items:center;
    gap:10px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow2);
    text-decoration:none;
    color: inherit;
    min-height: 60px;
    min-width:0;
  }

  .mnav-card-ico{
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display:grid;
    place-items:center;
    background: linear-gradient(135deg, rgba(233,197,113,.16), rgba(197,113,233,.10));
    color:var(--primary-ink);
    flex: 0 0 auto;
  }

  .mnav-card-txt{
    font-weight: 950;
    font-size: 14px;
    line-height: 1.15;
    color:var(--text);
  }

  .mnav-card.is-active{
    outline: 2px solid rgba(197,113,233,.18);
    background: linear-gradient(135deg, rgba(233,197,113,.10), rgba(197,113,233,.06));
  }

  .mnav-sections{
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }

  .mnav-row{
    display:flex;
    align-items:center;
    gap:10px;
    padding: 12px 12px;
    border-radius: 14px;
    text-decoration:none;
    color: inherit;
    min-width:0;
  }

  .mnav-row:hover{
    background: rgba(197,113,233,.06);
  }

  .mnav-row-ico{
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display:grid;
    place-items:center;
    background: linear-gradient(135deg, rgba(233,197,113,.16), rgba(197,113,233,.10));
    color:var(--primary-ink);
    flex: 0 0 auto;
  }

  .mnav-row-end{
    margin-left:auto;
    opacity:.55;
    display:grid;
    place-items:center;
    color:var(--muted);
  }

  .mnav-row.is-danger{
    color: #a64117;
  }

  .mnav-row.is-danger .mnav-row-ico{
    background: rgba(233,197,113,.16);
    color: var(--accent1-ink);
  }
}

@media (max-width: 820px){
  .topbar{
    flex-direction:column;
    align-items:stretch;
  }

  .top-right{
    width:100%;
    justify-content:flex-start;
    flex-wrap:wrap;
  }

  .mini-grid,
  .kpis{
    grid-template-columns:1fr;
  }
}

@media (max-width: 560px){
  .main{
    padding-left:14px;
    padding-right:14px;
  }

  .title{
    font-size:24px;
  }

  .subtitle{
    font-size:14px;
  }

  .mnav-grid{
    grid-template-columns:1fr;
  }
}