/* ============================================================================
   Pomelow design system — shared across the self-signup flow and the tenant
   admin portal (app/templates/signup_base.html, app/templates/portal/base.html).
   Lifted verbatim from the "Pomelow Tenant Console" / "Pomelow Home" design
   artifacts: a single committed "warm paper" world, no dark variant by
   design — every colour painted explicitly so the page holds on any ground.

   The operator console (/admin, app/templates/base.html) uses it too since
   brand v2: pomelow.css + portal.css (tokens, shell) + console.css. Light
   only, like the rest of Pomelow.
   ========================================================================== */

:root {
  color-scheme: light;
  --ink:        #16302B;
  --ink-soft:   #274A41;
  --pith:       #F7F4E7;
  --pith-dim:   #EFEBDA;
  --flesh:      #E8536F;
  --flesh-dark: #B23752;
  --rind:       #C9DD52;
  --rind-dark:  #5E7A1E;
  --sage:       #6E8177;
  --white:      #FFFFFF;
  --ground:     #E6E1CC;
  --line:       #E4DFC8;
  --amber:      #E0A94A;
  --amber-ink:  #7A5A17;
  --amber-bg:   #F3E4C9;
  --ok-bg:      #E4EFD2;
  --ok-ink:     #4C5E1E;
  --off-bg:     #F6E1E6;
  --off-ink:    #B23752;

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --body:    'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono:    'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: var(--body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 {
  font-family: var(--display);
  font-weight: 500;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: 25px; }
h2 { font-size: 17px; }

a { color: var(--flesh-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--flesh); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--flesh-dark);
  margin: 0 0 8px;
}

.muted, .hint { color: var(--sage); font-size: 12.5px; }

/* ---- forms ----------------------------------------------------------- */
button, input, select, textarea { font-family: var(--body); font-size: 13.5px; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; max-width: 420px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field label .muted { font-weight: 400; }

input[type="text"], input[type="email"], input[type="password"], input:not([type]),
select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  background: var(--white);
  color: var(--ink);
}
input[type="checkbox"] { accent-color: var(--flesh); }

button {
  cursor: pointer;
  border: 1px solid var(--ink);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 13px;
  background: transparent;
  color: var(--ink);
}
button:hover { background: var(--pith); }
button:disabled { opacity: .4; cursor: not-allowed; }

button[type="submit"], .btn-primary {
  background: var(--flesh);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 13.5px;
}
button[type="submit"]:hover, .btn-primary:hover { background: var(--flesh-dark); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.btn-ghost:hover { background: var(--pith); }

.btn-text {
  background: none;
  border: none;
  font-weight: 600;
  font-size: 13px;
  color: var(--sage);
  padding: 6px 2px;
}
.btn-text:hover { color: var(--flesh-dark); text-decoration: none; }

form.inline { display: inline; }

/* Small inline-table action buttons (Revoke/Grant/Enable/Disable/Suspend…)
   read better quiet, not as a full bordered button — anything inside a
   table cell or a form.inline gets the text-button treatment. */
td button, form.inline button {
  border: none;
  background: none;
  padding: 4px 2px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--sage);
}
td button:hover, form.inline button:hover { background: none; color: var(--flesh-dark); }

/* ---- notices ----------------------------------------------------------- */
.notice, .warning, .error {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}
.notice { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid transparent; }
.warning { background: var(--amber-bg); color: var(--amber-ink); }
p.error, span.error { color: var(--flesh-dark); background: none; padding: 0; }
.error { background: var(--off-bg); color: var(--off-ink); }

/* ---- badges & status dots ---------------------------------------------- */
.badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: .02em;
  white-space: nowrap;
  display: inline-block;
  border: none;
}
.badge.active, .badge.ready, .badge.live { background: var(--ok-bg); color: var(--ok-ink); }
.badge.provisioning, .badge.deleting, .badge.pending, .badge.soon { background: var(--amber-bg); color: var(--amber-ink); }
.badge.suspended { background: var(--pith-dim); color: var(--sage); }
.badge.needs_attention, .badge.off, .badge.error { background: var(--off-bg); color: var(--off-ink); }
.badge.deleted { background: transparent; color: var(--sage); border: 1px dashed var(--line); }
.badge.plan { background: #F6E1E6; color: var(--flesh-dark); }

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  background: #CFC7AB;
}
.dot.ready { background: var(--rind-dark); }
.dot.error { background: var(--flesh-dark); }
.dot.pending { background: var(--amber); }
.dot.skipped { background: transparent; border: 1px solid var(--line); }

/* ---- tables -------------------------------------------------------------- */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th {
  text-align: left;
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--sage);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--pith-dim);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---- cards --------------------------------------------------------------- */
.card {
  background: var(--pith);
  border-radius: 14px;
  padding: 18px 20px;
  margin: 0 0 18px;
}
.card table { background: transparent; }
.card > h2, .card > h3 { font-size: 15px; margin-bottom: 10px; }

/* ---- page header conventions --------------------------------------------- */
.phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 6px; flex-wrap: wrap; }
.phead h1 { margin: 0; }
.psub { font-size: 13px; color: var(--ink-soft); margin: 0 0 24px; max-width: 68ch; }

/* ---- first-run welcome banner (dismissed via localStorage, no DB state) --- */
.welcome-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.welcome-banner p { margin: 0; }
.welcome-banner button {
  border: none;
  background: none;
  padding: 4px 2px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ok-ink);
  flex-shrink: 0;
  white-space: nowrap;
}
.welcome-banner button:hover { color: var(--flesh-dark); }

/* ---- live per-tool access toggles (Mail -- see TOGGLEABLE_TOOLS) --
   Boxed and bordered so the cells in a status-heavy table that
   actually DO something when clicked read as controls, not as one of the
   surrounding pure-status cells. */
.tool-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--pith-dim);
}
.tool-control button {
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--white);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
}
.tool-control button:hover { background: var(--pith); color: var(--ink); }

/* ============================================================================
   Portal shell (sidebar app, matches the Pomelow Tenant Console artifact)
   ========================================================================== */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; background: var(--white); }

.sidebar { background: var(--ink); color: var(--pith); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 14px; }
.brand span { font-family: var(--display); font-size: 17px; font-weight: 500; }

.org-switch {
  display: flex; align-items: center; gap: 10px;
  background: rgba(247,244,231,.08);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
}
.org-switch .nm { font-size: 12.5px; font-weight: 600; line-height: 1.25; display: block; }
.org-switch .ur { font-family: var(--mono); font-size: 10px; color: #8FA69B; display: block; }

nav.portal-nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase;
  color: #7C9188; padding: 15px 12px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: #C7D6CE;
}
.nav-item:hover { color: var(--pith); background: rgba(247,244,231,.06); text-decoration: none; }
.nav-item.active { background: rgba(247,244,231,.12); color: var(--pith); }

.sidebar-foot {
  margin-top: auto; padding: 14px 12px 4px;
  border-top: 1px solid rgba(247,244,231,.1);
  font-size: 11.5px; color: #8FA69B;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-foot a { color: #8FA69B; }
.sidebar-foot a:hover { color: var(--pith); }
.sidebar-foot .av {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--rind); color: #3E4D1E;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

main.portal-main { padding: 34px 40px 64px; max-width: 1020px; min-width: 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; }
  .sidebar-foot, .nav-group { display: none; }
  nav.portal-nav { flex-direction: row; flex-wrap: wrap; }
  .org-switch { margin: 0 8px 0 0; }
  main.portal-main { padding: 24px 20px 48px; }
}

/* Signup form: grouped sections, suffixed workspace address, domain note */
.signup-form fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.signup-form legend {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--sage); margin-bottom: 10px; padding: 0;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 420px; }
.field-row .field { margin-bottom: 14px; }
.input-suffix { display: flex; align-items: stretch; max-width: 420px; }
/* The input never shrinks below 9em; a long domain (a long slug) wraps
   inside the suffix instead of squeezing the input to nothing. */
.input-suffix input { flex: 1 0 9em; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix .suffix {
  display: flex; align-items: center; padding: 0 10px; font-family: var(--mono); font-size: 12.5px;
  color: var(--sage); background: var(--pith); border: 1px solid var(--line); border-left: 0;
  border-radius: 0 8px 8px 0; min-width: 0; overflow-wrap: anywhere;
}
.domain-note { margin: 2px 0 14px; max-width: 420px; }
.domain-note summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.domain-note p { margin: 6px 0 0; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; gap: 0; } }

/* Portal Email screen: numbered steps + small inline buttons */
ol.steps { padding-left: 20px; margin: 12px 0; }
ol.steps > li { margin-bottom: 14px; }
ol.steps table { margin: 8px 0; }
.btn-small { padding: 3px 9px; font-size: 12px; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.signup-form .field, .signup-form .field-row, .signup-form .input-suffix, .domain-note { max-width: none; }
.signup-form input, .signup-form select { width: 100%; min-width: 0; }
.signup-form .input-suffix input { width: auto; }
/* Signup: plan cards + consent */
.signup-form .label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.plan-card {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--white); font-weight: 400;
}
.plan-card:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.plan-card input { position: absolute; opacity: 0; pointer-events: none; }
.plan-card:focus-within { outline: 2px solid var(--flesh); outline-offset: 2px; }
.plan-name { font-weight: 700; font-size: 14px; }
.plan-price { font-size: 13px; color: var(--ink); }
.plan-blurb { font-size: 12px; color: var(--sage); }
.consent .check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 13px; line-height: 1.45; }
.consent .check input { width: auto; margin-top: 2px; flex-shrink: 0; }
.cf-turnstile, .frc-captcha { margin: 4px 0 14px; }
.plan-card { position: relative; }
.signup-form input[type="radio"], .signup-form input[type="checkbox"] { width: auto; }

/* Closing an organization */
.closing-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.closing-banner form { margin: 0; }
.danger-card { border-left: 3px solid var(--flesh-dark); }
.btn-danger { background: var(--flesh-dark); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.save-list li { margin-bottom: 8px; }
.close-form .check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.close-form .check input { width: auto; margin-top: 3px; }
/* New member's sign-in details (_member_created.html) */
.credentials { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; max-width: 520px;
  padding: 14px 16px; background: var(--pith); border: 1px solid var(--line); border-radius: 8px; }
.credentials dt { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.credentials dd { margin: 0; overflow-wrap: anywhere; }
