/* ── Custom cursors ── */
* { cursor: url('/static/cursors/Normal.cur'), auto; }
a, button, [onclick], select, label { cursor: url('/static/cursors/Link.cur'), pointer; }
input, textarea { cursor: url('/static/cursors/Text.cur'), text; }

    :root {
      color-scheme: dark;
      --bg: #090b0f;
      --surface: #10141b;
      --surface-2: #151a23;
      --surface-3: #1b2230;
      --line: #263142;
      --line-soft: #1b2431;
      --text: #edf2f7;
      --muted: #98a6b8;
      --faint: #647184;
      --blue: #4aa3ff;
      --cyan: #37d5d6;
      --green: #48d597;
      --red: #ff6b73;
      --amber: #f4bd50;
      --violet: #9a8cff;
      --shadow: 0 20px 70px rgba(0, 0, 0, .38);
      --radius: 8px;
    }

    * { box-sizing: border-box; }
    html { min-height: 100%; background: var(--bg); }
    body {
      margin: 0;
      min-height: 100vh;
      color: var(--text);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: linear-gradient(180deg, rgba(13, 19, 27, .98), #090b0f 280px), var(--bg);
      letter-spacing: 0;
    }
    button, input, textarea { font: inherit; }
    button { border: 0; }
    .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-variant-numeric: tabular-nums; }

    .app-shell { min-height: 100vh; display: grid; grid-template-rows: auto auto 1fr; }
    .topbar {
      position: sticky; top: 0; z-index: 20;
      min-height: 64px;
      display: flex; align-items: center; justify-content: space-between; gap: 16px;
      padding: 0 24px;
      background: rgba(9, 11, 15, .9);
      border-bottom: 1px solid var(--line-soft);
      backdrop-filter: blur(18px);
    }
    .brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
    .mark {
      width: 34px; height: 34px; border-radius: 8px;
      display: grid; place-items: center;
      background: linear-gradient(135deg, var(--cyan), var(--blue));
      color: #03111a; font-weight: 900;
      box-shadow: 0 10px 30px rgba(55, 213, 214, .18);
    }
    .brand h1 { margin: 0; font-size: 16px; line-height: 1.1; }
    .brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .top-actions { display: flex; align-items: center; gap: 10px; }
    .topbar-video-wrap {
      flex: 1;
      min-width: 0;
      height: 60px;
      overflow: hidden;
      border-radius: 6px;
    }
    .topbar-video {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center top;
      display: block;
      opacity: 0.92;
    }

    .btn {
      min-height: 36px; padding: 0 13px; border-radius: 7px;
      display: inline-flex; align-items: center; justify-content: center; gap: 8px;
      background: var(--surface-2); color: var(--text);
      border: 1px solid var(--line); cursor: pointer; transition: .16s ease;
      white-space: nowrap;
    }
    .btn:hover { border-color: #3b4a60; background: #1a2230; }
    .btn:disabled { opacity: .45; cursor: wait; }
    .btn.primary { background: #dceaff; color: #06111d; border-color: #dceaff; font-weight: 800; }
    .btn.primary:hover { background: #fff; }
    .btn.icon { width: 36px; padding: 0; }
    .btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; }

    .status-strip {
      display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 1px;
      padding: 1px 24px 0; background: var(--line-soft);
      border-bottom: 1px solid var(--line-soft);
    }
    .status-item {
      min-height: 76px; padding: 14px 16px;
      background: #0d1118; display: flex; flex-direction: column; justify-content: center; gap: 6px;
    }
    .status-label { color: var(--faint); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
    .status-value { display: flex; align-items: baseline; gap: 10px; font-weight: 900; font-size: 20px; }
    .status-value small { color: var(--muted); font-size: 12px; font-weight: 700; }
    .status-note { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    .war-room {
      width: min(1500px, calc(100% - 48px));
      margin: 18px auto 0;
      background: rgba(16, 20, 27, .96);
      border: 1px solid var(--line-soft);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .war-room-head {
      min-height: 54px;
      padding: 13px 15px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      border-bottom: 1px solid var(--line-soft);
      background: #0d1219;
    }
    .war-room-head h2 { margin: 0; font-size: 14px; font-weight: 900; }
    .war-room-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
    .war-room-grid {
      display: grid;
      grid-template-columns: 1.15fr .95fr .9fr .8fr;
      gap: 1px;
      background: var(--line-soft);
    }
    .war-card {
      min-height: 154px;
      padding: 14px;
      background: #0d1118;
    }
    .war-card.full { grid-column: 1 / -1; }
    .war-card h3 { margin: 10px 0 0; font-size: 20px; line-height: 1.15; }
    .war-card p { margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
    .war-label { color: var(--faint); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
    .war-kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 10px; margin-top: 10px; font-size: 12px; }
    .war-kv span { color: var(--faint); }
    .war-kv strong { color: var(--text); font-weight: 800; }
    .war-events { display: grid; gap: 8px; margin-top: 10px; }
    .war-event { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
    .war-event:last-child { padding-bottom: 0; border-bottom: 0; }
    .war-event strong { font-size: 12px; line-height: 1.4; }
    .war-event span { color: var(--muted); font-size: 11px; }
    .war-mini-list { display: grid; gap: 6px; margin-top: 10px; }
    .war-mini-list button {
      width: 100%;
      min-height: 28px;
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 8px;
      padding: 5px 7px;
      border-radius: 7px;
      border: 1px solid var(--line-soft);
      background: #0b0f15;
      color: var(--text);
      cursor: pointer;
      text-align: left;
    }
    .war-mini-list button:hover { border-color: #3b4a60; background: #121923; }
    .war-mini-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
    .war-mini-list strong { font-size: 12px; }
    .health-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
    .health-item {
      min-height: 34px;
      padding: 7px 8px;
      border-radius: 7px;
      background: #0b0f15;
      border: 1px solid var(--line-soft);
      font-size: 12px;
    }
    .health-item strong { display: block; font-size: 11px; color: var(--faint); }
    .health-item span { display: block; margin-top: 3px; font-weight: 900; }
    .health-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .market-map {
      width: min(1500px, calc(100% - 48px));
      margin: 18px auto 0;
      background: rgba(16, 20, 27, .96);
      border: 1px solid var(--line-soft);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .market-map-head {
      min-height: 54px;
      padding: 13px 15px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      border-bottom: 1px solid var(--line-soft);
      background: #0d1219;
    }
    .market-map-head h2 { margin: 0; font-size: 14px; font-weight: 900; }
    .market-map-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
    .market-map-actions { display: flex; align-items: center; gap: 8px; }
    .market-map-frame {
      width: 100%;
      height: clamp(300px, 42vh, 420px);
      border: 0;
      display: block;
      background: #05070a;
    }
    .market-map-fallback {
      min-height: 220px;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 28px;
      background: #05070a;
      border-top: 1px solid var(--line-soft);
      color: var(--muted);
      text-align: center;
    }
    .market-map-fallback strong {
      display: block;
      margin-bottom: 8px;
      color: var(--text);
      font-size: 15px;
    }
    .market-map-fallback span {
      display: block;
      line-height: 1.7;
      font-size: 13px;
    }
    .market-map.offline .market-map-frame { display: none; }
    .market-map.offline .market-map-fallback { display: flex; }
    .market-map.collapsed .market-map-frame,
    .market-map.collapsed .market-map-fallback { display: none; }

    main {
      width: min(1500px, 100%);
      margin: 0 auto;
      padding: 22px 24px 34px;
      display: grid;
      grid-template-columns: 380px minmax(0, 1fr);
      gap: 18px;
    }
    .stack { display: grid; gap: 16px; align-content: start; }
    .workspace-stack { min-width: 0; }
    .grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, .82fr); gap: 16px; align-items: start; }
    .grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

    .mobile-page-title { display: none; }
    .mobile-page-title h2 { margin: 0; font-size: 18px; line-height: 1.2; }
    .mobile-page-title p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

    .panel {
      background: rgba(16, 20, 27, .96);
      border: 1px solid var(--line-soft);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .panel-head {
      min-height: 52px; padding: 14px 15px;
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
      border-bottom: 1px solid var(--line-soft);
    }
    .panel-title { margin: 0; font-size: 14px; font-weight: 900; }
    .panel-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
    .panel-body { padding: 14px; }

    .tabs { display: flex; gap: 4px; padding: 4px; background: #0b0f15; border: 1px solid var(--line-soft); border-radius: 7px; }
    .tab {
      min-height: 30px; padding: 0 11px; border-radius: 5px;
      color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800;
    }
    .tab.active { color: var(--text); background: var(--surface-3); }
    .tab-view { display: none; }
    .tab-view.active { display: block; }

    .field-row { display: flex; gap: 8px; align-items: center; }
    .input, textarea {
      width: 100%; min-height: 38px; border-radius: 7px; border: 1px solid var(--line);
      background: #0b0f15; color: var(--text); padding: 9px 11px; outline: none;
    }
    textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
    .input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(74, 163, 255, .15); }

    .metric {
      min-height: 92px; padding: 13px;
      background: #0d1219; border: 1px solid var(--line-soft); border-radius: 8px;
    }
    .metric .label { color: var(--muted); font-size: 12px; }
    .metric .value { margin-top: 9px; font-size: 24px; font-weight: 900; line-height: 1; }
    .metric .hint { margin-top: 8px; color: var(--faint); font-size: 12px; }

    .decision-hero {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 14px;
      align-items: center;
      padding: 14px;
      background: #0d1219;
      border: 1px solid var(--line-soft);
      border-radius: 8px;
    }
    .decision-hero h3 { margin: 8px 0 0; font-size: 20px; }
    .decision-hero p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
    .decision-score { text-align: right; min-width: 150px; }
    .decision-score .value { font-size: 28px; font-weight: 900; }
    .decision-score .label { margin-top: 6px; color: var(--muted); font-size: 12px; }
    .decision-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      margin-top: 12px;
    }
    .decision-card {
      min-height: 116px;
      padding: 12px;
      background: #0d1219;
      border: 1px solid var(--line-soft);
      border-radius: 8px;
      cursor: pointer;
    }
    .decision-card:hover { border-color: #3b4a60; background: #121925; }
    .decision-card h3 { margin: 8px 0 0; font-size: 14px; }
    .decision-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
    .scenario-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 8px;
      margin-top: 12px;
    }
    .scenario-item {
      padding: 11px;
      background: #0b0f15;
      border: 1px solid var(--line-soft);
      border-radius: 8px;
    }
    .scenario-item strong { display: block; font-size: 12px; }
    .scenario-item span { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.5; }
    .exit-table-wrap {
      margin-top: 12px;
      overflow: auto;
      border: 1px solid var(--line-soft);
      border-radius: 8px;
      background: #0b0f15;
    }
    .exit-table { min-width: 720px; }
    .exit-table th { background: #0b0f15; }
    .exit-table td { background: transparent; }

    .table-wrap { overflow: auto; max-height: 560px; }
    table { width: 100%; border-collapse: collapse; }
    th {
      position: sticky; top: 0; z-index: 1;
      padding: 9px 10px; text-align: left;
      color: var(--faint); background: #0d1219; border-bottom: 1px solid var(--line);
      font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    }
    td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); font-size: 13px; vertical-align: middle; }
    tr[data-clickable="true"] { cursor: pointer; }
    tr[data-clickable="true"]:hover td { background: #141c28; }
    .num { text-align: right; font-variant-numeric: tabular-nums; }
    .name-cell strong { display: block; font-size: 13px; }
    .name-cell span { color: var(--muted); font-size: 12px; }

    .pill {
      display: inline-flex; align-items: center; gap: 6px;
      min-height: 24px; padding: 0 8px; border-radius: 999px;
      border: 1px solid var(--line); background: #0d1219; color: var(--muted);
      font-size: 12px; font-weight: 800; white-space: nowrap;
    }
    .pill.green { color: var(--green); border-color: rgba(72, 213, 151, .35); background: rgba(72, 213, 151, .08); }
    .pill.red { color: var(--red); border-color: rgba(255, 107, 115, .36); background: rgba(255, 107, 115, .08); }
    .pill.amber { color: var(--amber); border-color: rgba(244, 189, 80, .36); background: rgba(244, 189, 80, .08); }
    .pill.blue { color: var(--blue); border-color: rgba(74, 163, 255, .36); background: rgba(74, 163, 255, .08); }
    .pill.violet { color: var(--violet); border-color: rgba(154, 140, 255, .36); background: rgba(154, 140, 255, .08); }

    .list { display: grid; gap: 9px; }
    .list-summary { color: var(--muted); font-size: 12px; padding: 0 2px 2px; }
    .trade-filter { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
    .trade-filter .tab { border: 1px solid var(--line-soft); background: #0b0f15; }
    .trade-filter .tab.active { background: var(--surface-3); color: var(--text); border-color: var(--line); }
    .list-item {
      padding: 12px; border: 1px solid var(--line-soft); background: #0d1219; border-radius: 8px;
    }
    .list-item-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
    .list-item h3 { margin: 0; font-size: 13px; line-height: 1.35; }
    .list-item p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

    .bar { height: 7px; background: #0a0e14; border-radius: 999px; overflow: hidden; border: 1px solid var(--line-soft); }
    .bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--green)); }
    .spark { width: 100%; height: 96px; display: block; border: 1px solid var(--line-soft); border-radius: 8px; background: #0b0f15; }
    .empty, .error {
      padding: 28px 16px; text-align: center; color: var(--muted);
      border: 1px dashed var(--line); border-radius: 8px; background: #0d1219;
      font-size: 13px; line-height: 1.55;
    }
    .error { color: #ffafb4; border-color: rgba(255, 107, 115, .35); }

    .detail-hero {
      display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start;
      padding: 16px; background: #0d1219; border-bottom: 1px solid var(--line-soft);
    }
    .detail-hero h2 { margin: 0; font-size: 24px; }
    .detail-hero .meta { margin-top: 6px; color: var(--muted); font-size: 13px; }
    .signal-box { text-align: right; min-width: 160px; }
    .signal-box .label { color: var(--muted); font-size: 12px; }
    .signal-box .signal { margin-top: 8px; font-size: 18px; font-weight: 900; }

    .mobile-nav { display: none; }
    .toast {
      position: fixed; right: 18px; bottom: 18px; z-index: 50;
      max-width: 360px; padding: 12px 14px; border-radius: 8px;
      background: #121923; border: 1px solid var(--line); box-shadow: var(--shadow);
      color: var(--text); font-size: 13px; display: none;
    }
    .toast.show { display: block; }
    .good { color: var(--green); }
    .bad { color: var(--red); }
    .warn { color: var(--amber); }

    @media (max-width: 1160px) {
      main { grid-template-columns: 1fr; }
      .grid-2 { grid-template-columns: 1fr; }
      .status-strip { grid-template-columns: 1fr 1fr; }
      .status-item:last-child { display: none; }
    }
    @media (max-width: 720px) {
      body { padding-bottom: 72px; }
      .topbar { height: auto; min-height: 60px; padding: 12px 14px; align-items: start; }
      .brand p { display: none; }
      .top-actions .btn:not(.icon) { display: none; }
      .status-strip { grid-template-columns: 1fr; padding: 1px 12px 0; }
      .status-item { min-height: 66px; padding: 12px; }
      .war-room { width: calc(100% - 24px); margin-top: 14px; }
      .war-room-head { align-items: flex-start; }
      .war-room-grid { grid-template-columns: 1fr; }
      .war-card { min-height: auto; }
      .health-grid { grid-template-columns: 1fr 1fr; }
      .market-map { width: calc(100% - 24px); margin-top: 14px; }
      .market-map-head { align-items: flex-start; }
      .market-map-actions { flex-shrink: 0; }
      .market-map-frame { height: 280px; }
      main { padding: 14px 12px 24px; }
      .mobile-page-title.active {
        display: block;
        padding: 2px 2px 0;
      }
      .grid-3 { grid-template-columns: 1fr; }
      .decision-hero { grid-template-columns: 1fr; }
      .decision-score { text-align: left; }
      .decision-grid { grid-template-columns: 1fr; }
      .scenario-grid { grid-template-columns: 1fr; }
      .detail-hero { grid-template-columns: 1fr; }
      .signal-box { text-align: left; }
      .mobile-nav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        display: grid; grid-template-columns: repeat(4, 1fr);
        background: rgba(9, 11, 15, .94); border-top: 1px solid var(--line); backdrop-filter: blur(18px);
      }
      .mobile-nav button {
        min-height: 58px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 900;
      }
      .mobile-nav button.active { color: var(--text); background: rgba(74, 163, 255, .08); box-shadow: inset 0 2px 0 var(--blue); }
      [data-mobile-section] { display: none; }
      [data-mobile-section].active { display: block; }
    }

    /* ── 隔夜外盤訊號 ──────────────────────────────────────── */
    .overseas-room {
      width: min(1500px, calc(100% - 48px));
      margin: 18px auto 0;
      background: rgba(16, 20, 27, .96);
      border: 1px solid var(--line-soft);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .overseas-head {
      display: flex; align-items: center; justify-content: space-between;
      padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
    }
    .overseas-head h2 { margin: 0; font-size: 14px; font-weight: 900; }
    .overseas-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
    .overseas-actions { display: flex; gap: 8px; }
    .overseas-body { padding: 10px 18px 16px; }
    .overseas-group-title { margin: 10px 0 6px; font-size: 12px; font-weight: 800; color: var(--muted); }
    .overseas-row {
      display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
      padding: 8px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13px;
    }
    .overseas-row:last-child { border-bottom: none; }
    .overseas-row .oname { font-weight: 700; }
    .overseas-row .obiz { color: var(--muted); font-size: 12px; }
    .overseas-row .otw { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; margin-top: 4px; }
    .overseas-muted-list { color: var(--muted); font-size: 12px; line-height: 2; }
