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

:root {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --border: #e1e1e1;
  --border-dark: #c8c8c8;
  --text: #242424;
  --text-2: #616161;
  --text-3: #a0a0a0;
  --accent: #0f6cbd;
  --accent-dark: #0c5aa6;
  --accent-light: #dce9f9;
  --danger: #c4314b;
  --danger-light: #fdf0f2;
  --radius: 4px;
  --radius-lg: 6px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page { max-width: 1100px; margin: 0 auto; padding-bottom: 40px; }

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f6cbd;
  padding: 14px 24px;
  margin-bottom: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
}
.brand:hover { opacity: 0.9; }
.brand-divider { width: 1px; height: 18px; background: rgba(255,255,255,0.3); margin: 0 2px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.sync-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 20px;
  color: #fff; background: rgba(255,255,255,0.15);
}
.sync-badge.sync-ok { background: rgba(255,255,255,0.25); }
.sync-badge.sync-error { background: rgba(255,0,0,0.25); }

.btn-new {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  background: #fff;
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.btn-new:hover { background: #f0f0f0; }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 0 10px;
  width: 320px;
}
.search-box:focus-within { background: #fff; border-color: var(--accent); }
.search-box i { color: var(--text-3); font-size: 13px; }
.search-box input {
  flex: 1; border: none; background: transparent;
  padding: 8px 0; font-size: 13px; color: var(--text); outline: none;
}

.stats { font-size: 12px; color: var(--text-3); }

/* ── Table ── */
.table-wrap { background: var(--surface); margin: 16px 24px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.th-actions { width: 160px; text-align: center; }

.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.data-table tbody tr:hover { background: #f8fafd; }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table td { padding: 11px 16px; font-size: 13px; color: var(--text); vertical-align: middle; }
.td-plataforma { font-weight: 600; }
.td-mono { font-family: 'Consolas', monospace; font-size: 12.5px; color: var(--text-2); }
.td-notas { color: var(--text-3); font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-notas a { color: var(--accent); text-decoration: none; }

.td-actions { text-align: center; white-space: nowrap; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 6px 9px; border-radius: var(--radius);
  font-size: 13px; transition: all 0.15s; margin: 0 2px;
}
.icon-btn:hover { background: var(--accent-light); color: var(--accent); }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); }
.icon-btn.copy:hover { background: #dcfce7; color: #166534; }

/* ── Empty state ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 60px 20px; color: var(--text-3); text-align: center;
}
.empty-icon { font-size: 40px; opacity: 0.3; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; top:0; left:0; width:100%; height:100%;
  background: rgba(0,0,0,0.5); z-index: 1000; overflow-y: auto;
}
.modal-overlay.open { display: flex; align-items: center; justify-content: center; padding: 24px; }

.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 440px; max-width: calc(100vw - 48px); max-height: calc(100vh - 48px);
  overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 15px; padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--surface-2); }

.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.form-group input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--surface); outline: none;
}
.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,108,189,0.1); }

.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.btn-cancel { padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-2); font-size: 13px; font-family: inherit; cursor: pointer; }
.btn-cancel:hover { background: var(--surface-2); }
.btn-save {
  display: flex; align-items: center; gap: 7px; padding: 8px 18px;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer;
}
.btn-save:hover { background: var(--accent-dark); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff;
  padding: 10px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  opacity: 0; transform: translateY(8px); transition: all 0.25s; pointer-events: none; z-index: 9999;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 700px) {
  .data-table thead { display: none; }
  .data-table tr { display: block; padding: 10px 16px; }
  .data-table td { display: block; padding: 4px 0; }
  .toolbar { flex-direction: column; gap: 10px; align-items: stretch; }
  .search-box { width: 100%; }
}

.brand-logo { font-size: 18px; }
