/* Plum Valley — admin panel. Refined plum + gold on warm cream. */
:root {
  --plum: #7c0042;
  --plum-700: #66003666;
  --plum-deep: #5a0030;
  --gold: #c2a86a;
  --gold-soft: #d8c79c;
  --cream: #faf6f2;
  --cream-2: #f3ebe4;
  --surface: #ffffff;
  --ink: #271b21;
  --muted: #8d7f86;
  --line: #ece2e7;
  --green: #2f7d5d;
  --green-bg: #e7f3ec;
  --red: #c0392b;
  --red-bg: #fbe9e7;
  --amber: #b07d18;
  --amber-bg: #f8efdb;
  --blue: #3a6ea5;
  --blue-bg: #e7eef7;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(60, 10, 35, .05), 0 10px 30px rgba(60, 10, 35, .05);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: var(--plum);
  background-image: radial-gradient(120% 60% at 50% -10%, rgba(194, 168, 106, .18), transparent 60%),
    linear-gradient(180deg, #7c0042 0%, #6b0039 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { padding: 26px 22px 18px; text-align: center; background: #7c0042; }
.brand-logo { width: 130px; height: auto; display: block; margin: 0 auto 10px; }
.brand-name { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; letter-spacing: .04em; }
.brand-sub { font-size: .68rem; letter-spacing: .26em; text-transform: uppercase; color: var(--gold-soft); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 14px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .82); font-weight: 500; font-size: .92rem;
  border: 0; background: transparent; width: 100%; cursor: pointer; text-align: left;
  font-family: var(--font-ui);
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 18px; height: 18px; opacity: .85; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.nav-item.is-active {
  background: rgba(255, 255, 255, .12); color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}
.nav-spacer { flex: 1; }
.nav-logout { color: rgba(255, 255, 255, .6); }
.nav-logout:hover { background: rgba(0, 0, 0, .16); color: #fff; }
.sidebar-foot { padding: 14px 20px 20px; font-size: .7rem; color: rgba(255, 255, 255, .4); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 22px 40px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .6);
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px);
}
.page-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; margin: 0; }
.topbar-actions { display: flex; gap: 10px; }
.content { padding: 30px 40px 56px; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.card-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; margin: 0 0 16px; }

.grid { display: grid; gap: 20px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.cols-2 { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 900px) { .cols-2 { grid-template-columns: 1fr; } }

.stat { position: relative; overflow: hidden; }
.stat::after {
  content: ""; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px;
  border-radius: 50%; background: radial-gradient(circle, rgba(124, 0, 66, .06), transparent 70%);
}
.stat-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.stat-value { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; line-height: 1.1; margin-top: 6px; }
.stat-value.small { font-size: 2rem; }
.stat-foot { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ---------------- Segments (tag bars) ---------------- */
.segment { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.segment + .segment { border-top: 1px solid var(--line); }
.segment-name { width: 140px; font-weight: 500; text-transform: capitalize; flex-shrink: 0; }
.segment-bar { flex: 1; height: 8px; background: var(--cream-2); border-radius: 99px; overflow: hidden; }
.segment-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--plum), var(--gold)); border-radius: 99px; }
.segment-count { width: 44px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-weight: 600; font-size: .9rem;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--plum); color: #fff; }
.btn-primary:hover { background: var(--plum-deep); }
.btn-gold { background: var(--gold); color: #3a2410; }
.btn-gold:hover { filter: brightness(1.04); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--gold); }

/* ---------------- Status pills ---------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 99px; font-size: .76rem; font-weight: 600; letter-spacing: .02em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-sent, .pill-delivered { background: var(--green-bg); color: var(--green); }
.pill-opened { background: var(--blue-bg); color: var(--blue); }
.pill-draft, .pill-sending, .pill-queued { background: var(--amber-bg); color: var(--amber); }
.pill-bounced, .pill-failed, .pill-complained { background: var(--red-bg); color: var(--red); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--cream); }

/* ---------------- Misc ---------------- */
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.placeholder { text-align: center; padding: 70px 20px; }
.placeholder h2 { font-family: var(--font-display); font-size: 1.5rem; margin: 0 0 8px; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(130% 90% at 50% 0%, #7c0042 0%, #5a0030 70%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 18px; padding: 38px 34px; box-shadow: 0 30px 70px rgba(0, 0, 0, .3);
}
.login-logo { width: 96px; display: block; margin: 0 auto 14px; border-radius: 10px; }
.login-card h1 { font-family: var(--font-display); text-align: center; font-size: 1.5rem; margin: 0 0 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: .85rem; margin: 0 0 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 6px; }
.input {
  width: 100%; padding: 11px 13px; font-family: var(--font-ui); font-size: .95rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--cream);
  color: var(--ink); transition: border .15s ease, box-shadow .15s ease;
}
.input:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px rgba(124, 0, 66, .12); background: #fff; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.alert { background: var(--red-bg); color: var(--red); padding: 10px 13px; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: 18px; }
.note { background: var(--amber-bg); color: var(--amber); padding: 10px 13px; border-radius: var(--radius-sm); font-size: .82rem; margin-bottom: 18px; }

/* ---------------- Toolbar / filters ---------------- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 220px; }
.select {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font-family: var(--font-ui); font-size: .9rem; color: var(--ink); cursor: pointer;
}
.select:focus { outline: none; border-color: var(--plum); }

/* ---------------- Chips ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--cream-2); color: var(--plum);
  border-radius: 99px; padding: 3px 10px; font-size: .78rem; font-weight: 600; text-transform: capitalize;
}
.chip button { border: 0; background: none; cursor: pointer; color: inherit; font-size: .95rem; line-height: 1; padding: 0; opacity: .55; }
.chip button:hover { opacity: 1; }

/* ---------------- Bulk bar ---------------- */
.bulkbar { display: none; align-items: center; gap: 12px; background: var(--plum); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; flex-wrap: wrap; }
.bulkbar.show { display: flex; }
.bulkbar .select { padding: 6px 10px; }
.bulkbar-count { font-weight: 600; }

/* ---------------- Row actions ---------------- */
.row-actions { display: inline-flex; gap: 6px; vertical-align: middle; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 9px; cursor: pointer; color: var(--muted); font-size: .8rem; font-weight: 600; }
.icon-btn:hover { border-color: var(--plum); color: var(--plum); }
.contact-email { font-weight: 600; }
.muted-cell { color: var(--muted); font-size: .86rem; }
.cell-status { white-space: nowrap; }

/* ---------------- Pagination ---------------- */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 18px; color: var(--muted); font-size: .86rem; }
.pagination button[disabled] { opacity: .4; cursor: not-allowed; }

/* ---------------- Modal ---------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(40, 12, 28, .45); display: none; place-items: center; padding: 24px; z-index: 50; backdrop-filter: blur(2px); }
.modal-overlay.open { display: grid; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 470px; box-shadow: 0 30px 70px rgba(0, 0, 0, .3); max-height: 90vh; overflow: auto; }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-family: var(--font-display); margin: 0; font-size: 1.2rem; }
.modal-close { border: 0; background: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 22px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tag-add { display: flex; gap: 8px; margin-top: 10px; }
.tag-add .input { flex: 1; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; font-weight: 500; }
.help { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }

/* ---------------- Toast ---------------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 10px; font-size: .88rem; z-index: 60; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Compose ---------------- */
.compose-grid { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
@media (max-width: 980px) { .compose-grid { grid-template-columns: 1fr; } }
.editor-card { padding: 0; overflow: hidden; }
.subject-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 18px 20px;
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; color: var(--ink); background: transparent;
}
.subject-input:focus { outline: none; background: var(--cream); }
#editor { min-height: 440px; font-family: var(--font-ui); font-size: 15px; }
#editor img { max-width: min(100%, 540px); height: auto; }
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--line) !important; }
.ql-toolbar.ql-snow { border-left: 0; border-right: 0; }
.ql-container.ql-snow { border: 0; }
.send-panel { position: sticky; top: 90px; display: flex; flex-direction: column; }
.panel-section + .panel-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.panel-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 7px; display: block; }
.recipients-badge { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.recipients-badge .n { font-family: var(--font-display); font-size: 2rem; font-weight: 600; color: var(--plum); line-height: 1; }
.btn-block { width: 100%; justify-content: center; }
.send-row { display: flex; gap: 8px; margin-top: 8px; }
.send-row .input { flex: 1; }
.mt-10 { margin-top: 10px; }
.seg-list { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; max-height: 230px; overflow: auto; }
.seg-check { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-weight: 500; text-transform: capitalize; }
.seg-check:hover { background: var(--cream); }
.seg-check input { width: 16px; height: 16px; cursor: pointer; }
.seg-check .muted { margin-left: auto; font-variant-numeric: tabular-nums; }
.seg-all { font-weight: 600; text-transform: none; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 3px; padding-bottom: 9px; }
