/* LPA portal — heatmap.com design language.
   Tokens per OnboardingLoop/System design system, heatmap (.hm-web) scope:
   Poppins display face, Inter product face, brand-tinted neutral ramp,
   primary #10b068, deep-green accent #009050, dark floor #004323,
   squircle corners (corner-shape, Chromium progressive enhancement).
   Semantic colors are utility only (success/warning/destructive). */

:root {
  /* brand */
  --primary: #10b068;
  --primary-foreground: #ffffff;
  --accent-strong: #009050;   /* deep green: money, positive emphasis */
  --acc-tint: #e7fdef;        /* mint wash chips */
  --acc-tint-stroke: #bbe3c8;
  --accent-tint: #e2f6ed;     /* 12% primary — focus rings, active fills */
  --hm-dark: #004323;         /* the ONE dark floor (wordmark, dark chrome) */

  /* neutral ramp (heatmap brand tint, computed hexes) */
  --neutral-0: #ffffff;  --neutral-12: #fcfbf8;  --neutral-25: #f8f7f4;
  --neutral-50: #f1f0ed;  --neutral-100: #eae9e6;  --neutral-200: #dedcd9;
  --neutral-300: #d1cfcc;  --neutral-400: #c1bfbc;  --neutral-500: #a5a3a0;
  --neutral-600: #92918e;  --neutral-700: #747370;  --neutral-750: #676663;
  --neutral-800: #41403e;  --neutral-900: #272624;  --neutral-950: #1a1917;

  /* roles */
  --surface: var(--neutral-0);
  --canvas: var(--neutral-25);
  --subtle: var(--neutral-50);
  --border: var(--neutral-100);
  --edge: var(--neutral-200);
  --icon: var(--neutral-500);
  --text-muted: var(--neutral-750);
  --text: var(--neutral-900);
  --background: var(--neutral-12);

  /* control face */
  --ctl-face: #ffffff;
  --ctl-face-2: var(--neutral-25);
  --ctl-face-hover: var(--neutral-50);
  --ctl-face-press: var(--neutral-100);
  --ctl-line: var(--neutral-200);
  --ctl-line-hover: var(--neutral-300);
  --ctl-ink: var(--neutral-900);
  --ctl-ink-quiet: var(--neutral-700);
  --ctl-outline: rgba(17, 24, 39, .16);
  --ctl-wash: rgba(17, 24, 39, .04);
  --ctl-wash-strong: rgba(17, 24, 39, .07);

  /* semantic states */
  --success: #4e9961;  --success-tint: #d8f8e2;
  --warning: #d97230;  --warning-tint: #ffe8d9;
  --destructive: #b45e55;  --destructive-tint: #ffe9e5;
  --info: #3e7bb7;  --info-tint: #e2f0ff;

  /* type */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Poppins', 'Inter', system-ui, -apple-system, sans-serif;
  --font-display-weight: 600;
  --font-display-track: -.03em;
  --text-xs: .75rem;  --text-sm: .8125rem;  --text-base: .875rem;
  --text-md: 1rem;  --text-lg: 1.125rem;  --text-xl: 1.375rem;

  /* radii + corners */
  --radius-sm: .75rem;
  --radius: .75rem;
  --radius-lg: 1.5rem;      /* controls: buttons, inputs, nav rows */
  --r: 14px;                /* cards, panels, tables */
  --r-sm: 10px;             /* small insets */
  --ctl-radius: 1.5rem;
  --corner-shape: superellipse(1.5);

  /* layout + elevation + motion */
  --content: 1072px;
  --bar-h: 73px;            /* 72px bar + 1px rule */
  --shadow-xs: 0 1px 2px 0 rgb(10 13 18 / .05);
  --shadow-card: 0 2px 8px rgba(25, 25, 25, .05), 0 12px 28px -16px rgba(25, 25, 25, .18);
  --shadow-lift: 0 18px 46px -22px rgba(25, 25, 25, .34), 0 2px 8px rgba(25, 25, 25, .06);
  --shadow-control: 0 2px 4px -1px rgb(10 13 18 / .08);
  --ease-standard: cubic-bezier(.2, .8, .2, 1);
  --ease-emphasized: cubic-bezier(.22, 1, .36, 1);

  /* legacy aliases (older inline styles) */
  --bg: var(--background);
  --panel: var(--surface);
  --panel2: var(--canvas);
  --chip: var(--subtle);
  --line: var(--border);
  --line-strong: var(--edge);
  --muted: var(--text-muted);
  --muted-strong: var(--neutral-800);
  --accent: var(--primary);
  --accent-bright: #28b877;   /* primary mixed 10% white */
  --accent-hi: #3fea7e;
  --good: var(--success);
  --warn: var(--warning);
  --warn-deep: #a25423;       /* warning mixed 26% black */
  --warn-tint: var(--warning-tint);
  --bad: var(--destructive);
  --bad-deep: #87463f;        /* destructive mixed 25% black */
  --shadow-sm: var(--shadow-xs);
  --shadow-md: var(--shadow-card);
  --shadow-lg: var(--shadow-lift);
}

* { box-sizing: border-box; }
html { scrollbar-width: thin; scrollbar-color: var(--neutral-300) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--neutral-400); border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-corner { background: transparent; }
::selection { background: var(--accent-tint); }

body { margin: 0; background: var(--background); color: var(--text);
  font: 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: #0d9055; }

/* ---------- chrome (bar-h 73px, hm-nav recipe) ---------- */
.top { display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 72px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; }
.brand img { display: block; }
.top nav { display: flex; gap: 2px; min-width: 0; }
.top nav a { color: var(--neutral-800); font-weight: 500; font-size: 14px; line-height: 20px;
  padding: 7px 14px; border-radius: var(--ctl-radius); corner-shape: var(--corner-shape); }
.top nav a.active, .top nav a:hover { color: var(--text); background: var(--canvas); }
.top nav a.nav-project { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subnav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 0 18px; min-height: 44px; background: var(--canvas);
  border-bottom: 1px solid var(--border); position: sticky; top: 72px; z-index: 4; }
.subnav[hidden] { display: none; }
.insight-site[hidden] { display: none; }
.subnav a { color: var(--neutral-800); font-weight: 500; font-size: 13px; line-height: 20px;
  padding: 5px 12px; border-radius: var(--ctl-radius); corner-shape: var(--corner-shape); }
.subnav a.active { color: var(--accent-strong); background: var(--accent-tint); }
.subnav a:hover { color: var(--text); background: var(--surface); }
.subnav .nav-gap { width: 1px; align-self: stretch; margin: 10px 8px; background: var(--border); }
.spacer { flex: 1; }
main { padding: 20px; max-width: calc(var(--content) + 48px); margin: 0 auto; }
.loading { color: var(--text-muted); padding: 40px; text-align: center; }

/* ---------- type ---------- */
h1 { font-family: var(--font-display); font-weight: var(--font-display-weight);
  letter-spacing: calc(-.02em + var(--font-display-track)); font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 13px; margin: 22px 0 10px; color: var(--text-muted); font-weight: 600; }

/* ---------- surfaces ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow-xs); corner-shape: var(--corner-shape); }
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card .sub { color: var(--text-muted); font-size: 12px; }
.card .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 14px; box-shadow: var(--shadow-xs); corner-shape: var(--corner-shape); }
.stat .n { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--text-muted); font-size: 12px; }

/* ---------- badges (DS status recipe) ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--subtle); color: var(--text-muted);
  corner-shape: var(--corner-shape); }
.badge.live, .badge.done, .badge.approved, .badge.auto-approved { background: var(--success-tint); color: #3b744a; }
.badge.running { background: var(--accent-tint); color: var(--accent-strong); }
.badge.draining, .badge.pending { background: var(--warning-tint); color: var(--warn-deep); }
.badge.off, .badge.queued { background: var(--subtle); color: var(--text-muted); }
.badge.failed, .badge.retrying, .badge.rejected { background: var(--destructive-tint); color: var(--bad-deep); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-xs); }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-muted); font-weight: 600; background: var(--canvas); font-size: 12px; }
tbody tr:hover { background: var(--neutral-12); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.url { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

/* ---------- buttons (DS variants) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, var(--ctl-face), var(--ctl-face-2)); color: var(--ctl-ink);
  border: 1px solid var(--ctl-line); border-radius: var(--ctl-radius); corner-shape: var(--corner-shape);
  padding: 0 16px; min-height: 34px; font-size: 13px; font-weight: 500; line-height: 1; cursor: pointer;
  font-family: inherit; user-select: none; white-space: nowrap;
  box-shadow: var(--shadow-control);
  transition: background .15s var(--ease-standard), border-color .15s, color .15s, transform .1s; }
.btn:hover { border-color: var(--ctl-line-hover); background: linear-gradient(180deg, var(--ctl-face), var(--ctl-face-hover)); }
.btn:active { transform: translateY(.5px); background: linear-gradient(180deg, var(--ctl-face-2), var(--ctl-face-press)); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(16, 176, 104, .32); }
.btn.primary { background: linear-gradient(180deg, #28b877, #0e9e5e); border-color: var(--primary); color: var(--primary-foreground); }
.btn.primary:hover { background: linear-gradient(180deg, #10b068, #0d9055); }
.btn.primary:active { background: linear-gradient(180deg, #0d9457, #0c7f4b); }
.btn.danger { background: color-mix(in srgb, var(--destructive) 12%, transparent); border-color: transparent; color: var(--destructive); }
.btn.danger:hover { background: color-mix(in srgb, var(--destructive) 18%, transparent); }
.btn.small { min-height: 28px; padding: 0 12px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }
.btnrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }

/* ---------- inputs (DS control face) ---------- */
input, select { background: var(--ctl-face); border: 1px solid var(--edge); color: var(--text);
  border-radius: var(--ctl-radius); corner-shape: var(--corner-shape); padding: 0 14px; min-height: 34px; font-size: 13px; font-family: inherit; }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-tint); }
input::placeholder { color: var(--neutral-500); }
input:disabled, select:disabled { opacity: .45; cursor: not-allowed; }
label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 12px; }

/* ---------- tabs / notices ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs .btn.active { border-color: var(--primary); color: var(--accent-strong); background: var(--accent-tint); box-shadow: none; }
.notice { padding: 10px 14px; border-radius: var(--r-sm); margin: 12px 0; font-size: 13px;
  background: var(--warning-tint); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); color: var(--warn-deep); }
.notice.error { background: var(--destructive-tint); border-color: color-mix(in srgb, var(--destructive) 40%, transparent); color: var(--bad-deep); }
.ok { color: var(--success); }
.notice.success { background: var(--success-tint); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: #3b744a; }

/* ---------- pasted domain list + unattended pipeline chain ---------- */
textarea.domains { width: 100%; box-sizing: border-box; min-height: 160px; padding: 10px 14px; resize: vertical;
  background: var(--ctl-face); border: 1px solid var(--edge); color: var(--text); border-radius: var(--ctl-radius);
  font: 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace; }
textarea.domains:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-tint); }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; color: var(--text); }
label.inline input[type="checkbox"] { min-height: 0; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 4px; }
.chain-step { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--subtle); color: var(--text-muted); }
.chain-step::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-500); }
.chain-step.on { background: var(--success-tint); color: #3b744a; border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.chain-step.on::before { background: var(--success); }
.chain-step .muted { font-weight: 500; }
.chain-arrow { color: var(--text-muted); font-size: 12px; }
.chain-gaps { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--warn-deep); }

/* ---------- expansion affordance: chevron on every disclosure control ---------- */
summary { list-style: none; cursor: pointer; user-select: none; }
summary::-webkit-details-marker { display: none; }
summary::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px;
  vertical-align: -1.5px; background: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .2s var(--ease-standard);
}
details[open] > summary::before { transform: rotate(180deg); }

/* ---------- login ---------- */
.login-wrap { min-height: calc(100vh - 140px); display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 1.5rem;
  corner-shape: var(--corner-shape); padding: 30px 32px; width: min(380px, 92vw); box-shadow: var(--shadow-lift); }
.login-card h1.login-brand { margin: 0 0 6px; font-family: inherit; font-weight: 700; letter-spacing: -.02em; }
.login-card h1.login-brand img { display: block; }
.login-card p { margin: 0 0 18px; font-size: 13px; color: var(--text-muted); }
.login-card input[type=text], .login-card input:not([type]) { width: 100%; }
.login-card input[type=password] { width: 100%; }
.login-card .field label { margin-bottom: 4px; }
.login-card .row-flex { display: flex; align-items: center; }
.login-card .check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); margin: 2px 0 6px; cursor: pointer; }
.login-card .check input { margin: 0; accent-color: var(--primary); }
.login-error { color: var(--bad-deep); font-size: 12.5px; min-height: 18px; margin-bottom: 8px; }

/* ---------- user chip ---------- */
.userchip { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.userchip .chip { background: var(--accent-tint); border-radius: 999px; padding: 3px 10px; font-weight: 600; color: var(--accent-strong); }
.userchip a { color: var(--text-muted); }
.userchip a:hover { color: var(--text); }

/* insights QA */
.insight-site { margin-bottom: 14px; }
.insight { margin: 8px 0; padding: 8px 12px; }
.insight > summary { display: flex; gap: 8px; align-items: center; }
.insight-head { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.insight-gist { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insight-body { margin-top: 10px; }
.insight-shot { display: block; max-width: 100%; max-height: 360px; border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 8px; }
.insight-ack { display: flex; gap: 6px; align-items: center; margin: 4px 0 8px; }

/* Analysis paused: no Kimi account can take a run (usage limit, signed out). */
.pausebar { background: var(--warn-tint); color: var(--warn-deep); border-bottom: 1px solid var(--warn); padding: 10px 24px; font-size: 13.5px; line-height: 1.5; }
.pausebar b { font-weight: 600; }
