/* App chrome: staff admin, partner sign-in/landing pages, dialogs, toasts.
   Report content styles live in style.css and are deliberately untouched
   here -- anything the partner sees *inside* the report stays as designed. */

:root {
  --ink: #0f2238;              /* app bar navy */
  --ink-2: #1b3656;
  --sme-blue: #0a84cf;         /* from the SME wordmark */
  --sme-lime: #b3cf2c;         /* from the SME swoosh */
  --admin-bg: #eceff4;
  --zone-tint: #f5f8fc;
  --zone-border: #d6e2f0;
  --warn-bg: #fff8eb;
  --warn-border: #f3d59b;
  --warn-text: #8a5a00;
  --warn-icon: #d98a00;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 34, 56, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 34, 56, 0.08), 0 1px 3px rgba(15, 34, 56, 0.06);
}

.icon { flex-shrink: 0; vertical-align: -0.15em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.muted-line { color: var(--text-muted); font-size: 12px; }
.nowrap { white-space: nowrap; }
.hint { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; line-height: 1.45; }
.hint.center { text-align: center; }
.hint.warn { color: var(--warn-text); display: flex; gap: 6px; align-items: flex-start; }
.hint a { color: var(--seq-blue); }
.eyebrow { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sme-blue); margin-bottom: 4px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.button-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------- buttons */
.btn, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none; font-weight: 550; line-height: 1.2;
  transition: background 0.12s, box-shadow 0.12s, transform 0.06s, opacity 0.12s;
}
.btn { box-shadow: 0 1px 2px rgba(42, 111, 214, 0.3); }
.btn:hover { opacity: 1; background: #1f5fc0; }
.btn:active, .btn-secondary:active { transform: translateY(1px); }
.btn:disabled, .btn-secondary:disabled { opacity: 0.6; cursor: progress; }
.btn-secondary { background: var(--surface-1); border-color: #d5dbe3; font-size: 13px; padding: 8px 12px; }
.btn-secondary:hover { background: #f1f4f8; border-color: #c4ccd6; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px 16px; }
.btn-danger { background: var(--status-serious); box-shadow: none; }
.btn-danger:hover { background: #bf4122; }
.btn-microsoft { background: #fff; color: var(--text-primary); border: 1px solid #c9d0d9; box-shadow: var(--shadow-sm); }
.btn-microsoft:hover { background: #f5f7fa; }
.text-btn, .link-btn {
  background: none; border: none; padding: 4px 6px; border-radius: 6px;
  font: inherit; font-size: 13px; color: var(--seq-blue); cursor: pointer; font-weight: 500;
}
.text-btn:hover, .link-btn:hover { background: #eaf2fd; }
.text-btn.danger { color: var(--status-serious); }
.text-btn.danger:hover { background: #fdeee9; }
.text-link { display: inline-flex; align-items: center; gap: 6px; color: var(--seq-blue); text-decoration: none; font-size: 13px; font-weight: 550; }
.text-link:hover { text-decoration: underline; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent;
  background: none; color: var(--text-secondary); cursor: pointer;
}
.icon-btn:hover { background: #e6ebf1; color: var(--text-primary); }
.icon-btn.spinning .icon { animation: spin 0.8s linear infinite; }
.upload-btn { cursor: pointer; }
.upload-btn.busy { opacity: 0.6; pointer-events: none; }

/* ----------------------------------------------------------- fields */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.field > span em { font-style: normal; font-weight: 400; color: var(--text-muted); }
.field-input { font-family: inherit; transition: border-color 0.12s, box-shadow 0.12s; border-color: #d5dbe3; }
.field-input:focus { outline: none; border-color: var(--seq-blue); box-shadow: 0 0 0 3px rgba(42, 111, 214, 0.15); }
textarea.field-input { resize: vertical; min-height: 44px; }
select.field-input { cursor: pointer; }
.field-input.compact { width: auto; flex: 0 0 auto; padding: 7px 10px; font-size: 13px; }
.prefixed { display: flex; align-items: stretch; }
.prefixed .prefix {
  display: flex; align-items: center; padding: 0 10px; font-size: 13px; color: var(--text-muted);
  background: #f1f4f8; border: 1px solid #d5dbe3; border-right: none; border-radius: 8px 0 0 8px; white-space: nowrap;
}
.prefixed .field-input { border-radius: 0 8px 8px 0; }

/* ------------------------------------------------------------ pills */
.pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; line-height: 1.5; }
.pill-ok { background: #e3f5e9; color: #0b7a31; }
.pill-muted { background: #eceff3; color: var(--text-secondary); }
.pill-danger { background: #fdebe6; color: #b23d20; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--baseline); display: inline-block; flex-shrink: 0; }
.status-dot.active { background: var(--status-good); box-shadow: 0 0 0 3px rgba(15, 157, 63, 0.14); }
.status-dot.expired { background: var(--status-serious); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #eef2f7; color: var(--text-primary); border: 1px solid #e0e6ee; }

/* ----------------------------------------------------------- alerts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.alert > .icon { margin-top: 1px; }
.alert-warning { background: var(--warn-bg); border: 1px solid var(--warn-border); border-left: 4px solid var(--warn-icon); color: var(--warn-text); }
.alert-warning > .icon { color: var(--warn-icon); }
.alert-body { flex: 1; min-width: 0; }
.alert-body strong { color: #5f3e00; font-size: 14px; }
.alert-body p { margin: 3px 0 0; font-size: 13px; line-height: 1.45; }
.alert .btn { align-self: center; flex-shrink: 0; }
.alert.inline { margin-bottom: 18px; }
.link-list { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 8px; }
.link-list .link-btn { padding: 2px 8px; background: #fff; border: 1px solid var(--warn-border); color: var(--warn-text); }
.link-list .link-btn:hover { background: #fff1d6; }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 36px 16px; color: var(--text-secondary); }
.empty-state .icon { color: var(--text-muted); }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.5; }
.empty-state strong { color: var(--text-primary); font-size: 14px; }
.empty-state.compact { padding: 22px 16px; border: 1px dashed #d5dbe3; border-radius: 10px; background: #fbfcfd; }

/* ---------------------------------------------- brand mark + app bar */
.brand-mark {
  display: block; width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  background: #fff; object-fit: contain;
  box-shadow: 0 0 0 1px rgba(15, 35, 70, 0.12);
}
.app-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.app-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.app-brand-text strong { font-size: 15px; font-weight: 650; }
.app-brand.small .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
.app-brand.small .app-brand-text strong { font-size: 13.5px; }
.app-brand.small .app-brand-text span { font-size: 12px; color: var(--text-secondary); }

body.admin-body { background: var(--admin-bg); }
.app-bar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 50; padding-top: env(safe-area-inset-top); }

/* App-like touch behaviour (see pwa.js): no pinch or double-tap zoom, no
   rubber-banding past the page edges, no gray tap flashes. */
html { touch-action: pan-x pan-y; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; overflow-x: clip; }
* { -webkit-tap-highlight-color: transparent; }
button, .btn, .btn-secondary, .tab, .org-item, .app-bar-link, .text-btn, .chip-btn { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.sheet-list, .drilldown-panel, .dialog { overscroll-behavior: contain; }
/* iOS zooms into any input under 16px when focused. */
@media screen and (max-width: 700px) { input, select, textarea, .field-input { font-size: 16px !important; } }

/* Pull-to-refresh indicator. */
.ptr {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; z-index: 300; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; color: var(--text-muted); box-shadow: 0 4px 14px rgba(15, 34, 56, 0.22);
  transform: translate(-50%, -48px); opacity: 0; pointer-events: none;
}
.ptr.ready { color: var(--seq-blue); }
.ptr.spinning svg { animation: spin 0.7s linear infinite; }
.app-bar::after { content: ""; display: block; height: 3px; background: linear-gradient(90deg, var(--sme-lime), var(--sme-blue) 55%, #2a6fd6); }
.app-bar-inner { max-width: 1440px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.staff-badge {
  display: inline-flex; align-items: center; gap: 5px; width: fit-content; margin-top: 3px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--sme-lime); background: rgba(179, 207, 44, 0.12); padding: 2px 8px; border-radius: 999px;
}
.app-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink-2); border: 1px solid rgba(255, 255, 255, 0.18); font-size: 11.5px; font-weight: 700;
}
.user-avatar img, .staff-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.user-avatar:has(img) { overflow: hidden; }
.staff-photo { border-radius: 50%; overflow: hidden; background: var(--zone-tint); }
.user-name { color: rgba(255, 255, 255, 0.9); }
.app-bar-link { color: rgba(255, 255, 255, 0.75); text-decoration: none; padding: 5px 9px; border-radius: 6px; }
.app-bar-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.app-bar-nav { display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; }
.role-chip {
  margin-left: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: rgba(255, 255, 255, 0.85); vertical-align: 1px;
}
.role-chip.role-admin { background: rgba(185, 214, 58, 0.18); color: #d6ec7a; }

/* ------------------------------------------------------ staff access */
.staff-page { max-width: 1040px; }
.activity-page { max-width: 1180px; }
.activity-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; align-items: end; }
.activity-filters .activity-search { grid-column: span 2; }
.activity-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 14px 0 6px; }
.activity-toolbar-actions { display: inline-flex; align-items: center; gap: 12px; }
.activity-table td { vertical-align: top; }
.activity-table tr.has-details { cursor: pointer; }
.activity-table tr.has-details:hover td, .activity-table tr.open td { background: #f7f9fc; }
.activity-details { margin: 8px 0 2px; padding: 8px 12px; background: #f1f4f8; border-radius: 8px; font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; }
.activity-details[hidden] { display: none; }
.activity-details dt { font-weight: 600; color: var(--text-primary); }
.activity-details dd { margin: 0; word-break: break-word; }
.activity-more { display: flex; justify-content: center; margin-top: 12px; }
.cat-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 650; margin-right: 6px; white-space: nowrap; vertical-align: 1px; }
.cat-muted { background: #eef1f5; color: #4f5967; }
.cat-blue { background: #e6eef9; color: #2a5ea8; }
.cat-violet { background: #ece8f7; color: #5b3fa0; }
.cat-teal { background: #e2f3f1; color: #17675c; }
.cat-amber { background: #fdf0dc; color: #8a5300; }
.cat-green { background: #e5f4e7; color: #23683a; }
@media screen and (max-width: 700px) {
  .activity-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .activity-filters .field-input { min-width: 0; width: 100%; }
  .activity-table td.no-org { display: none; }
  .activity-search { grid-column: 1 / -1; }
  /* Rows become cards on phones. */
  .activity-table thead { display: none; }
  .activity-table, .activity-table tbody, .activity-table tr, .activity-table td { display: block; width: 100%; }
  .activity-table tr { padding: 10px 0; border-bottom: 1px solid var(--gridline); }
  .activity-table td { border: 0 !important; padding: 2px 0 !important; }
  .activity-table td:first-child { font-size: 12px; color: var(--text-muted); }
}
.settings-page { max-width: 880px; display: grid; gap: 20px; }
.settings-page > .card { margin: 0; }
.settings-page .home-hero { margin-bottom: -4px; }
.settings-logo-side .button-row + .hint { margin-top: 10px; }
.settings-page .section-head h3 { display: inline-flex; align-items: center; gap: 8px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.settings-form-wide { grid-template-columns: 1fr auto; }
.settings-page .placeholder-chips { margin-top: 10px; align-items: center; }
.settings-page .subject-preview { margin-top: 12px; }
.settings-logo { display: grid; grid-template-columns: minmax(220px, 1fr) 1.2fr; gap: 20px; align-items: center; }
.settings-logo-side p { margin: 0 0 12px; font-size: 13.5px; color: var(--text-secondary); }
@media screen and (max-width: 760px) { .settings-form, .settings-logo { grid-template-columns: 1fr; } }
.staff-card { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.staff-card .section-head { margin-top: 0; }
.staff-card h3 { margin: 0; font-size: 15px; }
.staff-add { display: grid; grid-template-columns: 1.4fr 1.2fr 150px auto; gap: 12px; align-items: end; }
.staff-add-options { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent, #2a6fd6); margin: 0; }
.staff-table td .text-btn + .text-btn { margin-left: 12px; }
.role-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--gridline); }
.role-legend div { font-size: 12.5px; color: var(--text-secondary); line-height: 1.45; }
.role-legend strong { display: block; color: var(--text-primary); font-size: 13px; margin-bottom: 2px; }
.staff-table td { vertical-align: middle; }
.staff-person { display: flex; align-items: center; gap: 10px; }
.staff-person strong { font-weight: 600; }
.role-select { width: auto; min-width: 110px; padding-top: 6px; padding-bottom: 6px; }
@media screen and (max-width: 760px) {
  .staff-add, .role-legend { grid-template-columns: 1fr; }
  .staff-table th:nth-child(4), .staff-table td:nth-child(4) { display: none; }
}

/* ------------------------------------------------------ admin layout */
.admin-shell { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 24px; padding: 24px; align-items: start; }
.org-sidebar {
  position: sticky; top: 83px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 10px; max-height: calc(100vh - 107px); overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 10px; }
.sidebar-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.count-badge { font-size: 11px; background: #eef2f7; color: var(--text-secondary); padding: 1px 7px; border-radius: 999px; letter-spacing: 0; }
.search-box { display: flex; align-items: center; gap: 7px; margin: 0 4px 10px; padding: 7px 10px; border: 1px solid #d5dbe3; border-radius: 8px; color: var(--text-muted); }
.search-box input { border: none; outline: none; font: inherit; font-size: 13px; width: 100%; background: none; }
.org-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.org-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  border: none; background: none; font: inherit; text-align: left; cursor: pointer; color: inherit;
  transition: background 0.1s;
}
.org-item:hover { background: #f1f4f8; }
.org-item.active { background: #e8f1fd; box-shadow: inset 3px 0 0 var(--seq-blue); }
.org-item.active .org-name { color: #1a56b0; }
.org-avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: hsl(var(--hue) 45% 30%); background: hsl(var(--hue) 60% 92%);
}
.org-avatar.lg { width: 64px; height: 64px; border-radius: 14px; font-size: 20px; }
.org-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.org-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-sub { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.flag-warn { color: var(--warn-icon); display: inline-flex; }

.admin-main { min-width: 0; }

/* home */
.home-hero h1 { font-size: 24px; margin-bottom: 4px; }
.home-hero .subtitle { margin-bottom: 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); color: var(--sme-blue); }
.kpi-value { font-size: 30px; font-weight: 750; color: var(--text-primary); margin-top: 8px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value span { font-size: 17px; color: var(--text-muted); font-weight: 600; }
.kpi-label { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.kpi-warn { color: var(--warn-icon); background: var(--warn-bg); border-color: var(--warn-border); }

/* org hero */
.org-hero {
  display: flex; align-items: center; gap: 18px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; margin-bottom: 16px;
}
.org-hero-logo {
  width: 150px; height: 64px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; background: #fff; border: 1px solid var(--gridline); padding: 8px 10px;
}
.org-hero-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.org-hero-logo.empty { width: 64px; padding: 0; border: none; background: none; }
.org-hero-text { flex: 1; min-width: 0; }
.org-hero-text h1 { font-size: 22px; margin: 0 0 6px; }
.org-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.org-hero-meta .sep { color: var(--baseline); }
.hero-action { flex-shrink: 0; }

/* staff tools zone */
.zone-label {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-2);
  background: #dde7f3; padding: 3px 9px; border-radius: 999px;
}
.zone-label-preview { color: #3c4a5c; background: #e3e7ec; }
.zone-label .view-only { margin-left: 4px; padding-left: 7px; border-left: 1px solid rgba(0, 0, 0, 0.18); font-weight: 600; }
.admin-zone { background: var(--zone-tint); border: 1px solid var(--zone-border); border-radius: var(--radius); margin-bottom: 28px; box-shadow: var(--shadow-sm); overflow: hidden; }
.zone-head { display: flex; align-items: center; gap: 16px; padding: 12px 16px 0; border-bottom: 1px solid var(--zone-border); flex-wrap: wrap; }
.zone-head .zone-label { margin-bottom: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px 12px;
  border: none; background: none; font: inherit; font-size: 13.5px; font-weight: 550; color: var(--text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.6); }
.tab.active { color: #1a56b0; border-bottom-color: var(--seq-blue); background: var(--surface-1); }
.tab-count { font-size: 11px; background: #dbe8fb; color: #1a56b0; padding: 0 7px; border-radius: 999px; line-height: 18px; }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn-icon); }
.tab-panel { background: var(--surface-1); padding: 20px; min-height: 120px; }
.tab-panel h3 { font-size: 14px; margin: 0; font-weight: 650; }
.tab-panel .loading-state { padding: 24px 0; }
.panel-intro { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); padding-bottom: 14px; border-bottom: 1px solid var(--gridline); }
.panel-intro p { margin: 0; }
.sender-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding: 9px 12px;
  font-size: 13px; background: #f6f8fb; border: 1px solid var(--gridline); border-radius: 9px; color: var(--text-primary);
}
.sender-line > .icon { color: var(--text-muted); flex-shrink: 0; }
.sender-line > span { flex: 1; min-width: 0; }
.sender-line .sep { color: var(--baseline); margin: 0 4px; }
.sender-line + .sender-line { margin-top: 8px; }
.placeholder-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.chip-btn { cursor: pointer; font: inherit; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.chip-btn:hover { background: #dbe8fb; color: #1a56b0; }
.subject-preview { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; background: #f6f8fb; border: 1px solid var(--gridline); border-radius: 9px; font-size: 13px; margin-bottom: 8px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 20px 0 10px; flex-wrap: wrap; }

/* schedules */
.schedule-list { display: flex; flex-direction: column; gap: 10px; }
.schedule-card { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--gridline); border-radius: 10px; background: #fff; transition: border-color 0.12s, box-shadow 0.12s; }
.schedule-card:hover { border-color: #cfd8e3; box-shadow: var(--shadow-sm); }
.schedule-card.paused { background: #fafbfc; }
.schedule-card.paused .schedule-icon { background: #eceff3; color: var(--text-muted); }
.schedule-icon { width: 36px; height: 36px; border-radius: 10px; background: #e8f1fd; color: var(--seq-blue); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.schedule-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.schedule-title { font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.schedule-sub { font-size: 12.5px; color: var(--text-secondary); }
.cc-row { display: flex; align-items: center; gap: 6px; }
.cc-row > span { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.schedule-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.schedule-actions .btn-secondary { margin-right: 6px; }

.schedule-form { margin-bottom: 14px; padding: 16px; border: 1px solid #cfdcef; border-radius: 10px; background: var(--zone-tint); display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cadence-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.cadence-word { font-size: 13px; color: var(--text-secondary); }
.cadence-word.muted { color: var(--text-muted); }
.schedule-form .hint { margin: -4px 0 0; }

.send-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }

.history { margin-top: 24px; border-top: 1px solid var(--gridline); padding-top: 6px; }
.history summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; padding: 10px 0; list-style: none; }
.history summary::-webkit-details-marker { display: none; }
.history summary::before { content: "▸"; color: var(--text-muted); font-size: 12px; transition: transform 0.15s; }
.history[open] summary::before { transform: rotate(90deg); }
.data-table td { vertical-align: top; padding: 9px 8px; }
.data-table th { font-size: 12px; }

/* access */
.access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.tool-card { border: 1px solid var(--gridline); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.tool-card-head { display: flex; gap: 12px; align-items: flex-start; }
.tool-card-head p { margin: 3px 0 0; font-size: 13px; color: var(--text-secondary); }
.tool-icon { width: 36px; height: 36px; border-radius: 10px; background: #e8f1fd; color: var(--seq-blue); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.url-box { display: flex; align-items: center; gap: 9px; padding: 8px 8px 8px 12px; background: #f4f8f5; border: 1px solid #d6eadb; border-radius: 8px; font-size: 13px; min-width: 0; }
.url-box a { color: #0b6a2c; font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.url-box a:hover { text-decoration: underline; }
.url-box.off { background: #f5f6f8; border-color: var(--gridline); color: var(--text-muted); padding: 10px 12px; }
.url-box.result { background: #f2f7fe; border-color: #cfe0f7; }
.url-box.result a { color: #1a56b0; }

/* branding */
.logo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.logo-tile { border: 1px solid var(--gridline); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.logo-tile.missing { border-color: var(--warn-border); background: #fffdf8; }
.logo-tile-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.logo-stage {
  height: 120px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 16px 20px;
  background: #fff; border: 1px solid var(--gridline);
  background-image: linear-gradient(45deg, #f4f6f9 25%, transparent 25%), linear-gradient(-45deg, #f4f6f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f4f6f9 75%), linear-gradient(-45deg, transparent 75%, #f4f6f9 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.logo-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-missing { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--warn-icon); font-size: 12.5px; font-weight: 600; }
.logo-tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-preview { margin-top: 8px; }
/* A letter page's content width, so the header previews at report scale. */
.paper { background: #fff; border: 1px solid var(--gridline); border-radius: 8px; box-shadow: var(--shadow-sm); padding: 20px 28px 4px; max-width: 816px; }
.paper .brand-header { margin-bottom: 0; border-bottom: none; padding-bottom: 16px; }

/* report preview */
.preview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.preview-head h2 { color: var(--text-primary); font-size: 18px; margin: 8px 0 2px; }
.preview-head .subtitle { margin: 0; font-size: 13px; }
.preview-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.freshness { font-size: 12px; color: var(--text-muted); margin-right: 4px; }
.report-frame {
  background: var(--page); border: 1px solid #d3d9e1; border-radius: 16px; padding: 28px 32px 36px;
  box-shadow: var(--shadow-md);
}
.report-frame > .report-toolbar { display: none; } /* actions live in .preview-head */
.report-skeleton { min-height: 240px; display: flex; align-items: center; justify-content: center; }

/* ------------------------------------------------ auth + landing pages */
.center-stage {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, #e2eefb 0%, transparent 60%), var(--page);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-md); padding: 32px; position: relative; overflow: hidden;
}
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--sme-lime), var(--sme-blue) 55%, #2a6fd6); }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card .subtitle { font-size: 14px; line-height: 1.5; margin-bottom: 22px; }
.auth-logos { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-logo { max-height: 44px; max-width: 200px; object-fit: contain; }
.brand-lockup { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.brand-lockup div { display: flex; flex-direction: column; line-height: 1.25; }
.brand-lockup strong { font-size: 14px; }
.brand-lockup span:not(.brand-mark) { font-size: 12px; color: var(--text-muted); }
.info-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--zone-tint); border: 1px solid var(--zone-border); border-radius: 10px; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.info-row .icon { color: var(--sme-blue); margin-top: 2px; }
.info-row strong { color: var(--text-primary); }
.auth-card .hint.center { margin-top: 18px; }

.partner-bar { background: var(--surface-1); border-bottom: 1px solid var(--gridline); position: sticky; top: 0; z-index: 50; border-top: env(safe-area-inset-top) solid var(--ink); }
.partner-bar::before { content: ""; display: block; height: 3px; background: linear-gradient(90deg, var(--sme-lime), var(--sme-blue) 55%, #2a6fd6); }
.partner-bar-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.partner-bar-right { display: flex; align-items: center; gap: 12px; }

/* --------------------------------------------------- dialogs + toasts */
.dialog-overlay { position: fixed; inset: 0; background: rgba(15, 34, 56, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 200; animation: fade-in 0.12s ease-out; }
.dialog { background: var(--surface-1); border-radius: 14px; box-shadow: 0 20px 50px rgba(15, 34, 56, 0.25); width: 100%; max-width: 440px; padding: 22px; animation: pop-in 0.14s ease-out; }
.dialog h2 { color: var(--text-primary); font-size: 17px; margin: 0 0 10px; }
.dialog-body { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.dialog-body p { margin: 0 0 10px; }
.dialog-recipients { max-height: 180px; overflow-y: auto; margin-bottom: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 300; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
  background: var(--ink); color: #fff; box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast-success .icon { color: var(--sme-lime); }
.toast-error { background: #7a2410; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.97) translateY(4px); } }

/* ------------------------------------------------------------ mobile */
@media screen and (max-width: 980px) {
  .admin-shell { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .org-sidebar { position: static; max-height: none; }
}
@media screen and (max-width: 700px) {
  .app-bar-inner { padding: 10px 16px; }
  .user-name { display: none; }
  .org-hero { flex-wrap: wrap; }
  .form-grid, .access-grid, .logo-grid, .send-row { grid-template-columns: 1fr; }
  .schedule-card { flex-wrap: wrap; }
  .schedule-actions { justify-content: flex-start; width: 100%; }
  .report-frame { padding: 16px; border-radius: 12px; }
  .tab-panel { padding: 16px; }
}

/* ------------------------------------------------------------- print */
/* Export PDF from the admin prints only the report, laid out exactly like
   the partner's own export (.page's print rules in style.css). */
@media print {
  body.admin-body { background: white; }
  .admin-shell { display: block; padding: 0; max-width: none; }
  .report-frame { background: white; border: none; box-shadow: none; border-radius: 0; padding: 0 28px 40px; }
  .partner-bar, .toast-host, .dialog-overlay { display: none !important; }
}

.error:empty { display: none; }
.app-bar-link { white-space: nowrap; }
.brand-short { display: none; }

/* Settings menu (header): Settings for everyone, Staff access for admins. */
.nav-menu { position: relative; }
.nav-menu > button { background: none; border: 0; font: inherit; cursor: pointer; }
.nav-menu .chev { opacity: 0.7; margin-left: -2px; }
.nav-menu-list {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 14px 34px rgba(15, 34, 56, 0.22); padding: 6px; z-index: 60;
}
.nav-menu-list[hidden] { display: none; }
.nav-menu-list a { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: inherit; }
.nav-menu-list a:hover, .nav-menu-list a:focus-visible { background: #f1f4f8; outline: none; }
.nav-menu-list a .icon { margin-top: 2px; color: var(--text-muted); flex-shrink: 0; }
.nav-menu-list strong { display: block; font-size: 13.5px; font-weight: 600; }
.nav-menu-list small { display: block; font-size: 12px; color: var(--text-secondary); line-height: 1.35; margin-top: 1px; }
.nowrap { white-space: nowrap; }

/* Phone partner picker: a "current partner" bar that opens a bottom sheet. */
.org-switcher { display: none; width: 100%; align-items: center; gap: 12px; padding: 4px 2px; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; color: inherit; }
.org-switcher .org-meta { flex: 1; min-width: 0; }
.org-switcher .org-name { font-size: 16px; font-weight: 650; }
.org-switcher-eyebrow { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 1px; }
.org-switcher-cta { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; font-size: 13.5px; font-weight: 600; color: var(--seq-blue); padding: 8px 10px; border-radius: 9px; background: #edf3fc; }
.overview-avatar { --hue: 212; color: #2a5ea8; }
.org-issues { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 12px; color: #8a5300; }
.org-check { color: var(--seq-blue); flex-shrink: 0; display: inline-flex; }

.sheet-overlay { position: fixed; inset: 0; z-index: 210; background: rgba(15, 34, 56, 0.45); display: flex; align-items: flex-end; animation: fade-in 0.16s ease-out; }
.sheet {
  width: 100%; max-height: 86vh; display: flex; flex-direction: column; background: var(--surface-1);
  border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(15, 34, 56, 0.25);
  padding: 6px 12px calc(12px + env(safe-area-inset-bottom)); animation: sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-overlay.closing { animation: fade-out 0.18s ease-in forwards; }
.sheet-overlay.closing .sheet { animation: sheet-down 0.18s ease-in forwards; }
.sheet-grabber { width: 38px; height: 5px; border-radius: 3px; background: #d5dbe3; margin: 4px auto 8px; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 10px; }
.sheet-head h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; color: var(--text-primary); }
.sheet-actions { display: flex; align-items: center; gap: 6px; }
.sheet-actions .icon-btn { width: 38px; height: 38px; }
.sheet-actions .text-btn { font-size: 15px; font-weight: 600; padding: 8px 6px; }
.sheet-search { margin: 0 4px 8px; }
.sheet-list { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; gap: 2px; }
.sheet-list .org-item { padding: 12px 10px; border: 0; width: 100%; }
.sheet-list .org-name { font-size: 15.5px; }
body.sheet-open { overflow: hidden; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes fade-out { to { opacity: 0; } }

@media screen and (max-width: 980px) {
  .org-sidebar { padding: 12px 14px; }
  .org-sidebar .sidebar-head, .org-sidebar .search-box, .org-sidebar .org-list { display: none; }
  .org-switcher { display: flex; }
}

@media screen and (max-width: 700px) {
  /* Header: one tidy row -- mark, short title, icon-only actions. */
  .app-bar-inner { padding: 8px 12px; gap: 8px; }
  .app-brand { gap: 9px; min-width: 0; }
  .app-brand .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
  .brand-full, .staff-badge { display: none; }
  .brand-short { display: inline; }
  .app-brand-text strong { font-size: 15px; white-space: nowrap; }
  .app-user { gap: 2px; }
  .app-bar-nav { margin-right: 0; padding: 8px; }
  .app-bar-nav .nav-label { display: none; }
  .user-avatar { margin: 0 4px; }

  /* Partner header card: stacked, nothing squeezed into a narrow column. */
  .org-hero { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; }
  .org-hero-logo { width: 100%; height: 72px; }
  .org-hero-logo.empty { width: auto; justify-content: flex-start; }
  .org-hero-text h1 { font-size: 21px; line-height: 1.25; }
  .org-hero-meta { row-gap: 4px; }
  .org-hero-meta .sep { display: none; }
  .hero-action { justify-content: center; width: 100%; }
  .alert { flex-wrap: wrap; }
  .alert .alert-body { flex-basis: calc(100% - 34px); }
  .alert .btn { margin-left: 30px; }

  /* Email sender/subject lines: link drops below the text. */
  .sender-line { flex-wrap: wrap; row-gap: 6px; }
  .sender-line > span { flex-basis: calc(100% - 30px); }
  .sender-line > .text-btn { margin-left: 25px; }
  .zone-head { gap: 8px; }
}

/* ------------------------------------------------------ logo editor */
.logo-tile-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.dialog-preview { max-width: 760px; display: flex; flex-direction: column; height: calc(100vh - 48px); max-height: 900px; }
.dialog-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.email-frame { flex: 1; width: 100%; border: 1px solid var(--gridline); border-radius: 10px; background: #f4f5f7; }
.dialog-preview .dialog-actions { margin-top: 14px; }
.dialog-wide { max-width: 920px; max-height: calc(100vh - 40px); overflow-y: auto; }
.logo-editor .le-grid { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 20px; }
.le-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px; }
.le-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.le-toolbar .le-label { margin: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { border: none; background: #fff; font: inherit; font-size: 12.5px; padding: 5px 11px; cursor: pointer; color: var(--text-secondary); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { background: #e7f0fc; color: #1a56b0; font-weight: 600; }
.checker, .le-canvas {
  background-color: #fff;
  background-image: linear-gradient(45deg, #eceff3 25%, transparent 25%), linear-gradient(-45deg, #eceff3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eceff3 75%), linear-gradient(-45deg, transparent 75%, #eceff3 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.le-stage { position: relative; min-height: 200px; display: flex; justify-content: center; align-items: center; border: 1px solid var(--gridline); border-radius: 10px; padding: 10px; background: #f6f8fb; }
.le-canvas { position: relative; visibility: hidden; border-radius: 4px; touch-action: none; user-select: none; }
.le-canvas.ready { visibility: visible; }
.le-canvas img { position: absolute; pointer-events: none; outline: 1px dashed rgba(26, 86, 176, 0.35); }
.le-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text-muted); }
.le-box { position: absolute; border: 2px solid #1a6fd6; box-shadow: 0 0 0 9999px rgba(15, 35, 70, 0.28); cursor: move; }
.le-box.auto { border-style: dashed; }
.le-handle { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid #1a6fd6; border-radius: 3px; }
.le-nw { left: -7px; top: -7px; cursor: nwse-resize; } .le-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.le-sw { left: -7px; bottom: -7px; cursor: nesw-resize; } .le-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.le-n { left: calc(50% - 6px); top: -7px; cursor: ns-resize; } .le-s { left: calc(50% - 6px); bottom: -7px; cursor: ns-resize; }
.le-w { top: calc(50% - 6px); left: -7px; cursor: ew-resize; } .le-e { top: calc(50% - 6px); right: -7px; cursor: ew-resize; }
.le-canvas { overflow: hidden; }
.le-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.le-option { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--gridline); border-radius: 8px; cursor: pointer; font-size: 13px; }
.le-option:has(input:checked) { border-color: #8db4ea; background: #f2f7fe; }
.le-option input { margin-top: 3px; }
.le-option span { display: flex; flex-direction: column; }
.le-option strong { color: var(--text-primary); font-weight: 600; }
.le-option em { font-style: normal; color: var(--text-muted); font-size: 12px; line-height: 1.35; }
.le-result { height: 110px; border: 1px solid var(--gridline); border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 8px; margin-bottom: 4px; }
.le-result img { max-width: 100%; max-height: 100%; transition: opacity 0.15s; }
.le-result img.pending { opacity: 0.45; }
.le-paper { margin: 0 0 4px; max-width: none; }
@media screen and (max-width: 760px) { .logo-editor .le-grid { grid-template-columns: 1fr; } }
