:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #17202a;
  --muted: #6b7785;
  --line: #d9e1e8;
  --red: #d73a31;
  --green: #16845b;
  --blue: #2563eb;
  --amber: #b7791f;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  --left-column: 300px;
  --middle-column: 480px;
  --resize-handle: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns:
    var(--left-column)
    var(--resize-handle)
    minmax(300px, var(--middle-column))
    var(--resize-handle)
    minmax(360px, 1fr);
  min-height: 100vh;
}

body.resizing-columns {
  cursor: col-resize;
  user-select: none;
}

.sidebar {
  background: #fbfcfd;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  min-width: 0;
  container-type: inline-size;
}

.resize-handle {
  position: relative;
  z-index: 5;
  background:
    linear-gradient(90deg, transparent 0, transparent 3px, var(--line) 3px, var(--line) 5px, transparent 5px);
  cursor: col-resize;
  touch-action: none;
}

.resize-handle::after {
  content: "";
  position: absolute;
  inset: 0 -3px;
}

.resize-handle:hover,
.resize-handle.active {
  background:
    linear-gradient(90deg, transparent 0, transparent 3px, var(--blue) 3px, var(--blue) 5px, transparent 5px);
}

.brand h1,
.section-head h2,
.detail-header h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.2;
}

.brand-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.brand-nav-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.brand-link.active {
  border-color: #9bb7ff;
  background: #eef4ff;
  color: var(--blue);
}

.account-bar {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 8px;
}

.account-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #e9efff;
  color: var(--blue);
  font-weight: 800;
}

.account-bar > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.account-bar small {
  color: var(--muted);
  font-size: 10px;
}

.account-bar strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-bar button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--muted);
  padding: 5px 9px;
  cursor: pointer;
}

.account-bar button:hover {
  border-color: #9bb7ff;
  color: var(--blue);
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.account-actions button {
  padding-inline: 7px;
  font-size: 11px;
  font-weight: 800;
}

.account-actions .account-action-guide {
  border-color: #9bb7ff;
  background: #eef4ff;
  color: var(--blue);
}

.account-actions .account-action-guide::before {
  display: inline-grid;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "?";
  font-size: 10px;
  line-height: 1;
}

.account-actions .account-action-logout {
  border-color: #efc3c0;
  background: #fff4f3;
  color: #b42318;
}

.account-actions .account-action-guide:hover,
.account-actions .account-action-guide:focus-visible {
  border-color: var(--blue);
  background: #dfe9ff;
  color: #1749b5;
  outline: none;
}

.account-actions .account-action-logout:hover,
.account-actions .account-action-logout:focus-visible {
  border-color: #d73a31;
  background: #ffe9e7;
  color: #9f1c14;
  outline: none;
}

.brand p,
.section-head p,
.panel-head span {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-page {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 20%, rgba(37, 99, 235, 0.14), transparent 34%),
    radial-gradient(circle at 84% 74%, rgba(22, 132, 91, 0.1), transparent 30%),
    #f4f7fb;
}

.login-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 32px 24px 124px;
}

.login-card {
  width: min(100%, 500px);
  border: 1px solid rgba(217, 225, 232, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.12);
  padding: clamp(28px, 6vw, 46px);
  text-align: center;
  backdrop-filter: blur(14px);
}

.login-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
  color: white;
  font-size: 27px;
  font-weight: 850;
}

.login-eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(25px, 5vw, 34px);
}

.login-card > p:not(.login-eyebrow):not(.login-status) {
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.login-security-note {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  margin-top: 24px;
  border: 1px solid #d9e8df;
  border-radius: 10px;
  background: #f3faf6;
  padding: 12px;
  text-align: left;
}

.login-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-top: 24px;
  border-radius: 10px;
  background: #edf1f6;
  padding: 4px;
}

.login-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  cursor: pointer;
}

.login-tabs button[aria-selected="true"] {
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
  color: var(--blue);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  text-align: left;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
}

.login-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.login-form .primary-button {
  min-height: 46px;
  margin-top: 2px;
  font-weight: 800;
}

.login-form > small {
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.login-security-note > span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #dff3e7;
  color: var(--green);
  font-weight: 900;
}

.login-security-note div {
  display: grid;
  gap: 3px;
}

.login-security-note strong {
  font-size: 13px;
}

.login-security-note small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.login-status {
  min-height: 20px;
  margin: 18px 0 0;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.login-status.error {
  color: var(--red);
}

.quick-login-corner {
  position: fixed;
  z-index: 10;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(217, 225, 232, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 11px;
  backdrop-filter: blur(12px);
}

.quick-login-corner > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quick-login-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 7px;
}

.quick-login-buttons button {
  min-height: 44px;
  border: 1px solid #c9d6f5;
  border-radius: 8px;
  background: #f4f7ff;
  color: #244ca5;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

.quick-login-buttons button:hover,
.quick-login-buttons button:focus-visible,
.quick-login-buttons button.is-loading {
  border-color: var(--blue);
  background: #eaf0ff;
  outline: none;
}

.quick-login-buttons button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.panel-head .help-icon {
  margin: 0;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

#screen-form {
  grid-template-columns: 1fr;
}

.primary-workflow-card {
  display: grid;
  gap: 14px;
  border: 1px solid #b9caff;
  border-radius: 14px;
  background: linear-gradient(180deg, #f7f9ff 0, #ffffff 120px);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.1);
  padding: 14px;
}

.workflow-header {
  display: block;
  padding: 2px 2px 0;
}

.workflow-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.workflow-header h2 {
  margin: 0;
  font-size: 17px;
}

.workflow-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.workflow-run-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0.02em;
}

.workflow-run-button:hover:not(:disabled),
.workflow-run-button:focus-visible {
  background: #1d4ed8;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.3);
  outline: none;
  transform: translateY(-1px);
}

.screen-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  border: 1px solid #d6def3;
  border-radius: 12px;
  background: #eef2fb;
  padding: 5px;
}

.screen-mode-switch button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 56px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  padding: 7px 9px;
  text-align: left;
  cursor: pointer;
}

.screen-mode-switch button.active {
  border-color: #c3d2ff;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.11);
}

.screen-mode-switch button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.screen-mode-switch button > span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.screen-mode-switch strong,
.screen-mode-switch small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-mode-switch strong {
  font-size: 13px;
}

.screen-mode-switch small {
  color: var(--muted);
  font-size: 10px;
}

.mode-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, #315be8, #7868e6);
  color: white;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.mode-icon.hardcore {
  background: #172033;
  font-family: Georgia, serif;
  font-size: 18px;
}

.ai-strategy-studio {
  display: grid;
  gap: 13px;
  overflow: visible;
  border: 1px solid #cbd8ff;
  border-radius: 12px;
  background:
    radial-gradient(circle at 95% 0%, rgba(117, 99, 246, 0.13), transparent 34%),
    linear-gradient(180deg, #f8faff, #ffffff 220px);
  padding: 13px;
}

.ai-studio-intro {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.ai-studio-kicker,
.ai-result-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: #5b56d9;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.ai-studio-intro h3,
.ai-result-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.ai-studio-intro p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.ai-service-status {
  flex: 0 0 auto;
  border: 1px solid #d8e0ee;
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  cursor: help;
}

.ai-service-status-control {
  position: relative;
  flex: 0 0 auto;
}

.ai-field-popover {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(420px, calc(100cqw - 26px));
  max-height: min(600px, 68vh);
  gap: 4px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #c9d4e5;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.2);
  color: var(--text);
  opacity: 0;
  padding: 12px;
  pointer-events: none;
  text-align: left;
  transform: translateY(-4px);
  visibility: hidden;
  -webkit-overflow-scrolling: touch;
}

.ai-service-status-control:hover .ai-field-popover,
.ai-service-status:focus-visible + .ai-field-popover,
.ai-service-status-control.open .ai-field-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.ai-field-popover > strong,
.ai-field-popover > small {
  display: block;
}

.ai-field-popover > strong {
  font-size: 12px;
}

.ai-field-popover > small,
.ai-field-empty {
  color: var(--muted);
  font-size: 10px;
}

.ai-field-groups {
  display: grid;
  gap: 9px;
  margin-top: 5px;
}

.ai-field-group {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.ai-field-group > b {
  color: #4e5b70;
  font-size: 10px;
}

.ai-field-group > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ai-field-group span {
  border-radius: 999px;
  background: #f1f4fa;
  color: #34445f;
  padding: 4px 7px;
  font-size: 9px;
  font-weight: 700;
}

.ai-field-group span small {
  color: #7a8799;
  font-size: inherit;
}

.ai-service-status.ready {
  border-color: #a7e2ca;
  background: #edf9f4;
  color: #087557;
}

.ai-service-status.unavailable {
  border-color: #f0cfaa;
  background: #fff8ed;
  color: #9a5d11;
}

.ai-progress-rail {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  gap: 6px;
  align-items: center;
  color: #8992a6;
  font-size: 10px;
  font-weight: 750;
}

.ai-progress-rail span {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}

.ai-progress-rail b {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 50%;
  background: #e6eaf2;
  color: #687286;
  font-size: 9px;
}

.ai-progress-rail i {
  height: 1px;
  background: #dce2ed;
}

.ai-progress-rail span.active,
.ai-strategy-studio.is-building .ai-progress-rail span:nth-of-type(2),
.ai-strategy-studio.has-draft .ai-progress-rail span:nth-of-type(2),
.ai-strategy-studio.has-screened .ai-progress-rail span:nth-of-type(3) {
  color: #3f48b8;
}

.ai-progress-rail span.active b,
.ai-strategy-studio.is-building .ai-progress-rail span:nth-of-type(2) b,
.ai-strategy-studio.has-draft .ai-progress-rail span:nth-of-type(2) b,
.ai-strategy-studio.has-screened .ai-progress-rail span:nth-of-type(3) b {
  background: #5b5bd6;
  color: white;
}

.ai-profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ai-profile-grid label {
  gap: 5px;
  font-size: 11px;
}

.ai-profile-grid .select-control {
  min-width: 0;
  border-color: #d4dcf3;
  padding: 8px 7px;
  font-size: 12px;
}

.ai-intent-chips,
.ai-refine-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-choice-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.ai-choice-title small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.ai-intent-chips button,
.ai-refine-chips button {
  border: 1px solid #d4dcf3;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #3d4f73;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.ai-intent-chips button:hover,
.ai-intent-chips button:focus-visible,
.ai-intent-chips button.active,
.ai-intent-chips button[aria-pressed="true"],
.ai-refine-chips button:hover,
.ai-refine-chips button:focus-visible,
.ai-refine-chips button.active,
.ai-refine-chips button[aria-pressed="true"] {
  border-color: #8098ea;
  background: #eef2ff;
  color: #3544af;
  outline: none;
}

.ai-intent-chips button[aria-pressed="true"]::before,
.ai-refine-chips button[aria-pressed="true"]::before {
  margin-right: 4px;
  content: "✓";
}

.ai-prompt-field {
  display: grid;
  gap: 6px;
}

.ai-prompt-field > span,
.ai-refine-box > span {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.ai-prompt-field textarea {
  width: 100%;
  min-height: 98px;
  resize: vertical;
  border: 1px solid #aebeee;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

.ai-prompt-field textarea:focus {
  border-color: #617ce2;
  box-shadow: 0 0 0 3px rgba(80, 105, 214, 0.12);
  outline: none;
}

.ai-prompt-field small {
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.ai-generate-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(110deg, #315be8, #6755d7);
  color: white;
  box-shadow: 0 8px 19px rgba(63, 72, 184, 0.22);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.ai-generate-button:hover:not(:disabled),
.ai-generate-button:focus-visible {
  box-shadow: 0 10px 24px rgba(63, 72, 184, 0.3);
  outline: none;
  transform: translateY(-1px);
}

.ai-generate-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.ai-button-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: ai-spin 800ms linear infinite;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

.ai-strategy-message {
  border-radius: 7px;
  background: #f1f4fa;
  color: #536078;
  padding: 8px 9px;
  font-size: 11px;
  line-height: 1.45;
}

.ai-strategy-message.success {
  background: #eaf8f2;
  color: #11674f;
}

.ai-strategy-message.error {
  background: #fff0ef;
  color: #9b352e;
}

.ai-strategy-message.loading {
  background: #eef1ff;
  color: #484ab2;
}

.task-progress {
  display: grid;
  gap: 7px;
  border: 1px solid #cbd6f5;
  border-radius: 9px;
  background: #f6f8ff;
  padding: 10px;
  color: #34425b;
}

.task-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.task-progress-head strong {
  font-size: 11px;
  line-height: 1.4;
}

.task-progress-head small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.task-progress-track {
  height: 8px;
  overflow: hidden;
  border: 1px solid #d7def1;
  border-radius: 999px;
  background: #e7ebf4;
}

.task-progress-track i {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #315be8, #7259dd);
  transition: width 350ms ease;
}

.task-progress.running .task-progress-track i::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.55) 50%, transparent 80%);
  animation: task-progress-shimmer 1.4s linear infinite;
  content: "";
  transform: translateX(-100%);
}

.task-progress.indeterminate .task-progress-track i {
  width: 38%;
  animation: task-progress-indeterminate 1.45s ease-in-out infinite;
  transition: none;
}

.task-progress.success {
  border-color: #b9dfcf;
  background: #edf9f4;
  color: #11674f;
}

.task-progress.success .task-progress-track i {
  background: var(--green);
}

.task-progress.error {
  border-color: #f0c4c1;
  background: #fff2f1;
  color: #9b352e;
}

.task-progress.error .task-progress-track i {
  background: var(--red);
}

.task-progress.compact {
  padding: 8px;
}

.screen-progress {
  margin-top: -3px;
}

@keyframes task-progress-shimmer {
  to { transform: translateX(100%); }
}

@keyframes task-progress-indeterminate {
  from { transform: translateX(-120%); }
  to { transform: translateX(300%); }
}

.ai-strategy-result {
  display: grid;
  gap: 11px;
  border: 1px solid #bdcbf4;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.97);
  padding: 12px;
  box-shadow: 0 9px 25px rgba(42, 55, 112, 0.1);
}

.ai-result-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.ai-verified-badge {
  flex: 0 0 auto;
  border: 1px solid #9edcc3;
  border-radius: 999px;
  background: #eaf8f2;
  color: #087557;
  padding: 5px 8px;
  font-size: 9px;
  font-weight: 850;
}

.ai-result-summary {
  margin: 0;
  color: #4d5a70;
  font-size: 11px;
  line-height: 1.6;
}

.ai-result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.ai-result-stats span {
  display: grid;
  min-height: 52px;
  align-content: center;
  justify-items: center;
  gap: 2px;
  border: 1px solid #e0e5f0;
  border-radius: 7px;
  background: #f8f9fd;
  color: var(--muted);
  padding: 7px;
  font-size: 9px;
  text-align: center;
}

.ai-result-stats b {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-result-stats small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
}

.ai-score-mode-note {
  grid-column: 1 / -1;
  margin: 0;
  border-left: 3px solid #9bb7ff;
  border-radius: 4px;
  background: #f4f7ff;
  color: #53617a;
  padding: 7px 9px;
  font-size: 10px;
  line-height: 1.5;
}

.ai-condition-cards {
  display: grid;
  gap: 7px;
  max-height: none;
  overflow: visible;
}

.ai-condition-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  border: 1px solid #e0e5f0;
  border-radius: 8px;
  background: #fbfcff;
  padding: 9px;
}

.ai-condition-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: #e9edff;
  color: #4c55c2;
  font-size: 9px;
  font-weight: 900;
}

.ai-condition-card > div {
  display: grid;
  gap: 3px;
}

.ai-condition-group {
  color: #6f7b91;
  font-size: 9px;
  font-weight: 800;
}

.ai-condition-card strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

.ai-condition-card small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.ai-insight-details {
  overflow: hidden;
  border: 1px solid #e0e5f0;
  border-radius: 8px;
  background: #fbfcfe;
}

.ai-insight-details > summary {
  cursor: pointer;
  padding: 9px 10px;
  color: #4d5a70;
  font-size: 11px;
  font-weight: 800;
}

.ai-insight-details > div {
  padding: 0 10px 9px;
}

.ai-insight-group strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 10px;
}

.ai-insight-group ul {
  margin: 0;
  padding-left: 17px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.ai-insight-group.unsupported {
  margin-top: 7px;
  border-top: 1px dashed #d9dfeb;
  padding-top: 7px;
}

.ai-risk-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
  border-radius: 7px;
  background: #fff7e8;
  color: #7d571a;
  padding: 8px 9px;
  font-size: 10px;
  line-height: 1.45;
}

.ai-refine-box {
  display: grid;
  gap: 8px;
  border-top: 1px solid #e3e7f0;
  padding-top: 11px;
}

.ai-refine-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.ai-refine-entry input {
  min-width: 0;
  border: 1px solid #cad4eb;
  border-radius: 7px;
  padding: 8px 9px;
}

#ai-refine-prompt::placeholder {
  font-size: 11px;
}

.ai-refine-entry .mini-button {
  min-width: 78px;
}

.ai-result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.ai-result-actions > button {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  font-size: 11px;
  font-weight: 800;
}

.ai-inspect-button {
  border: 1px solid #d3d9e6;
  border-radius: 7px;
  background: #f7f8fb;
  color: #455168;
  padding: 9px;
  cursor: pointer;
}

.hardcore-mode-panel {
  display: grid;
  gap: 9px;
}

.hardcore-mode-note {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 1px solid #d9dee8;
  border-radius: 9px;
  background: #f7f8fa;
  padding: 9px;
}

.hardcore-mode-note > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #172033;
  color: white;
  font-family: Georgia, serif;
  font-size: 18px;
}

.hardcore-mode-note div {
  display: grid;
  gap: 2px;
}

.hardcore-mode-note strong {
  color: var(--text);
  font-size: 12px;
}

.hardcore-mode-note small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.condition-editor-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.condition-editor-actions .ghost-button {
  width: 100%;
}

.condition-editor-actions .save-return-ai-mode {
  border-color: #b9c9f3;
  background: #eef3ff;
  color: #3154bd;
}

.condition-editor-actions .restore-ai-conditions {
  border-color: #e5d6b1;
  background: #fffaf0;
  color: #8b6516;
}

.advanced-settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  overflow: hidden;
}

.advanced-settings > summary,
.secondary-panel-summary {
  cursor: pointer;
  list-style: none;
}

.advanced-settings:not([open]) > :not(summary),
.secondary-panel:not([open]) > :not(summary),
.strategy-condition-editor:not([open]) > :not(summary) {
  display: none !important;
}

.advanced-settings > summary::-webkit-details-marker,
.secondary-panel-summary::-webkit-details-marker {
  display: none;
}

.advanced-settings > summary {
  position: relative;
  padding: 12px 34px 12px 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.advanced-settings > summary::after,
.secondary-panel-summary::after {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  color: var(--muted);
  transform: translateY(-65%) rotate(45deg);
  transition: transform 160ms ease;
}

.advanced-settings[open] > summary::after,
.secondary-panel[open] > .secondary-panel-summary::after {
  transform: translateY(-25%) rotate(225deg);
}

.advanced-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  border-top: 1px solid var(--line);
  padding: 13px;
}

.filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.filters input[type="number"],
.filters input[type="text"],
.select-control {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 9px 10px;
  color: var(--text);
}

.filters .range-control {
  width: 100%;
  accent-color: var(--blue);
}

.checkbox-row {
  grid-column: 1 / -1;
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.strategy-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px;
}

.primary-workflow-card .strategy-panel {
  border-color: #d5dfff;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.strategy-choice-block {
  display: grid;
  gap: 8px;
  border: 1px solid #cedaff;
  border-radius: 9px;
  background: #f5f8ff;
  padding: 10px;
}

.strategy-panel.readonly {
  background: #f8fafc;
}

.strategy-head,
.strategy-actions {
  display: grid;
  gap: 8px;
}

.strategy-head label:first-child {
  border: 1px solid #bfd0ff;
  border-radius: 7px;
  background: #eef4ff;
  padding: 9px;
}

.strategy-choice-block .strategy-head label:first-child {
  border: 0;
  background: transparent;
  padding: 0;
}

.strategy-head label:first-child .select-control {
  border-color: #9bb7ff;
  font-weight: 700;
}

.strategy-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.strategy-actions .mini-button {
  width: 100%;
  min-width: 0;
  padding-left: 4px;
  padding-right: 4px;
}

.pattern-metric-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.5fr) minmax(76px, 0.8fr) minmax(84px, 0.8fr) minmax(64px, 0.6fr);
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 8px;
}

.pattern-metric-row.compact {
  grid-template-columns: minmax(150px, 1.6fr) minmax(76px, 0.8fr) minmax(64px, 0.6fr);
}

.pattern-metric-row .checkbox-row {
  grid-column: auto;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  margin: 0;
}

.pattern-metric-row .checkbox-row span {
  color: var(--text);
  font-weight: 700;
  line-height: 1.35;
}

.pattern-metric-row input,
.pattern-metric-row .select-control {
  padding: 7px 8px;
}

.pattern-metric-row label.is-disabled span,
.pattern-metric-row input:disabled {
  color: var(--muted);
}

.pattern-metric-row input:disabled {
  cursor: not-allowed;
  border-color: #e2e8f0;
  background: #f1f5f9;
  opacity: 0.72;
}

.strategy-description {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.strategy-condition-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.strategy-condition-editor > summary {
  position: relative;
  cursor: pointer;
  list-style: none;
  padding: 11px 34px 11px 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.strategy-condition-editor > summary::-webkit-details-marker {
  display: none;
}

.strategy-condition-editor > summary::after {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  color: var(--muted);
  transform: translateY(-65%) rotate(45deg);
  transition: transform 160ms ease;
}

.strategy-condition-editor[open] > summary::after {
  transform: translateY(-25%) rotate(225deg);
}

.strategy-condition-editor[open] > summary {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.strategy-condition-editor > :not(summary) {
  margin-right: 11px;
  margin-left: 11px;
}

.strategy-condition-editor .condition-list {
  margin-top: 4px;
}

.strategy-editor-head {
  margin-top: 11px;
  margin-bottom: 9px;
}

.strategy-condition-editor > .ghost-button {
  width: calc(100% - 22px);
  margin-top: 10px;
  margin-bottom: 11px;
}

.condition-list {
  display: grid;
  gap: 10px;
  max-height: none;
  overflow: visible;
  padding-right: 2px;
}

.condition-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 9px;
}

.condition-row.readonly {
  background: #f3f6f9;
}

.condition-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.condition-title::after {
  content: "";
  flex: 1;
  height: 1px;
  margin-left: 10px;
  background: var(--line);
}

.condition-row label {
  min-width: 0;
}

.condition-row select,
.condition-row input[type="number"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 8px;
  font-size: 12px;
}

.condition-row .range-value {
  display: none;
}

.condition-row.range-mode .single-value,
.condition-row.exists-mode .single-value,
.condition-row.exists-mode .range-value {
  display: none;
}

.condition-row.range-mode .range-value {
  display: grid;
}

.condition-toggle {
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.condition-toggle input {
  margin: 0;
}

.condition-help {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.condition-remove {
  grid-column: 1 / -1;
}

.primary-button,
.ghost-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
}

.primary-button {
  grid-column: 1 / -1;
  background: var(--blue);
  color: white;
}

.ghost-button {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.secondary-button {
  background: #eef4ff;
  color: var(--blue);
  border-color: #bfd0ff;
}

.mini-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 6px 9px;
  font-size: 12px;
  cursor: pointer;
}

.primary-button:disabled,
.ghost-button:disabled,
.secondary-button:disabled,
.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.warnings {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.data-panel,
.backtest-record-panel {
  container-type: inline-size;
  display: grid;
  gap: 10px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.04);
  padding: 13px;
}

.secondary-panel {
  padding: 0;
}

.secondary-panel-summary {
  position: relative;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 10px 38px 10px 13px;
}

.secondary-panel[open] > .secondary-panel-summary {
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.secondary-panel-summary > span:first-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.secondary-panel-summary strong {
  font-size: 14px;
}

.secondary-panel-summary small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
}

.secondary-panel > :not(summary) {
  margin-right: 13px;
  margin-left: 13px;
}

.secondary-panel > :last-child {
  margin-bottom: 13px;
}

.section-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tour-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgba(8, 15, 29, 0.64);
  backdrop-filter: blur(1px);
}

.tour-dialog {
  position: fixed;
  z-index: 82;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  width: min(390px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  padding: 20px;
  transform: translateX(-50%);
}

.tour-counter {
  display: block;
  margin-top: 12px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.tour-dialog h2 {
  margin: 7px 0 0;
  font-size: 20px;
}

.tour-body {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.tour-progress {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf2;
}

.tour-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 180ms ease;
}

.tour-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 7px;
  margin-top: 18px;
}

.tour-actions button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 11px;
  font-weight: 750;
  cursor: pointer;
}

.tour-actions .tour-next {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.tour-actions .tour-skip {
  color: var(--muted);
}

.tour-actions button:disabled {
  opacity: 0.4;
}

.tour-active .tour-target {
  position: relative;
  z-index: 81;
  border-radius: 10px;
  box-shadow: 0 0 0 5px #7aa2ff, 0 18px 50px rgba(0, 0, 0, 0.24);
}

.data-panel h2,
.backtest-record-panel h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.data-panel p,
.backtest-record-panel p,
.sync-progress {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.warehouse-panel-head,
.sync-run-head,
.warehouse-dataset-head,
.warehouse-group-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.warehouse-eyebrow,
.sync-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.warehouse-state {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
}

.warehouse-state-control {
  position: relative;
  flex: 0 0 auto;
}

.warehouse-state-control.has-details .warehouse-state {
  cursor: help;
}

.warehouse-state::before {
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.warehouse-state.ready {
  border-color: #b9dfcf;
  background: #edf9f4;
  color: var(--green);
}

.warehouse-state.running {
  border-color: #bfd0ff;
  background: #eef4ff;
  color: var(--blue);
}

.warehouse-state.running::before {
  animation: warehouse-pulse 1.6s ease-in-out infinite;
}

.warehouse-state.error {
  border-color: #f0c4c1;
  background: #fff2f1;
  color: var(--red);
}

.warehouse-state.warning {
  border-color: #f1d18a;
  background: #fff8e7;
  color: #9a6500;
}

.warehouse-issue-popover {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(340px, calc(100vw - 48px));
  max-width: 240px;
  max-width: calc(100cqw - 36px);
  max-height: min(480px, 65vh);
  gap: 8px;
  overflow: auto;
  border: 1px solid #c9d2df;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
  color: var(--text);
  opacity: 0;
  padding: 12px;
  pointer-events: none;
  text-align: left;
  transform: translateY(-4px);
  visibility: hidden;
}

.warehouse-state-control.has-details:hover .warehouse-issue-popover,
.warehouse-state-control.has-details:focus-within .warehouse-issue-popover,
.warehouse-state-control.has-details.open .warehouse-issue-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.warehouse-issue-title,
.warehouse-issue-counts,
.warehouse-issue-reason,
.warehouse-issue-retry,
.warehouse-issue-group,
.warehouse-issue-item,
.warehouse-issue-more {
  display: block;
}

.warehouse-issue-title {
  font-size: 13px;
}

.warehouse-issue-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.warehouse-issue-counts b {
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 10px;
}

.warehouse-issue-counts .failure {
  background: #fff0ef;
  color: var(--red);
}

.warehouse-issue-counts .warning {
  background: #fff5d8;
  color: #8b5b00;
}

.warehouse-issue-reason,
.warehouse-issue-retry,
.warehouse-issue-more {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.warehouse-issue-group {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.warehouse-issue-group > b {
  color: var(--text);
  font-size: 11px;
}

.warehouse-issue-item {
  display: grid;
  gap: 2px;
  border-radius: 7px;
  background: #f7f9fc;
  padding: 7px;
}

.warehouse-issue-item strong {
  font-size: 11px;
}

.warehouse-issue-item span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

@container (max-width: 320px) {
  .data-panel > .secondary-panel-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    justify-content: normal;
  }

  .data-panel > .secondary-panel-summary > .warehouse-state-control {
    justify-self: stretch;
  }
}

@keyframes warehouse-pulse {
  50% {
    opacity: 0.35;
  }
}

.warehouse-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.warehouse-stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 8px;
}

.warehouse-stat span,
.warehouse-stat strong {
  display: block;
  min-width: 0;
}

.warehouse-stat span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.warehouse-stat strong {
  margin-top: 3px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-overview {
  display: grid;
  gap: 8px;
  border: 1px solid #cbd9fb;
  border-radius: 8px;
  background: linear-gradient(145deg, #f7faff, #ffffff 65%);
  padding: 10px;
}

.sync-run-head strong,
.sync-run-head small {
  display: block;
}

.sync-run-head strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.sync-run-head small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.sync-run-head > b {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 18px;
  line-height: 1;
}

.sync-run-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.4;
}

.warehouse-catalog {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.warehouse-catalog > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  list-style: none;
}

.warehouse-catalog > summary::-webkit-details-marker {
  display: none;
}

.warehouse-catalog > summary::after {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  color: var(--muted);
  content: "";
  transform: rotate(45deg) translate(-2px, 2px);
  transition: transform 160ms ease;
}

.warehouse-catalog[open] > summary::after {
  transform: rotate(225deg) translate(-2px, 2px);
}

.warehouse-catalog > summary small {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.warehouse-datasets {
  display: grid;
  gap: 12px;
  max-height: none;
  overflow: visible;
  padding: 0 8px 8px;
}

.warehouse-group {
  display: grid;
  gap: 6px;
}

.warehouse-group-title {
  align-items: baseline;
  padding: 4px 2px 0;
}

.warehouse-group-title strong {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.warehouse-group-title span {
  color: #9aa5b1;
  font-size: 9px;
}

.warehouse-dataset-grid {
  display: grid;
  gap: 6px;
}

.warehouse-dataset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 8px;
}

.warehouse-dataset-head {
  align-items: baseline;
}

.warehouse-dataset-head strong {
  min-width: 0;
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
}

.warehouse-dataset-head span {
  flex: 0 0 auto;
  color: var(--green);
  font-size: 9px;
  font-weight: 750;
  white-space: nowrap;
}

.data-panel .warehouse-dataset p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.warehouse-dataset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.warehouse-dataset-meta span {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 650;
}

.warehouse-empty {
  color: var(--muted);
  padding: 14px 6px;
  font-size: 11px;
  text-align: center;
}

.data-panel > .ghost-button {
  min-width: 0;
  width: calc(100% - 26px);
}

.backtest-record-list {
  display: grid;
  gap: 8px;
  max-height: none;
  overflow: visible;
}

.backtest-record-strategy {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backtest-record {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--text);
  padding: 8px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.backtest-record:hover {
  border-color: #9bb7ff;
  background: #eef4ff;
}

.backtest-record-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.backtest-record-head strong {
  font-size: 15px;
}

.backtest-record small {
  color: var(--muted);
}

.sync-progress {
  max-height: none;
  overflow: visible;
}

.sync-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.sync-meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 0.25s ease;
}

.sync-latest {
  margin-bottom: 6px;
  color: var(--muted);
}

@container (min-width: 520px) {
  .warehouse-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .warehouse-dataset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.sync-phases {
  display: grid;
  gap: 9px;
}

.sync-phase {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fbfcfd;
}

.sync-phase-head,
.sync-phase-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sync-phase-head span {
  color: var(--text);
  font-weight: 650;
}

.sync-phase-head b,
.sync-phase-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.sync-phase-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.sync-phase-bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.25s ease;
}

.sync-phase.running .sync-phase-bar i {
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.sync-phase.error .sync-phase-head b,
.sync-phase.error .sync-phase-meta {
  color: var(--red);
}

.sync-phase.error .sync-phase-bar i {
  background: var(--red);
}

.sync-phase-error {
  display: grid;
  gap: 4px;
  color: var(--red);
  font-size: 11px;
  line-height: 1.45;
}

.sync-phase-aborted {
  color: var(--amber);
  font-size: 11px;
  line-height: 1.45;
}

.sync-phase-error strong {
  font-weight: 700;
}

.sync-phase-error ul {
  display: grid;
  gap: 2px;
  margin: 0;
  padding-left: 16px;
}

.warning {
  border: 1px solid #f1d8a8;
  background: #fff8eb;
  color: #7c4a03;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.workspace {
  display: contents;
  min-width: 0;
}

.candidate-section,
.detail-section {
  padding: 20px 24px;
  min-width: 0;
  height: 100vh;
  overflow: auto;
  container-type: inline-size;
}

.candidate-section {
  background: #f8fafc;
  display: flex;
  flex-direction: column;
}

.candidate-section > .section-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-head,
.detail-header,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.candidate-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  overflow: hidden;
  border: 1px solid #9bb7ff;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

.view-toggle span {
  color: var(--blue);
  background: #eef4ff;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.view-toggle button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.view-toggle button:last-child {
  border-right: 0;
}

.view-toggle button.active {
  background: var(--blue);
  color: #fff;
}

.manual-add {
  display: flex;
  align-items: center;
  gap: 6px;
}

.manual-add input {
  width: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 8px;
  font-size: 12px;
}

.panel-actions .select-control {
  width: auto;
  min-width: 118px;
  padding: 6px 8px;
  font-size: 12px;
}

.select-control.hidden {
  display: none;
}

.table-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.04);
  flex: 1;
}

.candidate-empty-state {
  display: grid;
  width: min(100%, 520px);
  min-height: 280px;
  margin: clamp(28px, 12vh, 120px) auto 0;
  place-items: center;
  align-content: center;
  gap: 14px;
  border: 1px dashed #b9caff;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
  padding: 28px;
  text-align: center;
}

.candidate-empty-state > div {
  display: grid;
  gap: 6px;
}

.candidate-empty-state h3,
.candidate-empty-state p {
  margin: 0;
}

.candidate-empty-state h3 {
  font-size: 18px;
}

.candidate-empty-state p {
  max-width: 360px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.candidate-empty-state .secondary-button {
  min-width: 150px;
  font-weight: 800;
}

.candidate-empty-icon {
  position: relative;
  display: block;
  width: 48px;
  height: 48px;
  border: 2px solid #9bb7ff;
  border-radius: 14px;
  background: #eef4ff;
}

.candidate-empty-icon::before,
.candidate-empty-icon::after {
  position: absolute;
  left: 12px;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: var(--blue);
  content: "";
}

.candidate-empty-icon::before {
  top: 16px;
  box-shadow: 0 7px 0 #7aa2ff;
}

.candidate-empty-icon::after {
  top: 30px;
  width: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: min(820px, max(560px, 100%));
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: #f8fafc;
  font-weight: 600;
  box-shadow: 0 1px 0 var(--line);
}

th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef6ff;
}

.stock-cell {
  display: grid;
  gap: 3px;
}

.stock-cell span {
  color: var(--muted);
  font-size: 12px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.tag {
  background: var(--surface-2);
  color: #314155;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
}

.pattern-app-shell {
  --left-column: 320px;
  --middle-column: 520px;
}

.pattern-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.pattern-action-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.pattern-cache-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pattern-cache-badge.hit {
  border-color: #bfd0ff;
  background: #eef4ff;
  color: var(--blue);
}

.pattern-history-list-panel {
  margin-top: 14px;
}

.pattern-history-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.pattern-history-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 10px;
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.pattern-history-item strong {
  color: var(--text);
  font-size: 12px;
}

.pattern-history-item small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.pattern-history-item.active {
  border-color: #9bb7ff;
  background: #eef4ff;
}

.score-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-family: Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  cursor: help;
  flex: 0 0 16px;
}

.empty-cell,
.detail-empty {
  color: var(--muted);
  text-align: center;
  padding: 36px 12px;
}

.detail-content.hidden,
.detail-empty.hidden {
  display: none;
}

.detail-header {
  margin-bottom: 16px;
}

.timing-help {
  margin-left: 4px;
  vertical-align: middle;
}

.stock-code {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 3px;
}

.backtest-content {
  display: grid;
  gap: 14px;
}

.backtest-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px;
}

.backtest-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.backtest-form input,
.backtest-form select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
}

.backtest-form-note {
  grid-column: 1 / -1;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.5;
}

.backtest-form .primary-button {
  grid-column: 1 / -1;
}

.custom-weight-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.custom-weight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 8px;
}

.custom-weight-row span,
.custom-weight-row small {
  min-width: 0;
}

.custom-weight-row strong,
.custom-weight-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-weight-row small {
  color: var(--muted);
  font-size: 11px;
}

.custom-weight-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
}

.warning-text {
  color: var(--amber) !important;
}

.backtest-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.backtest-summary-card {
  display: grid;
  gap: 6px;
}

.backtest-summary-card span {
  color: var(--muted);
  font-size: 12px;
}

.backtest-summary-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
}

.backtest-table-panel {
  min-width: 0;
}

.backtest-warnings {
  display: grid;
  gap: 5px;
  margin: 8px 0 10px;
  color: var(--amber);
  font-size: 12px;
}

.backtest-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.backtest-table {
  min-width: 980px;
}

.backtest-table tbody tr {
  cursor: default;
}

.backtest-skipped-row td {
  color: var(--muted);
  background: #fbfcfd;
  text-align: left;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
}

.summary-grid > .panel {
  display: flex;
  flex-direction: column;
  height: 300px;
  min-height: 0;
  overflow: hidden;
}

.metric {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metric .metric-label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric strong {
  font-size: 20px;
}

.score-metric {
  box-shadow: none;
}

.score-metric > strong {
  display: block;
  font-size: 20px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.metric-foot {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.compact-panel {
  padding: 12px;
  box-shadow: none;
}

.compact-panel .panel-head {
  margin-bottom: 10px;
}

.metric-card {
  gap: 10px;
  justify-content: space-between;
}

.metric-card strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.1;
}

.pattern-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
}

.pattern-summary-grid > .panel {
  height: auto;
  min-height: 118px;
}

.basic-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(118px, 100%), 1fr));
  gap: 8px;
}

.basic-metrics div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px;
}

.basic-metrics span,
.overview-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.basic-metrics strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  white-space: nowrap;
}

.company-overview {
  display: grid;
  flex: 1;
  gap: 7px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.overview-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  font-size: 12px;
}

.overview-row.wide {
  grid-template-columns: 1fr;
  gap: 4px;
}

.overview-row span {
  margin: 0;
}

.overview-row strong {
  min-width: 0;
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.business-mix {
  display: grid;
  align-content: start;
  flex: 1;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.pattern-detail-section {
  display: grid;
  gap: 14px;
}

.pattern-symbol-panel {
  min-width: 0;
}

.pattern-symbol-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.pattern-symbol-chart,
.pattern-symbol-side {
  min-width: 0;
}

.pattern-symbol-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
  gap: 12px;
  align-content: start;
}

.pattern-chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.pattern-chart-toolbar > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pattern-chart-toolbar strong {
  color: var(--text);
  font-size: 13px;
}

.pattern-chart-toolbar span {
  color: var(--muted);
  font-size: 11px;
}

.chart-reset-button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
}

.chart-reset-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.pattern-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.pattern-status-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 10px;
  display: grid;
  gap: 5px;
}

.pattern-status-card span {
  color: var(--muted);
  font-size: 11px;
}

.pattern-status-card strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.pattern-signal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.pattern-signal-head strong,
.pattern-signal-head span {
  font-size: 12px;
}

.pattern-signal-head span {
  color: var(--muted);
}

.pattern-signal-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.pattern-signal-row {
  cursor: pointer;
}

.pattern-signal-row:hover td,
.pattern-signal-row:focus td {
  background: #f3f7ff;
}

.pattern-signal-row:focus {
  outline: none;
}

.pattern-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend-line,
.legend-dot {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.legend-line {
  width: 18px;
  height: 0;
  border-top: 2px solid currentColor;
}

.legend-line.close {
  color: #111827;
}

.legend-line.ma20 {
  color: var(--blue);
}

.legend-line.boll-upper {
  color: #c2410c;
}

.legend-line.boll-lower {
  color: var(--green);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
}

.legend-dot.cond1 {
  color: var(--blue);
}

.legend-dot.cond2 {
  color: #f59e0b;
  border-radius: 2px;
}

.legend-dot.current {
  color: transparent;
  border: 2px solid #7c3aed;
}

.pattern-svg-chart {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.axis-line {
  stroke: #cbd5e1;
  stroke-width: 1;
}

.chart-grid-line {
  stroke: #e5e7eb;
  stroke-width: 1;
}

.axis-label {
  fill: #6b7280;
  font-size: 11px;
}

.pattern-path {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.pattern-path.close {
  stroke: #111827;
}

.pattern-path.ma20 {
  stroke: var(--blue);
}

.pattern-path.boll-upper {
  stroke: #c2410c;
  stroke-dasharray: 5 4;
}

.pattern-path.boll-lower {
  stroke: var(--green);
  stroke-dasharray: 5 4;
}

.pattern-boll-area {
  fill: rgba(37, 99, 235, 0.06);
  stroke: none;
}

.pattern-marker.cond1 {
  fill: var(--blue);
}

.pattern-marker.cond2 {
  fill: #f59e0b;
}

.pattern-marker.current {
  fill: none;
  stroke: #7c3aed;
  stroke-width: 2;
}

.pattern-marker.selected {
  fill: rgba(255, 255, 255, 0.5);
  stroke: #dc2626;
  stroke-width: 2.5;
}

.signal-guide {
  stroke: #dc2626;
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.signal-guide-label {
  fill: #b91c1c;
  font-size: 12px;
  font-weight: 700;
}

.pattern-point-hover {
  fill: transparent;
  pointer-events: all;
}

.pattern-point-hover:hover {
  fill: rgba(220, 38, 38, 0.18);
  stroke: #dc2626;
  stroke-width: 1;
}

.active-row td {
  background: #eef4ff;
}

.pattern-grid .panel {
  min-width: 0;
  overflow: hidden;
}

.pattern-breakdown,
.pattern-assumptions {
  display: grid;
  gap: 10px;
}

.breakdown-row {
  display: grid;
  gap: 6px;
}

.breakdown-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.breakdown-row-head span {
  color: var(--text);
  font-weight: 650;
}

.breakdown-row-head strong,
.breakdown-row-head small {
  color: var(--muted);
  font-size: 12px;
}

.breakdown-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.breakdown-bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.pattern-assumption {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 9px 10px;
}

.pattern-assumption span {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.pattern-assumption small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.business-row {
  display: grid;
  gap: 4px;
}

.business-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.business-row-head span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.business-row-head b {
  color: var(--text);
}

.business-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.business-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.empty-compact {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.chart-grid > .panel {
  min-width: 0;
}

@container (max-width: 520px) {
  .section-head,
  .detail-header,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .candidate-actions,
  .manual-add,
  .panel-actions {
    justify-content: stretch;
  }

  .manual-add input,
  .manual-add button,
  .candidate-actions > button,
  .pattern-action-row > button {
    width: 100%;
  }

  .condition-row,
  .strategy-actions,
  .pattern-metric-row,
  .pattern-metric-row.compact {
    grid-template-columns: 1fr;
  }

  .screen-mode-switch button {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .screen-mode-switch .mode-icon {
    display: none;
  }

  .ai-studio-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-service-status {
    align-self: flex-start;
  }

  .ai-profile-grid,
  .ai-result-actions {
    grid-template-columns: 1fr;
  }

  .ai-refine-entry {
    grid-template-columns: 1fr;
  }

  .overview-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .backtest-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-weight-row {
    grid-template-columns: 1fr;
  }

  .pattern-status-grid {
    grid-template-columns: 1fr;
  }

  .pattern-symbol-side {
    grid-template-columns: 1fr;
  }

  .pattern-chart-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.chart {
  height: 245px;
  margin-top: 12px;
  min-width: 0;
}

.holder-evolution-chart {
  height: 520px;
  margin-bottom: 10px;
}

.financial-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 7px;
  margin-top: 12px;
}

.financial-chip,
.financial-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 7px 8px;
  min-width: 0;
}

.financial-chip span,
.financial-card-head span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.financial-chip strong,
.financial-card-head strong {
  display: block;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.financial-card {
  display: grid;
  gap: 5px;
}

.financial-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.financial-card p,
.financial-card small,
.financial-card em {
  margin: 0;
  line-height: 1.45;
  font-size: 11px;
}

.financial-card p {
  color: var(--muted);
}

.financial-card small {
  color: var(--text);
}

.financial-card em {
  color: var(--muted);
  font-style: normal;
}

.metric-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 9px 10px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.hover-band {
  fill: transparent;
  pointer-events: all;
  cursor: crosshair;
}

.hover-band:hover {
  fill: rgba(37, 99, 235, 0.08);
}

.volume-bar {
  fill: #94a3b8;
  opacity: 0.42;
}

.sankey-link {
  fill: none;
  stroke-linecap: round;
  transition: opacity 0.15s ease;
}

.sankey-link:hover {
  opacity: 0.72;
}

.sankey-node {
  stroke: rgba(15, 23, 42, 0.12);
  stroke-width: 1;
}

.sankey-link.personal {
  filter: drop-shadow(0 1px 2px rgba(220, 38, 38, 0.18));
}

.sankey-node.personal,
.sankey-personal-dot {
  stroke: #7f1d1d;
  stroke-width: 2;
}

.sankey-lane-label {
  font-size: 10px;
}

.sankey-personal-label {
  fill: #dc2626;
  font-weight: 700;
}

.score-breakdown {
  display: grid;
  align-content: start;
  flex: 1;
  gap: 7px;
  margin-top: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.score-part {
  display: grid;
  gap: 4px;
}

.score-part-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.score-part-head b {
  color: var(--text);
  font-weight: 700;
}

.score-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.score-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.checks {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.timing-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
  gap: 7px;
}

.timing-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 7px 8px;
}

.timing-metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 3px;
}

.timing-metric strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.check {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  font-size: 13px;
}

.check-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.check-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text);
  font-weight: 700;
}

.check:last-child {
  border-bottom: 0;
}

.check b {
  color: var(--green);
  white-space: nowrap;
}

.check.fail b {
  color: var(--red);
}

.check-body strong,
.check-body small,
.check-body em {
  min-width: 0;
  line-height: 1.45;
  font-size: 12px;
}

.check-body strong {
  font-weight: 600;
  color: var(--text);
}

.check-body small,
.check-body em {
  color: var(--muted);
  font-style: normal;
}

.holder-panel {
  margin-top: 14px;
}

.mini-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.mini-table {
  width: 100%;
  min-width: 680px;
  margin-top: 12px;
  table-layout: auto;
}

.mini-table th,
.mini-table td {
  font-size: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.mini-table th:first-child,
.mini-table td:first-child {
  text-align: left;
}

.positive {
  color: var(--red);
}

.negative {
  color: var(--green);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .resize-handle {
    display: none;
  }

  .workspace {
    display: grid;
    grid-template-rows: auto auto;
  }

  .sidebar {
    position: static;
    height: auto;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .candidate-section,
  .detail-section {
    height: auto;
    overflow: visible;
  }

  .candidate-section {
    border-bottom: 1px solid var(--line);
  }

  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pattern-symbol-layout {
    grid-template-columns: 1fr;
  }

  .pattern-symbol-side {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .candidate-section,
  .detail-section,
  .sidebar {
    padding: 16px;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .pattern-action-row {
    grid-template-columns: 1fr;
  }

  .basic-metrics {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .candidate-actions,
  .manual-add {
    justify-content: stretch;
  }

  .manual-add input,
  .manual-add button,
  .candidate-actions > button,
  .pattern-action-row > button {
    width: 100%;
  }
}

/* Shared responsive primitives: one DOM and one behavior path for every viewport. */
.mobile-workspace-nav {
  display: none;
}

.responsive-grid {
  --responsive-min: 220px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--responsive-min), 100%), 1fr));
  gap: var(--responsive-gap, 12px);
}

.responsive-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--responsive-gap, 8px);
}

.scroll-surface {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 760px) {
  :root {
    --mobile-nav-height: 58px;
  }

  html {
    scroll-padding-top: var(--mobile-nav-height);
  }

  body {
    overflow-x: hidden;
  }

  .login-shell {
    align-items: start;
    padding: 24px 16px 146px;
  }

  .login-card {
    margin-top: max(12px, env(safe-area-inset-top));
    border-radius: 14px;
    padding: 28px 22px;
  }

  .quick-login-corner {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
  }

  .quick-login-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .advanced-settings-grid {
    grid-template-columns: 1fr;
  }

  .ai-profile-grid {
    grid-template-columns: 1fr;
  }

  .ai-profile-grid .select-control,
  .ai-prompt-field textarea,
  .ai-refine-entry input {
    font-size: 16px;
  }

  .ai-intent-chips button,
  .ai-refine-chips button {
    flex: 1 1 132px;
  }

  .account-bar {
    grid-template-columns: 34px minmax(0, 1fr);
    padding: 10px;
  }

  .account-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    width: 100%;
    gap: 8px;
  }

  .account-actions button {
    justify-content: center;
    min-height: 44px;
    font-size: 13px;
  }

  .tour-dialog {
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 88px);
    overflow: auto;
    padding: 18px;
  }

  .tour-active .tour-target {
    box-shadow: 0 0 0 4px #7aa2ff;
  }

  .responsive-workspace-ready .mobile-workspace-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    min-height: var(--mobile-nav-height);
    padding: 7px max(12px, env(safe-area-inset-right)) 7px max(12px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px);
  }

  .mobile-workspace-nav button {
    min-width: 0;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 750;
  }

  .mobile-workspace-nav button.active {
    border-color: #bfd0ff;
    background: #eef4ff;
    color: var(--blue);
  }

  .mobile-workspace-nav button:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
  }

  .responsive-workspace-ready [data-responsive-pane] {
    display: none !important;
  }

  .responsive-workspace-ready [data-responsive-pane].responsive-pane-active {
    display: block !important;
  }

  .responsive-workspace-ready .candidate-section.responsive-pane-active {
    display: flex !important;
  }

  .sidebar,
  .candidate-section,
  .detail-section {
    width: 100%;
    min-height: calc(100dvh - var(--mobile-nav-height));
    padding: 14px;
  }

  .sidebar {
    border-bottom: 0;
  }

  .brand h1 {
    font-size: 20px;
  }

  .brand-nav {
    margin-top: 10px;
  }

  .filters {
    margin-top: 18px;
  }

  .strategy-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .candidate-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .candidate-actions > *,
  .candidate-actions > button {
    width: 100%;
    min-width: 0;
  }

  .manual-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .manual-add input {
    width: 100%;
  }

  .manual-add button {
    width: auto;
    min-width: 88px;
  }

  .view-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    margin-left: 0;
  }

  .view-toggle span {
    display: none;
  }

  .view-toggle button {
    border-right: 1px solid var(--line);
  }

  .table-wrap,
  .mini-table-wrap,
  .backtest-table-wrap,
  .pattern-signal-table-wrap {
    max-width: 100%;
    overflow: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .candidate-section .table-wrap {
    min-height: 58dvh;
  }

  .candidate-empty-state {
    width: 100%;
    min-height: 300px;
    margin-top: 24px;
    padding: 24px 18px;
  }

  .candidate-empty-state .secondary-button {
    width: 100%;
  }

  table {
    min-width: 720px;
  }

  .summary-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid > .panel {
    height: auto;
    min-height: 150px;
  }

  .pattern-summary-grid > .panel {
    min-height: 112px;
  }

  .panel {
    padding: 12px;
    box-shadow: 0 5px 16px rgba(15, 23, 42, 0.06);
  }

  .chart {
    height: 220px;
  }

  .holder-evolution-chart {
    height: 360px;
  }

  .backtest-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  button,
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  .brand-link,
  .account-bar button {
    min-height: 44px;
  }

  .tour-actions button {
    min-height: 44px;
  }

  .warehouse-state-control.has-details .warehouse-state {
    min-height: 44px;
  }

  .warehouse-issue-popover {
    width: min(340px, calc(100cqw - 36px));
    max-height: min(520px, 68dvh);
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 420px) {
  .sidebar,
  .candidate-section,
  .detail-section {
    padding: 12px;
  }

  .mobile-workspace-nav {
    gap: 4px;
  }

  .panel {
    border-radius: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
