:root {
  --bg: #f3f6f2;
  --ink: #20231f;
  --muted: #6f746b;
  --line: #d9e1d8;
  --panel: #ffffff;
  --deep: #17251f;
  --green: #1f7a4d;
  --green-2: #49a86f;
  --amber: #c8882c;
  --red: #b34b3f;
  --violet: #63527c;
  --shadow: 0 18px 55px rgba(35, 31, 24, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(31, 122, 77, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(99, 82, 124, 0.08), transparent 36%),
    var(--bg);
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden { display: none !important; }

.toast {
  position: fixed;
  right: 22px;
  top: 22px;
  z-index: 20;
  min-width: 260px;
  max-width: 420px;
  padding: 13px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--deep);
  box-shadow: var(--shadow);
  transform: translateY(-20px);
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(340px, 430px);
  gap: 28px;
  align-items: center;
  padding: 44px;
}

.brand-panel {
  min-height: 560px;
  padding: 48px;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(23, 37, 31, 0.96), rgba(32, 35, 31, 0.92)),
    url("data:image/svg+xml,%3Csvg width='240' height='240' viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d5b46f' stroke-opacity='.13'%3E%3Cpath d='M20 120h200M120 20v200M48 48l144 144M192 48L48 192'/%3E%3Ccircle cx='120' cy='120' r='76'/%3E%3Ccircle cx='120' cy='120' r='42'/%3E%3C/g%3E%3C/svg%3E");
  color: #fff8e8;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber), #f2cf7c);
  color: var(--deep);
  font-size: 34px;
  font-weight: 900;
  margin-bottom: 24px;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 20px;
  margin: 0;
}

.brand-panel h1 {
  margin: 0;
  font-size: 52px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand-panel p {
  margin: 18px 0 0;
  color: rgba(255, 248, 232, 0.78);
  font-size: 20px;
}

.brand-metrics {
  margin-top: 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-metrics span {
  padding: 9px 12px;
  border: 1px solid rgba(255, 248, 232, 0.2);
  border-radius: 8px;
  color: #fff8e8;
  background: rgba(255, 255, 255, 0.06);
}

.auth-panel {
  padding: 26px;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: var(--shadow);
  border: 1px solid rgba(222, 215, 201, 0.7);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: #eee8dc;
  border-radius: 8px;
  margin-bottom: 18px;
}

.tab, .nav {
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  font-weight: 700;
}

.tab.active, .nav.active {
  background: var(--panel);
  color: var(--deep);
  box-shadow: 0 5px 18px rgba(23, 37, 31, 0.08);
}

.form { display: none; }
.form.active { display: grid; gap: 13px; }

.form-note {
  padding: 10px 12px;
  border-radius: 6px;
  color: #6f4c18;
  background: rgba(200, 136, 44, 0.14);
  font-size: 13px;
  line-height: 1.55;
}

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

input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.14);
}

.primary, .secondary, .ghost {
  min-height: 42px;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 800;
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-2));
}

.secondary {
  color: var(--deep);
  background: #eee8dc;
}

.secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.wide { min-width: 156px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px 1fr;
}

.sidebar {
  padding: 24px 18px;
  background: var(--deep);
  color: #fff8e8;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.side-brand strong, .side-brand span {
  display: block;
}

.side-brand span {
  color: rgba(255, 248, 232, 0.62);
  font-size: 12px;
  margin-top: 2px;
}

nav { display: grid; gap: 8px; }

.nav {
  color: rgba(255, 248, 232, 0.65);
  text-align: left;
}

.nav.active {
  background: rgba(255, 248, 232, 0.1);
  color: #fff8e8;
  box-shadow: none;
}

.sidebar footer {
  margin-top: auto;
  color: rgba(255, 248, 232, 0.48);
  font-size: 12px;
  line-height: 1.6;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.topbar h2 {
  margin: 0;
  font-size: 26px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.page { display: none; }
.page.active { display: block; }

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 22px;
  border: 1px solid rgba(222, 215, 201, 0.85);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31, 122, 77, 0.1), transparent 42%),
    rgba(255, 253, 248, 0.94);
  box-shadow: 0 14px 34px rgba(35, 31, 24, 0.07);
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.dashboard-hero h3 {
  margin: 0;
  font-size: 28px;
  line-height: 1.22;
}

.dashboard-hero p {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.quick-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.quick-steps span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f6f0e5;
  color: var(--deep);
  font-weight: 800;
}

.quick-steps b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  font-size: 12px;
}

.hero-actions {
  display: grid;
  gap: 10px;
  align-content: center;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #ebe4d8;
}

.limit-field { width: 100%; }

.strategy-summary {
  padding: 9px 10px;
  border-radius: 6px;
  background: #f7faf6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.strategy-panel {
  margin: -2px 0 14px;
  padding: 18px;
  border: 1px solid rgba(222, 215, 201, 0.78);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: 0 12px 30px rgba(35, 31, 24, 0.06);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.preset-card {
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  background: #fff;
  color: var(--deep);
}

.preset-card.active {
  border-color: rgba(31, 122, 77, 0.55);
  background: rgba(31, 122, 77, 0.08);
  box-shadow: inset 0 0 0 1px rgba(31, 122, 77, 0.18);
}

.preset-card strong,
.preset-card span {
  display: block;
}

.preset-card strong {
  margin-bottom: 6px;
  font-size: 15px;
}

.preset-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.advanced-settings {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.advanced-settings summary {
  min-height: 44px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--deep);
  font-weight: 900;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}

.locked-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.locked-rules div {
  padding: 11px 12px;
  border-radius: 8px;
  background: #f7faf6;
  border: 1px solid var(--line);
}

.locked-rules span,
.locked-rules strong {
  display: block;
}

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

.locked-rules strong {
  margin-top: 3px;
  color: var(--green);
  font-size: 13px;
}

.settings-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

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

.metric, .table-panel, .insight-panel {
  border: 1px solid rgba(222, 215, 201, 0.78);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 12px 30px rgba(35, 31, 24, 0.06);
}

.metric {
  padding: 17px;
  min-height: 96px;
}

.metric.highlight {
  border-color: rgba(31, 122, 77, 0.32);
  background: rgba(31, 122, 77, 0.08);
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  color: var(--deep);
  overflow-wrap: anywhere;
}

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

.recommend-panel {
  margin-bottom: 14px;
  border: 1px solid rgba(222, 215, 201, 0.78);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 12px 30px rgba(35, 31, 24, 0.06);
  overflow: hidden;
}

.panel-head.compact {
  min-height: 58px;
  padding-top: 13px;
  padding-bottom: 13px;
}

.picked-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.pick-card, .empty-card {
  min-height: 134px;
  padding: 14px;
  border-radius: 8px;
  background: #f8f3ea;
  border: 1px solid #ebe4d8;
}

.pick-card {
  display: grid;
  gap: 10px;
  cursor: pointer;
}

.pick-card:hover {
  border-color: rgba(31, 122, 77, 0.35);
  background: #fffdf8;
}

.pick-card.active,
tbody tr.active-row {
  outline: 2px solid rgba(31, 122, 77, 0.38);
  outline-offset: -2px;
  background: #fffdf8;
}

.pick-card.is-watch {
  background: rgba(200, 136, 44, 0.1);
}

.pick-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.pick-top > div:last-child {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.pick-top strong {
  display: block;
  font-size: 16px;
}

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

.pick-price {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.pick-price b {
  color: var(--green);
  font-size: 20px;
}

.pick-reason {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.empty-card {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  align-items: start;
}

.table-panel, .insight-panel { overflow: hidden; }

.panel-head {
  min-height: 70px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3, .insight-panel h3 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  min-height: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th, td {
  padding: 13px 12px;
  border-bottom: 1px solid #ebe4d8;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #f6f0e5;
  font-size: 12px;
  white-space: nowrap;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: #fbf5ea;
}

tbody tr {
  cursor: pointer;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok { background: rgba(31, 122, 77, 0.12); color: var(--green); }
.badge.warn { background: rgba(200, 136, 44, 0.16); color: #8a5a14; }
.badge.bad { background: rgba(179, 75, 63, 0.12); color: var(--red); }
.badge.info { background: rgba(99, 82, 124, 0.13); color: var(--violet); }

.stock-name strong {
  display: block;
  font-size: 14px;
}

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

.score {
  font-size: 18px;
  font-weight: 900;
  color: var(--green);
}

.decision {
  display: grid;
  gap: 5px;
}

.decision small {
  color: var(--muted);
  font-size: 12px;
}

.plain-note {
  max-width: 260px;
  color: var(--muted);
  line-height: 1.55;
}

.history-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.history-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-head strong,
.history-head span {
  display: block;
}

.history-head span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.export-link {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  text-decoration: none;
}

.history-stats,
.history-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-stats span,
.history-picks span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 6px;
  background: #eef5ef;
  color: var(--deep);
  font-size: 12px;
  font-weight: 800;
}

.tracking-list {
  display: grid;
  gap: 8px;
}

.tracking-row {
  display: grid;
  grid-template-columns: minmax(96px, 150px) minmax(80px, 120px) 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  align-items: center;
}

.tracking-row b {
  color: var(--deep);
}

.tracking-row span,
.tracking-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.history-empty {
  margin: 0;
}

.insight-panel {
  padding: 18px;
}

.help-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.help-list div {
  padding: 11px;
  border-radius: 8px;
  background: #f6f0e5;
}

.help-list b,
.help-list span {
  display: block;
}

.help-list b {
  color: var(--deep);
  margin-bottom: 3px;
}

.help-list span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.selected-card {
  margin-top: 16px;
  padding: 14px;
  min-height: 94px;
  border-radius: 8px;
  background: #f7faf6;
  color: var(--muted);
  line-height: 1.7;
}

.selected-card p {
  margin: 10px 0;
}

.selected-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  color: var(--deep);
}

.selected-head strong,
.selected-head span {
  display: block;
}

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

.selected-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.selected-grid div {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.selected-grid span,
.selected-grid b {
  display: block;
}

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

.selected-grid b {
  color: var(--green);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.strategy-checklist {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.check-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 9px;
  align-items: start;
  padding: 9px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.check-item > span {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

.check-item.is-ok > span {
  color: var(--green);
  background: rgba(31, 122, 77, 0.12);
}

.check-item.is-warn > span {
  color: #8a5a14;
  background: rgba(200, 136, 44, 0.16);
}

.check-item b,
.check-item small {
  display: block;
}

.check-item b {
  color: var(--deep);
  line-height: 1.35;
}

.check-item small {
  color: var(--muted);
  line-height: 1.45;
}

.next-action {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e3d9c9;
  color: var(--deep);
  font-weight: 800;
}

.selected-card .secondary {
  margin-top: 12px;
}

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

.modal-note {
  margin: -4px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 37, 31, 0.42);
}

.modal-box {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-box h3 {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tiny {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.approve { color: #fff; background: var(--green); }
.reject { color: #fff; background: var(--red); }
.reset { color: var(--deep); background: #eee8dc; }

@media (max-width: 1100px) {
  .auth-shell { grid-template-columns: 1fr; }
  .brand-panel { min-height: 360px; }
  .dashboard-hero { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .picked-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .locked-rules { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .auth-shell { padding: 18px; }
  .brand-panel { padding: 28px; }
  .brand-panel h1 { font-size: 36px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .workspace { padding: 16px; }
  .dashboard-hero { padding: 16px; }
  .dashboard-hero h3 { font-size: 22px; }
  .quick-steps { display: grid; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; gap: 12px; flex-direction: column; }
  .top-actions { width: 100%; }
  .top-actions button { flex: 1; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .preset-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .settings-actions {
    display: grid;
  }
  .selected-grid { grid-template-columns: 1fr; }
  .tracking-row { grid-template-columns: 1fr; }
  .history-head { flex-direction: column; }
  .export-link { width: 100%; }
  .table-wrap { overflow: visible; }
  .responsive-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 10px;
  }
  .responsive-table thead { display: none; }
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    margin: 0 12px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }
  .responsive-table td {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 10px;
    align-items: start;
    padding: 11px 12px;
    border-bottom: 1px solid #edf1eb;
  }
  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }
  .responsive-table td:last-child { border-bottom: 0; }
  .responsive-table .empty {
    display: block;
    margin: 0;
    text-align: center;
  }
  .responsive-table .empty::before { content: ""; }
  .toast { left: 16px; right: 16px; min-width: 0; }
}
