:root {
  --primary: #1a56db;
  --primary-dark: #1245b3;
  --danger: #e02424;
  --success: #057a55;
  --warning: #c27803;
  --bg: #f3f4f6;
  --sidebar-bg: #111827;
  --sidebar-text: #d1d5db;
  --sidebar-hover: #1f2937;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── LAYOUT ── */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 240px; min-width: 240px;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 16px 12px;
  border-bottom: 1px solid #374151;
}
.sidebar-logo h1 { color: #fff; font-size: 16px; font-weight: 700; }
.sidebar-logo small { color: #6b7280; font-size: 11px; }

.sidebar nav { flex: 1; padding: 8px 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: var(--sidebar-text);
  text-decoration: none; font-size: 14px;
  transition: background .15s;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: var(--sidebar-hover); color: #fff;
}
.sidebar nav a .icon { width: 20px; text-align: center; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid #374151;
  color: #6b7280; font-size: 12px;
}
.sidebar-footer strong { display: block; color: var(--sidebar-text); }
.sidebar-section {
  padding: 10px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #4b5563;
}

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h2 { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── CARDS ── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--card-bg); border-radius: 8px;
  padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card-stat { font-size: 32px; font-weight: 700; line-height: 1; }
.card-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.card.danger .card-stat { color: var(--danger); }
.card.success .card-stat { color: var(--success); }
.card.primary .card-stat { color: var(--primary); }

/* ── TABELA ── */
.table-wrap { background: var(--card-bg); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border); }
.table-header { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.table-header h3 { font-size: 15px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); background: #f9fafb; }
td { padding: 11px 14px; font-size: 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-ok      { background: #d1fae5; color: #065f46; }
.badge-baixo   { background: #fee2e2; color: #991b1b; }
.badge-entrada { background: #dbeafe; color: #1e40af; }
.badge-saida   { background: #fef3c7; color: #92400e; }
.badge-insumo  { background: #ede9fe; color: #5b21b6; }
.badge-equip   { background: #e0f2fe; color: #075985; }

/* ── BOTÕES ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; border: none;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: opacity .15s;
  text-decoration: none;
}
.btn:hover { opacity: .85; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── FORMULÁRIOS ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--text-muted); }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; color: var(--text);
  background: #fff; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: 10px;
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-header {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── FILTROS ── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; flex: 1; min-width: 140px; }

/* ── SEARCH ── */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 34px; }
.search-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

/* ── LOGIN ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-card p  { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-err { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; display: none; }

/* ── ALERTAS ── */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error   { background: #fee2e2; color: #991b1b; }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty .icon { font-size: 48px; margin-bottom: 12px; }

/* ── LOADING ── */
.loading { text-align: center; padding: 32px; color: var(--text-muted); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 768px) {
  .sidebar { width: 0; min-width: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ── SIDEBAR SECTIONS ── */
.sidebar-section {
  padding: 14px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #4b5563;
  text-transform: uppercase;
}

/* ── STATUS BADGES CHAMADOS ── */
.badge-aberto       { background: #fee2e2; color: #991b1b; }
.badge-em_andamento { background: #fef3c7; color: #92400e; }
.badge-fechado      { background: #d1fae5; color: #065f46; }
.badge-urgente      { background: #fce7f3; color: #9d174d; }
.badge-alta         { background: #fee2e2; color: #991b1b; }
.badge-normal       { background: #e0f2fe; color: #075985; }
.badge-baixa        { background: #f3f4f6; color: #6b7280; }

/* ── CHAMADO CARD ── */
.chamado-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
}
.chamado-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); border-color: #d1d5db; }
.chamado-card.urgente { border-left: 4px solid var(--danger); }
.chamado-card.alta    { border-left: 4px solid #f97316; }
.chamado-card.normal  { border-left: 4px solid var(--primary); }
.chamado-card.baixa   { border-left: 4px solid #9ca3af; }
.chamado-numero { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.chamado-cliente { font-weight: 600; font-size: 14px; }
.chamado-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.chamado-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

/* ── AGENDA ── */
.agenda-dia {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}
.agenda-dia-header {
  padding: 10px 16px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.agenda-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: background .1s;
}
.agenda-item:last-child { border-bottom: none; }
.agenda-item:hover { background: #f9fafb; }
.agenda-hora { font-size: 13px; font-weight: 700; color: var(--primary); text-align: center; }
.agenda-info-nome { font-weight: 600; font-size: 13px; }
.agenda-info-meta { font-size: 12px; color: var(--text-muted); }

/* ── CALENDÁRIO ── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg);
}
.cal-header-day {
  padding: 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
}
.cal-day {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 90px;
  padding: 6px;
  vertical-align: top;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.cal-day.hoje .cal-day-num {
  background: var(--primary);
  color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.cal-day.outro-mes { background: #f9fafb; }
.cal-event {
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 10px;
  margin-bottom: 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event.urgente    { background: var(--danger); }
.cal-event.em_andamento { background: #d97706; }
.cal-event.fechado    { background: #6b7280; }
.cal-nav {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.cal-nav h3 { flex: 1; text-align: center; font-size: 15px; }

/* ── DETALHE CHAMADO ── */
.chamado-detalhe-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}
@media (max-width: 900px) { .chamado-detalhe-grid { grid-template-columns: 1fr; } }
.info-row { display: flex; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.info-label { font-weight: 600; min-width: 100px; color: var(--text-muted); font-size: 13px; }
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px,1fr)); gap: 8px; margin-top: 8px; }
.foto-thumb {
  aspect-ratio: 1; border-radius: 6px; object-fit: cover;
  border: 2px solid var(--border); cursor: pointer; width: 100%;
}
.foto-thumb:hover { border-color: var(--primary); }

/* ── LOG ── */
.log-row td:first-child { font-family: monospace; font-size: 12px; }
.acao-badge {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 700; font-family: monospace;
}
.acao-LOGIN         { background: #e0f2fe; color: #075985; }
.acao-CRIAR         { background: #d1fae5; color: #065f46; }
.acao-EDITAR        { background: #fef3c7; color: #92400e; }
.acao-EXCLUIR       { background: #fee2e2; color: #991b1b; }
.acao-ENTRADA       { background: #dbeafe; color: #1e40af; }
.acao-SAIDA         { background: #fce7f3; color: #9d174d; }
.acao-ABRIR         { background: #d1fae5; color: #065f46; }
.acao-FECHAR        { background: #e0f2fe; color: #075985; }
.acao-ATUALIZAR     { background: #fef3c7; color: #92400e; }
