html, body {
  height: 100%;
  overflow-x: hidden;
}

.page {
  min-height: 100vh;
  min-height: 100dvh; /* dvh = dynamic viewport height, mais preciso no mobile */
}
.topbar {
  height: 54px;
  min-height: 54px;
}
body {
  scrollbar-gutter: stable;
}
.tab-bar {
  min-height: 36px;
}
.section {
  min-height: calc(100vh - 54px);
  min-height: calc(100dvh - 54px);
}

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

:root {
  --bg:          #f5f4f2;
  --surface:     #ffffff;
  --border:      rgba(0,0,0,0.1);
  --border-md:   rgba(0,0,0,0.18);
  --text:        #1a1a18;
  --text-muted:  #6b6b67;
  --blue:        #185FA5;
  --blue-light:  #E6F1FB;
  --green:       #0F6E56;
  --green-light: #E1F5EE;
  --red:         #A32D2D;
  --red-light:   #FCEBEB;
  --amber:       #854F0B;
  --amber-light: #FAEEDA;
  --radius:      8px;
  --radius-lg:   12px;
}

body { font-family: system-ui,-apple-system,sans-serif; font-size:14px; background:var(--bg); color:var(--text); line-height:1.6; }
.page { min-height:100vh; }

/* ── LOGIN ─────────────────────────────────────────────────────────── */
.login-wrap { min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:24px; }
.login-logo { font-size:20px; font-weight:600; display:flex; align-items:center; gap:8px; margin-bottom:28px; color:var(--blue); }
.login-logo i { font-size:24px; }
.login-card { background:var(--surface); border:0.5px solid var(--border); border-radius:var(--radius-lg); padding:28px; width:100%; max-width:360px; }
.login-card h2 { font-size:18px; font-weight:500; margin-bottom:20px; }

/* ── TOPBAR ────────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 12px 0 16px; gap: 6px;
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
  overflow: hidden; /* impede que itens saiam da barra */
}
.topbar-logo { font-size:15px; font-weight:600; display:flex; align-items:center; gap:8px; color:var(--blue); white-space:nowrap; }
.topbar-logo i { font-size:20px; }
.tab-bar {
  display: flex; gap: 2px;
  flex: 1;
  min-width: 0;        /* permite encolher */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab { padding:6px 12px; border-radius:var(--radius); cursor:pointer; font-size:13px; border:0.5px solid transparent; color:var(--text-muted); transition:all 0.15s; background:none; }
.tab.active { background:var(--bg); border-color:var(--border); color:var(--text); font-weight:500; }
.user-pill {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto; font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;    /* nunca encolhe */
  min-width: 0;
}
.avatar { width:30px; height:30px; border-radius:50%; background:var(--blue-light); color:var(--blue); font-size:11px; font-weight:600; display:flex; align-items:center; justify-content:center; flex-shrink:0; overflow:hidden; }
.avatar img { width:100%; height:100%; object-fit:cover; }

/* ── LAYOUT ─────────────────────────────────────────────────────────── */
.section { min-height:calc(100vh - 54px); }
.content { max-width:860px; margin:0 auto; padding:20px 16px; }
.page-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.page-header h1 { font-size:17px; font-weight:500; }
.section-label { font-size:11px; color:var(--text-muted); font-weight:600; text-transform:uppercase; letter-spacing:0.06em; margin-bottom:12px; }

/* ── FORMS ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom:14px; }
.form-group label { display:block; font-size:12px; color:var(--text-muted); margin-bottom:5px; }
.form-group input, .form-input-sm, .form-input-select {
  width:100%; padding:8px 10px; border-radius:var(--radius);
  border:0.5px solid var(--border-md); background:var(--surface);
  font-size:13px; color:var(--text); font-family:inherit; transition:border-color 0.15s;
}
.form-group input:focus, .form-input-sm:focus { outline:none; border-color:var(--blue); }
.form-hint { font-size:11px; color:var(--text-muted); margin-top:3px; display:block; }

/* ── BUTTONS ────────────────────────────────────────────────────────── */
.btn-primary { padding:8px 18px; border-radius:var(--radius); border:none; background:var(--blue); color:#fff; font-size:13px; cursor:pointer; font-family:inherit; font-weight:500; transition:background 0.15s; display:inline-flex; align-items:center; gap:6px; }
.btn-primary:hover { background:#0C447C; }
.btn-primary.full { width:100%; padding:10px; justify-content:center; }
.btn-outline { display:inline-flex; align-items:center; gap:6px; padding:7px 14px; border-radius:var(--radius); border:0.5px solid var(--border-md); background:transparent; color:var(--text); font-size:13px; cursor:pointer; font-family:inherit; transition:background 0.15s; white-space:nowrap; }
.btn-outline:hover { background:var(--bg); }
.btn-icon { background:none; border:none; cursor:pointer; color:var(--text-muted); font-size:18px; padding:4px; border-radius:var(--radius); display:flex; align-items:center; }
.btn-icon:hover { background:var(--bg); color:var(--text); }
.btn-sm { font-size:12px; padding:5px 10px; border-radius:var(--radius); border:0.5px solid var(--border-md); background:transparent; color:var(--text); cursor:pointer; font-family:inherit; display:inline-flex; align-items:center; gap:4px; transition:background 0.12s; white-space:nowrap; }
.btn-sm:hover { background:var(--bg); }
.btn-sm.danger { border-color:#E24B4A; color:var(--red); }
.btn-sm.danger:hover { background:var(--red-light); }
.btn-sm.success { border-color:#1D9E75; color:var(--green); }
.btn-sm.success:hover { background:var(--green-light); }
.btn-danger { padding:7px 14px; border-radius:var(--radius); border:0.5px solid #E24B4A; background:transparent; color:var(--red); font-size:13px; cursor:pointer; font-family:inherit; display:inline-flex; align-items:center; gap:4px; transition:background 0.12s; }
.btn-danger:hover { background:var(--red-light); }

/* ── CARDS ──────────────────────────────────────────────────────────── */
.card { background:var(--surface); border:0.5px solid var(--border); border-radius:var(--radius-lg); padding:18px; margin-bottom:14px; }

/* ── METRICS ────────────────────────────────────────────────────────── */
.metrics-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:10px; margin-bottom:20px; }
.metric-card { background:var(--bg); border-radius:var(--radius); padding:12px 14px; }
.metric-label { font-size:12px; color:var(--text-muted); margin-bottom:4px; }
.metric-value { font-size:22px; font-weight:500; }
.metric-value.green { color:var(--green); }
.metric-value.amber { color:var(--amber); }
.metric-value.blue  { color:var(--blue); }

/* ── CLIENT ROW — DESKTOP ───────────────────────────────────────────── */
.client-row { display:flex; align-items:flex-start; gap:12px; padding:14px 0; border-bottom:0.5px solid var(--border); }
.client-row:last-child { border-bottom:none; padding-bottom:0; }

.client-avatar { width:40px; height:40px; border-radius:50%; background:#EEEDFE; color:#3C3489; font-size:13px; font-weight:600; display:flex; align-items:center; justify-content:center; flex-shrink:0; overflow:hidden; cursor:pointer; position:relative; }
.client-avatar img { width:100%; height:100%; object-fit:cover; }
.client-avatar:hover::after { content:'\ea94'; font-family:'tabler-icons'; position:absolute; inset:0; background:rgba(0,0,0,0.45); color:#fff; font-size:18px; display:flex; align-items:center; justify-content:center; border-radius:50%; }

.client-info { flex:1; min-width:0; }
.client-name { font-size:13px; font-weight:500; }
.client-sub { font-size:12px; color:var(--text-muted); }
.client-lic { display:flex; gap:6px; margin-top:4px; flex-wrap:wrap; }

/* ── CLIENT ACTIONS — mobile-first ─────────────────────────────────── */
.client-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}
/* On desktop, actions sit to the right — no margin-top */
@media (min-width: 640px) {
  .client-row { align-items: center; }
  .client-info { margin-bottom: 0; }
  .client-actions { margin-top: 0; flex-wrap: nowrap; }
}

/* ── ACTION BUTTONS GROUP ───────────────────────────────────────────── */
/* Each button is an icon-only pill on mobile, expands on desktop */
.client-actions .btn-sm { min-width: 36px; justify-content: center; }
@media (min-width: 480px) {
  .client-actions .btn-sm { min-width: unset; }
}

/* ── DEVICE PANEL ───────────────────────────────────────────────────── */
.devices-panel-inner { padding: 0 0 8px 52px; }
@media (max-width: 480px) { 
  
  .devices-panel-inner { padding-left: 0; } 
.page-header .btn-outline { 
  padding: 6px 8px; 
  font-size: 12px; 
}
.page-header .btn-outline .btn-text { display: inline; }
}
.client-devices { margin-top:10px; padding:10px 12px; background:var(--bg); border-radius:var(--radius); font-size:12px; }
.client-device-row { display:flex; align-items:center; gap:8px; padding:7px 0; border-bottom:0.5px solid var(--border); flex-wrap: wrap; }
.client-device-row:last-child { border-bottom:none; }
.client-device-info { display:flex; align-items:center; gap:8px; flex:1; min-width:0; }
.client-device-thumb { width:32px; height:32px; border-radius:6px; object-fit:cover; flex-shrink:0; background:var(--border); cursor:pointer; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.client-device-thumb img { width:100%; height:100%; object-fit:cover; }
.client-device-actions { display:flex; align-items:center; gap:6px; flex-shrink:0; }

/* ── DEVICE CARDS (cliente) ─────────────────────────────────────────── */
.device-card { background:var(--surface); border:0.5px solid var(--border); border-radius:var(--radius-lg); padding:16px; margin-bottom:10px; display:flex; align-items:center; gap:14px; }
.device-card.suspended { opacity:0.65; }
.device-icon { width:52px; height:52px; border-radius:var(--radius); background:var(--bg); flex-shrink:0; overflow:hidden; display:flex; align-items:center; justify-content:center; }
.device-icon img { width:100%; height:100%; object-fit:cover; }
.device-icon i { font-size:24px; color:var(--blue); }
.device-info { flex:1; min-width:0; }
.device-name { font-size:14px; font-weight:500; }
.device-model { font-size:11px; color:var(--text-muted); font-family:monospace; margin-top:2px; }
.device-status { display:flex; align-items:center; gap:5px; font-size:12px; color:var(--text-muted); margin-top:4px; }
.dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.dot.on        { background:#1D9E75; }
.dot.off       { background:#B4B2A9; }
.dot.suspended { background:#EF9F27; }

/* ── TOGGLE ─────────────────────────────────────────────────────────── */
.toggle-wrap { display:flex; flex-direction:column; align-items:center; gap:4px; }
.toggle { position:relative; width:42px; height:24px; cursor:pointer; flex-shrink:0; }
.toggle input { opacity:0; width:0; height:0; position:absolute; }
.toggle-track { position:absolute; inset:0; background:#D3D1C7; border-radius:999px; transition:background 0.2s; }
.toggle-track::before { content:''; position:absolute; width:18px; height:18px; left:3px; top:3px; background:white; border-radius:50%; transition:transform 0.2s; }
.toggle input:checked + .toggle-track { background:#1D9E75; }
.toggle input:checked + .toggle-track::before { transform:translateX(18px); }
.toggle input:disabled + .toggle-track { cursor:not-allowed; opacity:0.5; }
.toggle-label { font-size:11px; color:var(--text-muted); }
.toggle-sm { width:34px; height:19px; }
.toggle-sm .toggle-track::before { width:13px; height:13px; top:3px; left:3px; }
.toggle-sm input:checked + .toggle-track::before { transform:translateX(15px); }

/* ── BADGES ─────────────────────────────────────────────────────────── */
.badge { font-size:11px; padding:3px 9px; border-radius:999px; font-weight:500; white-space:nowrap; }
.badge.active    { background:var(--green-light); color:var(--green); }
.badge.suspended { background:var(--amber-light); color:var(--amber); }
.badge-info { font-size:11px; padding:2px 8px; border-radius:999px; background:#E6F1FB; color:#0C447C; font-weight:500; }
.count-badge { display:inline-flex; align-items:center; justify-content:center; width:17px; height:17px; border-radius:50%; background:#185FA5; color:#fff; font-size:10px; font-weight:600; margin-left:2px; }

/* ── ALERTS ─────────────────────────────────────────────────────────── */
.alert { border-radius:var(--radius); padding:10px 14px; font-size:13px; display:flex; align-items:center; gap:8px; margin-bottom:14px; }
.alert-danger  { background:var(--red-light);   color:var(--red);   }
.alert-warning { background:var(--amber-light);  color:var(--amber); }

/* ── MODAIS ─────────────────────────────────────────────────────────── */
.modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,0.4); display:flex; align-items:flex-end; justify-content:center; z-index:200; padding:0; }
@media (min-width:540px) { .modal-backdrop { align-items:center; padding:16px; } }
.modal { background:var(--surface); border-radius:var(--radius-lg) var(--radius-lg) 0 0; border:0.5px solid var(--border); padding:20px; width:100%; max-width:400px; max-height:90vh; overflow-y:auto; }
@media (min-width:540px) { .modal { border-radius:var(--radius-lg); } }
.modal-lg { max-width:560px; }
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.modal-title { font-size:15px; font-weight:500; }
.modal-footer { display:flex; gap:8px; justify-content:flex-end; margin-top:18px; flex-wrap:wrap; }
.divider-label { text-align:center; font-size:12px; color:var(--text-muted); margin:8px 0; }

/* ── MISC ───────────────────────────────────────────────────────────── */
.loading { padding:32px; text-align:center; color:var(--text-muted); font-size:13px; display:flex; align-items:center; justify-content:center; gap:8px; }
.empty { padding:40px; text-align:center; color:var(--text-muted); font-size:13px; }
.empty i { font-size:32px; display:block; margin-bottom:10px; opacity:0.4; }
@keyframes spin { to { transform:rotate(360deg); } }
.spin { display:inline-block; animation:spin 0.9s linear infinite; }

/* ── ROTINAS ────────────────────────────────────────────────────────── */
.rotina-form { background:var(--bg); border-radius:var(--radius); padding:14px; margin-bottom:4px; }
.rotina-form-row { display:flex; gap:10px; flex-wrap:wrap; align-items:flex-start; margin-bottom:8px; }
.rot-fg-device { flex:2; min-width:120px; }
.rot-fg-acao   { flex:1; min-width:100px; }
.rot-fg-hora, .rot-fg-min { width:70px; flex:none; }

/* Dias da semana */
.dias-semana-grid { display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.dia-btn { padding:5px 10px; border-radius:var(--radius); border:0.5px solid var(--border-md); background:var(--surface); color:var(--text-muted); font-size:12px; cursor:pointer; transition:all 0.12s; font-family:inherit; }
.dia-btn.sel { background:var(--blue); color:#fff; border-color:var(--blue); }

/* Rotinas table */
.rotinas-table { border:0.5px solid var(--border); border-radius:var(--radius); overflow:hidden; margin-bottom:8px; }
.rotinas-header { display:grid; grid-template-columns:2fr 1fr auto 40px 40px 32px; gap:6px; padding:8px 10px; background:var(--bg); font-size:11px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.05em; }
.rotina-row { display:grid; grid-template-columns:2fr 1fr auto 40px 40px 32px; gap:6px; padding:9px 10px; font-size:12px; border-top:0.5px solid var(--border); align-items:center; }
.rotina-row:hover { background:var(--bg); }
.rotina-acao.ligar    { color:var(--green); font-weight:500; }
.rotina-acao.desligar { color:var(--red); font-weight:500; }
.rotina-hora { font-family:monospace; font-size:13px; font-weight:600; }
.rotina-dias { font-size:10px; color:var(--text-muted); }

/* ── PHOTO UPLOAD ────────────────────────────────────────────────────── */
.photo-upload-area { border:1.5px dashed var(--border-md); border-radius:var(--radius-lg); padding:24px; text-align:center; margin-bottom:4px; }
.photo-upload-label { display:block; cursor:pointer; font-size:13px; color:var(--text-muted); }
.photo-upload-label i { font-size:28px; display:block; margin-bottom:6px; }
.photo-upload-label:hover { color:var(--blue); }

/* ── TUYA FEEDBACK ───────────────────────────────────────────────────── */
.tuya-feedback { display:none; align-items:center; gap:6px; font-size:12px; padding:5px 10px; border-radius:var(--radius); margin-top:6px; font-weight:500; }
.tuya-loading  { background:var(--bg); color:var(--text-muted); border:0.5px solid var(--border); }
.tuya-ok       { background:var(--green-light); color:var(--green); border:0.5px solid #A8E2D3; }
.tuya-err      { background:var(--red-light);   color:var(--red);   border:0.5px solid #F5C0C0; }
.tuya-feedback-inline { font-size:11px; padding:2px 7px; border-radius:999px; font-weight:500; white-space:nowrap; }
.tuya-ok-inline  { background:var(--green-light); color:var(--green); }
.tuya-err-inline { background:var(--red-light);   color:var(--red); }


/* ── MOBILE OVERRIDES ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  ...
  /* Rotinas: esconde colunas Ação e On, mostra só Device, Horário e lixeira */
  .rotinas-header,
  .rotina-row { grid-template-columns: 2fr 1fr 36px 36px; gap: 6px; }

  /* Oculta coluna Ação (2ª), Dias (4ª) e On (5ª) */
  .rotinas-header span:nth-child(2),
  .rotina-row > *:nth-child(2),
  .rotinas-header span:nth-child(4),
  .rotina-row > *:nth-child(4),
  .rotinas-header span:nth-child(5),
  .rotina-row > *:nth-child(5) { display: none; }
}
/* ── FATURAMENTO ─────────────────────────────────────────────────────────── */
.fat-filters { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.fat-filters input, .fat-filters select { font-size:13px; }

.fat-table { width:100%; border-collapse:collapse; font-size:13px; }
.fat-table thead tr { background:var(--bg); }
.fat-table th { padding:10px 14px; text-align:left; font-size:11px; font-weight:600;
                color:var(--text-muted); text-transform:uppercase; letter-spacing:0.05em;
                border-bottom:0.5px solid var(--border); white-space:nowrap; }
.fat-table td { padding:11px 14px; border-bottom:0.5px solid var(--border); vertical-align:middle; }
.fat-table tr:last-child td { border-bottom:none; }
.fat-table tr:hover td { background:var(--bg); }
.fat-row-venc td { background:#FAEEDA44; }

.fat-client { display:flex; align-items:center; gap:8px; }
.fat-avatar { width:28px; height:28px; border-radius:50%; object-fit:cover; flex-shrink:0; }
.fat-avatar-ini { background:#EEEDFE; color:#3C3489; font-size:11px; font-weight:600;
                  display:flex; align-items:center; justify-content:center; }
.fat-mes    { font-weight:500; white-space:nowrap; }
.fat-valor  { font-family:monospace; font-weight:600; }
.fat-date   { white-space:nowrap; color:var(--text-muted); font-size:12px; }
.fat-obs    { max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
              color:var(--text-muted); font-size:12px; }

.fat-badge { font-size:11px; padding:3px 9px; border-radius:999px; font-weight:500; white-space:nowrap; }
.fat-pago   { background:var(--green-light); color:var(--green); }
.fat-aberto { background:#E6F1FB; color:#185FA5; }
.fat-vencido{ background:var(--amber-light); color:var(--amber); }

.metric-value.red { color:var(--red); }

.assin-row { padding:12px 0; }

/* Mobile — tabela com scroll horizontal */
/* fat-table só aparece no desktop — no mobile JS renderiza .fat-card */
@media (max-width:639px) {
  .fat-table { display: none; }
}

/* ── MODAL FATURA POR CLIENTE ──────────────────────────────────────────────── */
.fc-fatura-card { background:var(--bg); border-radius:var(--radius); padding:14px 16px; margin-bottom:4px; }
.fc-row { display:flex; align-items:center; justify-content:space-between; padding:7px 0; border-bottom:0.5px solid var(--border); }
.fc-row:last-of-type { border-bottom:none; }
.fc-label { font-size:12px; color:var(--text-muted); }
.fc-val { font-size:13px; font-weight:500; }
.fc-val-destaque { font-size:20px; font-weight:600; color:var(--blue); font-family:monospace; }
.fc-acao { padding-top:12px; display:flex; gap:8px; flex-wrap:wrap; }
.fc-empty { font-size:13px; color:var(--text-muted); padding:8px 0 12px; }

/* ── MINHA ASSINATURA ─────────────────────────────────────────────────────── */
.cli-fat-status { display:flex; align-items:center; gap:14px; padding:16px; border-radius:var(--radius); margin-bottom:12px; }
.cli-fat-ok     { background:var(--green-light); border:1px solid #A8E2D3; }
.cli-fat-warn   { background:var(--amber-light); border:1px solid #F0C97A; }
.cli-fat-danger { background:var(--red-light);   border:1px solid #F5C0C0; }
.cli-fat-icon   { font-size:28px; flex-shrink:0; }
.cli-fat-ok .cli-fat-icon     { color:var(--green); }
.cli-fat-warn .cli-fat-icon   { color:var(--amber); }
.cli-fat-danger .cli-fat-icon { color:var(--red);   }
.cli-fat-titulo { font-size:15px; font-weight:600; margin-bottom:3px; }
.cli-fat-sub    { font-size:13px; opacity:0.85; }
.cli-fat-valor  { font-size:22px; font-weight:700; font-family:monospace; flex-shrink:0; }
.cli-fat-ok .cli-fat-valor     { color:var(--green); }
.cli-fat-warn .cli-fat-valor   { color:var(--amber); }
.cli-fat-danger .cli-fat-valor { color:var(--red);   }

.cli-fat-detalhe { display:flex; flex-direction:column; gap:0; margin-top:4px; }
.cli-fat-linha   { display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-bottom:0.5px solid var(--border); font-size:13px; }
.cli-fat-linha:last-child { border-bottom:none; }
.cli-fat-linha span:first-child { color:var(--text-muted); font-size:12px; }

/* ── NOTIFICAÇÕES ─────────────────────────────────────────────────────────── */
.notif-card { display:flex; align-items:flex-start; gap:14px; background:var(--surface); border:0.5px solid var(--border); border-radius:var(--radius-lg); padding:16px; margin-bottom:10px; }
.notif-ok     { border-left:3px solid #1D9E75; }
.notif-warn   { border-left:3px solid #EF9F27; }
.notif-danger { border-left:3px solid #E24B4A; }
.notif-icon   { font-size:22px; flex-shrink:0; margin-top:1px; }
.notif-ok .notif-icon     { color:var(--green); }
.notif-warn .notif-icon   { color:var(--amber); }
.notif-danger .notif-icon { color:var(--red);   }
.notif-body   { flex:1; min-width:0; }
.notif-titulo { font-size:14px; font-weight:600; margin-bottom:4px; }
.notif-msg    { font-size:13px; color:var(--text-muted); line-height:1.5; }
.notif-data   { font-size:11px; color:var(--text-muted); margin-top:6px; }

/* Badge notificação no tab */
#notif-badge { vertical-align: middle; }

/* Alert success */
.alert-success { background:var(--green-light); color:var(--green); border-radius:var(--radius); padding:10px 14px; font-size:13px; display:flex; align-items:center; gap:8px; margin-bottom:14px; }

/* ── FAT CARDS (mobile faturamento) ─────────────────────────────────────── */
.fat-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin: 0 0 10px;
}
.fat-card-venc { background: #FAEEDA44; border-color: #F0C97A; }
.fat-card-pago { opacity: 0.85; }

.fat-card-top {
  display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
}
.fat-card-nome { font-weight: 500; font-size: 14px; }

.fat-card-body { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; }
.fat-card-linha {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 6px 0; border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}
.fat-card-linha:last-child { border-bottom: none; }
.fat-card-label { font-size: 12px; color: var(--text-muted); }

.fat-card-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.fat-card-acoes .btn-primary { flex: 1; justify-content: center; }

/* ── MODAL fixes para mobile ─────────────────────────────────────────────── */
/* modal-footer empilha botões em telas pequenas */
@media (max-width: 480px) {
  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .modal-footer .btn-primary,
  .modal-footer .btn-outline,
  .modal-footer .btn-danger {
    width: 100%;
    justify-content: center;
  }
.top-name-text { display: none; }
.user-pill .btn-icon { 
  min-width: 32px; 
  min-height: 32px;
  flex-shrink: 0;   /* botão logout nunca desaparece */
}
  /* rotinas: comprime colunas no modal */
  .rotinas-header,
  .rotina-row {
    grid-template-columns: 2fr 28px 52px 32px 28px;
    gap: 4px; font-size: 11px;
  }
  .rotinas-header span:nth-child(4),
  .rotina-row > *:nth-child(4) { display: none; }

  /* fat-filters em coluna */
  .fat-filters { flex-direction: column; }
  .fat-filters select,
  .fat-filters input { width: 100%; }

  /* métricas em 2 colunas no mobile */
  .metrics-grid { grid-template-columns: 1fr 1fr; }

  /* client actions wrap melhor */
  .client-actions { gap: 4px; }
  .client-actions .btn-sm { padding: 5px 8px; font-size: 11px; }

  /* fc-fatura-card no modal */
  .fc-val-destaque { font-size: 18px; }

  /* modal de rotinas — form em coluna */
  .rotina-form-row { flex-direction: column; gap: 6px; }
  .rot-fg-hora, .rot-fg-min { width: 100%; }
}

/* ── PIX MODAL ───────────────────────────────────────────────────────────── */
.pix-valor-wrap  { text-align:center; padding:16px 0 12px; }
.pix-valor-label { font-size:12px; color:var(--text-muted); margin-bottom:4px; }
.pix-valor       { font-size:34px; font-weight:700; font-family:monospace; color:var(--green); }
.pix-venc        { font-size:12px; color:var(--text-muted); margin-top:4px; display:flex; align-items:center; justify-content:center; gap:6px; flex-wrap:wrap; }

.pix-chave-wrap  { background:var(--bg); border-radius:var(--radius); padding:12px 14px; margin:12px 0; }
.pix-chave-label { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.05em; color:var(--text-muted); margin-bottom:8px; display:flex; align-items:center; gap:6px; }
.pix-chave-row   { display:flex; align-items:center; gap:8px; }
.pix-chave       { flex:1; font-family:monospace; font-size:13px; word-break:break-all; padding:6px 8px; background:var(--surface); border-radius:var(--radius); border:0.5px solid var(--border); }
.pix-nome        { font-size:12px; color:var(--text-muted); margin-top:6px; }

.pix-instrucoes  { margin:12px 0; display:flex; flex-direction:column; gap:8px; }
.pix-step        { display:flex; align-items:center; gap:10px; font-size:13px; }
.pix-num         { width:22px; height:22px; border-radius:50%; background:var(--blue); color:#fff; font-size:11px; font-weight:600; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.pix-ok          { text-align:center; padding:24px; color:var(--green); font-size:14px; display:flex; flex-direction:column; align-items:center; gap:10px; }
.pix-ok i        { font-size:44px; }

/* ── AVISOS PIX ADMIN ────────────────────────────────────────────────────── */
.aviso-pix-card     { background:var(--surface); border:0.5px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:10px; }
.aviso-nao-lido     { border-left:3px solid var(--blue); background:var(--blue-light); }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.pix-toast {
  position:fixed; bottom:80px; right:16px;
  background:var(--surface); border:0.5px solid var(--border);
  border-left:3px solid var(--green);
  border-radius:var(--radius-lg); padding:14px 12px;
  display:flex; align-items:flex-start; gap:10px;
  max-width:320px; z-index:9999;
  box-shadow:0 4px 20px rgba(0,0,0,0.14);
  animation:toastIn 0.3s ease;
}
.pix-toast-icon  { font-size:22px; flex-shrink:0; }
.pix-toast-body  { flex:1; cursor:pointer; }
.pix-toast-titulo{ font-size:13px; font-weight:600; margin-bottom:2px; }
.pix-toast-msg   { font-size:12px; color:var(--text-muted); }
@keyframes toastIn { from { transform:translateX(110%); opacity:0; } to { transform:translateX(0); opacity:1; } }
@media (max-width:480px) { .pix-toast { bottom:16px; right:8px; left:8px; max-width:none; } }

/* ── Alert success ───────────────────────────────────────────────────────── */
.alert-success { background:var(--green-light); color:var(--green); border-radius:var(--radius); padding:10px 14px; font-size:13px; display:flex; align-items:center; gap:8px; margin-bottom:14px; }

/* ── CLIENT CARD MOBILE ──────────────────────────────────────────────────── */
.client-card-mobile {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  padding: 14px 0;
}
.client-card-mobile:last-of-type { border-bottom: none; }

.ccm-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.ccm-avatar {
  width: 42px; height: 42px;
  flex-shrink: 0;
}
.ccm-info { flex: 1; min-width: 0; }
.ccm-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.ccm-sub  { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* Grade 2×2 para os botões principais */
.ccm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}
.ccm-actions-2 {
  grid-template-columns: 1fr 1fr 1fr;
}

.ccm-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: var(--radius);
  border: 0.5px solid var(--border-md);
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
  min-height: 52px;
}
.ccm-btn i    { font-size: 18px; color: var(--blue); }
.ccm-btn span { font-weight: 500; text-align: center; line-height: 1.2; }
.ccm-btn:hover { background: var(--blue-light); }

/* Fatura com status colorido */
.ccm-btn.success { border-color: #1D9E75; }
.ccm-btn.success i { color: var(--green); }
.ccm-btn.danger  { border-color: #E24B4A; }
.ccm-btn.danger i { color: var(--red); }

/* Botões da linha 2 ficam mais compactos */
.ccm-actions-2 .btn-sm {
  justify-content: center;
  flex: 1;
  padding: 7px 4px;
}

/* ── NOTIFICAÇÕES ADMIN (aba) ────────────────────────────────────────────── */
.notif-admin-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.notif-admin-pendente {
  border-left: 3px solid var(--green);
  background: #F5FFFC;
}
.notif-admin-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.notif-admin-detalhe {
  display: flex;
  gap: 16px;
  font-size: 13px;
  flex-wrap: wrap;
  color: var(--text-muted);
}
.notif-admin-detalhe strong { color: var(--text); }
.notif-card-acoes {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.notif-card-acoes .btn-primary { flex: 1; justify-content: center; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* Tab bell badge */
#admin-notif-count { vertical-align: middle; }

/* QR fix override */
.pix-qr-img { width:min(160px,55vw)!important; height:min(160px,55vw)!important; display:block; margin:0 auto; }

/* ── Sino shake animation ─────────────────────────────────────────────────── */
@keyframes bellShake {
  0%,100% { transform: rotate(0); }
  20%     { transform: rotate(-15deg); }
  40%     { transform: rotate(15deg); }
  60%     { transform: rotate(-10deg); }
  80%     { transform: rotate(10deg); }
}

/* Badge do sino do cliente — garante visibilidade */
#notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #E24B4A;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  margin-left: 2px;
}

/* Badge do sino do admin na aba */
#admin-notif-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #E24B4A;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  margin-left: 2px;
}

/* Badge ponto vermelho no topbar (admin) */
#admin-bell-badge {
  width: 9px !important;
  height: 9px !important;
  background: #E24B4A !important;
  border-radius: 50% !important;
  border: 1.5px solid white !important;
  position: absolute !important;
  top: 3px !important;
  right: 3px !important;
}

/* ── Performance — scroll e rendering ───────────────────────────────────── */
/* Isola o layout de cada card para scroll mais suave */
.client-card-mobile,
.client-row,
.device-card,
.notif-admin-card,
.fat-card,
.aviso-pix-card {
  contain: layout style;
}

/* Imagens — evita layout shift */
.client-avatar img,
.device-icon img,
.fat-avatar,
.pix-qr-img {
  content-visibility: auto;
}

/* Scroll suave no iOS */
.content,
.modal,
.tab-bar {
  -webkit-overflow-scrolling: touch;
}

/* GPU acceleration para animações */
.toggle-track,
.toggle-track::before,
.pix-toast,
.tab {
  will-change: transform;
  transform: translateZ(0);
}

/* ── Drag & Drop ─────────────────────────────────────────────────────────── */
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  padding: 4px 8px 4px 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  font-size: 18px;
  opacity: 0.3;
  transition: opacity 0.15s;
  touch-action: none;
}
.drag-handle:hover  { opacity: 0.8; }
.drag-handle:active { cursor: grabbing; opacity: 1; }

.client-row.dragging,
.client-card-mobile.dragging {
  opacity: 0.4;
  background: var(--blue-light);
  border-radius: var(--radius);
}

[draggable="true"] { cursor: default; }
