/* HRFD Messaging - single stylesheet, mobile-first */
:root {
  --red: #b3251e;
  --red-dark: #8e1d17;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1d2129;
  --muted: #6b7280;
  --line: #e3e5e9;
  --ok-bg: #e7f6ec;  --ok-ink: #176639;
  --err-bg: #fdebea; --err-ink: #8e1d17;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

/* ---- Top bar ---- */
.topbar { background: var(--red); color: #fff; }
.topbar-inner {
  max-width: 980px; margin: 0 auto; padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand small { display: block; font-weight: 400; font-size: .75rem; opacity: .85; }
.brand-mark { font-size: 1.5rem; }
.brand-logo { height: 36px; width: auto; border-radius: 4px; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.nav a {
  color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 8px;
  font-size: .9rem; white-space: nowrap;
}
.nav a:hover { background: rgba(255,255,255,.15); }
.nav a.active { background: rgba(0,0,0,.25); }
.nav a.logout { opacity: .8; }

/* ---- Layout ---- */
.container { max-width: 980px; margin: 0 auto; padding: 16px; padding-bottom: 72px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px 32px; }
.legal-notice { font-size: .7rem; color: var(--muted); margin: 6px 0 0; max-width: 640px; margin-left: auto; margin-right: auto; line-height: 1.4; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 12px; font-size: 1rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}

/* ---- Flash messages ---- */
.flash { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.flash-ok  { background: var(--ok-bg);  color: var(--ok-ink); }
.flash-err { background: var(--err-bg); color: var(--err-ink); }

/* ---- Forms ---- */
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; font-size: 1rem; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--red); outline-offset: 1px; border-color: var(--red);
}
.field { margin-bottom: 14px; }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
.field-row .field { flex: 1 1 200px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 4px; }

.btn {
  display: inline-block; border: 0; border-radius: 8px; cursor: pointer;
  padding: 12px 20px; font-size: 1rem; font-weight: 600; text-decoration: none;
  background: var(--red); color: #fff;
}
.btn:hover { background: var(--red-dark); }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--bg); }
.btn-small { padding: 6px 12px; font-size: .85rem; }
.btn-danger { background: #fff; color: var(--err-ink); border: 1px solid var(--err-ink); }
.btn-danger:hover { background: var(--err-bg); }

/* ---- Recipient pickers ---- */
.check-grid {
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.check-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: .95rem; cursor: pointer; user-select: none;
}
.check-item:hover { border-color: var(--red); }
.check-item input { width: 20px; height: 20px; accent-color: var(--red); flex: none; }
.check-item.checked { background: #fbeeed; border-color: var(--red); }
.check-item .comment { color: var(--muted); font-size: .85rem; }

.filter-box { margin-bottom: 10px; }

/* ---- Send bar (fixed to bottom of viewport) ---- */
.send-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--card); border-top: 2px solid var(--line);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  padding: 12px 16px; display: flex; align-items: center; justify-content: center; gap: 12px;
}
.char-count { color: var(--muted); font-size: .85rem; }
.char-count.over { color: var(--err-ink); font-weight: 700; }

/* ---- Results list ---- */
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li {
  display: flex; gap: 10px; align-items: baseline;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.result-list li:last-child { border-bottom: 0; }
.result-ok::before  { content: "\2713"; color: var(--ok-ink); font-weight: 700; }
.result-err::before { content: "\2717"; color: var(--err-ink); font-weight: 700; }
.result-detail { color: var(--muted); font-size: .85rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td {
  text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted);
}
table.data tr:hover td { background: var(--bg); }
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--bg); color: var(--muted);
}
.badge-smtp { background: #e8f0fe; color: #1a56b0; }
.badge-sns  { background: #fef3e2; color: #9a5b00; }
.badge-admin { background: var(--err-bg); color: var(--err-ink); }

/* ---- Login ---- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.login-wrap .brand-big {
  text-align: center; margin-bottom: 20px; font-size: 1.3rem; font-weight: 700;
}
.login-wrap .brand-big small { display: block; font-weight: 400; color: var(--muted); font-size: .9rem; }

/* ---- Pagination ---- */
.pager-nav { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

@media (max-width: 600px) {
  .container { padding: 10px; }
  .check-grid { grid-template-columns: 1fr 1fr; }
  .check-item { font-size: .88rem; padding: 9px 10px; }
  .nav a { padding: 7px 9px; font-size: .82rem; }
}
@media (max-width: 420px) {
  .check-grid { grid-template-columns: 1fr; }
}
