:root {
  --blue-900: #0d3b73;
  --blue-700: #1a5fb4;
  --blue-600: #2571d1;
  --blue-100: #e8f1fc;
  --gray-900: #1b2430;
  --gray-700: #4a5568;
  --gray-500: #718096;
  --gray-300: #cbd5e0;
  --gray-200: #e2e8f0;
  --gray-100: #f4f6f9;
  --white: #ffffff;
  --green-600: #2f9e44;
  --green-100: #e6f7ec;
  --amber-600: #c77700;
  --amber-100: #fff3e0;
  --red-600: #d0342c;
  --red-100: #fdeceb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08), 0 1px 2px rgba(20, 30, 50, 0.06);
  --shadow-lg: 0 8px 24px rgba(20, 30, 50, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- layout ---------- */
.topbar {
  background: linear-gradient(135deg, var(--blue-900), var(--blue-700));
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: #7fd1ae; box-shadow: 0 0 0 3px rgba(127,209,174,0.25); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a, .topbar nav button.linklike {
  color: rgba(255,255,255,0.88);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
}
.topbar nav a:hover, .topbar nav button.linklike:hover { background: rgba(255,255,255,0.14); text-decoration: none; }
.topbar nav a.active { background: rgba(255,255,255,0.22); }
.topbar .user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar .user .name { font-weight: 600; }
.topbar .logout { color: white; opacity: 0.85; }

.container { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.container.narrow { max-width: 760px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.subtitle { color: var(--gray-500); font-size: 14px; margin: 0 0 20px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--blue-700); }
.stat-card .label { font-size: 12.5px; color: var(--gray-500); margin-top: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; background: var(--gray-200); color: var(--gray-900);
  transition: filter .12s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.96); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--blue-700); color: white; }
.btn.success { background: var(--green-600); color: white; }
.btn.danger { background: var(--red-600); color: white; }
.btn.outline { background: white; border-color: var(--gray-300); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--gray-300); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: white; color: var(--gray-900);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-600); outline-offset: 1px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; }
.hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ---------- table ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-500); padding: 10px 12px; border-bottom: 2px solid var(--gray-200); }
table.list td { padding: 12px; border-bottom: 1px solid var(--gray-200); font-size: 14px; vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover { background: var(--gray-100); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.badge.status-ABERTA { background: var(--amber-100); color: var(--amber-600); }
.badge.status-EM_ANDAMENTO { background: var(--blue-100); color: var(--blue-700); }
.badge.status-CONCLUIDA_TECNICO { background: #f1e9fc; color: #7341c6; }
.badge.status-FINALIZADA { background: var(--green-100); color: var(--green-600); }
.badge.status-CANCELADA { background: var(--red-100); color: var(--red-600); }

/* ---------- misc ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--gray-500); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }

.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--gray-900); color: white; padding: 11px 16px; border-radius: 8px; font-size: 13.5px; box-shadow: var(--shadow-lg); max-width: 340px; }
.toast.error { background: var(--red-600); }
.toast.success { background: var(--green-600); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at top, #16406e, #0d2138 70%); }
.login-card { background: white; width: 100%; max-width: 380px; border-radius: 14px; padding: 34px 30px; box-shadow: var(--shadow-lg); }
.login-card .logo-row { text-align: center; margin-bottom: 18px; }
.login-card .logo-row .icon { font-size: 34px; }
.login-card .logo-row .company { font-weight: 700; color: var(--blue-700); font-size: 15px; margin-top: 6px; }
.login-card .logo-row .tag { color: var(--gray-500); font-size: 12.5px; }
.error-msg { color: var(--red-600); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* equipment / photos */
.equip-card { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.equip-card .equip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.equip-title { font-weight: 700; font-size: 15px; }
.equip-sub { color: var(--gray-500); font-size: 12.5px; }
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; }
.slot { border: 1px dashed var(--gray-300); border-radius: 8px; padding: 10px; text-align: center; background: var(--gray-100); }
.slot.done { border-style: solid; border-color: var(--green-600); background: var(--green-100); }
.slot .slot-label { font-size: 12px; font-weight: 700; color: var(--gray-700); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.slot .thumbs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 8px; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.thumb .del { position: absolute; top: 0; right: 0; background: rgba(208,52,44,0.9); color: white; border: none; width: 18px; height: 18px; font-size: 11px; line-height: 18px; cursor: pointer; }

/* ---------- lightbox (visualizar foto em tela cheia) ---------- */
.lightbox-backdrop { position: fixed; inset: 0; background: rgba(10,15,25,0.92); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lightbox-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: var(--shadow-lg); }
.lightbox-actions { position: absolute; top: 18px; right: 18px; display: flex; gap: 10px; }
.lightbox-actions button { background: rgba(255,255,255,0.14); color: white; border: none; width: 38px; height: 38px; border-radius: 50%; font-size: 16px; cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center; }
.lightbox-actions button:hover { background: rgba(255,255,255,0.26); }

/* ---------- agrupamento de serviços do mesmo equipamento ---------- */
.servico-sub { border-top: 1px solid var(--gray-200); padding-top: 12px; margin-top: 12px; }
.servico-sub.first { border-top: none; padding-top: 0; margin-top: 0; }

.mini-badge.numero { background: var(--blue-100); color: var(--blue-700); }

/* ---------- QR Code (admin/clientes.html) ---------- */
.qr-preview { display: flex; justify-content: center; padding: 14px 0; }
.qr-caption { text-align: center; font-weight: 700; margin-bottom: 14px; }
.fachada-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.fachada-box .thumb { width: 110px; height: 90px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,25,40,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: white; border-radius: var(--radius); padding: 22px; max-width: 480px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--gray-300); background: white; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--gray-700); }
.tab-btn.active { background: var(--blue-700); color: white; border-color: var(--blue-700); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 10px 20px; font-size: 14px; }
.info-grid .k { color: var(--gray-500); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.info-grid .v { font-weight: 600; }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,0.15); border-top-color: var(--blue-700); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.file-btn { display: inline-block; }
.file-btn input[type=file] { display: none; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--gray-100); border: 1px solid var(--gray-200); font-size: 13px; font-weight: 600; color: var(--gray-700); }
.chip .chip-remove { border: none; background: none; color: var(--gray-500); cursor: pointer; font-size: 15px; line-height: 1; width: 20px; height: 20px; border-radius: 50%; }
.chip .chip-remove:hover { background: var(--red-100); color: var(--red-600); }
.chip-add-row { display: flex; gap: 8px; }
.chip-add-row input { flex: 1; }

/* ---------- árvore Clientes -> Contratos -> Locais ---------- */
.tree-node { border: 1px solid var(--gray-200); border-radius: 8px; margin-bottom: 8px; }
.tree-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex-wrap: wrap; }
.tree-toggle { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--gray-500); width: 20px; }
.tree-label { flex: 1; min-width: 160px; font-size: 14px; }
.tree-children { padding: 4px 12px 12px 34px; border-top: 1px solid var(--gray-200); }
.tree-children .tree-node { margin-top: 10px; }

/* ---------- filtros / relatórios ---------- */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; }
.report-row { display: flex; align-items: center; gap: 10px; }
.report-row input[type="checkbox"] { width: auto; }

/* ---------- painel do cliente: linha do tempo de andamento ---------- */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--gray-200); }
.tl-item { position: relative; padding-bottom: 22px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -30px; top: 1px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; color: white; font-weight: 700; }
.tl-dot.done { background: var(--green-600); }
.tl-dot.current { background: var(--blue-600); box-shadow: 0 0 0 4px var(--blue-100); }
.tl-dot.pending { background: var(--gray-300); }
.tl-title { font-weight: 700; font-size: 14px; }
.tl-title.pending-text { color: var(--gray-500); font-weight: 600; }
.tl-date { font-size: 12.5px; color: var(--gray-500); margin-top: 2px; }

.equip-row-simple { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-200); }
.equip-row-simple:last-child { border-bottom: none; }
.mini-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.mini-badge.completo { background: var(--green-100); color: var(--green-600); }
.mini-badge.pendente { background: var(--gray-200); color: var(--gray-700); }

.scope-note { display: flex; gap: 10px; align-items: flex-start; background: var(--gray-100); border: 1px dashed var(--gray-300); border-radius: 8px; padding: 13px 15px; font-size: 13px; color: var(--gray-700); }

@media (max-width: 640px) {
  .container { padding: 14px 12px 50px; }
  .topbar { padding: 10px 12px; }
}
