:root {
  --bg: #0f1420;
  --card: #161d2e;
  --border: #263049;
  --text: #e7ebf5;
  --muted: #93a0bd;
  --primary: #4f7cff;
  --primary-hover: #3d67e6;
  --ok: #34c77b;
  --fail: #ef5b5b;
  --pending: #ecc94b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; margin-top: 16px; }

input, select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0c111c;
  color: var(--text);
  font-size: 15px;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  margin-top: 22px;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.error-msg {
  color: var(--fail);
  font-size: 13px;
  margin-top: 12px;
  min-height: 16px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-header { padding: 20px 18px 12px; }
.sidebar-header h1 { font-size: 17px; margin: 0 0 10px; }

.account-switcher select {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0c111c;
  color: var(--text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  flex: 1;
}
.nav-item {
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}
.nav-item:hover { background: #0c111c; color: var(--text); }
.nav-item.active { background: var(--primary); color: white; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-footer .who { color: var(--muted); font-size: 13px; }
.sidebar-footer button { padding: 7px 12px; font-size: 13px; }

.main-content {
  flex: 1;
  padding: 28px 32px;
  min-width: 0; /* deixa a tabela encolher/rolar em vez de estourar a largura */
}

.page { max-width: 1400px; }

.page { display: none; }
.page.active { display: block; }

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .main-content { padding: 20px; }
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.settings-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #0c111c;
  border: 1px solid var(--border);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: var(--ok); }
.dot.off { background: var(--fail); }

.progress-wrap {
  margin-top: 24px;
}
.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: #0c111c;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}
.progress-summary {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}
.progress-summary b { color: var(--text); }

.device-list {
  margin-top: 20px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.device-row:last-child { border-bottom: none; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.pending { background: var(--pending); }
.status-dot.ok { background: var(--ok); }
.status-dot.failed { background: var(--fail); }
.device-key { font-weight: 600; font-family: monospace; }
.device-error { color: var(--fail); margin-left: auto; font-size: 12px; }

.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 10px; }

.settings-form { margin-top: 12px; }
.hidden { display: none !important; }

.devices-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.devices-toolbar input { flex: 1; min-width: 180px; }
.devices-toolbar select { flex: 0 0 auto; width: 170px; }
.devices-toolbar button { white-space: nowrap; }

.devices-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.devices-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.devices-table th, .devices-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.devices-table th { color: var(--muted); font-weight: 600; background: #0c111c; }
.devices-table tr:last-child td { border-bottom: none; }
.playlist-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; font-family: monospace; }
.client-name-input {
  width: 140px;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 6px;
}
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.status-pill.active { background: rgba(52,199,123,0.15); color: var(--ok); }
.status-pill.other { background: rgba(147,160,189,0.15); color: var(--muted); }
.status-pill.success { background: rgba(52,199,123,0.15); color: var(--ok); }
.status-pill.wrong, .status-pill.failed { background: rgba(239,91,91,0.15); color: var(--fail); }

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}
.pagination button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  font-size: 13px;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
}
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
