/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e2e8f0;
  --border-focus:  #93c5fd;

  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;

  --success:       #10b981;
  --success-light: #ecfdf5;
  --success-text:  #065f46;

  --danger:        #ef4444;
  --danger-dark:   #dc2626;
  --danger-light:  #fef2f2;
  --danger-text:   #991b1b;

  --warning:       #f59e0b;
  --warning-light: #fffbeb;

  --gray:          #64748b;
  --gray-light:    #f1f5f9;

  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;

  --header-bg:     #0f172a;
  --header-border: #1e293b;

  --radius:        12px;
  --radius-sm:     8px;
  --radius-xs:     6px;

  --shadow-sm:     0 1px 2px rgba(0,0,0,.05);
  --shadow:        0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:     0 8px 30px rgba(0,0,0,.12);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================================
   Reset / Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ============================================================
   Header
   ============================================================ */
.header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-box {
  background: white;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
}

.logo { height: 28px; }

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: #f8fafc;
  letter-spacing: -0.01em;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #94a3b8;
}

.user-info strong { color: #e2e8f0; font-weight: 500; }

.btn-logout {
  background: transparent;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 5px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  width: auto;
}

.btn-logout:hover {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #475569;
}

/* ============================================================
   Main / Layout
   ============================================================ */
main {
  flex: 1;
  padding: 28px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ============================================================
   Page title
   ============================================================ */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

/* ============================================================
   Tab nav
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
}

.tab-nav button {
  padding: 7px 18px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  width: auto;
}

.tab-nav button:hover {
  background: var(--gray-light);
  color: var(--text);
}

.tab-nav button.active {
  background: var(--primary);
  color: white;
}

.tab-nav button.active:hover { background: var(--primary-dark); }

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ============================================================
   Add device form
   ============================================================ */
.add-device-form {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.add-device-form input {
  flex: 1;
  max-width: 280px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  margin: 0;
  width: auto;
}

.add-device-form input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.add-device-form button {
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  width: auto;
}

/* ============================================================
   Device grid & cards
   ============================================================ */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
}

.device-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* Colored top strip based on status */
.device-card.is-online  { border-top: 3px solid var(--success); }
.device-card.is-offline { border-top: 3px solid var(--border); }

.device-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.device-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.device-name-row strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-edit-name {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  opacity: 0.35;
  transition: opacity .15s;
  line-height: 1;
  flex-shrink: 0;
  width: auto;
}

.btn-edit-name:hover { opacity: 1; background: none; }

.name-edit-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.name-edit-row input {
  flex: 1;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-family: var(--font);
  margin: 0;
  width: auto;
}

.name-edit-row input:focus { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.name-edit-row button {
  height: 30px;
  width: 30px;
  padding: 0;
  border-radius: var(--radius-xs);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.name-edit-row .btn-confirm { background: var(--success); }
.name-edit-row .btn-confirm:hover { background: #059669; }
.name-edit-row .btn-cancel  { background: var(--gray-light); color: var(--text-muted); border: 1px solid var(--border); }
.name-edit-row .btn-cancel:hover  { background: var(--border); }

/* Status badge — ponto colorido + texto */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-online {
  background: var(--success-light);
  color: var(--success-text);
}
.status-online::before { background: var(--success); }

.status-offline {
  background: var(--danger-light);
  color: var(--danger-text);
}
.status-offline::before { background: var(--danger); }

/* Card body */
.device-card-body {
  padding: 14px 16px;
  flex: 1;
}

.device-info-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.device-info-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.device-info-grid .info-label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  min-width: 44px;
}

.device-info-grid .info-value {
  color: var(--text);
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: 12.5px;
  word-break: break-all;
}

/* LED status row */
.led-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
}

.led-bulb {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.led-on {
  color: #f59e0b;
  filter: drop-shadow(0 0 5px rgba(251,191,36,.9)) drop-shadow(0 0 2px rgba(251,191,36,.6));
}

.led-off {
  color: #94a3b8;
}

/* Token panel */
.token-panel {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px;
}

.token-panel .token-label {
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.token-value {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  margin-bottom: 10px;
}

.token-value code {
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--primary);
  flex: 1;
}

.token-value button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  padding: 0;
  width: auto;
  height: auto;
}
.token-value button:hover { color: var(--text); background: none; }

.token-qr { text-align: center; }
.token-qr img { border-radius: var(--radius-xs); border: 1px solid var(--border); }

/* Card footer */
.device-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ============================================================
   Buttons
   ============================================================ */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  background: var(--primary);
  color: white;
  width: 100%;
  white-space: nowrap;
}

button:hover  { background: var(--primary-dark); }
button:active { transform: scale(.97); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-outline {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--gray-light); color: var(--text); }

.btn-success { background: var(--success); }
.btn-success:hover { background: #059669; }

.btn-gray { background: var(--gray-light); color: var(--text-muted); border: 1px solid var(--border); }
.btn-gray:hover { background: var(--border); color: var(--text); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); }

.btn-warning { background: var(--warning); }
.btn-warning:hover { background: #d97706; }

.btn-icon {
  background: none;
  border: none;
  padding: 6px;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  width: auto;
}
.btn-icon:hover { background: var(--gray-light); color: var(--text); }

/* Specific device buttons */
.btn-on  { background: var(--success); flex: 1; }
.btn-on:hover  { background: #059669; }
.btn-off { background: var(--gray-light); color: var(--text-muted); border: 1px solid var(--border); flex: 1; }
.btn-off:hover { background: var(--border); color: var(--text); }

.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-del { background: none; border: none; color: var(--danger); padding: 7px 10px; width: auto; font-size: 16px; }
.btn-del:hover { background: var(--danger-light); }
.btn-secret { background: var(--warning); flex: 1; }
.btn-secret:hover { background: #d97706; }

/* ============================================================
   Forms (generic)
   ============================================================ */
input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-group { margin-bottom: 16px; }

/* ============================================================
   Alert
   ============================================================ */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger-text);
  border: 1px solid #fca5a5;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ============================================================
   GIF section
   ============================================================ */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  background: var(--surface-2);
  transition: border-color .2s, background .2s;
  margin-bottom: 8px;
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-area input[type="file"] {
  display: none;
}

.upload-label {
  display: block;
  cursor: pointer;
}

.upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-hint { font-size: 13px; color: var(--text-muted); }
.upload-hint strong { color: var(--primary); }

.upload-submit-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.selected-file-name {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.gif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.gif-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  transition: box-shadow .2s;
}

.gif-item:hover { box-shadow: var(--shadow); }

.gif-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.gif-item-footer {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}

.gif-item-footer span { font-size: 11px; color: var(--text-muted); }

.gif-delete-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 14px;
  width: auto;
}

.gif-delete-btn:hover { background: var(--danger-light); }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-container {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
}

.auth-card {
  background: var(--surface);
  padding: 36px;
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo img { height: 40px; }

.auth-logo h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-top: 10px;
  letter-spacing: -0.02em;
}

.auth-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.auth-card .form-group input {
  height: 42px;
}

.auth-card button[type="submit"] {
  height: 42px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 500;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  .header { padding: 0 16px; }
  main    { padding: 20px 16px; }

  .device-grid { grid-template-columns: 1fr; }
  .gif-grid    { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }

  .add-device-form { flex-direction: column; }
  .add-device-form input { max-width: 100%; }

  .tab-nav { width: 100%; }
  .tab-nav button { flex: 1; }

  .user-info .user-name { display: none; }
}

/* ============================================================
   Modal Histórico
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 15px; color: var(--text); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  width: auto;
  line-height: 1;
}
.modal-close:hover { color: var(--danger); background: var(--danger-light); border-radius: 6px; }

.modal-body {
  overflow-y: auto;
  padding: 16px 20px;
  flex: 1;
}

.logs-empty { text-align: center; color: var(--text-muted); padding: 32px 0; margin: 0; }

.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.logs-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.logs-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.logs-table tr:last-child td { border-bottom: none; }
.logs-table tr:hover td { background: var(--surface-2); }

.log-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.log-on  { background: var(--success-light); color: var(--success-text); }
.log-off { background: var(--gray-light);    color: var(--gray); }

/* ============================================================
   Categorias de dispositivo
   ============================================================ */
.device-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin: 20px 0 10px;
  padding: 0 4px;
}
.device-section-icon { font-size: 15px; }

.device-type-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  width: auto;
}

/* ============================================================
   ESP32-CAM — stats no card
   ============================================================ */
.cam-status {
  display: flex;
  gap: 16px;
  padding: 10px 0 6px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}
.cam-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cam-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.cam-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.cam-motion { font-size: 13px; padding-top: 4px; }

/* ============================================================
   Galeria de fotos
   ============================================================ */
.modal-wide { max-width: 780px; }

.gallery-body { padding: 12px 16px; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.gallery-item {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.gallery-item:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.gallery-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}
.gallery-item-info {
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); color: #fff; }

.pir-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-bottom: 2px;
}
.pir-on  { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,.7); }
.pir-off { background: var(--border); }

/* ============================================================
   Modal tabs
   ============================================================ */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}
.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: auto;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.modal-tab:hover { color: var(--text); background: none; }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }

/* ============================================================
   Gallery toolbar + pagination
   ============================================================ */
.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
}
.select-all-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.select-all-wrap input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.gallery-action-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.gallery-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.page-info-text { font-size: 13px; color: var(--text-muted); min-width: 100px; text-align: center; }

/* ============================================================
   Gallery items com checkbox
   ============================================================ */
.gallery-item { position: relative; }

.gallery-checkbox-wrap {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  opacity: 0;
  transition: opacity .15s;
}
.gallery-checkbox-wrap input {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--primary);
  display: block;
}
.gallery-item:hover .gallery-checkbox-wrap,
.gallery-item.selected .gallery-checkbox-wrap { opacity: 1; }
.gallery-item.selected { box-shadow: 0 0 0 2px var(--primary); border-radius: 8px; }
.gallery-item.selected img { opacity: .85; }

.photo-dl-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background .15s, color .15s;
  line-height: 1;
}
.photo-dl-btn:hover { background: var(--primary); color: #fff; }

.log-pir { background: #ede9fe; color: #5b21b6; }

/* ============================================================
   Admin Panel
   ============================================================ */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }

.admin-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}
.admin-badge-ok    { background: var(--success-light); color: var(--success-text); }
.admin-badge-warn  { background: #fef9c3; color: #854d0e; }
.admin-badge-block { background: var(--danger-light); color: var(--danger-text); }
.admin-badge-role  { background: var(--primary-light); color: var(--primary); }

.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-actions .btn { flex: 0 0 auto; }

/* Registro — termos */
.terms-wrap { margin-bottom: 16px; }
.terms-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}
.terms-label input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.terms-link { color: var(--primary); text-decoration: underline; font-size: inherit; }
.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  width: auto;
  display: inline;
  white-space: normal;
  font-weight: inherit;
}
.btn-link:hover { background: none; color: var(--primary-dark); transform: none; }

/* ============================================================
   Notificações
   ============================================================ */
.btn-notif {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 0 2px;
  opacity: .55;
  transition: opacity .15s;
  line-height: 1;
}
.btn-notif:hover { opacity: 1; }

.notif-settings-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.notif-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notif-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 1rem;
}

.notif-input {
  width: 100%;
  max-width: 360px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}
.notif-input:focus { outline: 2px solid var(--primary); border-color: transparent; }

.notif-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.notif-hint-details {
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--bg);
}
.notif-hint-details summary { cursor: pointer; font-weight: 500; color: var(--primary); }
.notif-hint-details ol { margin: 10px 0 0 16px; padding: 0; line-height: 1.7; }
.notif-hint-details code { background: #e2e8f0; padding: 1px 5px; border-radius: 4px; font-size: 0.82rem; }

.notif-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Toggle switch */
.notif-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.notif-toggle input { opacity: 0; width: 0; height: 0; }
.notif-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.notif-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.notif-toggle input:checked + .notif-slider { background: var(--primary); }
.notif-toggle input:checked + .notif-slider::before { transform: translateX(20px); }

/* Lista de dispositivos na aba notificações */
.notif-device-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
}
.notif-device-row > span:first-child {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 20px;
}
.notif-device-name { font-weight: 500; }
