:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7f8;
  color: #18303b;
  --line: #dfe7eb;
  --line-soft: #edf2f4;
  --muted: #6d7e88;
  --text: #18303b;
  --accent: #087f8e;
  --accent-dark: #056570;
  --accent-soft: #e6f5f6;
  --surface: #fff;
  --danger: #b34d4d;
  --shadow: 0 8px 24px rgba(24, 48, 59, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: #f4f7f8; }
body { margin: 0; min-width: 320px; line-height: 1.45; }
button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, dialog:focus-visible {
  outline: 3px solid rgba(8, 127, 142, .24);
  outline-offset: 2px;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 22px max(20px, calc((100% - 1400px) / 2));
}
.topbar h1 { color: var(--text); font-size: 1.75rem; font-weight: 700; margin: 4px 0 0; }
.eyebrow { color: var(--accent); font-size: .68rem; font-weight: 700; letter-spacing: .1em; margin: 0; text-transform: uppercase; }
.freshness {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .78rem;
  max-width: 52%;
  padding: 7px 11px;
  text-align: right;
}
.freshness.stale { background: #fff6f3; border-color: #f0c8bd; color: #a84c3f; }

.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 max(20px, calc((100% - 1400px) / 2));
  position: sticky;
  top: 0;
  z-index: 5;
}
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .86rem;
  padding: 14px 16px 12px;
  white-space: nowrap;
}
.tab:hover { color: var(--accent); }
.tab.active { border-bottom-color: var(--accent); color: var(--accent-dark); font-weight: 650; }

main { margin: 0 auto; max-width: 1400px; padding: 24px 20px 64px; }
.tab-panel.active { display: block; }
.summary-grid { display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 18px; }
.metric, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.metric { min-height: 92px; padding: 16px 18px; }
.metric:hover { border-color: #c8dfe2; }
.metric-label { color: var(--muted); display: block; font-size: .76rem; }
.metric-value { color: var(--text); display: block; font-size: 1.55rem; font-weight: 700; margin-top: 7px; }
.panel { margin-bottom: 18px; overflow: visible; }
.panel-heading { align-items: center; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; gap: 18px; padding: 14px 20px; }
.panel-heading h2 { color: var(--text); font-size: 1.02rem; font-weight: 700; margin: 4px 0 0; }
.muted { color: var(--muted); font-size: .78rem; }

.panel-tools {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
}
.panel-tools label { color: var(--muted); font-size: .78rem; white-space: nowrap; }
select, input { background: var(--surface); border: 1px solid #c5d1d6; border-radius: 5px; color: var(--text); padding: 7px 9px; }
select:hover, input:hover { border-color: #9fb4ba; }
.panel-tools select { margin-left: 4px; padding: 5px 7px; }
.action-tools { align-items: center; display: inline-flex; gap: 8px; margin-left: 0; margin-right: auto; order: 0; }
.selection-count, .action-status { color: var(--muted); font-size: .76rem; }
.selection-count { background: #f5f8f9; border: 1px solid var(--line); border-radius: 999px; min-width: 4.7em; padding: 5px 9px; text-align: center; }
.bulk-actions { align-items: center; display: inline-flex; flex-wrap: wrap; gap: 6px; }
.action-button, .export-button, .pager button, .primary, .action-dialog-footer button:not(.primary) {
  border-radius: 5px;
  cursor: pointer;
  font-size: .79rem;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.action-button { background: var(--accent); border: 1px solid var(--accent); color: #fff; padding: 6px 13px; }
.action-button:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); box-shadow: 0 2px 6px rgba(8, 127, 142, .18); }
.action-button:disabled { cursor: not-allowed; opacity: .42; }
.action-menu {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 12px 28px rgba(24, 48, 59, .16);
  display: grid;
  gap: 2px;
  min-width: 128px;
  padding: 5px;
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  z-index: 10;
}
.action-menu button { background: transparent; border: 0; border-radius: 4px; color: #31515c; cursor: pointer; font-size: .79rem; padding: 8px 10px; text-align: left; }
.action-menu button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-dark); }
.action-menu button[data-action="unsubscribe"], .action-menu button[data-action="repel"], .action-menu button[data-row-action="unsubscribe"], .action-menu button[data-row-action="repel"] { color: var(--danger); }
.action-menu button[data-action="unsubscribe"]:hover:not(:disabled), .action-menu button[data-action="repel"]:hover:not(:disabled), .action-menu button[data-row-action="unsubscribe"]:hover:not(:disabled), .action-menu button[data-row-action="repel"]:hover:not(:disabled) { background: #fff2f1; color: #9f3f3f; }
.bulk-actions .action-button[data-bulk-action="unsubscribe"], .bulk-actions .action-button[data-bulk-action="repel"] { background: #fff2f1; border-color: #f0c8bd; color: #9f3f3f; }
.bulk-actions .action-button[data-bulk-action="unsubscribe"]:hover:not(:disabled), .bulk-actions .action-button[data-bulk-action="repel"]:hover:not(:disabled) { background: #fbe1de; border-color: #dfaaa0; color: #873833; }
.action-menu button:disabled { color: #b8c2c6; cursor: not-allowed; }
.action-status { order: 11; }
.export-button { background: var(--surface); border: 1px solid #b5c4ca; color: #31515c; padding: 6px 10px; }
.export-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.export-button:disabled { cursor: wait; opacity: .6; }
.export-status { color: var(--muted); font-size: .76rem; min-width: 5.5em; }
.export-status:empty, .action-status:empty { display: none; }

.table-wrap { overflow-x: auto; padding: 0 20px; }
table { border-collapse: collapse; min-width: 680px; width: 100%; }
th, td { border-bottom: 1px solid var(--line-soft); font-size: .79rem; padding: 10px 8px; text-align: left; vertical-align: top; }
th { background: #fbfcfd; color: var(--muted); font-size: .71rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
tbody tr:hover { background: #f8fbfb; }
td { color: #2d4650; white-space: nowrap; }
.selection-cell { text-align: center; width: 42px; }
.selection-cell input { accent-color: var(--accent); height: 16px; margin: 0; padding: 0; width: 16px; }
.row-action-header { width: 92px; }
.row-action-cell { color: var(--muted); width: 92px; }
.row-action { display: inline-flex; position: relative; }
.row-action-button { background: var(--surface); border: 1px solid #b5c4ca; border-radius: 5px; color: #31515c; cursor: pointer; font-size: .77rem; padding: 5px 10px; }
.row-action-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.row-action-button:disabled { color: #aebbc0; cursor: not-allowed; opacity: .58; }
.row-action-menu { min-width: 112px; right: 0; top: calc(100% + 5px); }
.row-action-menu button { white-space: nowrap; }
.copy-id { background: transparent; border: 0; color: var(--accent-dark); cursor: pointer; font-size: .73rem; max-width: 220px; overflow: hidden; padding: 0; text-align: left; text-overflow: ellipsis; vertical-align: top; white-space: nowrap; }
.copy-id:hover { text-decoration: underline; }
.empty { color: var(--muted); padding: 20px 0; }

.pager { align-items: center; border-top: 1px solid var(--line-soft); display: flex; gap: 12px; justify-content: flex-end; padding: 13px 20px 16px; }
.pager button, .primary { background: var(--accent); border: 1px solid var(--accent); color: #fff; padding: 7px 11px; }
.pager button:hover:not(:disabled), .primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.pager button:disabled { background: #eef2f3; border-color: #eef2f3; color: #9eacb1; cursor: not-allowed; }
.two-column { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.status-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 18px 20px; }
.status-grid div { background: #f7fafb; border-left: 3px solid var(--accent); border-radius: 0 5px 5px 0; padding: 12px 14px; }
.status-grid span, .status-grid strong { display: block; }
.status-grid span { color: var(--muted); font-size: .75rem; }
.status-grid strong { color: var(--text); margin-top: 5px; }

.account-layout { align-items: start; }
.account-form-panel { padding-bottom: 20px; }
#account-form { display: grid; gap: 12px; padding: 18px 20px 0; }
#account-form label, .action-dialog-body label { color: var(--muted); display: grid; font-size: .78rem; gap: 5px; }
#account-form .primary { justify-self: start; margin-top: 5px; }
.form-status { color: var(--muted); font-size: .8rem; min-height: 1.2em; margin: 0; }

dialog { border: 0; border-radius: 9px; box-shadow: 0 20px 58px rgba(24, 48, 59, .24); color: var(--text); max-width: min(560px, calc(100% - 32px)); padding: 0; width: 560px; }
dialog::backdrop { background: rgba(24, 48, 59, .32); }
.action-dialog-form { margin: 0; }
.action-dialog-body { display: grid; gap: 12px; padding: 18px 20px 4px; }
.action-dialog-body select, .action-dialog-body input { width: 100%; }
.action-summary { max-height: 260px; overflow: auto; }
.action-summary ul { list-style: none; margin: 0; padding: 0; }
.action-summary li { border-bottom: 1px solid var(--line-soft); font-size: .8rem; padding: 8px 0; }
.action-dialog-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; }
.action-dialog-footer button:not(.primary) { background: var(--surface); border: 1px solid #b5c4ca; color: #31515c; padding: 7px 11px; }
.action-dialog-footer button:not(.primary):hover { border-color: var(--accent); color: var(--accent-dark); }

@media (max-width: 980px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 20px; }
  .freshness { max-width: 100%; text-align: left; }
  .tabs { padding: 0 12px; }
  main { padding: 18px 14px 48px; }
}
@media (max-width: 520px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .panel-heading { align-items: flex-start; flex-direction: column; padding-left: 15px; padding-right: 15px; }
  .panel-tools { justify-content: flex-start; width: 100%; }
  .action-tools { flex-wrap: wrap; margin-left: 0; order: 0; width: 100%; }
  .bulk-actions { flex: 1 1 100%; }
  .panel-tools > label { margin-left: 0; }
  .export-status, .action-status { flex-basis: 100%; }
  .status-grid { grid-template-columns: 1fr; padding: 14px; }
  .table-wrap { padding-left: 14px; padding-right: 14px; }
  .pager { justify-content: space-between; padding-left: 14px; padding-right: 14px; }
  .action-dialog-footer button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
