:root {
  --ink: #102a2a;
  --muted: #617574;
  --line: #dce8e5;
  --paper: #f5faf8;
  --card: rgba(255, 255, 255, .92);
  --green: #167d6a;
  --green-dark: #0d5f52;
  --mint: #dff4ed;
  --orange: #e58b45;
  --red: #c84e56;
  --shadow: 0 18px 50px rgba(24, 72, 66, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(140, 213, 194, .28), transparent 34%),
    radial-gradient(circle at 100% 15%, rgba(246, 197, 147, .18), transparent 28%),
    var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(400px, .85fr);
}

.login-story {
  position: relative;
  overflow: hidden;
  padding: clamp(42px, 7vw, 100px);
  background: linear-gradient(145deg, #0b5d50 0%, #188875 56%, #6bc0a6 100%);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-story::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  right: -180px;
  bottom: -190px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  box-shadow: 0 0 0 80px rgba(255,255,255,.05), 0 0 0 160px rgba(255,255,255,.035);
}

.brand { display: flex; align-items: center; gap: 13px; font-weight: 700; letter-spacing: .03em; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
  font-size: 21px;
}
.story-copy { max-width: 680px; position: relative; z-index: 1; }
.story-copy h1 { font-size: clamp(42px, 6vw, 76px); line-height: 1.06; margin: 0 0 24px; letter-spacing: -.045em; }
.story-copy p { font-size: clamp(17px, 2vw, 22px); line-height: 1.7; margin: 0; color: rgba(255,255,255,.82); max-width: 580px; }
.story-foot { font-size: 13px; color: rgba(255,255,255,.62); position: relative; z-index: 1; }

.login-panel { display: grid; place-items: center; padding: 36px; }
.login-card { width: min(100%, 430px); }
.login-card .eyebrow, .eyebrow { color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.login-card h2 { font-size: 36px; margin: 12px 0 10px; letter-spacing: -.035em; }
.login-card > p { color: var(--muted); line-height: 1.7; margin: 0 0 34px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin: 0 0 8px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  background: rgba(255,255,255,.8); color: var(--ink); outline: none; transition: .2s ease;
}
.field input:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(22,125,106,.10); }
.primary-btn {
  width: 100%; border: 0; border-radius: 14px; padding: 15px 18px; color: white;
  background: var(--green); font-weight: 750; cursor: pointer; box-shadow: 0 10px 24px rgba(22,125,106,.22);
  transition: transform .2s ease, background .2s ease;
}
.primary-btn:hover { transform: translateY(-1px); background: var(--green-dark); }
.primary-btn:disabled { opacity: .55; cursor: wait; transform: none; }
.login-message { min-height: 24px; color: var(--red); font-size: 13px; margin: 16px 0 0; }

.app-shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 54px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.topbar .brand { color: var(--ink); }
.topbar .brand-mark { background: var(--green); color: white; border: 0; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 999px; background: white; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #a5b4b1; }
.status-dot.ready { background: #36a87e; box-shadow: 0 0 0 4px rgba(54,168,126,.12); }
.ghost-btn { border: 1px solid var(--line); color: var(--ink); background: white; border-radius: 11px; padding: 9px 14px; cursor: pointer; }

.hero { display: flex; justify-content: space-between; gap: 32px; align-items: end; margin-bottom: 28px; }
.hero h1 { margin: 9px 0 8px; font-size: clamp(34px, 4.5vw, 58px); letter-spacing: -.052em; line-height: 1.05; }
.hero p { margin: 0; color: var(--muted); font-size: 16px; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters select { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 12px; padding: 11px 38px 11px 13px; outline: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.metric-card, .panel { background: var(--card); border: 1px solid rgba(215,231,226,.9); border-radius: 22px; box-shadow: var(--shadow); }
.metric-card { padding: 22px; min-height: 152px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 86px; height: 86px; border-radius: 50%; right: -24px; top: -26px; background: var(--mint); opacity: .7; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { font-size: 38px; font-weight: 780; letter-spacing: -.045em; margin: 16px 0 5px; }
.metric-unit { color: var(--muted); font-size: 13px; }
.metric-detail { margin-top: 10px; color: var(--muted); font-size: 12px; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(330px, .8fr); gap: 16px; align-items: start; }
.panel { padding: 24px; }
.panel-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 20px; }
.panel-head h2 { margin: 0 0 5px; font-size: 20px; letter-spacing: -.02em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-wrap { min-height: 310px; display: grid; place-items: center; }
.chart-wrap svg { width: 100%; overflow: visible; }
.empty { color: var(--muted); font-size: 14px; padding: 54px 0; text-align: center; }

.ai-panel { background: linear-gradient(165deg, #103e39 0%, #0c6659 100%); color: white; border: none; }
.ai-panel .panel-head p { color: rgba(255,255,255,.65); }
.ai-panel textarea { width: 100%; min-height: 88px; resize: vertical; background: rgba(255,255,255,.09); color: white; border: 1px solid rgba(255,255,255,.18); border-radius: 14px; padding: 13px; outline: none; }
.ai-panel textarea::placeholder { color: rgba(255,255,255,.45); }
.ai-panel textarea:focus { border-color: rgba(255,255,255,.5); }
.ai-btn { margin-top: 12px; border: 0; background: #d4f2e9; color: #0b5a4e; border-radius: 13px; padding: 13px 17px; width: 100%; font-weight: 800; cursor: pointer; }
.ai-btn:disabled { opacity: .45; cursor: not-allowed; }
.ai-result { margin-top: 18px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.14); white-space: pre-wrap; font-size: 14px; line-height: 1.8; color: rgba(255,255,255,.88); max-height: 430px; overflow: auto; }
.ai-hint { color: rgba(255,255,255,.6); font-size: 12px; line-height: 1.6; margin-top: 12px; }

.table-panel { margin-top: 16px; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th { color: var(--muted); font-size: 12px; text-align: left; font-weight: 650; padding: 13px 12px; border-bottom: 1px solid var(--line); }
td { padding: 15px 12px; border-bottom: 1px solid #edf3f1; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
.bp-value { font-weight: 800; font-variant-numeric: tabular-nums; }
.level { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 12px; background: #edf4f2; color: var(--muted); }
.level.good { background: #e0f3ea; color: #1d7a5d; }
.level.warn { background: #fff0df; color: #ad641f; }
.level.danger { background: #fde7e8; color: #b83e49; }
.disclaimer { color: var(--muted); font-size: 12px; text-align: center; margin-top: 22px; line-height: 1.7; }
.toast { position: fixed; right: 22px; bottom: 22px; background: #203b38; color: white; padding: 13px 17px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .25s ease; max-width: 360px; z-index: 10; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-story { min-height: 38vh; padding: 34px; }
  .story-copy h1 { font-size: 42px; margin-top: 48px; }
  .story-foot { display: none; }
  .login-panel { padding: 42px 24px; }
  .hero { display: block; }
  .filters { margin-top: 22px; }
}
@media (max-width: 580px) {
  .app-shell { width: min(100% - 24px, 1480px); padding-top: 16px; }
  .status-pill { display: none; }
  .hero h1 { font-size: 38px; }
  .metric-grid { grid-template-columns: 1fr; }
  .panel, .metric-card { border-radius: 18px; }
  .panel { padding: 18px; }
  .legend { display: none; }
}
