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

:root {
  --bg: #0f1419;
  --surface: #1a2028;
  --surface-2: #232a34;
  --border: #2d3540;
  --text: #e8ecf1;
  --text-dim: #8b95a3;
  --accent: #4a9eff;
  --danger: #e24b4a;
  --success: #4ade80;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

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

.card h1 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 8px;
  text-align: center;
}

.card .subtitle {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  margin-bottom: 24px;
}

input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--accent);
}

.pin-input {
  text-align: center;
  font-size: 24px;
  letter-spacing: 6px;
  font-family: ui-monospace, monospace;
  padding: 16px;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
}

button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

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

button.danger { background: var(--danger); }

button.small { padding: 6px 12px; font-size: 13px; width: auto; }

.mt { margin-top: 16px; }
.mt-lg { margin-top: 24px; }

.error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

/* Top bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .title { font-size: 16px; font-weight: 500; }
.topbar .info { color: var(--text-dim); font-size: 13px; }

/* Canais list */
.channel-list { display: flex; flex-direction: column; gap: 12px; }

.channel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.channel-card:hover { border-color: var(--accent); }
.channel-card .name { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.channel-card .meta { font-size: 13px; color: var(--text-dim); }

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 1.5s infinite;
  vertical-align: middle;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* CFTV Grid */
.cftv {
  display: grid;
  gap: 8px;
  padding: 20px;
}

.cftv.g1 { grid-template-columns: 1fr; }
.cftv.g2 { grid-template-columns: 1fr 1fr; }
.cftv.g3 { grid-template-columns: 1fr 1fr 1fr; }
.cftv.g4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.cftv.g6 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.cftv.g9 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; }

.tile {
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.tile-label {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  z-index: 2;
}

.tile-live {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(226,75,74,0.9);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  z-index: 2;
}

.tile-offline {
  position: absolute;
  inset: 0;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 14px;
  flex-direction: column;
  gap: 8px;
}

.tile.expanded {
  position: fixed;
  inset: 0;
  z-index: 100;
  border-radius: 0;
  aspect-ratio: auto;
}

.hidden { display: none !important; }

/* Modal */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
}

.modal h2 { font-size: 18px; margin-bottom: 12px; }
.modal p { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; line-height: 1.5; }
.modal .buttons { display: flex; gap: 8px; }
.modal .buttons button { flex: 1; }
