:root{
  --bg:#f3f6fb;
  --card:#fff;
  --text:#1f2937;
  --muted:#64748b;
  --primary:#155e75;
  --primary2:#0e7490;
  --border:#e5e7eb;
  --danger:#dc2626;
  --success:#15803d;
  --warning:#ca8a04;
  --shadow:0 10px 30px rgba(15,23,42,.08);
  --topbar-h:64px;
}
*{box-sizing:border-box}
html,body{width:100%;max-width:100%;overflow-x:hidden}
body{margin:0;font-family:Arial,Helvetica,sans-serif;background:var(--bg);color:var(--text);-webkit-text-size-adjust:100%}
a{color:var(--primary);text-decoration:none}a:hover{text-decoration:underline}
img,video,canvas,svg{max-width:100%;height:auto}
hr{border:0;border-top:1px solid var(--border);margin:18px 0}

.topbar{min-height:var(--topbar-h);background:#fff;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:10px;padding:0 18px;position:sticky;top:0;z-index:50;box-shadow:0 4px 18px rgba(15,23,42,.04)}
.topbar-left{display:flex;align-items:center;gap:10px;min-width:0;flex:1}
.topbar-brand{min-width:0;flex:1}
.topbar-brand a{display:block;font-weight:800;color:var(--primary);font-size:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.topbar-user{display:flex;gap:12px;align-items:center;color:var(--muted);font-size:14px;min-width:0;white-space:nowrap;flex-shrink:0}
.topbar-user span{overflow:hidden;text-overflow:ellipsis;max-width:220px}
.notif-link{font-weight:700}
.menu-toggle{display:none;background:var(--primary);color:#fff;border:0;border-radius:12px;padding:9px 12px;font-weight:800;line-height:1;min-width:42px;min-height:40px;cursor:pointer}

.layout{display:flex;min-height:calc(100vh - var(--topbar-h));min-width:0}
.sidebar{width:260px;background:#0f172a;color:#cbd5e1;padding:18px;flex-shrink:0}
.sidebar nav{display:flex;flex-direction:column;gap:6px}
.sidebar a{color:#e2e8f0;padding:12px 12px;border-radius:12px;font-weight:700}
.sidebar a:hover{background:#1e293b;text-decoration:none}

.content{padding:26px;width:100%;max-width:1400px;margin:0 auto;min-width:0}
.page-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:20px;min-width:0}
.page-head h1{margin:0;font-size:28px;line-height:1.15;word-break:break-word}
.page-head p{color:var(--muted);margin:6px 0 0;line-height:1.45}
.page-head-actions,.card-actions-end{display:flex;gap:10px;flex-wrap:wrap;align-items:center}

.card{background:var(--card);border:1px solid var(--border);border-radius:18px;box-shadow:var(--shadow);padding:20px;margin-bottom:18px;min-width:0}
.card h2{font-size:20px;margin:0 0 14px}
.card p{line-height:1.55;word-break:break-word}
.card-subtitle{margin:-6px 0 14px;color:var(--muted)}

.grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:16px;min-width:0}
.col-12{grid-column:span 12}.col-8{grid-column:span 8}.col-6{grid-column:span 6}.col-4{grid-column:span 4}.col-3{grid-column:span 3}
.form-group{min-width:0}
.form-group label,label{display:block;font-weight:700;margin-bottom:8px;font-size:15px;color:#0f172a}
.form-group .small,.field-help,.login-help{display:block;margin-top:7px;font-size:12px;line-height:1.45;color:var(--muted)}
input:not([type]),
input[type=text],input[type=email],input[type=password],input[type=date],input[type=number],input[type=tel],input[type=url],input[type=search],
select,textarea,
.form-control{
  display:block;width:100%;max-width:100%;border:1px solid var(--border);border-radius:14px;padding:14px 14px;background:#fff;color:var(--text);font-size:16px;line-height:1.35;min-height:50px;box-shadow:inset 0 1px 1px rgba(15,23,42,.02)
}
textarea{min-height:140px;resize:vertical}
input::placeholder,textarea::placeholder{color:#94a3b8}
input:focus,select:focus,textarea:focus,.form-control:focus{outline:3px solid rgba(14,116,144,.18);border-color:var(--primary2)}
input[type=checkbox],input[type=radio]{width:auto;min-height:auto}
input[type=file]{display:block;width:100%;max-width:100%;border:1px dashed #cbd5e1;border-radius:14px;padding:14px 12px;background:#f8fafc;color:var(--muted);font-size:15px;min-height:54px}
.form-section-title{margin:0 0 6px;font-size:22px}
.form-section-desc{margin:0 0 14px;color:var(--muted)}

.btn,button.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:12px;padding:12px 15px;background:var(--primary);color:#fff;font-weight:800;cursor:pointer;min-height:46px;text-align:center
}
.btn:hover{text-decoration:none;background:var(--primary2)}
.btn-secondary{background:#475569}
.btn-danger{background:var(--danger)}
.btn-success{background:var(--success)}
.btn-warning{background:var(--warning)}
.btn-light{background:#e2e8f0;color:#0f172a}
.btn-outline{background:#fff;color:var(--primary);border:1px solid rgba(21,94,117,.25)}
.btn-outline-danger{background:#fff;color:var(--danger);border:1px solid #fecaca}
.btn-outline-danger:hover{background:#fee2e2;color:#991b1b}
.actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.actions form{display:inline-flex;gap:8px;flex-wrap:wrap;max-width:100%}
.actions input,.actions textarea,.actions select{min-width:0}
.action-stack{display:grid;gap:12px}
.action-item{border:1px solid var(--border);border-radius:16px;padding:14px;background:#f8fafc}
.action-item h3{margin:0 0 8px;font-size:16px}
.action-item p{margin:0 0 12px;color:var(--muted);font-size:14px;line-height:1.45}
.inline-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}

.table-wrap{overflow:auto;background:#fff;border:1px solid var(--border);border-radius:18px;box-shadow:var(--shadow);max-width:100%;-webkit-overflow-scrolling:touch}
table{width:100%;border-collapse:collapse;min-width:780px}
th,td{padding:13px 14px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top;word-break:break-word}
th{background:#f8fafc;color:#334155;font-size:13px;text-transform:uppercase;letter-spacing:.03em}
tr:last-child td{border-bottom:0}

.badge{display:inline-flex;border-radius:999px;padding:5px 9px;font-size:12px;font-weight:800;line-height:1.2}
.badge-warning{background:#fef3c7;color:#92400e}
.badge-info{background:#cffafe;color:#155e75}
.badge-primary{background:#dbeafe;color:#1d4ed8}
.badge-danger{background:#fee2e2;color:#b91c1c}
.badge-blue{background:#e0f2fe;color:#0369a1}
.badge-purple{background:#ede9fe;color:#6d28d9}
.badge-success{background:#dcfce7;color:#166534}
.badge-muted{background:#e5e7eb;color:#374151}

.alert{padding:13px 15px;border-radius:12px;margin-bottom:16px}
.alert-success{background:#dcfce7;color:#166534}
.alert-error{background:#fee2e2;color:#991b1b}
.alert-info{background:#dbeafe;color:#1d4ed8}
.alert-warning{background:#fef3c7;color:#92400e}

.login-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px}
.login-card{width:100%;max-width:460px;background:#fff;border:1px solid var(--border);border-radius:24px;box-shadow:var(--shadow);padding:28px}
.login-card h1{margin-top:0;color:var(--primary)}
.login-install-box{margin-top:18px;padding:14px;border:1px dashed #bfd8df;border-radius:16px;background:#f7fbfc}
.login-install-box p{margin:0 0 10px;color:var(--muted);font-size:14px}
.login-install-fallback{display:none;font-size:13px;color:var(--muted);margin-top:10px;line-height:1.45}

.stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}
.stat{background:#fff;border:1px solid var(--border);border-radius:18px;padding:18px;box-shadow:var(--shadow);min-width:0}
.stat strong{display:block;font-size:28px}
.stat span{color:var(--muted)}
.photo-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:14px}
.photo-card{border:1px solid var(--border);border-radius:14px;overflow:hidden;background:#fff}
.photo-card img{width:100%;height:145px;object-fit:cover;display:block}
.photo-card div{padding:10px;font-size:13px}
.timeline{border-left:3px solid #cbd5e1;padding-left:16px}
.timeline-item{margin:0 0 15px;background:#fff;border:1px solid var(--border);border-radius:12px;padding:12px;word-break:break-word}
.muted{color:var(--muted)}
.small{font-size:13px}
.filters{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:10px;margin-bottom:16px}.filters > *{min-width:0}
.checkbox-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:8px}
.checkbox-item{display:flex;gap:8px;align-items:center;background:#f8fafc;border:1px solid var(--border);border-radius:12px;padding:9px}
.checkbox-item input{width:auto;min-height:auto}
.empty{padding:24px;text-align:center;color:var(--muted)}
.pagination{display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap;margin:18px 0}
.mobile-only{display:none}.desktop-only{display:initial}

.upload-shell{display:grid;gap:10px}
.upload-buttons{display:flex;gap:10px;flex-wrap:wrap}
.upload-buttons .btn{flex:1 1 180px}
.upload-hidden{display:none !important}
.upload-file-name{font-size:13px;color:var(--muted);background:#f8fafc;border:1px solid var(--border);padding:10px 12px;border-radius:12px}
.upload-hint{display:block;font-size:12px;line-height:1.35;color:var(--muted);background:#f8fafc;border:1px solid var(--border);border-radius:10px;padding:8px 10px}
.upload-info{background:#eff6ff;color:#1d4ed8;border-color:#bfdbfe}
.upload-ok{background:#dcfce7;color:#166534;border-color:#bbf7d0}
.upload-warn{background:#fef3c7;color:#92400e;border-color:#fde68a}
button:disabled,.btn:disabled,input[type=submit]:disabled{opacity:.68;cursor:not-allowed;filter:grayscale(.15)}

@media(max-width:900px){
  :root{--topbar-h:60px}
  .menu-toggle{display:inline-flex;align-items:center;justify-content:center}
  .layout{display:block;min-width:0}
  .content{padding:16px;max-width:100%;overflow-x:hidden}
  .sidebar{display:block;position:fixed;top:var(--topbar-h);left:0;bottom:0;width:min(84vw,310px);z-index:70;transform:translateX(-105%);transition:transform .22s ease;box-shadow:18px 0 35px rgba(15,23,42,.25);overflow-y:auto}
  .sidebar-open .sidebar{transform:translateX(0)}
  .sidebar-open::after{content:"";position:fixed;left:0;right:0;top:var(--topbar-h);bottom:0;background:rgba(15,23,42,.42);z-index:60}
  .sidebar-open .content{pointer-events:none}
  .grid{grid-template-columns:1fr}
  .col-12,.col-8,.col-6,.col-4,.col-3{grid-column:span 1}
  .stats{grid-template-columns:1fr 1fr}
  .page-head{display:block}
  .page-head .btn,.page-head-actions{margin-top:12px}
  .topbar{padding:0 10px}
  .topbar-left{flex:1;min-width:0}
  .topbar-brand a{font-size:15px;max-width:100%}
  .topbar-user{gap:8px;font-size:13px}
  .topbar-user span{display:none}
  .notif-link{max-width:110px;overflow:hidden;text-overflow:ellipsis}
  .card{padding:16px;border-radius:16px}
  .photo-grid{grid-template-columns:repeat(auto-fill,minmax(130px,1fr))}
  .actions{display:grid;grid-template-columns:1fr;align-items:stretch}
  .actions .btn,.actions form,.actions form .btn{width:100%}
  .actions form{display:grid;grid-template-columns:1fr}
  .filters{grid-template-columns:1fr}
  .inline-fields{grid-template-columns:1fr}
}

@media(max-width:700px){
  .table-wrap{overflow:visible;background:transparent;border:0;border-radius:0;box-shadow:none}
  .table-wrap table{min-width:0;width:100%;border-collapse:separate;border-spacing:0}
  .table-wrap thead{display:none}
  .table-wrap tbody,.table-wrap tr,.table-wrap td{display:block;width:100%}
  .table-wrap tr{background:#fff;border:1px solid var(--border);border-radius:16px;margin:0 0 12px;box-shadow:var(--shadow);overflow:hidden}
  .table-wrap td{display:grid;grid-template-columns:minmax(92px,35%) minmax(0,1fr);gap:10px;padding:11px 12px;border-bottom:1px solid var(--border);align-items:start}
  .table-wrap td::before{content:attr(data-label);font-weight:800;color:#334155;font-size:12px;text-transform:uppercase;letter-spacing:.02em}
  .table-wrap td:last-child{border-bottom:0}
  .table-wrap td.empty{display:block;text-align:center}
  .table-wrap td.empty::before{display:none}
  .table-wrap td .btn{width:100%;margin-top:4px}
}

@media(max-width:560px){
  .stats{grid-template-columns:1fr}
  .topbar-brand a{font-size:14px;max-width:100%}
  .topbar-user a:not(.notif-link){font-size:13px}
  .btn{width:100%}
  .page-head h1{font-size:23px}
  .card h2{font-size:18px}
  .photo-grid{grid-template-columns:1fr 1fr}
  .photo-card img{height:120px}
  .checkbox-list{grid-template-columns:1fr}
  .desktop-only{display:none}
  .mobile-only{display:initial}
  .topbar-user{gap:6px}
  input[type=file]{padding:13px 10px;background:#f8fafc}
  .upload-buttons{display:grid;grid-template-columns:1fr}
}


/* v2.5 - ajustes mobile/câmera/dashboard */
.stat-link{
  display:block;
  color:inherit;
  text-decoration:none;
}
.stat-link:hover{
  text-decoration:none;
  border-color:rgba(21,94,117,.35);
  transform:translateY(-1px);
}
.stat-link:focus-visible{
  outline:3px solid rgba(14,116,144,.22);
  outline-offset:2px;
}
.upload-hidden{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  opacity:0 !important;
  overflow:hidden !important;
  pointer-events:none !important;
  left:-9999px !important;
}
details.card summary{
  list-style:none;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
details.card summary::-webkit-details-marker{display:none}
details.card summary::after{
  content:"Abrir";
  font-size:12px;
  font-weight:800;
  color:var(--primary);
  background:#e0f2fe;
  border-radius:999px;
  padding:6px 10px;
}
details.card[open] summary::after{content:"Recolher"}
details.card summary h2{margin:0}
.details-body{margin-top:16px}

.camera-open{overflow:hidden}
.camera-modal{
  position:fixed;
  inset:0;
  z-index:9999;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(15,23,42,.72);
  padding:16px;
}
.camera-box{
  width:min(96vw,520px);
  background:#fff;
  border-radius:22px;
  box-shadow:0 25px 80px rgba(15,23,42,.45);
  overflow:hidden;
}
.camera-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
}
.camera-close{
  border:0;
  background:#e2e8f0;
  color:#0f172a;
  border-radius:10px;
  width:38px;
  height:38px;
  font-size:24px;
  line-height:1;
}
.camera-video{
  display:block;
  width:100%;
  max-height:58vh;
  background:#0f172a;
  object-fit:cover;
}
.camera-help{
  margin:12px 16px 0;
  color:var(--muted);
  font-size:14px;
}
.camera-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  padding:16px;
}

@media(max-width:560px){
  .camera-actions{grid-template-columns:1fr}
  details.card summary{align-items:flex-start}
}


/* v2.5.1 - correção para clique em galeria/câmera em celulares */
.upload-hidden{
  display:block !important;
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  opacity:0 !important;
  overflow:hidden !important;
  pointer-events:none !important;
  left:-9999px !important;
  top:auto !important;
}

/* v2.5.2 - labels de upload compatíveis com celular */
label.btn{cursor:pointer}
label.btn:focus-within{outline:3px solid rgba(14,116,144,.18)}


/* v2.6 - modo offline */
.offline-dashboard-card,.offline-status-card{
  border-left:5px solid var(--primary);
}
.offline-list{
  display:grid;
  gap:12px;
}
.offline-item{
  border:1px solid var(--border);
  background:#fff;
  border-radius:16px;
  padding:14px;
  box-shadow:0 6px 18px rgba(15,23,42,.05);
}
.offline-item strong{
  display:block;
  margin-bottom:6px;
}
.offline-item .badge{
  margin-bottom:6px;
}
.offline-error{
  color:#991b1b;
  background:#fee2e2;
  border-radius:10px;
  padding:8px 10px;
}
@media(max-width:560px){
  .offline-dashboard-card .actions,
  .offline-status-card .actions{
    display:grid;
    grid-template-columns:1fr;
  }
}


/* v2.6.1 - visualizador de imagens dentro do sistema */
.image-viewer-open{overflow:hidden}
.image-viewer-modal{
  position:fixed;
  inset:0;
  z-index:10000;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(15,23,42,.82);
  padding:16px;
}
.image-viewer-box{
  width:min(96vw,980px);
  max-height:94vh;
  background:#fff;
  border-radius:22px;
  box-shadow:0 25px 90px rgba(15,23,42,.5);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.image-viewer-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
}
.image-viewer-title{display:block;font-size:15px;color:#0f172a}
.image-viewer-caption{margin:4px 0 0;color:var(--muted);font-size:13px;line-height:1.35}
.image-viewer-close{
  flex:0 0 auto;
  border:0;
  background:#e2e8f0;
  color:#0f172a;
  border-radius:12px;
  width:42px;
  height:42px;
  font-size:28px;
  line-height:1;
  cursor:pointer;
}
.image-viewer-body{
  background:#020617;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:220px;
  overflow:auto;
}
.image-viewer-body img{
  display:block;
  max-width:100%;
  max-height:calc(94vh - 76px);
  object-fit:contain;
}
.photo-card a.js-image-viewer{display:block;cursor:zoom-in}
@media(max-width:560px){
  .image-viewer-modal{padding:8px}
  .image-viewer-box{width:100%;max-height:96vh;border-radius:18px}
  .image-viewer-body img{max-height:calc(96vh - 84px)}
}
