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

:root {
  --bg: #0e1015;
  --panel: #171a22;
  --panel2: #1e222d;
  --panel3: #262b38;
  --border: #2a2f3f;
  --text: #e8eaf0;
  --muted: #8b91a5;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --accent2: #22c55e;
  --danger: #ef4444;
  --gold: #f5c518;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body { overflow-x: hidden; }

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

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--panel3) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #333a4d; }

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 20;
}
header h1 { font-size: 20px; letter-spacing: .5px; }
.subtitle { color: var(--muted); font-size: 13px; }
.status {
  margin-left: auto;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--panel2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status.online { color: var(--accent2); border-color: rgba(34,197,94,.3); }
.status.offline { color: var(--danger); border-color: rgba(239,68,68,.3); }

/* ---------- layout ---------- */
main {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 24px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;             /* impede overflow do grid item */
}
.panel h2 { font-size: 15px; margin-bottom: 14px; font-weight: 600; }
.count { color: var(--muted); font-weight: normal; font-size: 13px; }

.voices-panel { position: sticky; top: 84px; }

/* ---------- vozes ---------- */
.previews-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.previews-bar .mini { white-space: nowrap; }

.voice-filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 8px; }
.filter-row select { flex: 1; min-width: 0; }
.voice-filters input[type="text"], .voice-filters select {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color .12s;
}
.voice-filters input[type="text"]:focus, .voice-filters select:focus { border-color: var(--accent); }
.fav-toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }

.voice-list {
  overflow-y: auto;
  max-height: calc(100vh - 340px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
.voice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--panel2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.voice-item:hover { border-color: var(--accent); background: var(--panel3); }
.voice-item.selected { border-color: var(--accent); background: #1c2b4a; }
.voice-info { flex: 1; min-width: 0; }
.voice-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.vtag {
  font-size: 10px;
  background: var(--panel3);
  color: #aab4d4;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.gsym { font-size: 12px; flex-shrink: 0; }
.gsym.f { color: #ff8ac6; }
.gsym.m { color: #6db3ff; }
.voice-item button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color .12s, background .12s;
}
.voice-item button:hover { color: var(--text); background: rgba(255,255,255,.06); }
.voice-item .fav.active { color: var(--gold); }
.voice-item .preview.playing { color: var(--accent2); }

.loading, .empty { color: var(--muted); text-align: center; padding: 30px 0; font-size: 14px; }

/* ---------- gerador ---------- */
.selected-voice {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selected-voice .none { color: var(--muted); }
.selected-voice strong { color: var(--accent); }
.selected-voice .history-meta { color: var(--muted); font-size: 12px; }

textarea {
  width: 100%;
  min-height: 200px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .12s;
}
textarea:focus { border-color: var(--accent); }

.controls {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}
.controls label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 7px; }
.controls label span { color: var(--text); font-weight: 600; }
.controls input[type="range"] { width: 150px; accent-color: var(--accent); cursor: pointer; }
.label-field { flex: 1; min-width: 180px; }
.label-field input {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color .12s;
}
.label-field input:focus { border-color: var(--accent); }

#generateBtn {
  background: var(--accent);
  color: white;
  border: none;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s;
}
#generateBtn:hover:not(:disabled) { background: var(--accent-hover); }
#generateBtn:disabled { opacity: .45; cursor: not-allowed; }

.progress {
  margin-top: 14px;
  padding: 11px 14px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
}
.progress.error { color: var(--danger); border-color: rgba(239,68,68,.3); }
.progress.ok { color: var(--accent2); border-color: rgba(34,197,94,.3); }
.progress .clock {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
  background: var(--panel3);
  padding: 1px 8px;
  border-radius: 6px;
}
.hidden { display: none; }

/* ---------- histórico ---------- */
.history-title { margin-top: 26px; display: flex; align-items: center; gap: 10px; }
.mini {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 11px;
  cursor: pointer;
  font-size: 13px;
  transition: color .12s, border-color .12s;
}
.mini:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.mini:disabled { opacity: .5; cursor: default; }

.history { display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.history-item {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}
.history-top {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  min-width: 0;
}
.history-text {
  flex: 1;
  min-width: 0;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.history-meta { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.history-item audio {
  width: 100%;
  max-width: 100%;
  height: 36px;
  display: block;
}
.history-actions { display: flex; gap: 8px; }
.history-actions a, .history-actions button {
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 11px;
  cursor: pointer;
  text-decoration: none;
  transition: color .12s, border-color .12s;
}
.history-actions a:hover { color: var(--accent); border-color: var(--accent); }
.history-actions button:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- responsivo ---------- */
@media (max-width: 1000px) {
  main { grid-template-columns: 1fr; }
  .voices-panel { position: static; }
  .voice-list { max-height: 420px; }
}

/* ---------- SaaS: header do usuário ---------- */
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.userbox .status { margin-left: 0; }
.user-chip {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.plan-chip {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
  background: rgba(79,140,255,.12);
  border: 1px solid rgba(79,140,255,.4);
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.plan-chip.none { background: rgba(245,197,24,.1); border-color: rgba(245,197,24,.4); color: var(--gold); }
.header-link {
  font-size: 13px; color: var(--muted); text-decoration: none;
  padding: 5px 10px; border-radius: 6px; transition: color .12s;
}
.header-link:hover { color: var(--text); }

/* ---------- SaaS: barra de cota ---------- */
.quota-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px;
  font-size: 13px; color: var(--muted); flex-wrap: wrap;
}
.quota-bar strong { color: var(--text); }
.quota-track {
  flex: 1; min-width: 120px; height: 8px; border-radius: 4px;
  background: var(--panel3); overflow: hidden;
}
.quota-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.quota-fill.warn { background: var(--gold); }
.quota-fill.full { background: var(--danger); }

/* ---------- SaaS: páginas de auth ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; flex-direction: column; gap: 18px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.auth-card .subtitle { display: block; text-align: center; margin-bottom: 20px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tabs button {
  flex: 1; padding: 9px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  font-size: 14px; transition: all .12s;
}
.auth-tabs button.active { background: #1c2b4a; border-color: var(--accent); color: var(--text); }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card input {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; outline: none;
}
.auth-card input:focus { border-color: var(--accent); }
.btn-primary {
  background: var(--accent); color: white; border: none; font-size: 15px; font-weight: 600;
  padding: 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background .12s;
  text-align: center; text-decoration: none; display: block; width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 11px; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer;
  text-decoration: none; margin-top: 12px; transition: border-color .12s;
}
.btn-google:hover { border-color: var(--accent); }
.auth-msg { font-size: 13px; text-align: center; min-height: 18px; }
.auth-msg.error { color: var(--danger); }
.auth-msg.ok { color: var(--accent2); }
.auth-divider {
  display: flex; align-items: center; gap: 10px; color: var(--muted);
  font-size: 12px; margin: 16px 0 0;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---------- SaaS: página de planos ---------- */
.plans-wrap { max-width: 1000px; margin: 0 auto; padding: 30px 24px; }
.plans-wrap h1 { text-align: center; font-size: 26px; margin-bottom: 6px; }
.plans-sub { text-align: center; color: var(--muted); margin-bottom: 30px; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.plan-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; display: flex; flex-direction: column; gap: 14px; position: relative;
}
.plan-card.highlight { border-color: var(--accent); box-shadow: 0 0 24px rgba(79,140,255,.15); }
.plan-card .badge {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: white; font-size: 11px; font-weight: 700;
  padding: 3px 12px; border-radius: 12px; white-space: nowrap;
}
.plan-card.current { border-color: var(--accent2); }
.plan-card h2 { font-size: 17px; }
.plan-price { font-size: 34px; font-weight: 700; }
.plan-price small { font-size: 14px; color: var(--muted); font-weight: 400; }
.plan-card ul { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--muted); flex: 1; }
.plan-card ul li::before { content: '✓ '; color: var(--accent2); font-weight: 700; }
.plans-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 24px; }

/* ---------- SaaS: admin ---------- */
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table select, .admin-table input {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 5px 8px; border-radius: 6px; font-size: 12px;
}
.tag-pill {
  font-size: 11px; padding: 2px 9px; border-radius: 10px;
  background: var(--panel3); color: var(--muted); white-space: nowrap;
}
.tag-pill.active { background: rgba(34,197,94,.12); color: var(--accent2); }
.tag-pill.admin { background: rgba(245,197,24,.12); color: var(--gold); }
