:root {
  --navy: #0A2E4A;
  --navy-2: #123f63;
  --gold: #F39C12;
  --bg: #eef1f5;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e2e8f0;
  --green: #16a34a;
  --green-bg: #e8f7ee;
  --red: #dc2626;
  --red-bg: #fdecea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0A2E4A 0%, #123f63 55%, #0e3556 100%);
  padding: 24px;
}

.login-card {
  background: #fff;
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.login-logo {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gold);
  margin-bottom: 14px;
}

.login-card h1 { margin: 0; font-size: 22px; color: var(--navy); }
.login-sub { margin: 4px 0 24px; color: var(--muted); font-size: 13px; }

.login-card form { text-align: left; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: #374151;
}

input, textarea {
  width: 100%;
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-2);
  box-shadow: 0 0 0 3px rgba(18, 63, 99, 0.12);
}

textarea { resize: vertical; line-height: 1.55; }

.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #f5c6c6;
  border-radius: 8px;
}

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost {
  display: inline-block;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-2); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  background: #fff;
  color: #374151;
  border-color: var(--border);
}
.btn-ghost:hover { background: #f3f4f6; }

#loginBtn { width: 100%; margin-top: 20px; background: var(--navy); color: #fff; }
#loginBtn:hover { background: var(--navy-2); }
#loginBtn:disabled { opacity: .6; }

/* ---------- App layout ---------- */
.app-body { background: var(--bg); min-height: 100vh; }

.topbar {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--gold); background: #fff;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: #b8c9d6; }
.topbar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }

.container { max-width: 1180px; margin: 0 auto; padding: 24px; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.card-hint { font-size: 12px; color: var(--muted); }

.compose-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ---------- Preview ---------- */
.preview-frame {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 480px;
}
.preview-frame iframe {
  width: 100%;
  height: 560px;
  border: 0;
  display: block;
}

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  text-align: left;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  background: #f8fafc;
}
.table tbody tr:hover { background: #fafbfc; }
.th-actions, .table td:last-child { text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.table-actions { display: inline-flex; gap: 8px; }
.table-actions .btn-ghost { padding: 6px 12px; font-size: 12.5px; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
}
.badge-sent { color: var(--green); background: var(--green-bg); }
.badge-failed { color: var(--red); background: var(--red-bg); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 50, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal[hidden] { display: none; }

.modal-box {
  background: #fff;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  border-radius: 12px;
}
.modal-wide { max-width: 640px; }
.modal-box h3 { margin: 0 0 4px; color: var(--navy); font-size: 17px; }
.modal-sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal .form-error { margin-top: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .preview-frame iframe { height: 460px; }
}
