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

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e4e8;
  --text: #1f2328;
  --text-soft: #57606a;
  --primary: #2c5282;
  --primary-hover: #234069;
  --success: #2f855a;
  --danger: #c53030;
  --warning: #d69e2e;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header / nav */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 600; font-size: 16px; color: var(--primary); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
}
.topbar nav a:hover { background: #eef0f3; text-decoration: none; }
.topbar nav a.active { background: var(--primary); color: white; }
.topbar .user-info { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-soft); }
.topbar .user-info .badge {
  background: #e2e8f0; color: var(--text); padding: 2px 8px; border-radius: 10px; font-size: 11px;
}
.topbar .user-info .badge.admin { background: var(--primary); color: white; }
.topbar .user-info .badge.leitura { background: var(--warning); color: white; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.page-title { font-size: 20px; font-weight: 600; margin-bottom: 16px; }
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* Botões */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
  font-family: inherit;
}
.btn:hover { background: #eef0f3; }
.btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn.danger:hover { background: #9b2424; }
.btn.success { background: var(--success); color: white; border-color: var(--success); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.icon { padding: 4px 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tabela */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
thead { background: #f8f9fa; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
th { font-weight: 600; color: var(--text-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
tbody tr:hover { background: #f8f9fa; }
tbody tr:last-child td { border-bottom: none; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 4px; }

/* Forms */
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-row label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 700px) { .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; } }

.checkbox-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  max-height: 160px;
  overflow-y: auto;
}
.checkbox-list label {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; cursor: pointer;
  font-weight: normal; font-size: 13px; text-transform: none; letter-spacing: normal; color: var(--text);
}
.checkbox-list label:hover { background: #eef0f3; }
.checkbox-list input[type="checkbox"] { width: auto; cursor: pointer; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.modal.large { max-width: 720px; }
.modal-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-soft); padding: 0; line-height: 1;
}

/* Progresso */
.progress-bar {
  height: 14px; background: #e2e8f0; border-radius: 7px; overflow: hidden;
}
.progress-bar .fill {
  height: 100%; background: linear-gradient(90deg, var(--success), #38a169);
  transition: width 0.3s;
}
.progress-info {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px;
}
.progress-info strong { color: var(--success); }

/* Tags / chips */
.chip {
  display: inline-block; background: #e2e8f0; color: var(--text);
  padding: 2px 8px; border-radius: 10px; font-size: 11px; margin-right: 4px; margin-bottom: 2px;
}
.chip.success { background: #c6f6d5; color: var(--success); }
.chip.warning { background: #fef3c7; color: #92400e; }

/* Status indicador */
.status-ok { color: var(--success); font-weight: 600; }
.status-warn { color: var(--warning); font-weight: 600; }
.status-bad { color: var(--danger); font-weight: 600; }

/* Empty state */
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-soft);
}
.empty p { margin-bottom: 12px; }

/* Toast */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--text); color: white; padding: 10px 16px; border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); font-size: 13px; min-width: 220px;
  animation: toast-in 0.2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Login page */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2c5282 0%, #1a365d 100%); padding: 16px;
}
.login-box {
  background: var(--surface); padding: 32px; border-radius: 8px;
  width: 100%; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-box h1 { font-size: 22px; margin-bottom: 6px; color: var(--primary); }
.login-box p.sub { color: var(--text-soft); margin-bottom: 22px; font-size: 13px; }
.login-box .btn { width: 100%; padding: 10px; }
.login-box .error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* Obras / seções */
.secao {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 16px; overflow: hidden;
}
.secao-header {
  background: #f8f9fa; padding: 10px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.secao-header h3 { font-size: 15px; font-weight: 600; }
.secao-actions { display: flex; gap: 6px; }

.obra-row td.titulo strong { display: block; }
.obra-row td.titulo small { color: var(--text-soft); }
.obra-row.concluida td.titulo strong { text-decoration: line-through; color: var(--text-soft); }

/* Filtros */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters label { font-size: 12px; color: var(--text-soft); font-weight: 600; }
.filters select { width: auto; min-width: 200px; }

/* Stats cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.3px; }
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--primary); margin-top: 4px; }
