:root{
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #fbfcfd;
  --line: #dde2e8;
  --text: #202833;
  --muted: #6b7684;
  --accent: #2b8a83;
  --accent-bg: rgba(43,138,131,0.10);

  --green: #1f9d55;   --green-bg: rgba(31,157,85,0.09);
  --amber: #b9740a;   --amber-bg: rgba(232,169,59,0.16);
  --red: #d13b36;     --red-bg: rgba(209,59,54,0.10);
  --done: #7c8798;    --done-bg: rgba(124,135,152,0.08);

  --urg-baixa: #6b7684;
  --urg-media: #2f6fb0;
  --urg-alta: #8a4fd1;
  --urg-urgente: #e0314a;

  --card-shadow: 0 1px 2px rgba(20,30,45,0.06);

  --avatar-1: #2b8a83; --avatar-2: #b9740a; --avatar-3: #8a4fd1;
  --avatar-4: #2f6fb0; --avatar-5: #d13b36; --avatar-6: #4f9d5a;
}
* { box-sizing: border-box; }
html,body{
  margin:0; padding:0; min-height:100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.brand-stripe{ height:4px; width:100%; background: var(--accent); }
#app{ display:flex; flex-direction:column; min-height:100vh; }
a{ color: var(--accent); }

header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--line); flex-shrink:0;
  background: var(--panel);
}
header h1{ font-size: 20px; font-weight:800; margin:0; letter-spacing: -0.01em; color: var(--accent); }
header h1 span{ color:var(--accent); }
.brand{ display:flex; align-items:center; gap:10px; }
.brand-logo{ height: 32px; width:auto; max-width:140px; object-fit:contain; }
.login-logo{ height: 44px; width:auto; max-width:220px; object-fit:contain; margin-bottom:8px; }
.clock{ color:var(--muted); font-size:14px; }

nav.tabs{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
nav.tabs a, nav.tabs button{
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; cursor:pointer;
  text-decoration:none; transition: background .15s, color .15s, border-color .15s;
}
nav.tabs a:hover, nav.tabs button:hover{ color: var(--text); border-color:#c3ccd6; }
nav.tabs a.active{ background: var(--accent-bg); color: var(--accent); border-color: var(--accent); font-weight:600; }
nav.tabs .tv{ color: var(--accent); border-color: var(--accent); }
nav.tabs .whoami{ color: var(--text); font-size: 13px; padding: 0 6px; display:flex; align-items:center; gap:6px; font-weight:600; }
nav.tabs .logout{ color: var(--red); border-color: var(--line); }

.role-pills{ display:inline-flex; gap:4px; }
.role-pill{
  font-size: 10.5px; font-weight:700; padding: 2px 7px; border-radius: 20px; color:#fff;
}
.role-pill.admin{ background: var(--urg-alta); }
.role-pill.tecnico{ background: var(--accent); }
.role-pill.monitor{ background: var(--muted); }

main{ flex:1; padding: 22px 28px; }

/* ---- resumo ---- */
.stats-bar{ display:flex; gap:14px; margin-bottom: 18px; flex-wrap:wrap; }
.stat-chip{
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 18px; box-shadow: var(--card-shadow); min-width: 130px;
}
.stat-chip .stat-num{ font-size: 24px; font-weight:800; line-height:1; }
.stat-chip .stat-label{ font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-chip.total .stat-num{ color: var(--text); }
.stat-chip.vencidas .stat-num{ color: var(--red); }
.stat-chip.urgentes .stat-num{ color: var(--urg-urgente); }
.stat-chip.amarelas .stat-num{ color: var(--amber); }

/* ---- board ---- */
#board{ display:flex; gap:18px; align-items:flex-start; flex-wrap:wrap; }
.column{
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  min-width: 300px; flex: 1; display:flex; flex-direction:column;
  box-shadow: var(--card-shadow);
}
.column-head{
  padding: 14px 16px; border-bottom: 2px solid var(--line);
  display:flex; align-items:center; gap:10px; justify-content:space-between;
}
.column-head-left{ display:flex; align-items:center; gap:10px; }
.tech-avatar{
  width: 34px; height:34px; border-radius: 50%; display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight:700; font-size: 14px; flex-shrink:0;
}
.column-head h2{ margin:0; font-size:17px; font-weight:800; }
.column-head .count{ color: var(--muted); font-size: 12.5px; font-weight:600; background: var(--bg); padding:3px 10px; border-radius: 20px; }
.column-head .count.has-red{ color: var(--red); background: var(--red-bg); }
.cards{ padding: 12px; display:flex; flex-direction:column; gap:10px; }

.card{
  border-radius: 10px; padding: 14px 16px; border: 1px solid var(--line);
  border-left: 5px solid var(--muted); background: var(--panel-2);
  box-shadow: var(--card-shadow);
}
.card.green{ border-left-color: var(--green); }
.card.amber{ border-left-color: var(--amber); background: linear-gradient(0deg, var(--amber-bg), var(--amber-bg)), var(--panel-2); }
.card.red{ border-left-color: var(--red); background: linear-gradient(0deg, var(--red-bg), var(--red-bg)), var(--panel-2); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse{ 0%,100%{ box-shadow: var(--card-shadow); } 50%{ box-shadow: 0 0 0 3px rgba(209,59,54,0.25); } }

.card-top{ display:flex; align-items:flex-start; justify-content:space-between; gap:8px; }
.card-title{ font-size: 16px; font-weight:700; margin: 0 0 4px; }
.card-client{ font-size: 11.5px; color: var(--accent); margin-bottom: 4px; font-weight:700; text-transform:uppercase; letter-spacing:0.03em; }
.card-desc{ font-size: 13px; color: var(--muted); margin: 6px 0 10px; }

.badge-urg{
  font-size: 11.5px; font-weight:800; padding: 4px 10px; border-radius: 20px;
  white-space:nowrap; color: #ffffff; flex-shrink:0; display:inline-flex; align-items:center; gap:4px;
}
.badge-urg.baixa{ background: var(--urg-baixa); }
.badge-urg.media{ background: var(--urg-media); }
.badge-urg.alta{ background: var(--urg-alta); }
.badge-urg.urgente{ background: var(--urg-urgente); box-shadow: 0 0 0 2px rgba(224,49,74,0.18); }

.prazo-block{
  margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: rgba(0,0,0,0.02);
}
.prazo-row{ display:flex; justify-content:space-between; align-items:baseline; font-size: 12px; color: var(--muted); margin-bottom:4px; }
.prazo-status{ font-size: 14px; font-weight:800; }
.card.green .prazo-status{ color: var(--green); }
.card.amber .prazo-status{ color: var(--amber); }
.card.red .prazo-status{ color: var(--red); }
.prazo-dates{ font-size: 11.5px; color: var(--muted); margin-top:2px; }
.prazo-bar-track{ height:5px; border-radius:4px; background: var(--line); margin-top:8px; overflow:hidden; }
.prazo-bar-fill{ height:100%; border-radius:4px; }
.card.green .prazo-bar-fill{ background: var(--green); }
.card.amber .prazo-bar-fill{ background: var(--amber); }
.card.red .prazo-bar-fill{ background: var(--red); }

.card-ack-tag{
  font-size: 11.5px; font-weight:700; color: var(--red); margin-top:10px;
  display:inline-block; background: var(--red-bg); padding: 3px 9px; border-radius: 20px;
}
.card-ack-info{ font-size: 11.5px; color: var(--muted); margin-top:8px; }

.card-actions{ margin-top:12px; display:flex; gap:8px; flex-wrap:wrap; }
.card-actions button{
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-size: 12.5px; padding: 7px 12px; border-radius: 7px; cursor:pointer; font-weight:600;
}
.card-actions button:hover{ border-color: var(--accent); color: var(--accent); }
.card-actions button.ack-btn{ border-color: var(--red); color: var(--red); }
.card-actions button.complete-btn{ background: var(--accent); color:#fff; border-color: var(--accent); }
.card-actions button.complete-btn:hover{ filter:brightness(1.08); color:#fff; }

.update-section{ margin-top:12px; border-top: 1px solid var(--line); padding-top:10px; }
.update-list{ display:flex; flex-direction:column; gap:8px; margin-bottom:10px; max-height:160px; overflow-y:auto; }
.update-item{ background: var(--bg); border-radius: 7px; padding: 7px 10px; }
.update-author{ font-size: 11.5px; font-weight:700; color: var(--accent); }
.update-time{ font-size: 11px; color: var(--muted); margin-left:6px; }
.update-text{ font-size: 12.5px; color: var(--text); margin-top:2px; }
.update-form{ display:flex; gap:6px; }
.update-input{
  flex:1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; font-size: 12.5px; color: var(--text); font-family: inherit;
}
.update-input:focus{ outline:none; border-color: var(--accent); }
.update-send{
  background: var(--accent); color:#fff; border:none; border-radius: 7px;
  padding: 7px 12px; font-size: 12.5px; font-weight:600; cursor:pointer; white-space:nowrap;
}
.update-send:hover{ filter:brightness(1.08); }
.add-note-btn{
  background: transparent; border: 1px dashed var(--line); color: var(--muted);
  border-radius: 7px; padding: 7px 12px; font-size: 12.5px; font-weight:600;
  cursor:pointer; width:100%;
}
.add-note-btn:hover{ border-color: var(--accent); color: var(--accent); border-style:solid; }

.empty-col{ color: var(--muted); font-size: 13px; padding: 24px 14px; text-align:center; }

/* ---- siren banner ---- */
.siren-banner{
  background: var(--red-bg); border: 1px solid var(--red); border-radius: 10px;
  padding: 14px 18px; margin-bottom: 18px; animation: pulse 1.6s ease-in-out infinite;
}
.siren-banner-title{ font-weight:700; color: var(--red); margin-bottom: 8px; }
.siren-list{ display:flex; flex-direction:column; gap:8px; }
.siren-item{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.siren-item span{ font-size: 13.5px; }
.siren-item button{
  background: var(--red); border:none; color:#fff; font-weight:700;
  padding: 6px 12px; border-radius: 7px; cursor:pointer; font-size: 12.5px; white-space:nowrap;
}

.conn-warning{
  display:none; background: var(--red-bg); color: var(--red); font-size: 13px;
  padding: 8px 14px; text-align:center; border-radius: 8px; margin-bottom: 14px;
}
.conn-warning.show{ display:block; }

/* ---- TV mode ---- */
body.tv header{ display:none; }
body.tv main{ padding: 26px 34px; }
body.tv .column-head h2{ font-size: 21px; }
body.tv .card-title{ font-size: 19px; }
body.tv .prazo-status{ font-size: 16px; }
.tv-exit{
  position: fixed; top: 14px; right: 14px; z-index: 50;
  background: rgba(0,0,0,0.06); color: var(--muted); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 8px; font-size: 12px; cursor:pointer; display:none;
}
body.tv .tv-exit{ display:block; }

/* ---- forms ---- */
.form-wrap{ max-width: 480px; margin: 0 auto; }
.login-wrap{ max-width: 360px; margin: 90px auto 0; text-align:left; }
.login-title{ font-size: 22px; margin-bottom: 24px; color: var(--accent); font-weight:800; }
.login-title span{ color: var(--accent); }
.form-wrap h2{ font-size: 18px; margin-bottom: 18px; }
label{ display:block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=date], input[type=time], input[type=password], select, textarea{
  width:100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 14px;
  font-family: inherit;
}
input:disabled{ color: var(--muted); background: var(--bg); }
textarea{ resize: vertical; }
input:focus, select:focus, textarea:focus{ outline: none; border-color: var(--accent); }
.row2{ display:flex; gap:12px; }
.row2 > div{ flex:1; }
.primary-btn{
  margin-top: 20px; width:100%; padding: 12px; background: var(--accent); color:#fff;
  border:none; border-radius: 9px; font-size:15px; font-weight:700; cursor:pointer;
  text-align:center; text-decoration:none; display:inline-block;
}
.primary-btn:hover{ filter: brightness(1.08); color:#fff; }
.secondary-btn{
  margin-top: 20px; padding: 12px 16px; background: transparent; color: var(--muted);
  border:1px solid var(--line); border-radius: 9px; font-size:14px; cursor:pointer;
  text-decoration:none; display:inline-block; text-align:center;
}
.small-btn{ margin-top:0; padding: 6px 12px; font-size:12.5px; }
.danger-btn{ color: var(--red); border-color: var(--red); }
.checkbox-row{ display:flex; flex-direction:column; gap:10px; margin-top:6px; }
.checkbox-label{ display:flex; align-items:center; gap:8px; font-size: 14px; color: var(--text); margin:0; }
.checkbox-label input{ width:auto; }
.back-link{ display:inline-block; margin-top:18px; font-size:13.5px; color: var(--muted); text-decoration:none; }
.color-row{ display:flex; align-items:center; gap:12px; }
.color-row input[type=color]{ width:52px; height:38px; padding:2px; cursor:pointer; }
.current-logo-row{ display:flex; align-items:center; gap:14px; margin-bottom:10px; }
.current-logo{ height:48px; max-width:180px; object-fit:contain; background: var(--bg); border-radius:6px; padding:6px; border:1px solid var(--line); }
.plan-locked{
  background: var(--bg); border: 1px dashed var(--line); border-radius: 8px;
  padding: 14px 16px; font-size: 13.5px; color: var(--muted); margin-top: 8px;
}

.msg{ margin-top: 14px; font-size: 13.5px; padding: 10px 12px; border-radius: 8px; display:none; }
.msg.ok{ display:block; background: var(--green-bg); color: var(--green); }
.msg.err{ display:block; background: var(--red-bg); color: var(--red); }
.msg.show{ display:block; }
.flash-wrap{ max-width: 480px; margin: 0 auto 10px; }

/* ---- modal ---- */
.modal-backdrop{
  display:none; position: fixed; inset:0; background: rgba(20,25,35,0.5);
  align-items:center; justify-content:center; z-index: 100;
}
.modal-backdrop.show{ display:flex; }
.modal{
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 24px; width: 320px; box-shadow: 0 8px 24px rgba(20,30,45,0.18);
}
.modal h3{ margin:0 0 6px; font-size: 16px; }
.modal-hint{ font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.modal-actions{ display:flex; gap:10px; }
.modal-actions button{ flex:1; margin-top:16px; }

/* ---- histórico / usuários (tabelas) ---- */
.historico-wrap{ max-width: 1100px; margin: 0 auto; }
.historico-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom: 18px; }
.historico-head h2{ margin:0; font-size: 19px; }
.export-btn{ margin-top:0; }
.filter-bar{
  display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--card-shadow);
}
.filter-bar label{ margin: 0 0 6px; }
.filter-bar > div{ min-width: 150px; }
.filter-search{ flex:1; min-width: 200px; }
.filter-btn{ margin-top:0; width:auto; padding: 10px 20px; }

.hist-table-wrap{
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  overflow-x:auto; box-shadow: var(--card-shadow);
}
.hist-table{ width:100%; border-collapse: collapse; font-size: 13.5px; }
.hist-table th{
  text-align:left; padding: 12px 14px; border-bottom: 2px solid var(--line);
  color: var(--muted); font-size: 12px; text-transform:uppercase; letter-spacing:0.03em;
}
.hist-table td{ padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align:top; }
.hist-table tr:last-child td{ border-bottom:none; }
.hist-table tr.row-inactive{ opacity: 0.55; }
.muted-cell{ color: var(--muted); font-size:12.5px; }
.actions-cell{ display:flex; gap:8px; white-space:nowrap; }
.status-ok{ color: var(--green); font-weight:700; font-size:12.5px; }
.status-off{ color: var(--muted); font-weight:700; font-size:12.5px; }
.empty-note{ color: var(--muted); font-size: 14px; text-align:center; padding: 40px 0; }
