:root {
  /* Brand greens — machinamatrix-website/scripts/_brand_green_weight_preview.py */
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1a2332;
  --muted: #5c6b7a;
  --line: #d8dee6;
  --chrome: #1a2332;       /* app topbar / login chrome — not white, not blue */
  --accent: #668000;       /* primary olive (3rd / recommended) */
  --accent-hover: #7a9a14;
  --accent-soft: #e8efd0;
  --focus-ring: rgba(253, 92, 1, 0.22);
  --focus: #fd5c01;
  --ok: #1b7a4e;
  --warn: #9a5b00;
  --danger: #a12622;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --brand-logo-font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --brand-product-font: Georgia, "Palatino Linotype", "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(165deg, #eef2e8 0%, var(--bg) 42%, #eef2f6 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.ui-lang-en .only-zh { display: none !important; }
.ui-lang-zh .only-en { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.topbar {
  flex-shrink: 0;
  background: var(--chrome);
  color: #fff;
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.topbar .brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  font-weight: normal;
  font-size: inherit;
  letter-spacing: normal;
}
.topbar .brand small {
  display: block;
  font-weight: 400;
  opacity: 0.85;
  font-size: 0.75rem;
  margin-top: 0.15rem;
}
.topbar nav { display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: center; }
.topbar nav a { color: #e8eef5; font-size: 0.92rem; }
.topbar nav a.active { color: #fff; font-weight: 700; text-decoration: underline; }
.topbar .who {
  font-size: 0.8rem;
  opacity: 0.9;
  margin-left: 0.25rem;
}
.topbar,
.topbar nav,
.nav-dropdown {
  overflow: visible;
}
.nav-dropdown {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.nav-help-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: #e8eef5;
  border-radius: 8px;
  padding: 0.28rem 0.65rem;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}
.nav-help-btn:hover,
.nav-help-btn[aria-expanded="true"] {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.nav-help-btn.active {
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
}
.nav-help-menu a.active {
  background: var(--accent-soft);
  color: var(--accent) !important;
  font-weight: 700;
}
.nav-account-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 16rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 8px;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
  text-align: right;
}
.nav-account-btn:hover,
.nav-account-btn[aria-expanded="true"] {
  background: rgba(255,255,255,0.18);
}
.nav-account-org {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 15rem;
}
.nav-account-email {
  font-size: 0.68rem;
  opacity: 0.88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 15rem;
}
.nav-help-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 12rem;
  max-width: min(18rem, calc(100vw - 1rem));
  background: #fff;
  color: #1a2332;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(26, 35, 50, 0.18);
  display: none;
  flex-direction: column;
  padding: 0.4rem;
  z-index: 200;
}
.nav-help-menu.open,
.nav-dropdown.open > .nav-help-menu { display: flex; }
.nav-account-meta {
  padding: 0.4rem 0.55rem 0.55rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.25rem;
}
.nav-account-meta strong {
  display: block;
  font-size: 0.88rem;
}
.nav-account-meta span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
}
.nav-help-menu a,
.nav-help-menu button {
  display: block;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  color: #1a2332 !important;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.nav-help-menu a:hover,
.nav-help-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent) !important;
  text-decoration: none;
}

.wrap {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 0 rgba(26, 35, 50, 0.04);
}
h1 { font-size: 1.35rem; margin: 0 0 0.35rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.sub { color: var(--muted); margin: 0 0 1rem; font-size: 0.92rem; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.65rem 0 0.25rem; }
input, textarea, select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
input:focus, textarea:focus, select:focus,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

textarea { min-height: 110px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-block;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  font: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.btn:hover { background: var(--accent-hover); filter: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { filter: brightness(1.05); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.ok { background: #e5f6ee; color: var(--ok); }
.badge.warn { background: #fff3dd; color: var(--warn); }
.badge.subtle {
  margin-left: 0.35rem;
  background: #eef1f5;
  color: var(--muted, #5c6570);
  font-size: 0.78rem;
  font-weight: 500;
}

.flash { padding: 0.65rem 0.8rem; border-radius: 6px; margin-bottom: 0.85rem; }
.flash.ok { background: #e5f6ee; color: var(--ok); }
.flash.err { background: #fdeceb; color: var(--danger); }

.fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.65rem 0.85rem 0.85rem;
  margin: 0.85rem 0;
}
.fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.35rem 1rem 0.35rem 0;
  font-size: 0.92rem;
  color: var(--ink);
}
.check input { width: auto; margin: 0; }
.ai-panel {
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
}
.code-block {
  margin: 0;
  padding: 0.75rem;
  background: #f0f3f7;
  border-radius: 6px;
  overflow: auto;
  font-size: 0.82rem;
  white-space: pre-wrap;
}
.tile {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  background: #fff;
  color: inherit;
  text-decoration: none;
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile strong { display: block; margin-bottom: 0.35rem; color: var(--accent); }
.tile span { color: var(--muted); font-size: 0.9rem; }
.muted { color: var(--muted); font-size: 0.92rem; }

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.85rem;
}
.help-card h2 { margin-bottom: 0.55rem; }
.help-muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.85rem;
  line-height: 1.45;
}
.help-list {
  margin: 0 0 0.85rem;
  padding-left: 1.15rem;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.5;
}
.help-list li { margin-bottom: 0.35rem; }

.readonly-box {
  background: var(--accent-soft);
  border: 1px dashed #b7c7da;
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
}
.readonly-box strong { display: block; margin-bottom: 0.35rem; }

.footer {
  flex-shrink: 0;
  width: 100%;
  margin-top: auto;
  padding: 1rem 1.25rem 1.35rem;
  color: #3d4d5c;
  font-size: 0.82rem;
  text-align: center;
  border-top: 1px solid var(--line);
  background: rgba(244, 246, 248, 0.92);
}

/* --- Login page (match Outreach auth layout) --- */
body.mode-login {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.login-top {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  gap: 12px 20px;
  padding: 12px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--chrome);
  color: #fff;
}
.login-brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  line-height: 1.25;
  min-width: 0;
  max-width: min(92vw, 560px);
}
.login-brand-logo {
  font-family: var(--brand-logo-font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
}
.login-brand-logo:hover {
  color: #fff;
  text-decoration: none;
}
.topbar .brand-site {
  display: block;
  font-family: var(--brand-logo-font);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  margin-bottom: 0;
}
.topbar .brand-site:hover {
  color: #fff;
  text-decoration: none;
}
.topbar .brand-product {
  font-family: var(--brand-product-font);
  color: #fff;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
  opacity: 1;
}
.login-brand-product {
  font-family: var(--brand-product-font);
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  margin-top: 2px;
}
.login-brand-tagline {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 2px;
}
.login-top-right {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  margin-left: 0;
}
.lang-switch select {
  width: auto;
  min-width: 7rem;
  margin: 0;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.login-top .lang-switch select {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.login-top .lang-switch select option {
  color: #1a2332;
}
.topbar .lang-switch select {
  min-width: 6.4rem;
  padding: 5px 8px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.topbar .lang-switch select option {
  color: #1a2332;
}
.login-main {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.auth-shell {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  /* 右栏略宽，登录面板整体左移；左图仍够放 4:3 */
  grid-template-columns: minmax(0, 1fr) clamp(460px, 42vw, 580px);
  align-items: stretch;
  gap: 0;
}
.auth-visual {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  min-height: 0;
  height: 100%;
  padding: 12px 10px 12px 16px;
}
.auth-visual img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  object-position: center center;
}
.auth-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 40px;
  background: var(--card);
  border-left: 1px solid var(--line);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.auth-card {
  margin: 0;
  width: 100%;
  max-width: 440px;
  padding: 36px 36px 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 10px 32px rgba(26, 35, 50, 0.07);
}
.auth-card h1 {
  margin: 0 0 14px;
  font-size: 2rem;
  line-height: 1.15;
}
.auth-lead {
  margin: 0 0 22px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--muted);
}
.auth-card label {
  display: block;
  margin: 14px 0;
  font-size: 17px;
  color: var(--ink);
}
.auth-card label span {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.auth-card input {
  width: 100%;
  padding: 12px 14px;
  font-size: 17px;
}
.auth-card .btn-block {
  width: 100%;
  margin-top: 20px;
  padding: 13px 18px;
  font-size: 17px;
}
.auth-mini-footer {
  display: block;
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
  max-width: 440px;
}
.auth-footer-ver {
  letter-spacing: 0.06em;
  opacity: 0.75;
  font-weight: 600;
}

@media (max-width: 640px) {
  body.mode-login {
    height: auto;
    overflow: auto;
  }
  .login-main {
    overflow: visible;
  }
  .auth-shell {
    grid-template-columns: 1fr;
    height: auto;
  }
  .auth-visual {
    order: 1;
    height: 32vh;
    min-height: 180px;
    max-height: 240px;
    padding: 10px 16px;
  }
  .auth-panel {
    order: 2;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 20px 16px 28px;
    overflow: visible;
  }
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem;
}
.check-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; }
.check-row input { width: auto; }
.bare-fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.inline-user-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.inline-user-form input,
.inline-user-form select { width: auto; min-width: 8rem; }
.inline-user-form input[type="checkbox"] { width: auto; min-width: 0; }
.pdf-frame {
  width: 100%;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
