:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #11151a;
  --panel-2: #151a20;
  --border: #28303a;
  --border-soft: #1d242c;
  --text: #eef2f5;
  --muted: #8f9aa7;
  --blue: #4d8dff;
  --green: #20c77a;
  --red: #f05252;
  --amber: #f3a83b;
  --input: #0e1216;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 14px; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.app-header, .login-header {
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: #0a0d10;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }
.main-nav { display: flex; align-self: stretch; min-width: 0; overflow-x: auto; }
.main-nav a {
  display: flex;
  align-items: center;
  padding: 0 18px;
  color: #c8d0d7;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.main-nav a:hover { color: var(--text); background: #10151a; }
.main-nav a.active { color: var(--blue); border-bottom-color: var(--blue); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.health { color: #bdc6ce; display: inline-flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.username { color: var(--muted); }
.header-actions form { margin: 0; }

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  font-size: 18px;
}
.icon-button:hover { border-color: #43505e; background: var(--panel-2); }

.page { width: min(1560px, 100%); margin: 0 auto; padding: 14px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 16px 2px 12px; }
.page-heading h1 { margin: 0; font-size: 20px; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.read-only, .tag-neutral { color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 6px 9px; }

.status-strip, .metric-grid {
  display: grid;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 5px;
}
.status-strip { grid-template-columns: repeat(4, 1fr); }
.status-strip > div, .metric-grid > div { padding: 12px 16px; border-right: 1px solid var(--border-soft); }
.status-strip > div:last-child, .metric-grid > div:last-child { border-right: 0; }
.status-strip span, .metric-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.status-strip strong, .metric-grid strong { font-size: 18px; }

.overview-grid, .content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
}
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.surface {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  min-width: 0;
}
.section-gap { margin-top: 10px; }
.section-heading {
  height: 42px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.section-heading h2 { margin: 0; font-size: 15px; }
.section-heading span, .section-heading a { color: var(--muted); font-size: 12px; }
.section-heading a:hover { color: var(--blue); }

.asset-grid, .brief-grid { display: grid; grid-template-columns: 1fr 1fr; }
.asset-placeholder { min-height: 160px; padding: 16px; display: flex; flex-direction: column; gap: 52px; border-right: 1px solid var(--border-soft); }
.asset-placeholder:last-child { border-right: 0; }
.asset-placeholder span { color: var(--muted); }
.brief-placeholder { padding: 16px; border-right: 1px solid var(--border-soft); }
.brief-placeholder:last-child { border-right: 0; }
.brief-placeholder > div { display: flex; justify-content: space-between; align-items: center; }
.brief-placeholder dl { display: grid; grid-template-columns: 110px 1fr; margin: 18px 0 0; }
.brief-placeholder dt, .brief-placeholder dd { padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.brief-placeholder dt { color: var(--muted); }
.brief-placeholder dd { margin: 0; text-align: right; }

.market-summary, .brief-detail { padding: 16px; border-right: 1px solid var(--border-soft); }
.market-summary:last-child, .brief-detail:last-child { border-right: 0; }
.summary-title, .price-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.price-line { margin: 18px 0; }
.price-line > strong { font-size: 22px; }
.compact-dl { display: grid; grid-template-columns: 105px minmax(0, 1fr); margin: 0; }
.compact-dl dt, .compact-dl dd { padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.compact-dl dt { color: var(--muted); }
.compact-dl dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.scenario-box { margin-top: 16px; padding: 12px; border-left: 3px solid var(--blue); background: var(--input); }
.scenario-box p { margin: 8px 0 0; color: #c5cdd4; line-height: 1.7; }
.compact-value { font-size: 13px !important; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.warning-text { color: var(--amber); }
.direction { display: inline-block; min-width: 48px; font-size: 11px; font-weight: 700; }
.direction.long { color: var(--green); }
.direction.short { color: var(--red); }

.empty-state { min-height: 160px; display: grid; place-items: center; color: var(--muted); }
.service-list > div { display: flex; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid var(--border-soft); }
.service-list > div:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.event-list { max-height: 420px; overflow-y: auto; }
.event-list article { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.event-list article:last-child { border-bottom: 0; }
.event-list article > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.event-list p { margin: 7px 0; line-height: 1.5; }
.event-list small { color: var(--muted); }

.filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
}
.filter-bar label { display: grid; gap: 6px; }
.filter-bar label > span { color: var(--muted); font-size: 11px; }
.filter-bar input, .filter-bar select, .field input {
  height: 36px;
  min-width: 132px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--input);
  outline: none;
}
.filter-bar input:focus, .filter-bar select:focus, .field input:focus { border-color: var(--blue); }
.search-field { flex: 1; }
.search-field input { width: 100%; }

.primary-button, .secondary-button {
  height: 36px;
  padding: 0 18px;
  border-radius: 4px;
  cursor: pointer;
}
.primary-button { border: 1px solid var(--blue); background: var(--blue); color: white; font-weight: 650; }
.secondary-button { border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.primary-button:hover { background: #3f7eea; }
.secondary-button:hover { border-color: #43505e; }
.primary-button.compact { width: auto; align-self: flex-end; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.segmented button, .segmented a { height: 36px; padding: 0 15px; color: var(--muted); background: transparent; border: 0; border-right: 1px solid var(--border); display: inline-flex; align-items: center; }
.segmented button:last-child, .segmented a:last-child { border-right: 0; }
.segmented button.selected, .segmented a.selected { color: white; background: var(--blue); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; font-weight: 500; text-align: left; background: #0e1216; }
th, td { height: 38px; padding: 0 12px; border-bottom: 1px solid var(--border-soft); }
tbody tr:hover { background: #151b21; }
.empty-cell { height: 140px; text-align: center; color: var(--muted); }
td details { min-width: 54px; }
td details summary { color: var(--blue); cursor: pointer; }
td details p { white-space: normal; width: min(320px, 70vw); line-height: 1.5; }

.metric-grid { grid-template-columns: repeat(6, 1fr); margin-bottom: 10px; }
.pagination { height: 48px; display: flex; justify-content: center; align-items: center; gap: 20px; }
.pagination a { color: var(--blue); }
.pagination span { color: #59636e; }
.pagination strong { font-size: 12px; }
.button-link { display: inline-flex; align-items: center; }
.data-note { margin: 0 0 10px; padding: 10px 12px; color: var(--amber); border: 1px solid #60471e; background: #201a10; border-radius: 4px; }
.checkbox-filter { display: flex !important; align-items: center; min-height: 36px; grid-template-columns: auto 1fr; }
.checkbox-filter input { min-width: 17px; width: 17px; height: 17px; accent-color: var(--blue); }

.login-body { min-height: 100vh; display: grid; grid-template-rows: 56px 1fr 48px; }
.login-header { position: static; justify-content: space-between; }
.login-main { display: grid; place-items: center; padding: 32px 16px; }
.login-panel {
  width: min(410px, 100%);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}
.login-title { text-align: center; margin-bottom: 26px; }
.login-title h1 { margin: 0 0 8px; font-size: 26px; }
.login-title p { margin: 0; color: var(--muted); }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field > span:first-child { font-weight: 600; }
.field input { width: 100%; min-width: 0; height: 46px; }
.password-control { display: flex; position: relative; }
.password-control input { padding-right: 64px; }
.password-toggle { position: absolute; right: 6px; top: 6px; height: 34px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.checkbox-row { display: flex; gap: 9px; align-items: center; margin: 2px 0 20px; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--blue); }
.login-panel .primary-button { width: 100%; height: 44px; }
.form-error { padding: 10px 12px; margin: -10px 0 18px; border: 1px solid #7d3030; border-radius: 4px; background: #2b1517; color: #ffb2b2; }
.security-note { color: var(--muted); text-align: center; padding-top: 18px; margin: 18px 0 0; border-top: 1px solid var(--border-soft); }
.login-footer { display: grid; place-items: center; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .app-header { padding: 0 12px; gap: 10px; flex-wrap: wrap; height: auto; min-height: 56px; }
  .brand { height: 54px; display: flex; align-items: center; }
  .main-nav { order: 3; width: 100%; height: 44px; }
  .main-nav a { padding: 0 14px; }
  .header-actions { margin-left: auto; }
  .health, .username { display: none; }
  .page { padding: 10px; }
  .span-8, .span-4 { grid-column: 1 / -1; }
  .status-strip, .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .status-strip > div:nth-child(2), .metric-grid > div:nth-child(2n) { border-right: 0; }
  .asset-grid, .brief-grid { grid-template-columns: 1fr; }
  .asset-placeholder, .brief-placeholder { border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .filter-bar > label { flex: 1 1 140px; }
}

@media (max-width: 520px) {
  .page-heading { align-items: flex-start; }
  .read-only { display: none; }
  .status-strip, .metric-grid { grid-template-columns: 1fr 1fr; }
  .login-panel { padding: 24px 18px; }
  .login-header { padding: 0 16px; }
}
