* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: #f0f2f5; color: #333; }

/* top bar */
#topbar { background: #1f3450; color: #fff; position: sticky; top: 0; z-index: 100; }
.topbar-inner { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 48px; }
.logo { font-size: 15px; font-weight: 700; white-space: nowrap; }
#dbtabs { display: flex; gap: 4px; }
#dbtabs span { padding: 5px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; color: #cfd8e3; }
#dbtabs span.active, #dbtabs span:hover { background: rgba(255,255,255,.15); color: #fff; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
#search { width: 280px; padding: 6px 12px; border-radius: 14px; border: none; outline: none; font-size: 13px; }
#datastamp { font-size: 12px; color: #9fb3cc; white-space: nowrap; }
#search-results { position: absolute; right: 20px; top: 48px; width: 420px; max-height: 60vh; overflow: auto;
  background: #fff; color: #333; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.25); display: none; }
#search-results .sr-item { padding: 8px 14px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f0f0f0; }
#search-results .sr-item:hover { background: #eef4ff; }
#search-results .sr-cat { color: #98a; font-size: 11px; margin-left: 8px; }

/* section tabs */
#sectabs { display: flex; gap: 26px; padding: 0 20px; background: #fff; border-bottom: 1px solid #e3e6eb; }
#sectabs span { padding: 12px 2px; font-size: 14px; cursor: pointer; color: #555; border-bottom: 2px solid transparent; }
#sectabs span.active { color: #1f6feb; font-weight: 600; border-bottom-color: #1f6feb; }

/* chips */
#chips { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 20px; background: #fff; align-items: center; }
#chips .chip { font-size: 13px; color: #444; cursor: pointer; padding: 4px 6px; border-radius: 4px; white-space: nowrap; }
#chips .chip:hover { background: #f0f4fa; }
#chips .chip.active { color: #1f6feb; font-weight: 600; border-bottom: 2px solid #1f6feb; border-radius: 0; }
#chips .chip b { color: #98a4b5; font-weight: 400; font-size: 11px; margin-left: 3px; }
#chips .chip.active b { color: #1f6feb; }

/* overview */
.ov-title { font-size: 17px; font-weight: 700; padding: 16px 20px 4px; }
.ov-sub { font-size: 12px; color: #999; padding: 0 20px 12px; }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; padding: 0 20px 24px; }
.ov-card { background: #fff; border: 1px solid #e6e9ef; border-radius: 8px; padding: 18px 16px; cursor: pointer; transition: box-shadow .15s; }
.ov-card:hover { box-shadow: 0 4px 16px rgba(31,52,80,.12); }
.ov-card .t { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.ov-card .n { font-size: 12px; color: #98a4b5; }

/* chart grid */
.grid-title { font-size: 17px; font-weight: 700; padding: 16px 20px 4px; display: flex; align-items: center; gap: 14px; }
.grid-title .reset { font-size: 12px; color: #1f6feb; cursor: pointer; font-weight: 400; }
.grid-sub { font-size: 12px; color: #999; padding: 0 20px 12px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; padding: 0 20px 30px; }
.chart-card { background: #fff; border: 1px solid #e6e9ef; border-radius: 8px; padding: 10px 12px; cursor: pointer; transition: box-shadow .15s; }
.chart-card:hover { box-shadow: 0 4px 18px rgba(31,52,80,.14); }
.cc-head { display: flex; align-items: center; gap: 8px; }
.cc-title { font-size: 14px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-badge { font-size: 11px; color: #2b8a3e; background: #e7f5ea; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.cc-icon { color: #8a97a8; font-size: 13px; }
.cc-stats { font-size: 12px; margin: 6px 0 2px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.cc-stats .sv { white-space: nowrap; }
.cc-stats .sv .sn { color: #666; }
.cc-stats .sv .sv2 { color: #333; font-weight: 600; }
.cc-stats .up { color: #d4380d; } .cc-stats .down { color: #2b8a3e; }
.cc-chart { width: 100%; height: 200px; }
.cc-legend { font-size: 11px; color: #98a4b5; display: flex; flex-wrap: wrap; gap: 4px 12px; }

/* modal */
#modal-mask { position: fixed; inset: 0; background: rgba(15,25,40,.55); z-index: 200; display: flex; align-items: center; justify-content: center; }
#modal-mask.hidden { display: none; }
#modal { background: #fff; border-radius: 10px; width: 92vw; height: 90vh; display: flex; flex-direction: column; padding: 14px 18px; }
#modal-header { display: flex; align-items: center; gap: 12px; }
#modal-title { font-size: 16px; font-weight: 700; flex: 1; }
#modal-actions button { margin-left: 8px; padding: 5px 14px; border: 1px solid #d0d7e2; background: #fff; border-radius: 5px; cursor: pointer; font-size: 13px; }
#modal-actions button:hover { background: #f0f4fa; }
#modal-stats { font-size: 12px; color: #555; margin: 8px 0 4px; display: flex; flex-wrap: wrap; gap: 4px 18px; }
#modal-stats .sv2 { font-weight: 600; }
#modal-toolbar { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
#modal-toolbar button { padding: 4px 12px; border: 1px solid #d0d7e2; background: #fff; border-radius: 4px; cursor: pointer; font-size: 12px; }
#modal-toolbar button.active { background: #1f6feb; color: #fff; border-color: #1f6feb; }
#modal-chart { flex: 1; min-height: 0; }

.empty-hint { padding: 40px; text-align: center; color: #98a4b5; }

/* embedded downstream-indicators dashboard */
.external-head { min-height: 64px; padding: 12px 20px; background: #fff; border-bottom: 1px solid #e3e6eb; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.external-title { font-size: 17px; font-weight: 700; color: #1f3450; }
.external-sub { margin-top: 4px; font-size: 12px; color: #8996a8; }
.external-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.external-actions button { padding: 6px 13px; border: 1px solid #cfd8e3; border-radius: 5px; background: #fff; color: #1f3450; cursor: pointer; font-size: 12px; }
.external-actions button:hover { background: #f0f4fa; }
.external-actions a { color: #1f6feb; text-decoration: none; font-size: 12px; }
.external-frame { display: block; width: 100%; height: calc(100vh - 112px); min-height: 620px; border: 0; background: #f5f6f8; }
@media (max-width: 760px) {
  .external-head { align-items: flex-start; flex-direction: column; }
  .external-frame { height: calc(100vh - 160px); min-height: 560px; }
}

/* rubber cost calculator */
#calc-btn { padding:5px 11px; border:1px solid rgba(255,214,110,.42); border-radius:5px; background:rgba(255,255,255,.06); color:#ffd66e; cursor:pointer; font-size:13px; white-space:nowrap; }
#calc-btn:hover { background:rgba(255,255,255,.15); }
.calc-modal { position:fixed; inset:0; background:rgba(15,23,42,.5); z-index:300; display:none; align-items:flex-start; justify-content:center; backdrop-filter:blur(3px); }
.calc-modal.show { display:flex; }
.calc-box { background:#fff; border-radius:12px; width:min(94vw,1200px); max-height:88vh; overflow:auto; box-shadow:0 20px 60px rgba(0,0,0,.3); margin-top:5vh; }
.calc-head { display:flex; justify-content:space-between; align-items:center; padding:14px 18px; border-bottom:1px solid #e4e9f0; position:sticky; top:0; background:#fff; z-index:2; cursor:move; user-select:none; }
.calc-title { font-size:16px; font-weight:700; color:#1a365d; }
#calc-close, #pp-close { cursor:pointer; color:#8a97a8; font-size:16px; padding:2px 6px; border:0; background:transparent; }
#calc-close:hover, #pp-close:hover { color:#d64541; }
.calc-inputs { display:flex; gap:10px; padding:14px 18px; align-items:center; border-bottom:1px solid #eef1f6; flex-wrap:wrap; }
.calc-inputs select { padding:8px 10px; border:1px solid #d8e0ea; border-radius:8px; font-size:14px; min-width:150px; background:#fff; }
.calc-inputs input[type=number] { padding:8px 10px; border:1px solid #d8e0ea; border-radius:8px; font-size:14px; width:140px; }
.calc-unit { color:#718096; font-size:13px; }
.calc-btn-primary, .calc-btn-ghost { padding:8px 18px; border-radius:8px; cursor:pointer; font-size:14px; }
.calc-btn-primary { background:#2f7ed8; color:#fff; border:1px solid #2f7ed8; }
.calc-btn-primary:hover { background:#256abf; }
.calc-btn-ghost { background:#fff; color:#2f6fed; border:1px solid #2f7ed8; }
.calc-btn-ghost:hover { background:#f0f6ff; }
.calc-params { padding:10px 18px; font-size:12px; color:#2f7ed8; background:#f0f6ff; border-bottom:1px solid #eef1f6; line-height:1.6; }
.calc-result { padding:14px 18px; overflow-x:auto; }
.calc-hint { color:#a3b1c2; text-align:center; padding:30px; }
.calc-error { color:#c93338; text-align:center; padding:24px; }
.calc-table { width:100%; border-collapse:collapse; font-size:13px; }
.calc-table th { background:#f5f7fa; color:#4a5568; padding:9px 8px; text-align:left; border-bottom:2px solid #d8e0ea; font-size:12px; white-space:nowrap; }
.calc-table td { padding:9px 8px; border-bottom:1px solid #eef1f6; vertical-align:top; }
.calc-name { font-weight:600; color:#1a365d; white-space:nowrap; }
.calc-num { color:#d64541; font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }
.calc-market { color:#4a5568; font-size:12px; white-space:nowrap; }
.calc-date { color:#8a97a8; font-size:11px; }
.calc-formula { color:#718096; font-size:11px; line-height:1.5; min-width:260px; }
.calc-footnote { margin-top:10px; font-size:11px; color:#a3b1c2; }
.params-panel { position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); width:min(92vw,520px); max-height:80vh; overflow:auto; background:#fff; z-index:320; border-radius:12px; box-shadow:0 20px 60px rgba(0,0,0,.3); display:none; padding:0 0 14px; }
.params-panel.show { display:block; }
.params-panel.pp-right { position:fixed; right:16px; top:96px; left:auto; transform:none; margin:0; }
.pp-head { display:flex; justify-content:space-between; align-items:center; font-size:14px; font-weight:700; color:#1a365d; padding:12px 16px; border-bottom:1px solid #eef1f6; position:sticky; top:0; background:#fff; cursor:move; user-select:none; }
.pp-grid { padding:12px 16px; display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.pp-row { display:flex; flex-direction:column; gap:4px; }
.pp-row label { font-size:11px; color:#718096; }
.pp-row input { padding:6px 8px; border:1px solid #d8e0ea; border-radius:6px; font-size:13px; width:100%; }
.pp-row span { font-size:10px; color:#a3b1c2; }
.pp-actions { display:flex; gap:10px; justify-content:flex-end; padding:0 16px; }
.calc-box.dragging, .params-panel.dragging { box-shadow:0 24px 64px rgba(0,0,0,.4); }
.calc-toast { position:fixed; left:50%; bottom:34px; transform:translateX(-50%); z-index:400; padding:9px 18px; border-radius:7px; background:rgba(15,23,42,.9); color:#fff; font-size:13px; box-shadow:0 6px 24px rgba(0,0,0,.2); }
@media (max-width:768px) {
  #calc-btn { padding:5px 7px; font-size:12px; }
  .params-panel.pp-right { left:50%; right:auto; top:50%; transform:translate(-50%,-50%); }
  .calc-box { margin-top:2vh; max-height:94vh; }
  .pp-grid { grid-template-columns:1fr; }
}
