/* Palette sampled from the Instar logo: butterfly #ec8e43 / #d75e31,
   wordmark #0f3442. Orange is reserved for brand and primary actions so it
   never competes with the amber warning state. Navy carries structure. */
:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #eef1f3;
  --border: #dbe2e6;
  --text: #0f3442;
  --muted: #5d7480;

  --brand: #d75e31;
  --brand-strong: #b8491f;
  --brand-soft: #fdeee6;
  --accent: #0f3442;
  --accent-soft: #e8eff2;

  --pass: #10794a;
  --pass-bg: #e3f5eb;
  --warn: #8a5a00;
  --warn-bg: #fdf1dc;
  --fail: #b3261e;
  --fail-bg: #fdeceb;
  --unknown: #5a5f66;
  --unknown-bg: #e9edef;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 52, 66, .06), 0 8px 24px rgba(15, 52, 66, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1519;
    --surface: #122027;
    --surface-2: #182c34;
    --border: #223b45;
    --text: #e6eef1;
    --muted: #93a8b2;

    --brand: #ef8a54;
    --brand-strong: #f59e6d;
    --brand-soft: #2b1a12;
    --accent: #7fb3c4;
    --accent-soft: #162a33;

    --pass: #63d69c;
    --pass-bg: #14301f;
    --warn: #e8b563;
    --warn-bg: #33270f;
    --fail: #f28b82;
    --fail-bg: #3a1c1a;
    --unknown: #a8b0ba;
    --unknown-bg: #1d3038;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .4em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--fail); font-size: 14px; }
.error.ok { color: var(--pass); }
.invite-box {
  margin: 14px 0 4px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--pass-bg);
}
.invite-box p { margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 13px; }
.badge-invited {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; background: var(--pass-bg); color: var(--pass); margin-left: 8px;
}
.badge-invited.expired { background: var(--warn-bg); color: var(--warn); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ------------------------------------------------------------ controls */

.btn {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--fail); }
.btn:disabled { opacity: .55; cursor: default; }

input, select, textarea {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; }

/* ------------------------------------------------------------ login */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.brand { font-weight: 700; letter-spacing: -.02em; font-size: 16px; }

.login-card .btn { width: 100%; margin-top: 6px; }

/* ------------------------------------------------------------ chrome */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand .muted { font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }

.tabs { display: flex; gap: 4px; }
.tab {
  font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }

.view { max-width: 1060px; margin: 0 auto; padding: 24px 20px 80px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { margin: 0; }
.inline-form { margin-left: auto; display: flex; gap: 8px; }
.inline-form input, .inline-form select { width: auto; min-width: 200px; }
.stack-form { margin-bottom: 20px; }
.stack-form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }

/* ------------------------------------------------------------ summary */

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.approved .n { color: var(--pass); }
.stat.conditional .n { color: var(--warn); }
.stat.fixes .n { color: var(--fail); }

/* ------------------------------------------------------------ domain list */

.domain-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.domain-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px;
  background: var(--surface); cursor: pointer; border: none; width: 100%; text-align: left;
  font: inherit; color: inherit;
}
.domain-row:hover { background: var(--surface-2); }
.domain-name { font-weight: 550; }
.domain-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.domain-row .spacer { margin-left: auto; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); background: var(--surface); }

/* ------------------------------------------------------------ chips */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 500; padding: 3px 9px; border-radius: 20px;
  background: var(--unknown-bg); color: var(--unknown); white-space: nowrap;
}
.chip.approved { background: var(--pass-bg); color: var(--pass); }
.chip.approved_conditional { background: var(--warn-bg); color: var(--warn); }
.chip.needs_fixes { background: var(--fail-bg); color: var(--fail); }
.chip.rejected { background: var(--fail-bg); color: var(--fail); }
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.counts { display: flex; gap: 6px; font-size: 12px; }
.counts span { padding: 2px 7px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.counts .p { background: var(--pass-bg); color: var(--pass); }
.counts .w { background: var(--warn-bg); color: var(--warn); }
.counts .f { background: var(--fail-bg); color: var(--fail); }
.counts .u { background: var(--unknown-bg); color: var(--unknown); }

/* ------------------------------------------------------------ drawer */

.drawer-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .4); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw);
  background: var(--bg); border-left: 1px solid var(--border);
  z-index: 21; display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(16, 24, 40, .14);
}
.drawer-head {
  display: flex; align-items: flex-start; gap: 16px; padding: 18px 22px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.drawer-head h2 { margin: 0; font-size: 19px; }
.drawer-head p { margin: 2px 0 0; font-size: 13px; }
.drawer-head .btn { margin-left: auto; }
.drawer-body { overflow-y: auto; padding: 20px 22px 60px; }

.verdict { padding: 16px 18px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid var(--border); background: var(--surface); }
.verdict.approved { background: var(--pass-bg); border-color: transparent; }
.verdict.approved_conditional { background: var(--warn-bg); border-color: transparent; }
.verdict.needs_fixes, .verdict.rejected { background: var(--fail-bg); border-color: transparent; }
.verdict h3 { font-size: 16px; margin: 0 0 4px; }
.verdict p { margin: 0; font-size: 14px; }
.verdict .when { font-size: 12.5px; opacity: .8; margin-top: 8px; }

/* The registrant gate, first thing under the verdict. */
.whois-box { padding: 14px 16px; border-radius: var(--radius); margin: -8px 0 20px; border: 2px solid var(--border); background: var(--surface); }
.whois-box.pass { border-color: var(--pass); }
.whois-box.warn { border-color: var(--warn); }
.whois-box.fail { border-color: var(--fail); }
.whois-box.unknown { border-color: var(--unknown); }
.whois-head { display: flex; align-items: flex-start; gap: 12px; }
.whois-head h3 { margin: 2px 0 0; font-size: 15px; }
.whois-req { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.whois-state { margin-left: auto; white-space: nowrap; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: var(--surface-2); color: var(--muted); }
.whois-state.pass { background: var(--pass-bg); color: var(--pass); }
.whois-state.warn { background: var(--warn-bg); color: var(--warn); }
.whois-state.fail { background: var(--fail-bg); color: var(--fail); }
.whois-state.unknown { background: var(--unknown-bg); color: var(--unknown); }
.whois-box .detail { margin: 10px 0 0; font-size: 13.5px; }
.whois-box .fix { margin: 6px 0 0; font-size: 13.5px; }
.whois-tag { font-weight: 600; }

/* Two tiers in the domain panel: what blocks approval, then what helps delivery. */
.tier-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 15px; margin: 22px 0 10px; }
.tier-head span { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.tier-note { margin: -4px 0 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--fail-bg); color: var(--fail); font-size: 13.5px; }
/* A recommendation that fails is advice, not a block, so it reads amber, not red. */
.recommended .check.fail .icon { background: var(--warn-bg); color: var(--warn); }
.recommended .counts .f { background: var(--warn-bg); color: var(--warn); }
.whois-tag.pass { color: var(--pass); }
.whois-tag.warn { color: var(--warn); }
.whois-tag.fail { color: var(--fail); }
.whois-tag.unknown { color: var(--unknown); }

.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.group { margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.group > summary {
  padding: 11px 16px; cursor: pointer; font-weight: 550; font-size: 14px;
  display: flex; align-items: center; gap: 10px; list-style: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before { content: "›"; transition: transform .15s; font-size: 16px; color: var(--muted); }
.group[open] > summary::before { transform: rotate(90deg); }
.group > summary .spacer { margin-left: auto; }

.check { display: flex; gap: 12px; padding: 12px 16px 12px 18px; border-top: 1px solid var(--border); }
.check .icon { flex: 0 0 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.check.pass .icon { background: var(--pass-bg); color: var(--pass); }
.check.warn .icon { background: var(--warn-bg); color: var(--warn); }
.check.fail .icon { background: var(--fail-bg); color: var(--fail); }
.check.unknown .icon { background: var(--unknown-bg); color: var(--unknown); }
.check.info .icon { background: var(--unknown-bg); color: var(--unknown); }
.check .title { font-size: 14px; font-weight: 500; }
.check .detail { font-size: 13px; color: var(--muted); margin-top: 3px; word-break: break-word; }
.check .fix { font-size: 13px; margin-top: 6px; padding: 8px 10px; background: var(--accent-soft); color: var(--text); border-radius: 7px; }
.check .fix b { color: var(--brand-strong); font-weight: 600; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.checklist { display: flex; flex-direction: column; gap: 2px; }
.checklist label { display: flex; gap: 9px; align-items: flex-start; margin: 0; padding: 8px 10px; border-radius: 7px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.checklist label:hover { background: var(--surface-2); }
.checklist input { width: auto; margin: 3px 0 0; flex: 0 0 auto; }

.override-box { border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; background: var(--surface); }
.override-box .row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.override-box select, .override-box input { width: auto; flex: 1 1 160px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 12.5px; color: var(--muted); font-weight: 500; }

.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
  .inline-form { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .inline-form select, .inline-form input { flex: 1 1 100%; min-width: 0; }
  .inline-form .btn { flex: 1 1 0; }
  /* Two rows on a phone: logo and account on top, tabs underneath, so Sign
     out never ends up off the edge. */
  .topbar { gap: 6px 12px; padding: 8px 12px; height: auto; flex-wrap: wrap; }
  .topbar .tabs { order: 3; width: 100%; }
  .topbar-right { gap: 4px; min-width: 0; }
  #whoami { display: inline-block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
  .topbar-right .muted { display: none; }
  .view { padding: 16px 12px 60px; }
}

/* Several layout rules below use display:flex or display:grid, which would
   otherwise beat the hidden attribute and leave panels on screen. */
[hidden] { display: none !important; }

/* ------------------------------------------------------------ branding */

.logo { display: block; height: 30px; width: auto; }
.logo-dark { display: none; }
.login-card .logo, #reset-card .logo { height: 46px; margin: 0 auto 20px; }
@media (prefers-color-scheme: dark) {
  .logo-light { display: none; }
  .logo-dark { display: block; }
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .brand .label {
  font-size: 14px; font-weight: 500; color: var(--muted);
  padding-left: 11px; border-left: 1px solid var(--border);
}
@media (max-width: 680px) { .topbar .brand .label { display: none; } }

/* Filter box. At ~200 domains, scrolling to find one is not workable. */
.filter { width: auto; min-width: 190px; margin-left: auto; }
.panel-head .inline-form { margin-left: 0; }
@media (max-width: 680px) { .filter { margin-left: 0; width: 100%; } }

/* ------------------------------------------------------------ list sections */

/* The approved / not approved split. A publisher should be able to answer
   "what can I send from today" without reading a status column. */
/* Each section is a <details>, so it collapses with a click or the keyboard
   and the hairline separators keep working inside it. */
.list-section { display: flex; flex-direction: column; gap: 1px; }

.group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; background: var(--surface-2);
  font-size: 13px; font-weight: 600; letter-spacing: .01em;
  cursor: pointer; list-style: none; user-select: none;
}
.group-head::-webkit-details-marker { display: none; }
.group-head::before {
  content: "›"; font-size: 16px; line-height: 1; opacity: .65;
  transition: transform .15s ease; transform: rotate(0deg);
}
.list-section[open] > .group-head::before { transform: rotate(90deg); }
.group-head:hover { filter: brightness(.97); }
@media (prefers-color-scheme: dark) { .group-head:hover { filter: brightness(1.15); } }
.group-head .group-count {
  font-weight: 600; font-size: 12px; padding: 1px 8px; border-radius: 20px;
  background: var(--surface); color: var(--muted); font-variant-numeric: tabular-nums;
}
.group-head .group-note { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: auto; }
.group-head.ok { color: var(--pass); background: var(--pass-bg); }
.group-head.ok .group-count { color: var(--pass); }
.group-head.no { color: var(--fail); background: var(--fail-bg); }
.group-head.no .group-count { color: var(--fail); }
.empty.small { padding: 18px 16px; font-size: 13.5px; }
@media (max-width: 680px) { .group-head .group-note { display: none; } }

/* Text wordmark, used when a brand has no logo artwork yet. */
.wordmark {
  font-weight: 700; font-size: 21px; letter-spacing: -.02em; color: var(--brand);
  line-height: 1; white-space: nowrap;
}
.login-card .wordmark, #reset-card .wordmark { display: block; text-align: center; font-size: 26px; margin-bottom: 18px; }

/* ------------------------------------------------------------ utilities */

/* These replace inline style attributes. The Content-Security-Policy sets
   style-src 'self', which blocks style="..." as well as <style> blocks, so an
   inline style silently does nothing: the geos row was stacking because of it. */
.drawer-form { padding: 16px; }
.geo-row { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
label.geo { display: flex; gap: 5px; align-items: center; margin: 0; color: var(--text); }
label.geo input { width: auto; margin: 0; }
.spaced { margin-top: 14px; }
.muted.small, .small { font-size: 13px; }
.gap-left { margin-left: 10px; }
td.right { text-align: right; }

/* ------------------------------------------------------------ dialog */

.dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 24px; width: min(420px, 92vw); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(15, 52, 66, .45); }
.dialog h2 { margin: 0 0 4px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.btn.primary.destructive { background: var(--fail); border-color: var(--fail); }
.btn.primary.destructive:hover { filter: brightness(.92); }
#ask-field { display: block; margin-top: 12px; }
.dialog.wide { width: min(680px, 94vw); }
.auto-note { margin: -6px 0 12px; }
.auto-note .spin { vertical-align: -2px; }
#bulk-file { margin: 6px 0 4px; }
#bulk-preview { margin-top: 12px; }
.bulk-table { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.bulk-table table { width: 100%; font-size: 13px; }
.bulk-table td, .bulk-table th { padding: 6px 10px; }
.bulk-status { font-weight: 600; white-space: nowrap; }
.bulk-status.new, .bulk-status.added { color: var(--pass); }
.bulk-status.exists, .bulk-status.duplicate { color: var(--muted); }
.bulk-status.taken, .bulk-status.invalid { color: var(--fail); }
#account-open { font: inherit; font-size: 13px; }
#account-open:hover { text-decoration: underline; }

/* ------------------------------------------------------------ forgot */

.forgot { margin: 14px 0 0; text-align: center; }
.linkish {
  background: none; border: 0; padding: 0; font: inherit; font-size: 13px;
  color: var(--muted); cursor: pointer; text-decoration: underline;
}
.linkish:hover { color: var(--text); }
#forgot-note { margin-top: 10px; text-align: center; line-height: 1.5; }
#forgot-note a { color: var(--brand); }

.forgot-card { width: 100%; max-width: 380px; }
.login-wrap { flex-direction: column; }
.badge-reset {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; background: var(--warn-bg); color: var(--warn); margin-left: 8px;
}
