:root {
  --color-primary: #5b3df0;
  --color-primary-dark: #4527c9;
  --color-bg: #f5f3ff;
  --color-text: #221d3b;
  --color-muted: #6b6587;
  --color-border: #ddd6f3;
  --color-pendente: #c97f0a;
  --color-selecionada: #2563eb;
  --color-lida: #1f9d55;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ---- Login ---- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: 0 10px 30px rgba(91, 61, 240, 0.1);
  padding: 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-box h1 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.subtitle {
  color: var(--color-muted);
  margin: 0 0 22px;
  font-size: 0.95rem;
}

.field {
  text-align: left;
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

input[type='text'],
input[type='email'],
input[type='password'] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--color-border);
  border-radius: 9px;
  font-size: 1rem;
  font-family: inherit;
}

input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(91, 61, 240, 0.15);
}

.form-error {
  background: #fdecec;
  color: #b3261e;
  border: 1px solid #f4c7c4;
  border-radius: 9px;
  padding: 9px 12px;
  margin: 4px 0 14px;
  font-size: 0.9rem;
  text-align: left;
}

.btn-primary {
  border: none;
  border-radius: 9px;
  padding: 13px 22px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  background: var(--color-primary);
  color: #fff;
}

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.back-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--color-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* ---- Dashboard ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: 16px 28px;
}

.topbar h1 {
  font-size: 1.2rem;
  margin: 0;
}

.btn-secondary {
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text);
  border-radius: 9px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: var(--color-bg);
}

.dashboard {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tab {
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.tab .count {
  display: inline-block;
  margin-left: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.8rem;
}

.tab.active .count {
  background: rgba(255, 255, 255, 0.25);
}

.empty-state {
  text-align: center;
  color: var(--color-muted);
  padding: 40px 0;
}

.story-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.story-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.story-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.story-card-title {
  font-weight: 700;
}

.story-card-email {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.story-card-date {
  color: var(--color-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.story-card-preview {
  color: #4a4566;
  margin: 8px 0 14px;
  line-height: 1.45;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}

.badge.pendente {
  background: var(--color-pendente);
}

.badge.selecionada {
  background: var(--color-selecionada);
}

.badge.lida {
  background: var(--color-lida);
}

.story-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  border: 1px solid var(--color-border);
  background: #fafaff;
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text);
}

.action-btn:hover {
  background: var(--color-bg);
}

.action-btn.danger {
  color: #b3261e;
  border-color: #f4c7c4;
}

.action-btn.danger:hover {
  background: #fdecec;
}

.action-btn.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.action-btn.primary:hover {
  background: var(--color-primary-dark);
}

.load-more {
  display: block;
  margin: 24px auto 0;
}

.load-more[hidden] {
  display: none;
}

/* ---- Modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 29, 59, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--color-muted);
  line-height: 1;
}

.modal-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.modal h2 {
  margin: 0 0 4px;
}

.modal-email {
  color: var(--color-muted);
  margin: 0 0 18px;
  font-size: 0.9rem;
}

.modal-content {
  line-height: 1.6;
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
  margin-bottom: 20px;
  word-wrap: break-word;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
}

.modal-history {
  border-top: 1px solid var(--color-border);
  margin-top: 18px;
  padding-top: 14px;
}

.modal-history h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.modal-history ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-history li {
  font-size: 0.85rem;
  color: var(--color-text);
}

.modal-history .empty {
  color: var(--color-muted);
}
