/* COPLAN PORTAL — OBSIDIAN & GOLD luxury palette */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700;800&display=swap');

:root[data-theme="dark"], :root {
  /* Graphite luxury - more sophisticated than pure black */
  --bg: #15161A;
  --bg2: #1A1C20;
  --bg3: #22252B;
  --card: #1E2026;
  --card-h: #25282F;
  --bdr: #2E3138;
  --brd: #2E3138;
  --txt: #E8E4DD; --fg: #E8E4DD; --mut: #8A8580;
  --g: #C9A96E; --gold: #C9A96E; --gold-dark: #A89968; --gold-light: #D4B788;
  --warm-white: #F5F0E8;
  --teal: #5C8B8B; --b: #6B7A8F; --purple: #7B6F5C; --pink: #A67C52;
  --yel: #C9A96E; --red: #B85C5C; --grn: #7A8B6F; --orange: #C9893E;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --sh: 0 4px 20px rgba(0,0,0,.5); --sh-lg: 0 10px 40px rgba(0,0,0,.7);
  --sh-gold: 0 0 30px rgba(201,169,110,.15);
}
:root[data-theme="light"] {
  /* Backgrounds — off-white quente */
  --bg: #FAF6EF;
  --bg2: #F4EDE0;
  --bg3: #EBE3D2;
  --card: #FFFFFF;
  --card-h: #FAF6EF;
  --bdr: #D9CFB8;
  --brd: #D9CFB8;
  
  /* Texto — preto profundo */
  --txt: #1A1A1A;
  --fg: #1A1A1A;
  --mut: #6B5F4B;
  --warm-white: #1A1A1A;
  
  /* Status mantidos */
  --teal: #4A7373;
  --b: #5A6577;
  --purple: #6B5F4B;
  --pink: #8B6841;
  --yel: #B89657;
  --red: #A04848;
  --grn: #6B7A5E;
  --orange: #B57A30;
  
  /* Gold escurecido para contraste em fundo claro */
  --g: #A88A4F;
  --gold: #A88A4F;
  --gold-dark: #8B7340;
  --gold-light: #C9A96E;
  
  /* Sombras suaves */
  --sh: 0 2px 12px rgba(0,0,0,.08);
  --sh-lg: 0 8px 32px rgba(0,0,0,.15);
  --sh-gold: 0 0 30px rgba(168,138,79,.15);
}

/* Light theme tweaks */









































* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--txt); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
html { font-size: 14px; }
html.fs-small { font-size: 12px; }
html.fs-normal { font-size: 14px; }
html.fs-large { font-size: 17px; }

h1, h2, h3, .pg-title { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; letter-spacing: .5px; color: var(--txt); }
.pg-title { font-size: 28px; font-weight: 600; letter-spacing: 1px; margin-bottom: 4px; }
.pg-sub { font-size: 11px; color: var(--mut); letter-spacing: 3px; text-transform: uppercase; font-weight: 500; margin-bottom: 24px; }
.sec-title { font-family: 'Cormorant Garamond', serif; font-size: 18px; font-weight: 600; color: var(--txt); margin: 20px 0 12px; letter-spacing: .5px; }

#app, #ap { min-height: 100vh; }
#sb { width: 240px; background: var(--bg2); border-right: 1px solid var(--bdr); display: flex; flex-direction: column; flex-shrink: 0; transition: transform .3s; }
#sb.closed { transform: translateX(-100%); }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#pc { flex: 1; padding: 24px; overflow-y: auto; max-width: 100%; }

.sb-hdr { padding: 20px 18px; border-bottom: 1px solid var(--bdr); display: flex; align-items: center; gap: 12px; }
.sb-hdr .logo { width: 42px; height: 42px; border-radius: 8px; background: linear-gradient(135deg, #FFF 0%, #F5F0E8 100%); display: flex; align-items: center; justify-content: center; font-family: 'Cormorant Garamond', serif; font-weight: 700; font-size: 22px; color: #1A1A1A; box-shadow: 0 2px 10px rgba(201,169,110,.2); }
.sb-hdr .br-name { font-family: 'Cormorant Garamond', serif; font-size: 14px; font-weight: 600; letter-spacing: 3px; color: var(--gold); text-transform: uppercase; }
.sb-hdr .br-tag { font-size: 9px; color: var(--mut); letter-spacing: 2px; margin-top: 2px; }

.nav-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 18px; background: transparent; border: none; color: var(--mut); text-align: left; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .2s; border-left: 2px solid transparent; letter-spacing: .3px; }
.nav-btn:hover { background: var(--bg3); color: var(--txt); }
.nav-btn.active { background: linear-gradient(90deg, rgba(201,169,110,.08) 0%, transparent 100%); color: var(--gold); border-left-color: var(--gold); }
.nav-btn svg { flex-shrink: 0; }
.nav-btn .badge { margin-left: auto; background: var(--gold); color: #0A0A0A; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 8px; letter-spacing: 0; }

.sb-user { margin-top: auto; padding: 16px 18px; border-top: 1px solid var(--bdr); display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%); display: flex; align-items: center; justify-content: center; color: #1A1A1A; font-weight: 700; font-family: 'Cormorant Garamond', serif; font-size: 16px; flex-shrink: 0; }

.card { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--r-lg); padding: 16px; transition: all .2s; }
.card-click { cursor: pointer; }
.card-click:hover { background: var(--card-h); border-color: rgba(201,169,110,.3); }

.btn-primary { background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%); color: #0A0A0A; border: none; padding: 12px 24px; border-radius: var(--r-md); font-weight: 600; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; transition: all .2s; font-family: 'Inter', sans-serif; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--sh-gold); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-sm { background: var(--gold); color: #0A0A0A; border: none; padding: 8px 14px; border-radius: var(--r-sm); font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; transition: all .2s; }
.btn-sm:hover { background: var(--gold-light); }
.btn-out { background: transparent; border: 1px solid var(--bdr); color: var(--txt); }
.btn-out:hover { border-color: var(--gold); color: var(--gold); }
.btn-icon { background: transparent; border: 1px solid var(--bdr); color: var(--mut); width: 32px; height: 32px; border-radius: var(--r-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all .2s; }
.btn-icon:hover { border-color: var(--gold); color: var(--gold); }

.ts-btn { background: transparent; border: 1px solid var(--bdr); color: var(--mut); padding: 8px 16px; border-radius: var(--r-sm); font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; cursor: pointer; transition: all .2s; font-family: 'Inter', sans-serif; }
.ts-btn:hover { color: var(--txt); border-color: var(--mut); }
.ts-btn.active { background: rgba(201,169,110,.08); border-color: var(--gold); color: var(--gold); }

.inp, .sel { width: 100%; background: var(--bg3); border: 1px solid var(--bdr); color: var(--txt); padding: 12px 14px; border-radius: var(--r-md); font-size: 14px; font-family: 'Inter', sans-serif; outline: none; transition: border-color .2s; }
.inp:focus, .sel:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,169,110,.1); }
textarea.inp { resize: vertical; min-height: 80px; }
.lbl { display: block; font-size: 10px; font-weight: 600; color: var(--mut); text-transform: uppercase; letter-spacing: 2px; margin: 14px 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.modal-ov { position: fixed; inset: 0; background: rgba(0,0,0,.85); backdrop-filter: blur(8px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade-in .25s; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--bg2); border: 1px solid var(--bdr); border-radius: var(--r-xl); padding: 28px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: var(--sh-lg); }
.modal-lg { max-width: 720px; }
.modal-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--bdr); }
.modal-title span { font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 600; color: var(--gold); letter-spacing: .5px; }

.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-100px); background: var(--card); border: 1px solid var(--gold); color: var(--gold); padding: 14px 24px; border-radius: var(--r-md); font-size: 13px; font-weight: 500; z-index: 2000; transition: transform .35s cubic-bezier(.22,1,.36,1); box-shadow: var(--sh-lg); letter-spacing: .5px; }
.toast.show { transform: translateX(-50%) translateY(0); }

.pbar { background: var(--bg3); border-radius: 10px; overflow: hidden; height: 6px; }
.pfill { height: 100%; background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 100%); border-radius: 10px; transition: width .6s cubic-bezier(.22,1,.36,1); }

.hl-card { background: linear-gradient(135deg, rgba(201,169,110,.04) 0%, transparent 100%); border: 1px solid rgba(201,169,110,.2); border-radius: var(--r-lg); padding: 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
.hl-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #0A0A0A; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 10px; font-weight: 600; letter-spacing: .5px; }

#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at top, rgba(201,169,110,.04) 0%, transparent 50%), var(--bg); padding: 20px; }
.login-box { background: var(--card); border: 1px solid var(--bdr); border-radius: var(--r-xl); padding: 40px 32px; width: 100%; max-width: 400px; box-shadow: var(--sh-lg); position: relative; overflow: hidden; }
.login-box::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%); }
.login-logo { width: 70px; height: 70px; border-radius: 12px; background: linear-gradient(135deg, #FFF 0%, #F5F0E8 100%); display: flex; align-items: center; justify-content: center; font-family: 'Cormorant Garamond', serif; font-weight: 700; font-size: 36px; color: #1A1A1A; margin: 0 auto 16px; box-shadow: 0 4px 20px rgba(201,169,110,.2); }
.login-title { font-family: 'Cormorant Garamond', serif; font-size: 14px; font-weight: 500; text-align: center; letter-spacing: 4px; color: var(--gold); text-transform: uppercase; }
.login-sub { font-size: 10px; text-align: center; letter-spacing: 3px; color: var(--mut); margin-top: 4px; margin-bottom: 28px; text-transform: uppercase; }
.login-portal { font-family: 'Cormorant Garamond', serif; font-size: 22px; text-align: center; color: var(--txt); margin-bottom: 24px; font-weight: 500; }

@media (max-width: 768px) {
  #sb { position: fixed; top: 0; left: 0; bottom: 0; z-index: 999; width: 240px; transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,.5); }
  #sb.open { transform: translateX(0); }
  #pc { padding: 16px; }
  .modal { padding: 20px; }
  .pg-title { font-size: 22px; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bdr); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

table { width: 100%; border-collapse: collapse; }
th { font-size: 10px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--mut); padding: 10px; text-align: left; border-bottom: 1px solid var(--bdr); }
td { padding: 10px; border-bottom: 1px solid var(--bdr); font-size: 13px; color: var(--txt); }

.med-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.s-card { background: var(--bg3); border: 1px solid var(--bdr); border-radius: var(--r-md); padding: 12px; text-align: center; }
.s-card .s-val { font-size: 18px; font-weight: 700; color: var(--gold); margin-bottom: 4px; }
.s-card .s-lbl { font-size: 9px; color: var(--mut); letter-spacing: 1.5px; text-transform: uppercase; }

.ed-toolbar { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; background: var(--bg3); border: 1px solid var(--bdr); border-radius: var(--r-md) var(--r-md) 0 0; border-bottom: none; }
.ed-btn { background: transparent; border: none; color: var(--mut); padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; transition: all .15s; }
.ed-btn:hover { background: var(--bg2); color: var(--gold); }
.ed-area { min-height: 200px; padding: 12px; background: var(--bg3); border: 1px solid var(--bdr); border-radius: 0 0 var(--r-md) var(--r-md); outline: none; color: var(--txt); font-family: 'Inter', sans-serif; font-size: 14px; line-height: 1.6; }
.ed-area:focus { border-color: var(--gold); }

details summary { outline: none; }
details summary::-webkit-details-marker { display: none; }

/* Welcome hero card - dashboard top */
.welcome-hero {
  position: relative;
  background: linear-gradient(135deg, #0F0F0F 0%, #1A1A1A 100%);
  border: 1px solid var(--bdr);
  border-radius: var(--r-xl);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 20px;
  overflow: hidden;
}
.welcome-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
}
.welcome-smoke, .welcome-smoke.s2 { display: none; }
.welcome-content { position: relative; z-index: 2; }
.welcome-logo {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  margin: 0 auto 12px;
  display: block;
  background: linear-gradient(135deg, #FFFFFF 0%, #F5F0E8 100%);
  padding: 6px;
  object-fit: contain;
  box-shadow: 0 4px 20px rgba(201,169,110,.2);
}
.welcome-brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 6px;
  color: var(--gold);
  text-transform: uppercase;
}
.welcome-sub {
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--mut);
  text-transform: uppercase;
  margin-top: 2px;
  margin-bottom: 20px;
}
.welcome-greeting {
  font-style: italic;
  color: var(--mut);
  font-size: 14px;
  font-family: 'Cormorant Garamond', serif;
}
.welcome-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--txt);
  letter-spacing: 1px;
  margin: 4px 0;
}
.welcome-subtitle {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--mut);
  text-transform: uppercase;
  margin-top: 4px;
}

@media (max-width: 600px) {
  .welcome-hero { padding: 20px 16px; }
  .welcome-name { font-size: 24px; }
  .welcome-logo { width: 50px; height: 50px; }
}

/* Fade in animation */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
:root { --anim: cubic-bezier(.22,1,.36,1); }

/* Settings bar tweaks */
.ts-btn { white-space: nowrap; }

/* Login form spacing */
#login .inp { margin-bottom: 12px; }
#login .btn-primary { width: 100%; margin-top: 8px; }

/* ═══════════════════════════════════════════════════════════
   ESTRUTURA DO APP — Topbar, Sidebar, Main
   ═══════════════════════════════════════════════════════════ */

/* Topbar - aparece em mobile */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg2);
  border-bottom: 1px solid var(--bdr);
  padding: 10px 14px;
  align-items: center;
  justify-content: space-between;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

.logo-area {
  padding: 20px 18px;
  border-bottom: 1px solid var(--bdr);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-area img {
  background: linear-gradient(135deg, #FFFFFF 0%, #F5F0E8 100%);
  padding: 4px;
  object-fit: contain;
  box-shadow: 0 2px 10px rgba(201,169,110,.15);
}

.portal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--txt);
  letter-spacing: 0.5px;
}

#nv {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.user-bottom {
  padding: 14px 16px;
  border-top: 1px solid var(--bdr);
}

.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  max-width: 100%;
  min-width: 0;
}

/* Overlay para sidebar drawer mobile */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
  z-index: 998;
}
.overlay.active {
  display: block;
}

/* App wrapper layout */
#app {
  min-height: 100vh;
  display: flex;
}
body.on-login #app {
  display: block;
}

/* ─── Login ─── */
.login-pg {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, rgba(201,169,110,.04) 0%, transparent 50%), var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--r-xl);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--sh-lg);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
}

/* Error box */
.err-box {
  background: rgba(184,92,92,.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--r-md);
  margin-bottom: 14px;
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVIDADE MOBILE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .topbar { display: flex; }
  
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform .3s;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
    height: 100vh;
  }
  .sidebar.open { transform: translateX(0); }
  
  .main-content {
    padding: 16px;
    width: 100%;
  }
  
  #app { flex-direction: column; }
}

/* ═══════════════════════════════════════════════════════════
   SPLASH SCREEN — Cinematic intro with smoke effect
   ═══════════════════════════════════════════════════════════ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: radial-gradient(ellipse at center, #1A1A1A 0%, #0A0A0A 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  transition: opacity .6s ease, transform .6s ease;
}

.splash.fade-out {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

/* Smoke layers */
.splash-smoke {
  position: absolute;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(201,169,110,.15) 0%, rgba(201,169,110,.05) 30%, transparent 70%);
  border-radius: 50%;
  filter: blur(60px);
  animation: smoke-drift 8s ease-in-out infinite;
  opacity: 0;
  pointer-events: none;
}
.splash-smoke.s2 {
  background: radial-gradient(circle, rgba(167,124,82,.12) 0%, rgba(167,124,82,.04) 30%, transparent 70%);
  animation: smoke-drift2 10s ease-in-out infinite;
  animation-delay: -2s;
}
.splash-smoke.s3 {
  background: radial-gradient(circle, rgba(91,139,139,.08) 0%, rgba(91,139,139,.02) 30%, transparent 70%);
  animation: smoke-drift3 12s ease-in-out infinite;
  animation-delay: -4s;
}

@keyframes smoke-drift {
  0% { transform: translate(-30%, 20%) scale(0.8); opacity: 0; }
  20% { opacity: .6; }
  50% { transform: translate(20%, -20%) scale(1.2); opacity: .8; }
  80% { opacity: .4; }
  100% { transform: translate(-30%, 20%) scale(0.8); opacity: 0; }
}
@keyframes smoke-drift2 {
  0% { transform: translate(30%, -20%) scale(0.9); opacity: 0; }
  25% { opacity: .5; }
  50% { transform: translate(-20%, 20%) scale(1.1); opacity: .7; }
  75% { opacity: .3; }
  100% { transform: translate(30%, -20%) scale(0.9); opacity: 0; }
}
@keyframes smoke-drift3 {
  0% { transform: translate(0, 30%) scale(1); opacity: 0; }
  30% { opacity: .4; }
  60% { transform: translate(10%, -10%) scale(1.3); opacity: .6; }
  100% { transform: translate(0, 30%) scale(1); opacity: 0; }
}

/* Content reveals from smoke */
.splash-content {
  position: relative;
  z-index: 2;
  text-align: center;
  opacity: 0;
  animation: splash-reveal 2.5s ease-out forwards;
  animation-delay: .5s;
}

@keyframes splash-reveal {
  0% { opacity: 0; transform: scale(0.92) translateY(20px); filter: blur(15px); }
  40% { opacity: .7; filter: blur(4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

.splash-logo-wrap {
  margin-bottom: 20px;
  display: inline-block;
  position: relative;
}

.splash-logo-wrap::before {
  content: '';
  position: absolute;
  inset: -20px;
  background: radial-gradient(circle, rgba(201,169,110,.3) 0%, transparent 60%);
  filter: blur(20px);
  z-index: -1;
  animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { opacity: .5; transform: scale(1); }
  50% { opacity: .9; transform: scale(1.1); }
}

.splash-logo {
  width: 110px;
  height: 110px;
  border-radius: 18px;
  background: linear-gradient(135deg, #FFFFFF 0%, #F5F0E8 100%);
  padding: 10px;
  object-fit: contain;
  box-shadow:
    0 10px 40px rgba(201,169,110,.4),
    0 0 80px rgba(201,169,110,.2),
    inset 0 0 0 1px rgba(255,255,255,.5);
}

.splash-brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 42px;
  font-weight: 600;
  letter-spacing: 14px;
  color: var(--gold);
  text-transform: uppercase;
  margin-top: 8px;
  margin-left: 14px; /* offset for letter-spacing */
  text-shadow: 0 2px 20px rgba(201,169,110,.4);
}

.splash-line {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
  margin: 16px auto;
  animation: line-grow 1.5s ease-out forwards;
  animation-delay: 1.5s;
  transform: scaleX(0);
  transform-origin: center;
}

@keyframes line-grow {
  to { transform: scaleX(1); width: 120px; }
}

.splash-sub {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 6px;
  color: var(--warm-white);
  text-transform: uppercase;
  font-weight: 300;
  margin-bottom: 24px;
  opacity: 0;
  animation: fade-in 1s ease-out forwards;
  animation-delay: 1.8s;
}

.splash-tagline {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--mut);
  letter-spacing: 1px;
  opacity: 0;
  animation: fade-in 1.5s ease-out forwards;
  animation-delay: 2.2s;
}

.splash-bottom {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--mut);
  text-transform: uppercase;
  opacity: 0;
  animation: fade-in 1s ease-out forwards;
  animation-delay: 2.5s;
}

/* Mobile splash */
@media (max-width: 600px) {
  .splash-logo { width: 90px; height: 90px; }
  .splash-brand { font-size: 32px; letter-spacing: 10px; margin-left: 10px; }
  .splash-sub { font-size: 10px; letter-spacing: 4px; }
  .splash-tagline { font-size: 13px; }
  .splash-smoke { width: 500px; height: 500px; }
}

@media (max-width: 380px) {
  .splash-logo { width: 76px; height: 76px; }
  .splash-brand { font-size: 28px; letter-spacing: 8px; margin-left: 8px; }
  .splash-bottom { bottom: 24px; font-size: 8px; }
}

/* Login pg full width fallback for browsers without :has() */
body.on-login #app { display: block !important; }
.login-pg { width: 100vw; max-width: 100%; }


/* ═══ Light theme overrides — must be at end for specificity ═══ */
:root[data-theme="light"] body { color: #1A1A1A; }
:root[data-theme="light"] .nav-btn.active {
  background: linear-gradient(90deg, rgba(168,138,79,.12) 0%, transparent 100%);
}
:root[data-theme="light"] .ts-btn.active {
  background: rgba(168,138,79,.12);
}
:root[data-theme="light"] .toast {
  background: var(--card);
  color: var(--gold);
  border-color: var(--gold);
}
:root[data-theme="light"] .login-card,
:root[data-theme="light"] .modal,
:root[data-theme="light"] .card {
  background: var(--card);
  border-color: var(--bdr);
  color: var(--txt);
}
:root[data-theme="light"] .inp,
:root[data-theme="light"] .sel,
:root[data-theme="light"] textarea {
  background: #FFFFFF;
  color: #1A1A1A;
  border-color: var(--bdr);
}
:root[data-theme="light"] .inp::placeholder { color: #999; }
:root[data-theme="light"] .welcome-hero {
  background: linear-gradient(135deg, #FFFFFF 0%, #FAF6EF 100%);
  border-color: var(--bdr);
}
:root[data-theme="light"] .welcome-name {
  color: #1A1A1A;
}
:root[data-theme="light"] .splash {
  background: radial-gradient(ellipse at center, #FFFFFF 0%, #F4EDE0 70%);
}
:root[data-theme="light"] .splash-brand {
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(168,138,79,.3);
}
:root[data-theme="light"] .splash-tagline,
:root[data-theme="light"] .splash-sub,
:root[data-theme="light"] .splash-bottom {
  color: var(--mut);
}
:root[data-theme="light"] .btn-out:hover {
  background: rgba(168,138,79,.08);
}
:root[data-theme="light"] .sidebar,
:root[data-theme="light"] #sb {
  background: var(--bg2);
}
:root[data-theme="light"] .topbar {
  background: var(--bg2);
}
:root[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg2); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--bdr); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: var(--gold); }
:root[data-theme="light"] .s-card {
  background: var(--bg);
  border-color: var(--bdr);
}
:root[data-theme="light"] .s-card .s-val { color: var(--gold); }
:root[data-theme="light"] .ed-toolbar,
:root[data-theme="light"] .ed-area {
  background: #FFFFFF;
  border-color: var(--bdr);
  color: #1A1A1A;
}
:root[data-theme="light"] .err-box {
  background: rgba(160,72,72,.08);
  color: var(--red);
  border-color: var(--red);
}
/* ═══ Garantias finais de contraste — ambos temas ═══ */

/* Placeholders sempre visíveis */
.inp::placeholder, .sel::placeholder, textarea.inp::placeholder {
  color: var(--mut);
  opacity: 0.7;
}

/* Garantir que sec-titles e h2/h3 sejam visíveis */
h1, h2, h3, .sec-title, .pg-title {
  color: var(--txt);
}

/* Garantir que <strong>/<b> herde a cor correta */
strong, b { color: inherit; }

/* Tags coloridas devem ter background com opacity, não cor fixa */
[style*="background:var(--red)20"],
[style*="background:var(--teal)20"],
[style*="background:var(--yel)20"],
[style*="background:var(--purple)20"] {
  /* These have hexa transparency that may not work as inline style */
}

/* Texto de erro/avisos garantido */
[style*="color:var(--red)"] { color: var(--red) !important; }

/* Garantir que os cards.s-val (KPIs grandes) sempre apareçam */
.s-card { color: var(--txt); }

/* Mode claro - garantir mais um nível de fix */
:root[data-theme="light"] .welcome-greeting,
:root[data-theme="light"] .welcome-subtitle {
  color: var(--mut);
}

:root[data-theme="light"] .pg-sub,
:root[data-theme="light"] .lbl,
:root[data-theme="light"] .stxt {
  color: var(--mut);
}

:root[data-theme="light"] .nav-btn { color: var(--mut); }
:root[data-theme="light"] .nav-btn:hover { color: var(--txt); }
:root[data-theme="light"] .nav-btn.active { color: var(--gold); }

:root[data-theme="light"] .ts-btn { color: var(--mut); }
:root[data-theme="light"] .ts-btn:hover { color: var(--txt); }
:root[data-theme="light"] .ts-btn.active { color: var(--gold); }

:root[data-theme="light"] .btn-out { color: var(--txt); }
:root[data-theme="light"] .btn-out:hover { color: var(--gold); }

:root[data-theme="light"] .btn-icon { color: var(--mut); }
:root[data-theme="light"] .btn-icon:hover { color: var(--gold); }

/* Tema escuro - texto branco em fundos brancos não pode acontecer */
:root[data-theme="dark"] [style*="background:#fff"],
:root[data-theme="dark"] [style*="background:#FFFFFF"] {
  color: #1A1A1A;
}

/* Tabelas em ambos os temas */
table { color: var(--txt); }
th { color: var(--mut); }
td { color: var(--txt); }

:root[data-theme="light"] th { background: var(--bg2); }

/* ═══ Settings bar compacta ═══ */
.topbar-settings {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: var(--r-md);
  font-size: 11px;
}

.topbar-settings .ts-lbl {
  font-size: 10px;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.topbar-settings .ts-group {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  overflow: hidden;
}

.topbar-settings .ts-group .ts-btn {
  border: none;
  border-radius: 0;
  padding: 6px 10px;
  font-size: 11px;
  border-right: 1px solid var(--bdr);
  min-width: 32px;
}

.topbar-settings .ts-group .ts-btn:last-child { border-right: none; }

.topbar-settings .ts-group .ts-btn.active {
  background: var(--gold);
  color: #0A0A0A;
  border-color: var(--gold);
}

@media (max-width: 480px) {
  .topbar-settings {
    gap: 6px;
    padding: 6px 8px;
    font-size: 10px;
  }
  .topbar-settings .ts-lbl {
    font-size: 9px;
    letter-spacing: 1px;
  }
  .topbar-settings .ts-group .ts-btn {
    padding: 5px 8px;
    font-size: 10px;
    min-width: 28px;
  }
}

/* ═══ AI Assistant — Luxury floating button ═══ */
#ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #0A0A0A;
  border: none;
  cursor: pointer;
  z-index: 800;
  box-shadow: 
    0 6px 24px rgba(201,169,110,.35),
    0 0 0 1px rgba(255,255,255,.1) inset;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .3s cubic-bezier(.22,1,.36,1);
}

#ai-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 
    0 8px 32px rgba(201,169,110,.5),
    0 0 0 1px rgba(255,255,255,.15) inset;
}

#ai-fab svg {
  animation: ai-rotate 12s linear infinite;
}

@keyframes ai-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.fab-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4CAF50;
  border: 2px solid var(--bg);
  animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* AI Chat panel */
#ai-chat {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--r-xl);
  z-index: 801;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-lg);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all .3s cubic-bezier(.22,1,.36,1);
  pointer-events: none;
  overflow: hidden;
}

#ai-chat.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#ai-chat-head {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #0A0A0A;
}

#ai-chat-head h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #0A0A0A;
  margin: 0;
  display: flex;
  align-items: center;
}

#ai-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg2);
}

#ai-chat-msgs .msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

#ai-chat-msgs .msg.user {
  align-self: flex-end;
  background: var(--gold);
  color: #0A0A0A;
  border-bottom-right-radius: 4px;
}

#ai-chat-msgs .msg.bot {
  align-self: flex-start;
  background: var(--card);
  color: var(--txt);
  border: 1px solid var(--bdr);
  border-bottom-left-radius: 4px;
}

#ai-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--card);
  border-top: 1px solid var(--bdr);
}

#ai-inp {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 10px 12px;
  border-radius: 22px;
  font-size: 13px;
  outline: none;
  font-family: 'Inter', sans-serif;
}

#ai-inp:focus { border-color: var(--gold); }

.ai-btn {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--gold);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  flex-shrink: 0;
}

.ai-btn:hover {
  background: var(--gold);
  color: #0A0A0A;
  border-color: var(--gold);
}

#ai-mic-btn.recording {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  animation: rec-pulse 1s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196,92,92,.5); }
  50% { box-shadow: 0 0 0 8px rgba(196,92,92,0); }
}

@media (max-width: 600px) {
  #ai-fab { width: 50px; height: 50px; bottom: 16px; right: 16px; }
  #ai-chat {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 80px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
}

/* Light theme AI tweaks */
:root[data-theme="light"] #ai-fab {
  box-shadow: 0 6px 20px rgba(168,138,79,.3);
}
:root[data-theme="light"] #ai-chat {
  background: #FFFFFF;
}
:root[data-theme="light"] .fab-dot {
  border-color: var(--bg);
}

/* ═══ Garantia anti-texto-invisível ═══ */
/* Caso algum elemento tenha color: var(--bdr) ou var(--brd) por engano,
   o opacity garante que ainda seja visível */
[style*="color:var(--brd)"],
[style*="color:var(--bdr)"] {
  color: var(--mut) !important;
}

/* Garantir que cards e seus textos sempre tenham contraste mínimo */
.card { color: var(--txt); }
.card .pg-sub, .card .mut { color: var(--mut); }

/* Valores monetários sempre visíveis */
[style*="R$"], .num, [class*="valor"] {
  color: inherit;
}

/* ═══════════════════════════════════════════════════════════
   FILTROS — Filter bar e inputs/selects luxury
   ═══════════════════════════════════════════════════════════ */

.filter-bar {
  display: flex;
  gap: 10px;
  margin: 16px 0;
  flex-wrap: wrap;
  align-items: center;
}

.filter-inp,
.filter-sel {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: all .2s;
  min-height: 40px;
  font-weight: 500;
}

.filter-inp {
  flex: 1;
  min-width: 180px;
}

.filter-inp:focus,
.filter-sel:focus {
  border-color: var(--gold);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(201,169,110,.1);
}

.filter-inp::placeholder { color: var(--mut); opacity: .8; }

/* Custom select arrow - replace native */
.filter-sel,
.sel,
select.inp {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath d='M1 1l5 5 5-5' stroke='%23C9A96E' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}

.filter-sel {
  min-width: 140px;
}

/* Select options (dropdown items) styled by browser, but we can force */
select.filter-sel option,
.sel option,
select.inp option {
  background: var(--card);
  color: var(--txt);
  padding: 10px;
}

.filter-sel:hover,
.sel:hover {
  border-color: var(--gold);
  background: var(--card);
}

/* Date inputs */
input[type="date"].inp,
input[type="date"] {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

input[type="date"]:focus { border-color: var(--gold); }

/* Date picker icon */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7) sepia(1) saturate(2) hue-rotate(15deg);
  cursor: pointer;
  opacity: .7;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

input[type="time"] {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
}
input[type="time"]:focus { border-color: var(--gold); }

input[type="number"].inp,
input[type="text"].inp,
input[type="email"].inp,
input[type="password"].inp,
input[type="tel"].inp {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
}

/* Light theme adjustments for filters */
:root[data-theme="light"] .filter-inp,
:root[data-theme="light"] .filter-sel,
:root[data-theme="light"] input[type="date"],
:root[data-theme="light"] input[type="time"] {
  background: #FFFFFF;
  border-color: var(--bdr);
  color: var(--txt);
}

:root[data-theme="light"] .filter-sel,
:root[data-theme="light"] .sel,
:root[data-theme="light"] select.inp {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath d='M1 1l5 5 5-5' stroke='%23A88A4F' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
}

:root[data-theme="light"] select.filter-sel option,
:root[data-theme="light"] .sel option {
  background: #FFFFFF;
  color: #1A1A1A;
}

/* Mobile filter bar */
@media (max-width: 600px) {
  .filter-bar {
    gap: 8px;
  }
  .filter-inp,
  .filter-sel,
  input[type="date"],
  input[type="time"] {
    font-size: 14px; /* iOS minimum to prevent zoom */
    padding: 10px 12px;
    min-width: 0;
    flex: 1 1 calc(50% - 4px);
  }
  .filter-inp {
    flex: 1 1 100%;
  }
}


/* ═══ Garantia de containment - elementos não podem vazar do card ═══ */
.card {
  overflow: hidden;
  position: relative;
}

.card .pbar,
.card [class*="pbar"] {
  max-width: 100%;
}

/* Subitens dentro de card etapa */
.card > div[style*="border-top:1px solid var(--bdr)"] {
  width: 100%;
  box-sizing: border-box;
}

/* Flex children sempre min-width 0 */
.card > div[style*="flex:1"] {
  min-width: 0;
  flex: 1 1 0;
}

/* Subitem rows - garantir que percentual e valor não saiam */
.card div[style*="padding:4px 0 4px 12px"] {
  width: 100%;
  box-sizing: border-box;
}

/* Span com valor (R$ X.XXX,XX) não pode quebrar */
.card span[style*="flex-shrink:0"] {
  white-space: nowrap;
  max-width: 50%;
  text-align: right;
}

/* Mobile - se valor for muito grande, permite quebrar */
@media (max-width: 480px) {
  .card span[style*="flex-shrink:0"] {
    font-size: 10px;
    max-width: 60%;
  }
  .card div[style*="padding:4px 0 4px 12px"] {
    padding-left: 8px !important;
    gap: 6px !important;
  }
}

/* ═══ Espaçamento entre cards ═══ */
.card + .card {
  margin-top: 12px;
}

/* Para listagens (obras, etapas, relatórios, etc) — espaço entre cards */
#og .card,
#rl .card,
#etl .card,
.card-list .card {
  margin-bottom: 12px;
}

#og .card:last-child,
#rl .card:last-child,
#etl .card:last-child {
  margin-bottom: 0;
}

/* Etapa cards no cronograma têm espaço entre eles */
[id*="etapa"] .card,
.etapa-card {
  margin-bottom: 12px;
}

/* Cards dentro de div com flex direction column */
[style*="flex-direction:column"] > .card {
  margin-bottom: 12px;
}

/* Garantia geral - qualquer card subsequente tem margem */
.card {
  margin-bottom: 12px;
}

/* Mas não duplicar margem para cards aninhados */
.card .card {
  margin-bottom: 0;
}

/* Card-click (lista) sempre tem espaço */
.card.card-click {
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .card { margin-bottom: 10px; }
  .card + .card { margin-top: 10px; }
}

/* ═══════════════════════════════════════════════════════════
   FORM ELEMENTS — Classes que faltavam estilo
   ═══════════════════════════════════════════════════════════ */

/* Textareas */
.txtarea, textarea.txtarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color .2s;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.txtarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,169,110,.1);
}

.txtarea::placeholder { color: var(--mut); opacity: .8; }

/* Percentage inputs (small numeric) */
.pct-inp, .nm-pct {
  width: 60px;
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 6px 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  text-align: center;
  outline: none;
  font-weight: 600;
}

.pct-inp:focus, .nm-pct:focus {
  border-color: var(--gold);
  background: var(--card);
}

/* Editor select */
.ed-sel {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 12 8'%3e%3cpath d='M1 1l5 5 5-5' stroke='%23C9A96E' stroke-width='2' fill='none'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

/* Specific pedido edit inputs */
.edit-ped-mat, .epm,
.edit-ped-qtd, .epq,
.ept, .si-val, .pt-obs {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color .2s;
}

.edit-ped-mat:focus, .epm:focus,
.edit-ped-qtd:focus, .epq:focus,
.ept:focus, .si-val:focus, .pt-obs:focus {
  border-color: var(--gold);
  background: var(--card);
}

.pt-regime-sel {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 10px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6' viewBox='0 0 12 8'%3e%3cpath d='M1 1l5 5 5-5' stroke='%23C9A96E' stroke-width='2' fill='none'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 18px;
}

/* Status buttons (cronograma) */
.st-btn {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--txt);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  transition: all .2s;
  padding: 0;
}

.st-btn:hover {
  border-color: var(--gold);
  background: var(--card);
}

.st-btn.sd:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
.st-btn.sl:hover { background: var(--yel); color: #000; border-color: var(--yel); }
.st-btn.si-btn { background: var(--gold); color: #0A0A0A; border-color: var(--gold); }
.st-btn.si-btn:hover { background: var(--gold-light); }

/* Etapa Row (cronograma classic - legacy) */
.etapa-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg3);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  border: 1px solid var(--bdr);
  transition: border-color .2s;
}

.etapa-row:hover {
  border-color: var(--gold);
}

.etapa-nm {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--txt);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.etapa-bar {
  flex: 1.5;
  min-width: 100px;
  height: 22px;
  background: var(--bg2);
  border-radius: 11px;
  overflow: hidden;
  position: relative;
}

.etapa-fill {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border-radius: 11px;
  transition: width .5s cubic-bezier(.22,1,.36,1);
  min-width: 26px;
}

.etapa-ctrl {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

/* Mobile etapa-row */
@media (max-width: 600px) {
  .etapa-row {
    flex-wrap: wrap;
    padding: 8px;
    gap: 8px;
  }
  .etapa-nm {
    flex: 1 1 100%;
    font-size: 12px;
  }
  .etapa-bar {
    flex: 1 1 100%;
    min-width: 0;
  }
  .etapa-ctrl {
    flex: 1 1 100%;
    justify-content: flex-end;
  }
}

/* Card list helper */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card-list > .card { margin-bottom: 0; }

/* File inputs - estilo customizado */
input[type="file"] {
  background: var(--bg3);
  border: 1px dashed var(--bdr);
  color: var(--txt);
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  width: 100%;
}

input[type="file"]:hover { border-color: var(--gold); }

input[type="file"]::-webkit-file-upload-button,
input[type="file"]::file-selector-button {
  background: var(--gold);
  color: #0A0A0A;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  margin-right: 10px;
  transition: background .2s;
}

input[type="file"]::-webkit-file-upload-button:hover,
input[type="file"]::file-selector-button:hover {
  background: var(--gold-light);
}

/* Checkboxes */
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* Radio */
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* Color picker */
input[type="color"] {
  width: 50px;
  height: 36px;
  border: 1px solid var(--bdr);
  border-radius: 6px;
  background: var(--bg3);
  cursor: pointer;
  padding: 2px;
}

/* Light theme */
:root[data-theme="light"] .txtarea,
:root[data-theme="light"] .pct-inp,
:root[data-theme="light"] .nm-pct,
:root[data-theme="light"] .edit-ped-mat,
:root[data-theme="light"] .epm,
:root[data-theme="light"] .edit-ped-qtd,
:root[data-theme="light"] .epq,
:root[data-theme="light"] .ept,
:root[data-theme="light"] .si-val,
:root[data-theme="light"] .pt-obs,
:root[data-theme="light"] .pt-regime-sel,
:root[data-theme="light"] .ed-sel,
:root[data-theme="light"] input[type="file"] {
  background: #FFFFFF;
  color: #1A1A1A;
  border-color: var(--bdr);
}

:root[data-theme="light"] .st-btn {
  background: #FFFFFF;
  color: var(--txt);
}

:root[data-theme="light"] .etapa-row {
  background: #FFFFFF;
  border-color: var(--bdr);
}


/* ═══ Hamburger menu fix - força transformação no mobile ═══ */
@media (max-width: 768px) {
  .sidebar, #sb {
    transform: translateX(-100%) !important;
  }
  .sidebar.open, #sb.open {
    transform: translateX(0) !important;
  }
  
  .overlay {
    display: none !important;
  }
  .overlay.active {
    display: block !important;
  }
}

/* Esconde a topbar no desktop */
@media (min-width: 769px) {
  .topbar, #tb {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   PROGRESS CIRCLE — Gauge limpo e bem espaçado
   ═══════════════════════════════════════════════════════════ */
.prog-circle {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 16px;
}

.prog-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.prog-num {
  font-family: 'Cormorant Garamond', serif;
  font-size: 56px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
  letter-spacing: 1px;
}

.prog-pct {
  font-family: 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--mut);
  margin-left: 4px;
  vertical-align: top;
  position: relative;
  top: 8px;
}

.prog-lbl {
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--mut);
  font-weight: 600;
  text-transform: uppercase;
}

@media (max-width: 600px) {
  .prog-circle { width: 160px; height: 160px; }
  .prog-num { font-size: 48px; }
  .prog-pct { font-size: 18px; top: 6px; }
  .prog-lbl { font-size: 8px; letter-spacing: 3px; }
}

/* ═══════════════════════════════════════════════════════════
   ESPAÇAMENTO REAL ENTRE CARDS — força bruta
   ═══════════════════════════════════════════════════════════ */

/* Qualquer card que tem outro card ou div como irmão recebe margem */
.card ~ .card,
.card ~ div > .card:first-child {
  margin-top: 14px !important;
}

/* Cards consecutivos no mesmo container */
.card + .card {
  margin-top: 14px !important;
}

/* Container do cronograma específico */
.main-content > div > .card,
#pc > div > .card,
[id*="prog"] .card,
[id*="cron"] .card,
[id*="etapa"] .card {
  margin-bottom: 14px !important;
}

/* Containers que possam ter cards */
.main-content .card,
#pc .card {
  margin-bottom: 14px;
}

/* Mas remover margem do último filho */
.main-content > div > .card:last-child,
#pc > div > .card:last-child {
  margin-bottom: 0;
}

/* Card aninhado em outro card não tem margem */
.card .card {
  margin-bottom: 0 !important;
  margin-top: 0 !important;
}

/* Cards inline-flex (no flex container) com gap */
[style*="display:flex"][style*="flex-direction:column"],
[style*="display: flex"][style*="flex-direction: column"] {
  gap: 14px;
}

/* ═══ MARGEM FORÇADA EM TODOS OS CARDS — Última palavra ═══ */
.card {
  margin-bottom: 14px !important;
}

.timeline-item {
  margin-bottom: 14px;
}
.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-item .card {
  margin-bottom: 0 !important;
}

/* Mas não duplica em aninhados */
.card > .card,
.card .card {
  margin-bottom: 0 !important;
}

/* Último card de uma seção */
.card:last-of-type {
  margin-bottom: 14px !important;
}

/* ═══ Dashboard duo cards - mesma altura ═══ */
.dash-c-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
  align-items: stretch;
}

.dash-c-duo > .card {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center;
  min-height: 320px;
  padding: 20px 16px !important;
}

.dash-c-duo > .card h3 {
  width: 100%;
  margin-bottom: 16px;
}

.dash-c-duo > .card > div:not(h3) {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

@media (max-width: 600px) {
  .dash-c-duo {
    grid-template-columns: 1fr;
  }
  .dash-c-duo > .card {
    min-height: 280px;
  }
}

/* ═══════════════════════════════════════════════════════════
   DONUT CHART TEXT — Layout limpo e fixo
   ═══════════════════════════════════════════════════════════ */
.donut-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  width: auto;
  max-width: 70%;
}

.donut-num {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  line-height: 1;
}

.donut-val {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 36px;
  font-weight: 600;
  color: var(--txt);
  line-height: 1;
}

.donut-pct {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--mut);
  line-height: 1;
}

.donut-lbl {
  font-size: 8px;
  font-weight: 600;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 6px;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .donut-val { font-size: 30px; }
  .donut-pct { font-size: 12px; }
  .donut-lbl { font-size: 7px; letter-spacing: 1px; margin-top: 4px; }
}

/* Garantir que cards no dashboard NUNCA cortam conteúdo */
.dash-c-duo > .card {
  overflow: visible !important;
}

/* Container do duo - centralizar conteúdo */
.dash-c-duo > .card > div {
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   TABLET — Range 600px-1024px (iPad, Galaxy Tab, etc)
   ═══════════════════════════════════════════════════════════ */

/* Tablet portrait + landscape */
@media (min-width: 600px) and (max-width: 1024px) {
  /* Sidebar fica visível mas menor */
  #sb, .sidebar {
    width: 200px;
    transform: translateX(0) !important;
    position: sticky !important;
    top: 0;
  }
  
  .nav-btn {
    padding: 10px 14px;
    font-size: 12px;
    gap: 8px;
  }
  
  .nav-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .sb-hdr {
    padding: 16px 12px;
  }
  
  .sb-hdr .logo {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  
  .sb-hdr .br-name, .portal-title {
    font-size: 12px;
    letter-spacing: 2px;
  }
  
  .sb-hdr .br-tag {
    font-size: 8px;
  }
  
  /* Topbar mobile escondida em tablet */
  .topbar, #tb {
    display: none !important;
  }
  
  /* Overlay nunca aparece em tablet */
  .overlay, #ov {
    display: none !important;
  }
  
  /* Main content */
  .main-content, #pc {
    padding: 20px;
  }
  
  /* Page title menor */
  .pg-title {
    font-size: 24px;
  }
  
  .pg-sub {
    font-size: 10px;
    margin-bottom: 18px;
  }
  
  /* Cards com padding ajustado */
  .card {
    padding: 14px;
  }
  
  /* Grids 2 colunas no tablet */
  .med-summary {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  
  /* KPI cards - 2 colunas */
  [style*="grid-template-columns:repeat(5,1fr)"],
  [style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }
  
  /* Dash duo - mantém 2 colunas */
  .dash-c-duo {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  
  .dash-c-duo > .card {
    min-height: 280px;
    padding: 16px !important;
  }
  
  /* Welcome hero */
  .welcome-hero {
    padding: 22px 18px;
  }
  
  .welcome-name {
    font-size: 26px;
  }
  
  .welcome-logo {
    width: 54px;
    height: 54px;
  }
  
  /* Donut text */
  .donut-val {
    font-size: 32px;
  }
  
  .donut-pct {
    font-size: 13px;
  }
  
  .donut-lbl {
    font-size: 7px;
  }
  
  /* Tabs */
  .ts-btn {
    padding: 7px 12px;
    font-size: 10px;
  }
  
  /* Tabelas legíveis */
  table {
    font-size: 12px;
  }
  
  th, td {
    padding: 8px 6px;
  }
  
  /* Modal */
  .modal {
    max-width: 520px;
    padding: 24px;
  }
  
  /* Buttons */
  .btn-primary {
    padding: 11px 20px;
    font-size: 12px;
  }
  
  .btn-sm {
    padding: 7px 12px;
    font-size: 11px;
  }
  
  /* Inputs */
  .inp, .sel, .filter-inp, .filter-sel {
    padding: 11px 13px;
    font-size: 13px;
  }
  
  /* Chart areas - usar largura disponível */
  svg {
    max-width: 100%;
    height: auto;
  }
}

/* ═══ Tablet portrait apenas ═══ */
@media (min-width: 600px) and (max-width: 900px) and (orientation: portrait) {
  /* Em portrait, esconde sidebar e usa drawer */
  #sb, .sidebar {
    position: fixed !important;
    transform: translateX(-100%) !important;
    width: 240px;
    height: 100vh;
    top: 0; left: 0;
    z-index: 999;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  
  #sb.open, .sidebar.open {
    transform: translateX(0) !important;
  }
  
  /* Topbar aparece em portrait */
  .topbar, #tb {
    display: flex !important;
  }
  
  .overlay, #ov {
    display: none;
  }
  
  .overlay.active, #ov.active {
    display: block !important;
  }
  
  /* Main usa largura total */
  .main-content, #pc {
    width: 100%;
    max-width: 100%;
  }
  
  /* Dash duo vira 1 coluna em portrait pequeno */
  .dash-c-duo {
    grid-template-columns: 1fr;
  }
  
  .dash-c-duo > .card {
    min-height: 260px;
  }
}

/* ═══ iPad Pro / Tablet grande landscape ═══ */
@media (min-width: 1024px) and (max-width: 1366px) {
  .main-content, #pc {
    padding: 24px 28px;
  }
  
  .pg-title {
    font-size: 26px;
  }
  
  .card {
    padding: 16px;
  }
}

/* ═══════════════════════════════════════════════════════════
   KPI MINI STATS — Cards de KPI sem quebra de texto
   ═══════════════════════════════════════════════════════════ */
.ministat-card {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-top: 2px solid var(--gold);
  border-radius: var(--r-lg);
  padding: 14px 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.ministat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  opacity: .9;
}

.ministat-icon svg {
  width: 20px;
  height: 20px;
}

.ministat-val {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Inter', sans-serif;
  padding: 0 2px;
}

/* Auto-shrink for large numbers */
.ministat-val:has(> *),
.ministat-card .ministat-val {
  font-size: clamp(11px, 2vw, 18px);
}

.ministat-lbl {
  font-size: 8px;
  color: var(--mut);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 4px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .ministat-card { padding: 10px 6px; }
  .ministat-val { font-size: 14px; }
  .ministat-lbl { font-size: 7px; letter-spacing: 1px; }
}

@media (max-width: 480px) {
  .ministat-val { font-size: 12px; }
}

/* For long currency values like R$ 1.336.918,79 - use container query simulation */
.ministat-card .ministat-val {
  /* Use container-aware font sizing */
  font-size: min(18px, 8cqw, 4vw);
}

/* Fallback for browsers without container queries */
@supports not (container-type: inline-size) {
  .ministat-card .ministat-val {
    font-size: clamp(11px, 3.5vw, 18px);
  }
}
