/* ================================================================
   Sodril Eventos — Folha de estilos principal
   Editar este ficheiro para alterações visuais da aplicação.
   ================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Brand palette — rich teal + amber accent */
  --bg:       #F0F4F8;
  --bg2:      #FFFFFF;
  --bg3:      #F7F9FC;
  --bg4:      #EEF2F7;
  --border:   #DDE3ED;
  --border2:  #C8D0DF;
  --text:     #1A2035;
  --text2:    #5A6480;
  --text3:    #9AA3B8;
  --accent:   #0066FF;
  --accent2:  #E8F0FF;
  --accent3:  #003DB3;
  --teal:     #00B4A0;
  --teal2:    #E0F7F5;
  --green:    #00A86B;
  --green2:   #E0F7EF;
  --amber:    #F59E0B;
  --amber2:   #FEF3C7;
  --red:      #E53E3E;
  --red2:     #FFF0F0;
  --purple:   #7C3AED;
  --purple2:  #F3EEFF;
  --r:        10px;
  --r2:       14px;
  --r3:       20px;
  --sh:       0 2px 8px rgba(0,40,120,.07);
  --sh2:      0 4px 20px rgba(0,40,120,.10);
  --sh3:      0 8px 32px rgba(0,40,120,.13);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overscroll-behavior-y: contain;
  position: relative;
}
/* Esconder marca de água quando o login está visível */
body:has(#login-screen)::before { display: none !important; }

body::before {
  content: '';
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 200px;
  height: 115px;
  /* background-image removida — marca de água desativada */
  background-repeat: no-repeat;
  background-size: contain;
  background-position: bottom right;
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}
@media (max-width: 700px) {
  .tl-legenda-card { display: none; }
}

@media (max-width: 600px) {
  body::before {
    width: 130px;
    height: 75px;
    bottom: 80px;
    right: 15px;
    opacity: 0.05;
  }
}

/* Esconder marca de água quando o login está visível */
body:has(#login-screen)::before { display: none !important; }

body::before {
  content: '';
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 200px;
  height: 115px;
  /* background removida — marca de água desativada */
  opacity: 0.14;
  pointer-events: none;
  z-index: 0;
}
@media (max-width: 700px) {
  body::before { width: 130px; height: 75px; bottom: 80px; right: 15px; opacity: 0.11; }
}
.app, .header, .panel { position: relative; z-index: 1; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ── HEADER ── */
.header {
  background: linear-gradient(135deg, rgb(26,4,8) 0%, rgb(92,10,18) 35%, rgb(139,0,0) 65%, rgb(184,134,11) 100%);
  height: 62px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 4px 24px rgba(80,10,18,.4);
  border-bottom: 2px solid #FFD700;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #8B0000 0%, #B8860B 100%);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(184,134,11,.5);
  border: 1.5px solid rgba(255,215,0,.4);
}
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: -.03em; color: #fff; }
.brand-sub  { font-size: 10px; color: rgba(255,255,255,.5); margin-top: -1px; }
.hstats { display: flex; gap: 1.5rem; }
.hstat { text-align: right; }
.hstat-val { font-size: 20px; font-weight: 800; color: #FFD700; display: block; font-family: 'JetBrains Mono', monospace; line-height: 1.1; }
.hstat-lbl { font-size: 9px; color: rgba(255,235,200,.7); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }

/* ── LAYOUT ── */
.app { display: flex; min-height: calc(100vh - 58px); position: relative; }

/* ── SIDEBAR ── */
.sidebar {
  width: 210px; flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  position: sticky; top: 58px;
  height: calc(100vh - 58px); overflow-y: auto;
  box-shadow: 2px 0 12px rgba(0,20,80,.04);
  transition: width .25s ease;
}
.sidebar.collapsed { width: 56px; padding: 1.25rem 0; overflow-y: auto; }
.sidebar.collapsed .nav-lbl,
.sidebar.collapsed .nav-btn-text { display: none; }
.sidebar.collapsed .nav-btn { justify-content: center; padding: 9px 0; }
.sidebar.collapsed .nav-grp { padding: 0 .35rem; }
/* Botão de toggle da sidebar — fora da sidebar, posicionado em relação ao .app */
.sidebar-toggle {
  position: fixed; top: 70px; left: 194px; z-index: 200;
  width: 26px; height: 44px; border-radius: 0 8px 8px 0;
  border: none;
  border-right: 2px solid rgba(139,0,0,.5);
  border-top: 2px solid rgba(139,0,0,.5);
  border-bottom: 2px solid rgba(139,0,0,.5);
  background: linear-gradient(135deg, #8B0000 0%, #B30000 100%);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 3px 0 12px rgba(139,0,0,.3), inset -1px 0 0 rgba(255,255,255,.15);
  transition: left .25s ease, background .18s, box-shadow .18s, transform .18s;
  -webkit-tap-highlight-color: transparent;
}
.sidebar.collapsed ~ .sidebar-toggle,
body.sidebar-collapsed .sidebar-toggle { left: 40px; }
.sidebar-toggle:hover {
  background: linear-gradient(135deg, #A00000 0%, #CC0000 100%);
  box-shadow: 4px 0 16px rgba(139,0,0,.5), inset -1px 0 0 rgba(255,255,255,.2);
  transform: scaleX(1.08);
}
.sidebar-toggle svg { transition: transform .25s ease; }
body:not(.sidebar-collapsed) .sidebar-toggle svg { transform: rotate(0deg); }
body.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.nav-grp { padding: 0 .75rem; margin-bottom: 1.5rem; }
.nav-lbl {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text3);
  padding: 0 .5rem; margin-bottom: .5rem; display: block;
}
.nav-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 12px; border-radius: var(--r);
  border: none; background: none; cursor: pointer;
  color: var(--text2); font-size: 13px; font-weight: 500;
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-align: left; margin-bottom: 2px;
  transition: all .18s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  white-space: nowrap;
}
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.act {
  background: linear-gradient(135deg, #E8F0FF, #EEF5FF);
  color: var(--accent); font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-btn span { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

/* ── MAIN ── */
.main { flex: 1; padding: 1.5rem; min-width: 0; }

/* ── PANELS ── */
.panel { display: none; }
.panel.act { display: block; }

/* ── BOTTOM NAV ── */
.bnav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,20,80,.08);
  padding: 4px 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}
.bnav-inner { display: flex; justify-content: space-around; }
.bnav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  flex: 1; padding: 6px 4px; border: none; background: none;
  cursor: pointer; color: var(--text3); font-size: 10px; font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none; min-height: 48px;
}
.bnav-btn .ico { font-size: 19px; line-height: 1.2; display: block; }
.bnav-btn.act { color: var(--accent); }

/* ── PAGE HEADER ── */
.ph { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.ph-title { font-size: 22px; font-weight: 800; letter-spacing: -.04em; color: var(--text); }
.ph-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── STAT CARDS ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.5rem; }
.sc {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--r2); padding: 1rem 1.1rem;
  box-shadow: var(--sh); position: relative; overflow: hidden;
}
.sc::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
}
.sc-lbl { font-size: 10px; color: var(--text2); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.sc-val { font-size: 28px; font-weight: 800; letter-spacing: -.03em; font-family: 'JetBrains Mono', monospace; }
.sc-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.sc-bar { height: 3px; border-radius: 2px; background: var(--bg4); margin-top: 8px; overflow: hidden; }
.sc-bar-fill { height: 100%; border-radius: 2px; transition: width .6s cubic-bezier(.4,0,.2,1); }

/* ── CARDS ── */
.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--r2); margin-bottom: .85rem;
  box-shadow: var(--sh);
  transition: box-shadow .2s;
}
.card:focus-within { box-shadow: var(--sh2); }
.card-head {
  padding: .75rem 1.1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 4px;
  background: linear-gradient(to right, var(--bg3), #fff);
  border-radius: var(--r2) var(--r2) 0 0;
}
.card-title { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; color: var(--text); letter-spacing: -.01em; }
.card-body { padding: 1.1rem; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--r);
  font-size: 13px; font-weight: 700;
  cursor: pointer; border: none;
  font-family: 'Plus Jakarta Sans', sans-serif;
  white-space: nowrap;
  transition: all .18s cubic-bezier(.4,0,.2,1);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; user-select: none;
  letter-spacing: -.01em;
}
.btn-primary {
  background: linear-gradient(135deg, #0066FF, #0044CC);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,102,255,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,102,255,.45); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: var(--bg3); color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg4); color: var(--text); }
.btn-danger { background: var(--red2); color: var(--red); border: 1px solid #FFC5C5; }
.btn-danger:hover { background: #FFE0E0; }
.btn-sm { padding: 6px 13px; font-size: 12px; }
.btn-xs { padding: 5px 10px; font-size: 11px; }

/* ── ALERTS ── */
.alert { padding: 10px 14px; border-radius: var(--r); font-size: 13px; margin: .5rem 0; font-weight: 500; }
.a-ok   { background: var(--green2); color: #007A4F; border: 1px solid #A3E6CE; }
.a-warn { background: var(--amber2); color: #92600A; border: 1px solid #FCD47A; }
.a-err  { background: var(--red2);   color: var(--red);  border: 1px solid #FFC5C5; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.bg-g { background: var(--green2); color: #007A4F; }
.bg-a { background: var(--amber2); color: #92600A; }
.bg-r { background: var(--red2);   color: var(--red); }
.bg-n { background: var(--bg4);    color: var(--text2); }
.bg-p { background: var(--purple2); color: var(--purple); }

/* ── FORM ── */
.fg { display: grid; gap: 10px; margin-bottom: .85rem; }
.fg1 { grid-template-columns: 1fr; }
.fg2 { grid-template-columns: 1fr 1fr; }
.fg3 { grid-template-columns: 1fr 1fr 1fr; }
.fg4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.fld { display: flex; flex-direction: column; }
.fld label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text3); margin-bottom: 5px;
}
.fld input, .fld select, .fld textarea {
  font-size: 16px; padding: 9px 12px;
  border: 1.5px solid var(--border2); border-radius: var(--r);
  background: #fff; color: #1A2035;
  font-family: 'Plus Jakarta Sans', sans-serif;
  width: 100%; transition: all .18s;
  -webkit-appearance: none; appearance: none;
  position: relative; z-index: 1;
  touch-action: manipulation; min-height: 44px;
  font-weight: 600;
}
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,102,255,.12);
}
.fld input:hover:not(:focus), .fld select:hover:not(:focus) { border-color: var(--border2); background: #fff; }
.fld textarea { resize: vertical; min-height: 70px; }
.fld select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%239AA3B8' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px; cursor: pointer;
}
.fld input[disabled] { opacity: 1; cursor: not-allowed; background: var(--bg4); }
.num-note {
  font-size: 11px; color: var(--text3); font-style: italic;
  padding: 5px 9px; background: var(--amber2);
  border-radius: var(--r); border: 1px dashed #FCD47A; margin-top: 5px;
  color: #92600A;
}
.ssect {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--accent);
  display: flex; align-items: center; gap: 10px; margin: 1rem 0 .6rem;
}
.ssect::after { content: ''; flex: 1; height: 1.5px; background: linear-gradient(to right, var(--accent2), transparent); }

/* ── TABLE ── */
.tw { overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; border-radius: 0 0 var(--r2) var(--r2); }
.card:has(.tw) { overflow: visible; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead tr { background: linear-gradient(to right, var(--bg3), var(--bg4)); }
th {
  padding: 9px 10px; text-align: left; font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text2);
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg3); }

/* ── TIMELINE ── */
.tl { display: flex; flex-direction: column; }
.tl-row { display: flex; }
.tl-spine { width: 36px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 12px; flex-shrink: 0; border: 2px solid #fff; box-shadow: var(--sh); }
.tl-dot-m { background: var(--green); }
.tl-dot-d { background: var(--amber); }
.tl-line { width: 2px; background: var(--border); flex: 1; margin: 3px 0; border-radius: 1px; }
.tl-row:last-child .tl-line { display: none; }
.tl-body { flex: 1; padding: 8px 0 14px; }
.tl-meta { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; font-weight: 500; }
.tl-title { font-size: 14px; font-weight: 700; margin-top: 2px; }
.tl-detail { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── MISC ── */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text3); }
.empty-ico { font-size: 32px; opacity: .3; margin-bottom: .5rem; }
.frow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.frow label { font-size: 12px; color: var(--text2); font-weight: 600; }
.frow input, .frow select {
  padding: 8px 11px; border: 1.5px solid var(--border2); border-radius: var(--r);
  font-size: 14px; background: var(--bg3); color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif; min-height: 40px;
  -webkit-appearance: none; transition: border-color .18s;
}
.frow input:focus, .frow select:focus { outline: none; border-color: var(--accent); background: #fff; }
.dbar { height: 10px; border-radius: 5px; background: var(--bg4); overflow: hidden; margin: .5rem 0 .75rem; }
.dbar-fill { height: 100%; border-radius: 5px; transition: width .5s; }
.pg-wrap { border-radius: var(--r2); padding: 5px; margin-bottom: .85rem; }
.pg-wrap-1 { background: linear-gradient(135deg, #E8F0FF 0%, #F0F7FF 100%); border: 1.5px solid #C0D4FF; }
.pg-wrap-2 { background: linear-gradient(135deg, #F5F7FA 0%, #F0F4F8 100%); border: 1.5px solid var(--border); }
.pg-lbl { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 5px 10px 3px; display: block; }
.tag { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 10px; font-weight: 800; letter-spacing: .05em; }

/* ── REFRIGERADORES ── */
.ref-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ref-machine {
  background: linear-gradient(160deg, #F7F9FC, #EEF2F7);
  border: 1.5px solid var(--border); border-radius: var(--r2); padding: 10px;
  box-shadow: var(--sh);
  transition: border-color .25s;
}
.ref-num {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--accent);
  margin-bottom: 8px; padding-bottom: 6px;
  border-bottom: 2px solid var(--accent2);
  display: flex; align-items: center; gap: 6px;
  justify-content: space-between;
}
.ref-num::before { content: '🍺'; font-size: 12px; }
.ref-cat { margin-bottom: 6px; }
.ref-cat-lbl {
  font-size: 10px; font-weight: 700; color: var(--text2);
  margin-bottom: 3px; letter-spacing: .03em;
}
.cb-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer;
  padding: 4px 6px; min-height: 36px; border-radius: var(--r);
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; user-select: none;
}
.cb-item:hover { background: var(--accent2); }
.cb-item input[type=checkbox] {
  width: 17px; height: 17px; flex-shrink: 0;
  accent-color: var(--accent); cursor: pointer;
  touch-action: manipulation;
}

/* ── PAGE WRAP LABEL COLORS ── */
.pg-lbl-1 { color: var(--accent3); }
.pg-lbl-2 { color: var(--text2); }

.cliente-grid {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 1rem;
  align-items: start;
}
.cliente-sep {
  background: var(--border);
  width: 1px;
  align-self: stretch;
  margin: 4px 0;
}
.cliente-left, .cliente-right { min-width: 0; }

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .sidebar-toggle { display: none; }
  .cliente-grid { grid-template-columns: 1fr; }
  .cliente-sep { display: none; }
  .bnav { display: block; }
  .main { padding: 1rem 1rem 72px; }
  .hstats { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .ref-grid { grid-template-columns: 1fr 1fr; }
  .fg3, .fg4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  #global-search { display: none; }
  div:has(> #global-search) { display: none !important; }
  .fg2, .fg3, .fg4 { grid-template-columns: 1fr; }
  .ref-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .ph-title { font-size: 18px; }
  .main { padding: .75rem .75rem 72px; }
  .pg-wrap { padding: 3px; }
}

/* ── TABLET (portrait e landscape) ── */
@media (min-width: 541px) and (max-width: 1024px) {
  .main { padding: 1rem 1.25rem 72px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .ref-grid { grid-template-columns: repeat(3, 1fr); }
  .fg3 { grid-template-columns: 1fr 1fr 1fr; }
  .fg4 { grid-template-columns: 1fr 1fr; }
  .header { padding: 0 1rem; height: 58px; }
  .hstats { gap: 8px; }
  .hstat-val { font-size: 14px; }
  .hstat-lbl { font-size: 10px; }
  #global-search { width: 200px !important; }
}

/* ── TELEMÓVEL LANDSCAPE (rotação horizontal) ── */
@media (max-height: 500px) and (orientation: landscape) {
  .header { height: 48px; padding: 0 .75rem; }
  .main { padding: .5rem .75rem 60px; }
  .bnav { padding: 4px 0; }
  .bnav a { padding: 4px 8px; font-size: 11px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .ph-title { font-size: 16px; margin: .25rem 0; }
  .card-body { padding: .5rem .75rem; }
}

/* ── TABLES RESPONSIVAS (scroll horizontal em vez de quebrar) ── */
@media (max-width: 900px) {
  .tw, .panel table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel table { width: max-content; min-width: 100%; }
  .panel table td, .panel table th { white-space: nowrap; }
  table input[type="number"], table input[type="text"] { font-size: 16px !important; }
}

/* ── BOTÕES E INPUTS TOUCH-FRIENDLY (mínimo 44x44 px no iOS) ── */
@media (hover: none) and (pointer: coarse) {
  button, .btn, input[type="button"], input[type="submit"], select {
    min-height: 40px;
  }
  input[type="text"], input[type="number"], input[type="date"], input[type="time"], textarea {
    font-size: 16px; /* impede zoom automático no iOS ao focar */
  }
  .bnav a { min-height: 48px; display: flex; align-items: center; justify-content: center; }
}

/* ── SAFE AREA (iPhone com notch / Android com bordas) ── */
@supports (padding: env(safe-area-inset-bottom)) {
  .main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .bnav { padding-bottom: env(safe-area-inset-bottom); }
  .header { padding-left: calc(1.5rem + env(safe-area-inset-left)); padding-right: calc(1.5rem + env(safe-area-inset-right)); }
}

/* ── FERIADOS ── */
.fld input[type=date].feriado { border-color: #E53E3E; background: #FFF0F0; }
.feriado-aviso {
  font-size: 11px; color: #E53E3E; font-weight: 600;
  margin-top: 3px; display: none;
}
.feriado-aviso.show { display: block; }


/* ── Sticky table headers (eventos, dashboard, etc) ── */
.panel table.tbl-sticky thead {
  position: sticky;
  top: 62px;
  z-index: 11;
  background: var(--bg2);
}
.panel table.tbl-sticky thead th {
  background: var(--bg3) !important;
  border-bottom: 2px solid var(--border) !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

/* Campo bloqueado (visualização) */
.campo-bloqueado,
input.campo-bloqueado,
select.campo-bloqueado,
textarea.campo-bloqueado {
  background: #F8F9FB !important;
  color: #1A2035 !important;
  cursor: not-allowed !important;
  opacity: 1 !important;
  -webkit-text-fill-color: #1A2035 !important;
}

/* Detecção visual de alterações em edição */
.campo-alterado,
input.campo-alterado,
select.campo-alterado,
textarea.campo-alterado {
  border-color: #E53E3E !important;
  background: rgba(229,62,62,.05) !important;
  box-shadow: 0 0 0 3px rgba(229,62,62,.15) !important;
}
.campo-alterado::after {
  content: '● alterado';
}

#global-search::placeholder { color: rgba(255,255,255,.7) !important; font-weight: 500 !important; }

/* ── Fix browser autofill white background on login inputs ── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px rgba(15,5,10,.85) inset !important;
  -webkit-text-fill-color: #fff !important;
  caret-color: #fff;
  border-color: rgba(255,215,0,.45) !important;
  transition: background-color 9999s ease-in-out 0s;
}

/* ── Animação de saída do ecrã de login ── */
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
#login-screen.hidden { animation: fadeOut .5s forwards; }


/* ================================================================
   TEMA ESCURO — sobrepõe apenas as variáveis neutras.
   As cores de marca (accent, teal, amber, etc.) ficam iguais.
   ================================================================ */
[data-theme="dark"] {
  --bg:       #0F1419;
  --bg2:      #1A1F26;
  --bg3:      #232A33;
  --bg4:      #2B3340;
  --border:   #2F3845;
  --border2:  #3D4654;
  --text:     #E4E8EF;
  --text2:    #A0AAB8;
  --text3:    #6B7384;
  --accent2:  #1A2942;
  --teal2:    #143834;
  --green2:   #14322B;
  --amber2:   #3D2E0B;
  --red2:     #3D1E1E;
  --purple2:  #2A1F3D;
  --sh:       0 2px 8px rgba(0,0,0,.35);
  --sh2:      0 4px 20px rgba(0,0,0,.50);
  --sh3:      0 8px 32px rgba(0,0,0,.65);
}

/* No tema escuro, cartões e tabelas usam o fundo escuro adequado,
   mesmo onde estava hardcoded em background:#fff */
[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .sc-card {
  background: var(--bg2);
}
[data-theme="dark"] .card-head {
  background: linear-gradient(to right, var(--bg3), var(--bg2));
}
[data-theme="dark"] table { background: var(--bg2); }
[data-theme="dark"] tbody tr { background: var(--bg2); }
[data-theme="dark"] tbody tr:nth-child(even) td { background: var(--bg3); }
[data-theme="dark"] thead th { background: var(--bg3); color: var(--text2); }
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border2);
}
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
}
[data-theme="dark"] ::placeholder { color: var(--text3); opacity: .8; }

/* Botões "ghost" e tabs */
[data-theme="dark"] .btn-ghost {
  background: var(--bg3);
  color: var(--text2);
  border-color: var(--border2);
}
[data-theme="dark"] .btn-ghost:hover {
  background: var(--bg4);
  color: var(--text);
}
[data-theme="dark"] .badge.bg-n { background: var(--bg4); color: var(--text2); }
[data-theme="dark"] .nav-btn:hover { background: var(--bg3); color: var(--text); }
[data-theme="dark"] .search-results { background: var(--bg2) !important; border-color: var(--border) !important; }

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg2); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border2); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Alguns elementos com fundo branco hardcoded em inline styles */
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#FFFFFF"],
[data-theme="dark"] [style*="background: #FFFFFF"] {
  background: var(--bg2) !important;
}

/* Transição suave ao trocar de tema */
body, .card, .header, input, select, textarea, button {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* ══ DESKTOP — controlos à direita ══ */
@media (min-width: 901px) {
  .header > #header-controls { margin-left: auto; }
  .header > #sync-status { margin-left: .6rem; flex-shrink: 0; }
  .header > .hstats { margin-left: 1.5rem; flex-shrink: 0; }
}
/* ══ MOBILE ══ */
@media (max-width: 900px) {
  .header { height:auto !important; flex-wrap:wrap; padding:6px 10px !important; gap:4px; }
  .header > .brand { order:1; flex:0 0 100%; justify-content:center; padding:4px 0 2px; }
  .header > #header-controls { order:2; flex:0 0 100%; justify-content:center; margin-left:0; }
  .header > #sync-status { order:3; flex:0 0 100%; text-align:center; margin-left:0; font-size:10px !important; padding-bottom:4px; }
  #header-search { display:none !important; }
  .brand-icon { width:30px !important; height:30px !important; }

  /* Cobranças — cards verticais em mobile (versão óptima) */
  #cob-table-head { display: none !important; }
  .cob-grid {
    display: block !important;
    padding: 12px !important;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid var(--border) !important;
  }
  .cob-grid > div {
    padding: 4px 0 !important;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
  }
  .cob-grid > div:last-child { border-bottom: none; }
  .cob-grid > div::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: .05em;
    flex-shrink: 0;
  }
  .cob-cell-evento {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    text-align: right;
    font-weight: 600;
  }
}

/* ── VISTA MOBILE MOVIMENTOS ── */
.tl-mob-panel { display: none; }

@media (max-width: 700px) {
  /* Esconder tabela desktop, mostrar painel mobile */
  #tl-container, #tl-disp-card { display: none !important; }
  .tl-mob-panel { display: block; padding: 0 0 1rem; }
  .tl-grp-btns { display: none !important; }

  .tl-mob-header {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: .75rem;
  }
  .tl-mob-title {
    font-size: 15px; font-weight: 800; color: var(--text);
    margin-bottom: .75rem;
  }
  .tl-mob-dates {
    display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap;
  }
  .tl-mob-date-group { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 120px; }
  .tl-mob-label { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; }
  .tl-mob-input {
    padding: 8px 10px; border: 1.5px solid var(--border2); border-radius: 8px;
    font-size: 13px; font-weight: 600; background: var(--bg); color: var(--text);
    width: 100%;
  }
  .tl-mob-sep { font-size: 16px; font-weight: 700; color: var(--text3); padding-bottom: 8px; }
  .tl-mob-btn-hoje {
    padding: 8px 14px; font-size: 12px; font-weight: 700;
    border-radius: 8px; background: var(--accent2, #EBF5FF);
    color: var(--accent); border: 1.5px solid var(--accent);
    cursor: pointer; white-space: nowrap; align-self: flex-end;
  }

  .tl-mob-result { display: flex; flex-direction: column; gap: .5rem; }
  .tl-mob-empty {
    text-align: center; padding: 2rem 1rem;
    font-size: 13px; color: var(--text3); font-weight: 600;
  }
  .tl-mob-aviso {
    background: #FFF7ED; border: 1.5px solid #FED7AA;
    border-radius: 10px; padding: .6rem .9rem;
    font-size: 12px; color: #92400E; font-weight: 600;
    text-align: center;
  }
  .tl-mob-item {
    background: var(--bg3); border: 1.5px solid var(--border);
    border-radius: 12px; padding: .75rem 1rem;
  }
  .tl-mob-item.critico { border-color: #FCA5A5; background: #FFF5F5; }
  .tl-mob-item.ok { border-color: #A7F3D0; background: #F0FFF8; }
  .tl-mob-item-top {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .5rem;
  }
  .tl-mob-item-nome { font-size: 13px; font-weight: 700; color: var(--text); }
  .tl-mob-item-nums { font-size: 18px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
  .tl-mob-item-nums.critico { color: #DC2626; }
  .tl-mob-item-nums.ok { color: #059669; }
  .tl-mob-item-nums.aviso { color: #D97706; }
  .tl-mob-bar-bg {
    height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
  }
  .tl-mob-bar-fill {
    height: 100%; border-radius: 4px; transition: width .3s ease;
  }
  .tl-mob-item-sub {
    font-size: 10px; color: var(--text3); margin-top: 4px; font-weight: 600;
  }
  .tl-mob-sem-total {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 10px; padding: .6rem .9rem;
    display: flex; align-items: center; justify-content: space-between;
  }
  .tl-mob-sem-total-nome { font-size: 12px; font-weight: 700; color: var(--text2); }
  .tl-mob-sem-total-val { font-size: 16px; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--text); }
}

/* ── IMPRESSÃO MODAL SEMANAL ── */
@media print {
  body.print-modal-semana * { visibility: hidden; }
  body.print-modal-semana #modal-semana,
  body.print-modal-semana #modal-semana * { visibility: visible; }
  body.print-modal-semana #modal-semana {
    position: absolute; top: 0; left: 0; width: 100%;
    background: white; z-index: 99999; padding: 20px;
    box-shadow: none; border-radius: 0;
    display: block !important; overflow: visible !important;
    max-height: none !important; height: auto !important;
  }
  body.print-modal-semana #modal-semana > div {
    max-height: none !important; overflow: visible !important;
    height: auto !important;
  }
  body.print-modal-semana #modal-semana-body {
    overflow: visible !important; max-height: none !important;
    height: auto !important;
  }
  body.print-modal-semana .modal-semana-footer { display: none !important; }
}

/* ── MODO VENDEDOR — só visualização ── */
body.modo-vendedor #bn-novo,
body.modo-vendedor .nav-btn[onclick="navNovo()"] {
  display: none !important;
}
