/* ===================== RESET & BASE ===================== */
*{box-sizing:border-box;margin:0;padding:0;}
:root{
  --primary:#0F8B7C;
  --primary-dark:#0A6459;
  --primary-light:#E4F5F2;
  --accent:#2F6FED;
  --accent-light:#EAF0FE;
  --bg:#F4F7F8;
  --surface:#FFFFFF;
  --text:#152B33;
  --text-muted:#6C808A;
  --border:#E6EDEF;
  --danger:#E14B4B;
  --danger-light:#FCEAEA;
  --warning:#DC9A22;
  --warning-light:#FDF3E1;
  --success:#1B9E71;
  --success-light:#E3F6EE;
  --radius:14px;
  --shadow:0 1px 2px rgba(15,43,51,.05), 0 2px 8px rgba(15,43,51,.05);
  --shadow-md:0 8px 24px rgba(15,43,51,.09);
}
html,body{height:100%;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  font-size:14px;
}
.hidden{display:none !important;}
button{font-family:inherit;cursor:pointer;border:none;background:none;color:inherit;font-size:inherit;}
input,select,textarea{font-family:inherit;font-size:14px;color:var(--text);}
a{color:inherit;text-decoration:none;}
::-webkit-scrollbar{width:8px;height:8px;}
::-webkit-scrollbar-thumb{background:#C7D4D1;border-radius:8px;}

/* ===================== LOGIN ===================== */
#loginScreen{
  min-height:100vh;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(150deg,#0A6459 0%,#0F8B7C 42%,#2F6FED 130%);
  padding:20px;
}
.login-card{
  background:var(--surface);
  width:100%;max-width:390px;
  border-radius:22px;
  box-shadow:0 25px 60px rgba(0,0,0,.28);
  padding:42px 34px;
}
.login-logo{
  width:60px;height:60px;border-radius:16px;
  background:linear-gradient(135deg,var(--primary),var(--accent));
  display:flex;align-items:center;justify-content:center;
  font-size:26px;margin:0 auto 18px;box-shadow:var(--shadow-md);
}
.login-logo.has-image{background:#fff;padding:0;overflow:hidden;}
.login-logo.has-image img{width:100%;height:100%;object-fit:contain;display:block;}
.login-card h1{text-align:center;font-size:22px;font-weight:800;color:var(--text);letter-spacing:-.3px;}
.login-card .brand-tag{display:block;text-align:center;font-size:11px;font-weight:700;color:var(--primary);letter-spacing:1.5px;margin-top:2px;}
.login-card p.sub{text-align:center;color:var(--text-muted);font-size:13px;margin-top:8px;margin-bottom:28px;}
.field{margin-bottom:16px;}
.field label{display:block;font-size:12.5px;font-weight:600;color:var(--text-muted);margin-bottom:6px;letter-spacing:.2px;}
.field input,.field select,.field textarea{
  width:100%;padding:11px 13px;border:1.5px solid var(--border);border-radius:10px;
  outline:none;transition:border-color .15s,box-shadow .15s;background:#FCFDFD;
}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--primary);background:#fff;box-shadow:0 0 0 3px var(--primary-light);}
.field textarea{resize:vertical;min-height:70px;}
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  padding:11px 18px;border-radius:10px;font-weight:700;font-size:13.5px;
  transition:.15s;white-space:nowrap;
}
.btn-primary{background:var(--primary);color:#fff;box-shadow:0 2px 8px rgba(15,139,124,.25);}
.btn-primary:hover{background:var(--primary-dark);box-shadow:0 4px 12px rgba(15,139,124,.32);}
.btn-block{width:100%;}
.btn-secondary{background:var(--surface);color:var(--text);border:1.5px solid var(--border);}
.btn-secondary:hover{background:#F1F5F4;}
.btn-danger{background:var(--danger-light);color:var(--danger);}
.btn-danger:hover{background:#F6D5D5;}
.btn-ghost{background:transparent;color:var(--text-muted);}
.btn-ghost:hover{color:var(--text);background:#F1F5F4;}
.btn-sm{padding:7px 12px;font-size:12.5px;border-radius:8px;}
.btn-icon{width:34px;height:34px;padding:0;border-radius:8px;}
.login-hint{
  margin-top:22px;padding:12px 14px;background:var(--primary-light);border-radius:10px;
  font-size:12px;color:var(--primary-dark);line-height:1.6;
}
.login-error{
  background:var(--danger-light);color:var(--danger);padding:10px 12px;border-radius:8px;
  font-size:12.5px;margin-bottom:14px;font-weight:600;
}

/* ===================== APP SHELL ===================== */
#appShell{display:flex;min-height:100vh;}
#sidebar{
  width:246px;background:linear-gradient(180deg,#0A6459 0%,#0B4E45 100%);flex-shrink:0;
  display:flex;flex-direction:column;
  position:fixed;top:0;left:0;bottom:0;z-index:50;
  transition:transform .2s ease;
}
.sidebar-brand{
  display:flex;align-items:center;gap:11px;padding:24px 20px 20px;
  color:#fff;border-bottom:1px solid rgba(255,255,255,.1);
}
.sidebar-brand .logo-mark{
  width:38px;height:38px;border-radius:11px;background:rgba(255,255,255,.14);
  display:flex;align-items:center;justify-content:center;font-size:18px;flex-shrink:0;
}
.sidebar-brand .brand-txt{line-height:1.25;}
.sidebar-brand .brand-txt b{display:block;font-weight:800;font-size:15.5px;letter-spacing:-.2px;}
.sidebar-brand .brand-txt span{display:block;font-size:10px;font-weight:700;letter-spacing:2px;color:rgba(255,255,255,.55);}
#navList{list-style:none;padding:14px 10px;flex:1;overflow-y:auto;}
.nav-item{
  display:flex;align-items:center;gap:11px;padding:10px 12px;border-radius:10px;
  color:rgba(255,255,255,.72);font-size:13.5px;font-weight:500;cursor:pointer;
  margin-bottom:2px;transition:.12s;
}
.nav-item .ic{font-size:16px;width:20px;text-align:center;}
.nav-item:hover{background:rgba(255,255,255,.08);color:#fff;}
.nav-item.active{background:var(--accent);color:#fff;box-shadow:0 4px 12px rgba(47,111,237,.35);}
.sidebar-foot{padding:14px 16px 18px;border-top:1px solid rgba(255,255,255,.1);}
.user-chip{display:flex;align-items:center;gap:10px;margin-bottom:10px;}
.user-avatar{
  width:36px;height:36px;border-radius:50%;background:rgba(255,255,255,.16);
  display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:13px;
}
.user-chip-info{color:#fff;overflow:hidden;}
.user-chip-info .name{font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.user-chip-info .role{font-size:11px;color:rgba(255,255,255,.6);}
.logout-btn{width:100%;color:rgba(255,255,255,.75);font-size:12.5px;text-align:left;padding:8px 4px;font-weight:600;}
.logout-btn:hover{color:#fff;}

#mainArea{flex:1;margin-left:246px;display:flex;flex-direction:column;min-width:0;}
#topbar{
  height:64px;background:var(--surface);border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;padding:0 28px;
  position:sticky;top:0;z-index:30;
}
.topbar-left{display:flex;align-items:center;gap:14px;}
#menuToggle{display:none;font-size:20px;}
#screenTitle{font-size:18px;font-weight:800;letter-spacing:-.3px;}
#screenSubtitle{font-size:12.5px;color:var(--text-muted);margin-top:1px;}
#content{padding:26px 28px 60px;max-width:1400px;width:100%;margin:0 auto;}
.overlay-bg{position:fixed;inset:0;background:rgba(10,25,20,.4);z-index:40;display:none;}
.overlay-bg.show{display:block;}
.greeting{margin-bottom:22px;}
.greeting h1{font-size:21px;font-weight:800;letter-spacing:-.3px;}
.greeting p{font-size:13px;color:var(--text-muted);margin-top:3px;}

/* ===================== DASHBOARD ===================== */
.cards-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:16px;margin-bottom:26px;}
.stat-card{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:20px;box-shadow:var(--shadow);transition:.15s;
}
.stat-card:hover{box-shadow:var(--shadow-md);transform:translateY(-1px);}
.stat-card .stat-label{font-size:11.5px;color:var(--text-muted);font-weight:700;margin-bottom:10px;text-transform:uppercase;letter-spacing:.4px;}
.stat-card .stat-value{font-size:25px;font-weight:800;letter-spacing:-.4px;}
.stat-card.accent-primary .stat-value{color:var(--primary);}
.stat-card.accent-warning .stat-value{color:var(--warning);}
.stat-card.accent-danger .stat-value{color:var(--danger);}
.stat-card.accent-accent .stat-value{color:var(--accent);}

.section-block{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);margin-bottom:22px;overflow:hidden;}
.section-head{display:flex;align-items:center;justify-content:space-between;padding:18px 22px;border-bottom:1px solid var(--border);flex-wrap:wrap;gap:10px;}
.section-head h2{font-size:15px;font-weight:800;letter-spacing:-.1px;}
.section-head .muted{font-size:12px;color:var(--text-muted);font-weight:600;}
.section-body{padding:20px 22px;}

.due-item{
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  padding:14px 16px;border:1px solid var(--border);border-radius:12px;margin-bottom:10px;flex-wrap:wrap;
  transition:.12s;
}
.due-item:hover{border-color:#CFE0DC;background:#FAFDFC;}
.due-item:last-child{margin-bottom:0;}
.due-info{display:flex;flex-direction:column;gap:2px;}
.due-info .client{font-weight:700;font-size:13.5px;}
.due-info .product{font-size:12.5px;color:var(--text-muted);}
.due-badges{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.due-actions{display:flex;gap:8px;}

.badge{display:inline-flex;align-items:center;gap:4px;padding:4px 11px;border-radius:20px;font-size:11.5px;font-weight:700;}
.badge-warning{background:var(--warning-light);color:var(--warning);}
.badge-danger{background:var(--danger-light);color:var(--danger);}
.badge-success{background:var(--success-light);color:var(--success);}
.badge-muted{background:#EEF2F1;color:var(--text-muted);}
.badge-accent{background:var(--accent-light);color:var(--accent);}

/* ===================== ACTIVITY / CHARTS ===================== */
.activity-item{display:flex;gap:12px;padding:11px 0;border-bottom:1px solid var(--border);}
.activity-item:last-child{border-bottom:none;}
.activity-dot{width:8px;height:8px;border-radius:50%;background:var(--accent);margin-top:6px;flex-shrink:0;}
.activity-item .at{font-size:11px;color:var(--text-muted);}
.activity-item .tx{font-size:13px;}
.chart-grid{display:grid;grid-template-columns:1fr 1fr;gap:20px;}
@media(max-width:900px){.chart-grid{grid-template-columns:1fr;}}
.bar-chart{display:flex;align-items:flex-end;gap:10px;height:150px;padding-top:10px;}
.bar-chart .bar-col{flex:1;display:flex;flex-direction:column;align-items:center;gap:6px;height:100%;justify-content:flex-end;}
.bar-chart .bar{width:100%;max-width:34px;background:linear-gradient(180deg,var(--accent),var(--primary));border-radius:6px 6px 0 0;min-height:3px;}
.bar-chart .bar-lbl{font-size:10.5px;color:var(--text-muted);font-weight:600;}
.hbar-row{display:flex;align-items:center;gap:10px;margin-bottom:12px;}
.hbar-row:last-child{margin-bottom:0;}
.hbar-lbl{width:110px;font-size:12px;font-weight:600;flex-shrink:0;}
.hbar-track{flex:1;background:#EEF2F1;border-radius:6px;height:10px;overflow:hidden;}
.hbar-fill{height:100%;border-radius:6px;background:var(--primary);}
.hbar-val{width:34px;text-align:right;font-size:12px;font-weight:700;color:var(--text-muted);}

/* ===================== BUSCA GLOBAL / ALERTAS / TIMELINE ===================== */
.global-search-wrap{position:relative;width:340px;max-width:40vw;}
.global-search-wrap .sic{position:absolute;left:12px;top:50%;transform:translateY(-50%);font-size:13px;color:var(--text-muted);}
.global-search-wrap input{width:100%;padding:9px 12px 9px 34px;border:1.5px solid var(--border);border-radius:10px;background:var(--bg);font-size:13px;outline:none;}
.global-search-wrap input:focus{border-color:var(--primary);background:#fff;}
.global-search-results{
  position:absolute;top:calc(100% + 6px);left:0;right:0;background:#fff;border:1px solid var(--border);
  border-radius:12px;box-shadow:var(--shadow-md);max-height:60vh;overflow-y:auto;display:none;z-index:80;
}
.gsr-group{padding:8px 0;border-bottom:1px solid var(--border);}
.gsr-group:last-child{border-bottom:none;}
.gsr-label{font-size:10.5px;font-weight:800;color:var(--text-muted);letter-spacing:.6px;padding:4px 14px;}
.gsr-item{display:flex;flex-direction:column;padding:8px 14px;cursor:pointer;}
.gsr-item:hover{background:var(--primary-light);}
.gsr-item strong{font-size:13px;}
.gsr-item span{font-size:11.5px;color:var(--text-muted);}
.gsr-empty{padding:16px;text-align:center;font-size:12.5px;color:var(--text-muted);}

.alert-bell-wrap{position:relative;}
.icon-btn{position:relative;font-size:19px;padding:8px;border-radius:10px;background:transparent;}
.icon-btn:hover{background:var(--bg);}
.alert-badge{
  position:absolute;top:2px;right:2px;background:var(--danger);color:#fff;font-size:10px;font-weight:800;
  border-radius:20px;min-width:16px;height:16px;display:flex;align-items:center;justify-content:center;padding:0 4px;
}
.alerts-panel{
  position:absolute;top:calc(100% + 8px);right:0;width:340px;max-width:88vw;background:#fff;border:1px solid var(--border);
  border-radius:14px;box-shadow:var(--shadow-md);max-height:70vh;overflow-y:auto;z-index:80;
}
.alerts-panel.hidden{display:none;}
.alerts-panel-head{padding:14px 16px;font-weight:800;font-size:13.5px;border-bottom:1px solid var(--border);}
.alert-group-label{font-size:10.5px;font-weight:800;color:var(--text-muted);letter-spacing:.6px;padding:10px 16px 4px;}
.alert-row{display:flex;flex-direction:column;padding:9px 16px;cursor:pointer;border-bottom:1px solid var(--border);}
.alert-row:hover{background:var(--primary-light);}
.alert-row strong{font-size:12.5px;}
.alert-row span{font-size:11.5px;color:var(--text-muted);}

.timeline{position:relative;padding-left:22px;}
.timeline::before{content:'';position:absolute;left:5px;top:4px;bottom:4px;width:2px;background:var(--border);}
.timeline-item{position:relative;padding-bottom:16px;}
.timeline-item:last-child{padding-bottom:0;}
.timeline-item::before{content:'';position:absolute;left:-22px;top:3px;width:10px;height:10px;border-radius:50%;background:var(--primary);border:2px solid #fff;box-shadow:0 0 0 1px var(--primary);}
.timeline-item .tl-date{font-size:11px;color:var(--text-muted);font-weight:600;}
.timeline-item .tl-text{font-size:13px;margin-top:1px;}
.detail-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:4px 20px;}
.detail-grid .dl{font-size:11.5px;color:var(--text-muted);font-weight:700;margin-top:8px;}
.detail-grid .dv{font-size:13.5px;font-weight:600;}

/* ===================== TOOLBAR & TABLES ===================== */
.toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:16px;}
.search-wrap{position:relative;flex:1;min-width:200px;max-width:340px;}
.search-wrap input{width:100%;padding:10px 14px 10px 34px;border:1.5px solid var(--border);border-radius:10px;background:#fff;outline:none;}
.search-wrap input:focus{border-color:var(--primary);}
.search-wrap .sic{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--text-muted);font-size:14px;}
.table-wrap{width:100%;max-width:100%;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);}
table{width:max-content;min-width:100%;border-collapse:collapse;}
thead th{
  text-align:left;font-size:11.5px;text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);
  padding:12px 16px;background:#FAFBFB;border-bottom:1px solid var(--border);font-weight:700;white-space:nowrap;
}
tbody td{padding:13px 16px;border-bottom:1px solid var(--border);font-size:13.5px;vertical-align:middle;}
tbody tr:last-child td{border-bottom:none;}
tbody tr:hover{background:#FAFCFB;}
.row-actions{display:flex;gap:6px;}
.cell-strong{font-weight:700;}
.cell-muted{color:var(--text-muted);}
.prod-thumb{width:34px;height:34px;border-radius:8px;object-fit:cover;background:#EEF2F1;}
.prod-thumb-ph{width:34px;height:34px;border-radius:8px;background:var(--primary-light);display:flex;align-items:center;justify-content:center;font-size:15px;}

.empty-state{text-align:center;padding:50px 20px;color:var(--text-muted);}
.empty-state .ic{font-size:34px;margin-bottom:10px;}
.empty-state p{font-size:13.5px;}

/* ===================== MODAL ===================== */
.modal-overlay{
  position:fixed;inset:0;background:rgba(10,25,20,.45);z-index:100;
  display:flex;align-items:center;justify-content:center;padding:20px;
}
.modal-box{
  background:var(--surface);border-radius:16px;width:100%;max-width:560px;
  max-height:90vh;overflow-y:auto;box-shadow:0 25px 60px rgba(0,0,0,.3);
}
.modal-box.wide{max-width:720px;}
.modal-head{display:flex;align-items:center;justify-content:space-between;padding:20px 24px;border-bottom:1px solid var(--border);position:sticky;top:0;background:var(--surface);z-index:2;}
.modal-head h3{font-size:16px;font-weight:700;}
.modal-close{font-size:18px;color:var(--text-muted);width:30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center;}
.modal-close:hover{background:#F1F5F4;color:var(--text);}
.modal-body{padding:22px 24px;}
.modal-foot{display:flex;justify-content:flex-end;gap:10px;padding:16px 24px;border-top:1px solid var(--border);position:sticky;bottom:0;background:var(--surface);}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;}
.form-grid .full{grid-column:1/-1;}
@media(max-width:520px){.form-grid{grid-template-columns:1fr;}}

/* ===================== RENTAL CALC ===================== */
.calc-box{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin:16px 0;}
.calc-tile{background:var(--primary-light);border-radius:12px;padding:14px;text-align:center;}
.calc-tile .lbl{font-size:11px;font-weight:700;color:var(--primary-dark);text-transform:uppercase;letter-spacing:.3px;margin-bottom:6px;}
.calc-tile .val{font-size:19px;font-weight:800;color:var(--primary-dark);letter-spacing:-.3px;}
@media(max-width:480px){.calc-box{grid-template-columns:1fr;}}

/* ===================== PRINT DOCS (cupom/recibo) ===================== */
.doc-preview{font-family:'Courier New',monospace;font-size:12.5px;line-height:1.55;background:#fff;padding:18px;border:1px dashed var(--border);border-radius:8px;}
.doc-preview .doc-center{text-align:center;}
.doc-preview .doc-divider{border-top:1px dashed #999;margin:10px 0;}
.doc-preview .doc-row{display:flex;justify-content:space-between;gap:8px;}
.doc-preview .doc-total{font-weight:700;font-size:14px;}
.doc-preview h4{font-size:14px;margin-bottom:2px;}

/* ===================== MISC ===================== */
.status-dot{width:8px;height:8px;border-radius:50%;display:inline-block;margin-right:6px;}
.dot-primary{background:var(--primary);}
.dot-warning{background:var(--warning);}
.dot-danger{background:var(--danger);}
.dot-muted{background:#B7C2BF;}
.mt-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:18px;}
.tag-status{padding:5px 10px;border-radius:7px;font-size:11.5px;font-weight:700;}
.step-track{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap;}
.step{padding:6px 12px;border-radius:8px;font-size:12px;font-weight:700;background:#EEF2F1;color:var(--text-muted);}
.step.done{background:var(--success-light);color:var(--success);}
.step.current{background:var(--primary);color:#fff;}
.info-line{font-size:12.5px;color:var(--text-muted);margin-top:2px;}
.photo-upload{display:flex;align-items:center;gap:12px;}
.photo-preview{width:60px;height:60px;border-radius:10px;object-fit:cover;background:var(--primary-light);}
.report-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px;}
.client-search-results{border:1px solid var(--border);border-radius:10px;margin-top:6px;max-height:220px;overflow-y:auto;background:#fff;}
.client-search-item{padding:10px 12px;border-bottom:1px solid var(--border);cursor:pointer;font-size:13px;}
.client-search-item:last-child{border-bottom:none;}
.client-search-item:hover{background:var(--primary-light);}
.client-search-item .csi-name{font-weight:700;}
.client-selected-card{background:var(--primary-light);border-radius:12px;padding:14px;margin-top:6px;}
.client-selected-card .csc-title{font-size:11px;font-weight:700;color:var(--primary-dark);text-transform:uppercase;letter-spacing:.3px;margin-bottom:6px;}
.client-selected-card .csc-name{font-weight:800;font-size:15px;margin-bottom:2px;}

/* ===================== RESPONSIVE ===================== */
@media(max-width:900px){
  /* No celular, as tabelas viram cartões. Não é mais necessário arrastar para o lado. */
  #content .table-wrap{width:100%;max-width:100%;overflow:visible;border:none;background:transparent;border-radius:0;}
  #content .table-wrap table{width:100%;min-width:0;display:block;background:transparent;}
  #content .table-wrap thead{display:none;}
  #content .table-wrap tbody{display:block;width:100%;}
  #content .table-wrap tbody tr{
    display:block;width:100%;margin:0 0 12px;background:var(--surface);border:1px solid var(--border);
    border-radius:14px;overflow:hidden;box-shadow:0 2px 8px rgba(10,25,20,.04);
  }
  #content .table-wrap tbody tr:last-child{margin-bottom:0;}
  #content .table-wrap tbody tr:hover{background:var(--surface);}
  #content .table-wrap tbody td{
    display:flex;align-items:flex-start;justify-content:space-between;gap:14px;width:100%;padding:11px 14px;
    border-bottom:1px solid var(--border);font-size:13px;white-space:normal;word-break:break-word;
  }
  #content .table-wrap tbody td:last-child{border-bottom:none;}
  #content .table-wrap tbody td::before{
    content:attr(data-label);flex:0 0 42%;font-size:10.5px;font-weight:800;text-transform:uppercase;
    letter-spacing:.35px;color:var(--text-muted);padding-top:2px;
  }
  #content .table-wrap tbody td:empty::before{content:'';}
  #content .table-wrap tbody td[colspan]{display:block;text-align:center;padding:0;border:none;}
  #content .table-wrap tbody td[colspan]::before{display:none;}
  #content .table-wrap .row-actions{justify-content:flex-end;flex-wrap:wrap;}
  #content .table-wrap td:last-child .btn{max-width:100%;}
  #sidebar{transform:translateX(-100%);}
  #sidebar.open{transform:translateX(0);}
  #mainArea{margin-left:0;min-width:0;overflow-x:hidden;}
  #menuToggle{display:block;}
  #content{padding:18px 14px 50px;max-width:100%;overflow-x:hidden;}
  .form-grid{grid-template-columns:1fr;}
}
@media(max-width:480px){
  #content .table-wrap tbody td{gap:10px;padding:10px 12px;}
  #content .table-wrap tbody td::before{flex-basis:40%;font-size:10px;}
}

/* ===================== PRINT ===================== */
@media print{
  body.printing #appShell, body.printing #loginScreen, body.printing .modal-overlay, body.printing .overlay-bg{display:none !important;}
  body.printing #printArea{display:block !important;position:absolute;top:0;left:0;width:100%;}
  #printArea{display:none;}
  @page{size:A4;margin:4mm;}
}

/* Modernização visual segura */
:root{--modern-bg:#f6f8fb;--modern-card:#fff;--modern-border:#e7ebf0;--modern-primary:#2563eb;--modern-ink:#172033;--modern-muted:#667085}
body{background:var(--modern-bg);color:var(--modern-ink)}
.section-block,.table-wrap,.modal-content,.stat-card,.calc-box{border-radius:16px!important;border:1px solid var(--modern-border)!important;box-shadow:0 8px 28px rgba(16,24,40,.05)!important;background:var(--modern-card)}
.btn{border-radius:10px!important;font-weight:700!important;transition:.18s transform,.18s box-shadow}.btn:hover{transform:translateY(-1px);box-shadow:0 6px 16px rgba(16,24,40,.12)}
input,select,textarea{border-radius:10px!important;border-color:#d8dee8!important;min-height:42px}input:focus,select:focus,textarea:focus{outline:none!important;border-color:var(--modern-primary)!important;box-shadow:0 0 0 3px rgba(37,99,235,.12)!important}
.section-head{padding:18px 20px!important}.section-head h2{font-size:16px!important}.section-body{padding:20px!important}.modal-head{padding:18px 22px!important}.modal-body{padding:22px!important}.modal-foot{padding:16px 22px!important}
@media(max-width:760px){.section-body,.modal-body{padding:14px!important}.calc-box{grid-template-columns:1fr!important}}

/* =========================================================
   HOSPIMED — DESIGN SYSTEM 2026
   Modernização exclusivamente visual. Nenhuma regra de PHP,
   API, MySQL ou JavaScript é alterada neste bloco.
   ========================================================= */
:root{
  --h-bg:#f4f7fb;
  --h-surface:#ffffff;
  --h-surface-soft:#f8fafc;
  --h-ink:#162033;
  --h-muted:#738097;
  --h-line:#e5eaf1;
  --h-primary:#2563eb;
  --h-primary-2:#1747c7;
  --h-primary-soft:#edf3ff;
  --h-sidebar:#111a2e;
  --h-sidebar-2:#18243d;
  --h-success:#159a70;
  --h-warning:#d98a15;
  --h-danger:#df4e58;
  --h-radius:18px;
  --h-radius-sm:12px;
  --h-shadow:0 10px 30px rgba(24,36,61,.055);
  --h-shadow-lg:0 20px 55px rgba(17,26,46,.14);
}

body{background:var(--h-bg)!important;color:var(--h-ink)!important;font-size:14px;letter-spacing:.005em}
body::selection{background:rgba(37,99,235,.18)}
#appShell{background:var(--h-bg)}

/* Sidebar moderna */
#sidebar{
  width:272px!important;
  background:linear-gradient(180deg,var(--h-sidebar) 0%,#142039 52%,#0f1729 100%)!important;
  box-shadow:10px 0 35px rgba(17,26,46,.08);
}
.sidebar-brand{padding:24px 20px 22px!important;border-bottom:1px solid rgba(255,255,255,.075)!important}
.sidebar-brand .logo-mark{
  width:44px!important;height:44px!important;border-radius:14px!important;
  background:linear-gradient(135deg,#2f73ff,#2255c9)!important;
  box-shadow:0 10px 25px rgba(37,99,235,.28);
}
.sidebar-brand .brand-txt b{font-size:17px!important;letter-spacing:.01em!important}
.sidebar-brand .brand-txt span{font-size:9.5px!important;letter-spacing:2.4px!important;color:#9cadc9!important;margin-top:3px}
#navList{padding:18px 12px!important}
.nav-item{
  min-height:46px;padding:11px 13px!important;margin:3px 0!important;border-radius:13px!important;
  color:#aeb9cc!important;font-weight:650!important;transition:background .18s,color .18s,transform .18s!important;
}
.nav-item .ic{font-size:17px!important;width:23px!important;filter:saturate(.8)}
.nav-item:hover{background:rgba(255,255,255,.065)!important;color:#fff!important;transform:translateX(2px)}
.nav-item.active{background:linear-gradient(135deg,#2f73ff,#2457cf)!important;color:#fff!important;box-shadow:0 10px 22px rgba(20,75,202,.28)!important}
.sidebar-foot{padding:16px!important;background:rgba(0,0,0,.09)!important;border-top:1px solid rgba(255,255,255,.07)!important}
.user-chip{padding:8px!important;border-radius:14px!important;background:rgba(255,255,255,.045)!important;margin-bottom:9px!important}
.user-avatar{width:38px!important;height:38px!important;background:linear-gradient(135deg,#2d72ff,#274da8)!important}
.user-chip-info .name{font-size:12.5px!important}.user-chip-info .role{color:#8fa0bc!important}
.logout-btn{border-radius:10px!important;padding:10px!important;color:#aeb9cc!important}.logout-btn:hover{background:rgba(255,255,255,.06)!important;color:#fff!important}

/* Área principal e topo */
#mainArea{margin-left:272px!important;background:var(--h-bg)!important}
#topbar{
  height:76px!important;padding:0 32px!important;background:rgba(255,255,255,.92)!important;
  border-bottom:1px solid rgba(229,234,241,.92)!important;backdrop-filter:blur(16px);box-shadow:0 4px 18px rgba(17,26,46,.025)!important;
}
.topbar-left{gap:16px!important}
#screenTitle{font-size:20px!important;font-weight:800!important;letter-spacing:-.025em!important;color:var(--h-ink)!important}
#screenSubtitle{font-size:12px!important;color:var(--h-muted)!important;margin-top:3px!important}
#menuToggle{width:40px!important;height:40px!important;border:1px solid var(--h-line)!important;border-radius:12px!important;background:#fff!important}
#content{max-width:1500px!important;padding:30px 32px 64px!important}
.greeting{margin-bottom:26px!important}.greeting h1{font-size:25px!important;letter-spacing:-.035em!important}.greeting p{font-size:13px!important;color:var(--h-muted)!important;margin-top:6px!important}

/* Cards, blocos e métricas */
.section-block,.stat-card,.table-wrap,.modal-box{
  background:var(--h-surface)!important;border:1px solid var(--h-line)!important;border-radius:var(--h-radius)!important;box-shadow:var(--h-shadow)!important;
}
.section-block{overflow:hidden!important;margin-bottom:20px!important}
.section-head{min-height:70px;padding:19px 22px!important;background:linear-gradient(180deg,#fff,#fcfdff)!important;border-bottom:1px solid var(--h-line)!important}
.section-head h2{font-size:15px!important;font-weight:800!important;color:var(--h-ink)!important;letter-spacing:-.015em!important}
.section-head .muted{color:var(--h-muted)!important}
.section-body{padding:22px!important}
.cards-grid{gap:18px!important;margin-bottom:22px!important}
.stat-card{padding:20px!important;min-height:132px!important;position:relative!important;overflow:hidden!important;transition:transform .2s,box-shadow .2s,border-color .2s!important}
.stat-card::after{content:'';position:absolute;right:-24px;bottom:-38px;width:100px;height:100px;border-radius:50%;background:linear-gradient(135deg,rgba(37,99,235,.10),rgba(37,99,235,0));pointer-events:none}
.stat-card:hover{transform:translateY(-3px)!important;box-shadow:0 18px 38px rgba(17,26,46,.10)!important;border-color:#d7e1f1!important}
.stat-card .stat-label{font-size:10.5px!important;letter-spacing:.08em!important;color:var(--h-muted)!important}
.stat-card .stat-value{font-size:28px!important;line-height:1!important;color:var(--h-ink)!important;margin-top:12px!important}
.stat-card.accent-primary .stat-value{color:var(--h-primary)!important}.stat-card.accent-warning .stat-value{color:var(--h-warning)!important}.stat-card.accent-danger .stat-value{color:var(--h-danger)!important}.stat-card.accent-accent .stat-value{color:#7c4dff!important}

/* Botões */
.btn{min-height:40px;padding:10px 16px!important;border-radius:12px!important;font-weight:750!important;letter-spacing:.005em!important;box-shadow:none!important;transition:transform .18s,box-shadow .18s,background .18s,border-color .18s!important}
.btn:hover{transform:translateY(-1px)!important}
.btn:active{transform:translateY(0)!important}
.btn-primary{background:linear-gradient(135deg,var(--h-primary),#1d4ed8)!important;color:#fff!important;box-shadow:0 8px 18px rgba(37,99,235,.20)!important}.btn-primary:hover{background:linear-gradient(135deg,#1d5ee4,#183fb7)!important;box-shadow:0 12px 24px rgba(37,99,235,.25)!important}
.btn-secondary{background:#fff!important;color:#344054!important;border:1px solid #dce3ec!important}.btn-secondary:hover{background:#f8fafc!important;border-color:#cbd5e1!important}
.btn-danger{background:#fff0f1!important;color:#d13f4b!important;border:1px solid #ffd8dc!important}.btn-danger:hover{background:#ffe5e7!important}
.btn-ghost{color:#667085!important}.btn-ghost:hover{background:#f1f5f9!important;color:#1f2937!important}
.btn-sm{min-height:34px!important;padding:7px 11px!important;border-radius:10px!important;font-size:12px!important}.btn-icon{width:38px!important;height:38px!important}

/* Campos */
.field{margin-bottom:18px!important}.field label{font-size:11.5px!important;font-weight:800!important;letter-spacing:.025em!important;color:#526077!important;margin-bottom:8px!important}
.field input,.field select,.field textarea,.search-wrap input,.global-search-wrap input{
  min-height:44px!important;background:#fbfcfe!important;border:1px solid #dfe5ee!important;border-radius:12px!important;color:var(--h-ink)!important;transition:border-color .18s,box-shadow .18s,background .18s!important;
}
.field input,.field select{padding:11px 13px!important}.field textarea{padding:12px 13px!important;min-height:96px!important}
.field input:focus,.field select:focus,.field textarea:focus,.search-wrap input:focus,.global-search-wrap input:focus{background:#fff!important;border-color:#7ca7ff!important;box-shadow:0 0 0 4px rgba(37,99,235,.10)!important}
.field input::placeholder,.field textarea::placeholder{color:#a0acbc!important}
.form-grid{gap:18px!important}

/* Toolbars e busca */
.toolbar{margin-bottom:18px!important;gap:14px!important}.search-wrap{max-width:380px!important}.search-wrap input{padding-left:38px!important;background:#fff!important}.search-wrap .sic{left:14px!important;color:#8b97a8!important}
.global-search-wrap input{background:#f7f9fc!important}.global-search-wrap{max-width:430px!important}

/* Tabelas */
.table-wrap{overflow-x:auto!important}.table-wrap table{background:#fff!important}
thead th{height:50px!important;padding:14px 18px!important;background:#f8fafc!important;color:#7a8699!important;font-size:10px!important;font-weight:850!important;letter-spacing:.08em!important;border-bottom:1px solid var(--h-line)!important}
tbody td{padding:15px 18px!important;border-bottom:1px solid #eef1f5!important;font-size:13px!important;color:#344054!important}
tbody tr{transition:background .16s!important}tbody tr:hover{background:#f8fbff!important}.cell-strong{font-weight:750!important;color:#1f2a3d!important}.cell-muted{color:#8490a3!important}.row-actions{gap:7px!important}
.prod-thumb,.prod-thumb-ph{width:38px!important;height:38px!important;border-radius:11px!important}
.empty-state{padding:62px 24px!important;color:#8a95a7!important}.empty-state .ic{font-size:42px!important;margin-bottom:14px!important}

/* Badges e status */
.badge{padding:5px 10px!important;border-radius:999px!important;font-size:10.5px!important;font-weight:800!important;letter-spacing:.015em!important}
.badge-success{background:#e8f8f1!important;color:#0d8a61!important}.badge-warning{background:#fff5e5!important;color:#b86b00!important}.badge-danger{background:#fff0f1!important;color:#cf3f4b!important}.badge-muted{background:#f0f3f7!important;color:#69768a!important}.badge-accent{background:#edf3ff!important;color:#245ed6!important}

/* Listas, agenda e itens */
.due-item{padding:16px!important;border:1px solid var(--h-line)!important;border-radius:15px!important;background:#fff!important;box-shadow:none!important}.due-item:hover{border-color:#cddcf6!important;background:#fbfdff!important;box-shadow:0 8px 18px rgba(37,99,235,.055)!important}.due-info .client{font-size:14px!important;color:#243047!important}.due-info .product{color:var(--h-muted)!important}
.activity-item{padding:14px 0!important;border-color:#edf0f4!important}.activity-dot{width:9px!important;height:9px!important;background:var(--h-primary)!important;box-shadow:0 0 0 4px rgba(37,99,235,.09)!important}.activity-item .tx{font-size:13px!important;color:#344054!important}.activity-item .at{color:#8b96a8!important}

/* Gráficos */
.bar-chart{height:170px!important}.bar-chart .bar{background:linear-gradient(180deg,#5b8cff,#2454d3)!important;border-radius:8px 8px 3px 3px!important}.hbar-track{background:#edf1f6!important;height:9px!important}.hbar-fill{background:linear-gradient(90deg,#3b82f6,#2454d3)!important}

/* Modal */
.modal-overlay{background:rgba(11,19,35,.52)!important;backdrop-filter:blur(5px)!important}
.modal-box{max-height:88vh!important;box-shadow:var(--h-shadow-lg)!important;border-radius:20px!important;animation:hospimedModalIn .18s ease-out}
@keyframes hospimedModalIn{from{opacity:0;transform:translateY(8px) scale(.985)}to{opacity:1;transform:translateY(0) scale(1)}}
.modal-head{padding:20px 24px!important;background:#fff!important;border-bottom:1px solid var(--h-line)!important}.modal-head h3{font-size:17px!important;font-weight:800!important;color:var(--h-ink)!important}.modal-close{width:36px!important;height:36px!important;border-radius:11px!important;background:#f7f9fc!important}.modal-close:hover{background:#eef2f7!important}.modal-body{padding:24px!important}.modal-foot{padding:17px 24px!important;background:#fbfcfe!important;border-top:1px solid var(--h-line)!important}

/* Cálculos e cartões de resumo */
.calc-box{gap:14px!important;margin:18px 0!important;background:transparent!important;border:none!important;box-shadow:none!important}.calc-tile{background:linear-gradient(180deg,#f8fbff,#eef4ff)!important;border:1px solid #dce8ff!important;border-radius:15px!important;padding:16px!important;text-align:left!important}.calc-tile .lbl{color:#71809a!important;font-size:10px!important;letter-spacing:.07em!important}.calc-tile .val{color:#244fae!important;font-size:21px!important}
.client-selected-card{background:linear-gradient(135deg,#f3f7ff,#edf4ff)!important;border:1px solid #dce8ff!important;border-radius:15px!important;padding:16px!important}.client-selected-card .csc-title{color:#5870a2!important}.client-selected-card .csc-name{color:#20355f!important}
.client-search-results{border-color:#dfe5ee!important;border-radius:13px!important;box-shadow:0 10px 24px rgba(17,26,46,.08)!important}.client-search-item{padding:12px 14px!important}.client-search-item:hover{background:#f3f7ff!important}

/* Login */
#loginScreen{background:radial-gradient(circle at 18% 15%,rgba(73,125,255,.30),transparent 32%),radial-gradient(circle at 82% 80%,rgba(20,184,166,.20),transparent 28%),linear-gradient(135deg,#0d1426 0%,#15233f 52%,#1a2b4e 100%)!important}
.login-card{max-width:430px!important;padding:42px 38px!important;border-radius:24px!important;box-shadow:0 28px 70px rgba(0,0,0,.30)!important;border:1px solid rgba(255,255,255,.18)!important}.login-logo{width:66px!important;height:66px!important;border-radius:19px!important;background:linear-gradient(135deg,#2f73ff,#1d4ed8)!important;box-shadow:0 14px 28px rgba(37,99,235,.25)!important}.login-card h1{font-size:24px!important}.login-card .brand-tag{color:#3567d6!important}.login-card p.sub{font-size:13px!important;line-height:1.55!important}.login-error{border-radius:12px!important}

/* Pequenos detalhes */
.detail-grid .dl{color:#8490a3!important;font-size:10.5px!important;letter-spacing:.06em!important;text-transform:uppercase!important}.detail-grid .dv{color:#2b364b!important;font-size:13.5px!important}.timeline::before{background:#dfe6f0!important}.timeline-item::before{background:#fff!important;border-color:#fff!important;box-shadow:0 0 0 3px #dbe7ff!important}.timeline-item .tl-date{color:#8b96a8!important}.timeline-item .tl-text{color:#344054!important}.step{background:#f0f3f7!important;border-radius:999px!important;padding:7px 12px!important}.step.current{background:var(--h-primary)!important;box-shadow:0 6px 14px rgba(37,99,235,.18)!important}.photo-preview{border-radius:14px!important;border:1px solid var(--h-line)!important}

/* Responsividade preservando toda a lógica existente */
@media(max-width:900px){
  #sidebar{width:272px!important}
  #mainArea{margin-left:0!important}
  #topbar{height:68px!important;padding:0 16px!important}
  #content{padding:20px 14px 48px!important}
  .cards-grid{gap:12px!important}
  .stat-card{min-height:118px!important;padding:17px!important}
  .section-head{padding:16px!important;min-height:62px!important}.section-body{padding:16px!important}
  .toolbar{align-items:stretch!important}.toolbar .btn{width:auto!important}
  #content .table-wrap tbody tr{border:1px solid var(--h-line)!important;border-radius:16px!important;box-shadow:var(--h-shadow)!important}
  #content .table-wrap tbody td{padding:12px 14px!important;border-color:#eef1f5!important}
  #content .table-wrap tbody td::before{color:#8490a3!important}
  .modal-overlay{padding:12px!important}.modal-box{border-radius:18px!important;max-height:92vh!important}.modal-body{padding:18px!important}.modal-head{padding:17px 18px!important}.modal-foot{padding:14px 18px!important}
}
@media(max-width:560px){
  #screenTitle{font-size:17px!important}.global-search-wrap{max-width:58vw!important}.login-card{padding:34px 22px!important;border-radius:20px!important}
  .cards-grid{grid-template-columns:1fr!important}.stat-card .stat-value{font-size:26px!important}.toolbar .search-wrap{max-width:none!important;flex-basis:100%!important}.toolbar>.btn{width:100%!important}
  .due-item{padding:14px!important}.due-actions{width:100%!important}.due-actions .btn{flex:1!important}
}


/* ===================== CONTRATO HOSPIMED ===================== */
.contract-preview.doc-preview{font-family:Arial,Helvetica,sans-serif!important;background:#fff!important;border:0!important;border-radius:0!important;padding:0!important;color:#17212f!important;font-size:12px!important;line-height:1.42!important;max-width:920px;margin:0 auto;box-shadow:none!important}
.contract-page{width:100%;min-height:1120px;border:1px solid #aeb7c2;background:#fff;padding:18px 22px;position:relative}
.contract-top{display:grid;grid-template-columns:1.1fr 1.7fr .8fr;min-height:58px;border:1px solid #9aa5b1;align-items:center}
.contract-brand{height:100%;padding:8px 12px;border-right:1px solid #9aa5b1;display:flex;align-items:center}.contract-brand img{max-height:42px;max-width:160px;object-fit:contain}.contract-brand-name{font-size:24px;font-weight:800;letter-spacing:1px}
.contract-title{text-align:center;font-size:17px;font-weight:800}.contract-date{height:100%;border-left:1px solid #9aa5b1;padding:10px;font-size:14px}
.contract-company{border:1px solid #9aa5b1;border-top:0;padding:9px 11px;line-height:1.55;font-size:11px}
.contract-client-grid{display:grid;grid-template-columns:1.4fr 1fr 1fr;border-left:1px solid #9aa5b1;border-right:1px solid #9aa5b1}
.contract-client-grid>div{min-height:31px;padding:7px 9px;border-bottom:1px solid #c4cbd4}.contract-client-grid>div:nth-child(3n+1){border-right:1px solid #c4cbd4}.contract-client-grid>div:nth-child(3n+2){border-right:1px solid #c4cbd4}
.contract-client-grid>div:nth-child(4){grid-column:span 2}.contract-client-grid>div:nth-child(5){grid-column:auto}
.contract-info-grid{display:grid;grid-template-columns:repeat(2,1fr);border:1px solid #9aa5b1;border-top:0}.contract-info-grid>div{padding:8px 9px;border-bottom:1px solid #d0d6de}.contract-info-grid>div:nth-child(odd){border-right:1px solid #d0d6de}.contract-info-grid>div:last-child{grid-column:1/-1;border-bottom:0;background:#f7f9fb}
.contract-periods{border:1px solid #9aa5b1;border-top:0}.contract-periods h3,.contract-clauses h3{font-size:13px;text-align:center;letter-spacing:.2px;padding:8px;border-bottom:1px solid #9aa5b1;margin:0;background:#f5f7f9}.contract-period-row{display:grid;grid-template-columns:1fr 130px;min-height:45px;border-bottom:1px solid #d0d6de}.contract-period-row:last-child{border-bottom:0}.contract-period-row>div{padding:7px 10px}.contract-period-row>div:last-child{border-left:1px solid #d0d6de;text-align:right;font-weight:700;display:flex;align-items:center;justify-content:flex-end}.contract-period-main{display:flex;flex-direction:column;gap:2px}.contract-period-main span{font-size:11px;color:#5b6775}
.contract-clauses{border:1px solid #9aa5b1;border-top:0}.contract-clauses>div{padding:12px 14px;font-size:10.5px;line-height:1.6;text-align:justify}
.contract-signatures{display:grid;grid-template-columns:1fr 1fr;gap:70px;margin-top:52px;padding:0 28px;text-align:center;font-size:11px}.signature-line{border-top:1px solid #334155;margin-bottom:7px}
@media(max-width:700px){.contract-page{padding:10px;font-size:10px}.contract-top{grid-template-columns:1fr;min-height:auto}.contract-brand,.contract-title,.contract-date{border:0;border-bottom:1px solid #9aa5b1;min-height:44px}.contract-client-grid{grid-template-columns:1fr}.contract-client-grid>div,.contract-client-grid>div:nth-child(n){grid-column:auto;border-right:0!important}.contract-info-grid{grid-template-columns:1fr}.contract-info-grid>div{border-right:0!important}.contract-info-grid>div:last-child{grid-column:auto}.contract-period-row{grid-template-columns:1fr 95px}.contract-signatures{gap:24px;padding:0;margin-top:38px}}
@media print{
  .contract-preview.doc-preview{font-size:14.5px!important;line-height:1.2!important;max-width:100%!important;margin:0!important}
  .contract-page{border:0!important;min-height:auto!important;height:auto!important;padding:0!important;page-break-inside:avoid;break-inside:avoid}
  .contract-top{min-height:9mm!important}
  .contract-brand{padding:1px 6px!important}
  .contract-brand img{max-height:24px!important}
  .contract-brand-name{font-size:20px!important}
  .contract-title{font-size:17.5px!important}
  .contract-date{padding:1px 6px!important;font-size:13.5px!important}
  .contract-company{padding:1px 6px!important;font-size:12.5px!important;line-height:1.16!important}
  .contract-client-grid>div{min-height:auto!important;padding:0 7px!important;font-size:14.5px!important}
  .contract-info-grid>div{padding:0 7px!important;font-size:14.5px!important}
  .contract-periods h3,.contract-clauses h3{font-size:14.5px!important;padding:1px!important;margin:0!important}
  .contract-period-row{min-height:auto!important}
  .contract-period-row>div{padding:0 7px!important}
  .contract-period-main span{font-size:12px!important}
  .contract-clauses>div{font-size:12px!important;line-height:1.16!important;padding:2px 8px!important;text-align:justify}
  .contract-signatures{margin-top:16mm!important;gap:24px!important;padding:0 6px!important;font-size:14px!important;page-break-inside:avoid;break-inside:avoid}
  .signature-line{margin-bottom:1px!important}
}
