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

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #0ea5e9;
  --success: #16a34a;
  --warning: #d97706;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: flex; }

/* Login */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.login-card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand h1 { font-size: 1.75rem; margin-top: .5rem; }
.login-brand p { color: var(--text-muted); font-size: .9rem; }

.logo-mark {
  width: 48px; height: 48px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.4rem;
}
.logo-mark.sm { width: 32px; height: 32px; font-size: 1rem; border-radius: 6px; }

.login-card label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; margin-top: 1rem; }
.login-card input {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
}
.preview-note { text-align: center; color: var(--text-muted); font-size: .8rem; margin-top: 1.25rem; }

/* App shell */
#app-shell { min-height: 100vh; width: 100%; }

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.25rem 1rem;
  font-weight: 700;
  color: #fff;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .9rem;
  transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(37,99,235,.35); color: #fff; }
.nav-item .icon { opacity: .7; width: 1.2rem; text-align: center; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .75rem;
  font-size: .85rem;
}
.user-chip small { color: #94a3b8; }

.avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
}

.main-content {
  margin-left: 240px;
  padding: 1.5rem 2rem;
  flex: 1;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.topbar h2 { font-size: 1.5rem; font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-ghost { background: transparent; color: var(--sidebar-text); border: 1px solid rgba(255,255,255,.15); }
.btn-block { width: 100%; margin-top: 1.5rem; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-icon { background: none; border: none; cursor: pointer; padding: .25rem .4rem; opacity: .6; font-size: .9rem; }
.btn-icon:hover { opacity: 1; }

/* Badges */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }
.badge-live { background: #dbeafe; color: var(--primary); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.stat-card.accent { border-color: var(--accent); background: #f0f9ff; }
.stat-label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .35rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; }

/* Panels */
.panel-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1rem; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.panel-header h3 { font-size: .95rem; font-weight: 600; }
.mt { margin-top: 1rem; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left;
  padding: .65rem 1.25rem;
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.data-table td { padding: .75rem 1.25rem; border-top: 1px solid var(--border); }
.data-table.compact td, .data-table.compact th { padding: .5rem 1rem; }
.data-table code { background: #f1f5f9; padding: .15rem .4rem; border-radius: 4px; font-size: .8rem; }
.actions { white-space: nowrap; }

/* Lists */
.queue-list { list-style: none; padding: .5rem 0; }
.queue-list li {
  display: flex;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .875rem;
}
.queue-list li:first-child { border-top: none; }

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

.page-toolbar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1rem;
  align-items: center;
}

.search-input {
  padding: .5rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  min-width: 220px;
}

/* Forms */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; padding: 1rem 1.25rem; }
.form-group { margin-bottom: .75rem; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
}
.form-group textarea { resize: vertical; }
.form-actions { padding: 1rem 1.25rem; }

.upload-form { padding: 1.25rem; }
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin: 1rem 0;
  background: #f8fafc;
}
.drop-zone p { font-weight: 600; margin-bottom: .25rem; }
.drop-zone small { color: var(--text-muted); display: block; margin-bottom: 1rem; }

/* Drafts */
.draft-list { list-style: none; }
.draft-item {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: .875rem;
}
.draft-item:hover { background: #f8fafc; }
.draft-item.active { background: #eff6ff; border-left: 3px solid var(--primary); }
.draft-item small { color: var(--text-muted); }

.attachment-list { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.attachment-chip {
  background: #f1f5f9;
  padding: .35rem .65rem;
  border-radius: var(--radius);
  font-size: .8rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.attachment-chip button { background: none; border: none; cursor: pointer; color: var(--text-muted); }

/* Send wizard */
.wizard-steps {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.step {
  padding: .5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.step.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.recipient-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}

.recipient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .5rem;
  padding: 1rem 1.25rem;
  max-height: 200px;
  overflow-y: auto;
}

.recipient-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .8rem;
  cursor: pointer;
}
.recipient-chip.checked { background: #eff6ff; border-color: var(--primary); }

.selection-summary { padding: .75rem 1.25rem; font-size: .875rem; color: var(--text-muted); border-top: 1px solid var(--border); }

.send-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem 1.25rem;
}
.option-card {
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .875rem;
}
.option-card.selected { border-color: var(--primary); background: #eff6ff; }
.option-card input { margin-right: .5rem; }
.option-card small { color: var(--text-muted); }

.schedule-fields { padding: 0 1.25rem 1rem; }
.hidden { display: none !important; }

.tracking-note {
  padding: 1rem 1.25rem;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: 12px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto; box-shadow: 0 25px 50px rgba(0,0,0,.2);
}
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }
.alert {
  padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem;
}
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.help-text { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.nav-item.hidden-nav { display: none; }
