@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-page:    #0B1120;
  --bg-card:    #131D2E;
  --bg-card2:   #1A2538;
  --line:       rgba(255,255,255,.08);
  --line-hover: rgba(255,255,255,.15);
  --cyan:       #26FEFE;
  --blue:       #59B0FE;
  --gradient:   linear-gradient(90deg, #59B0FE, #26FEFE);
  --text-main:  #FFFFFF;
  --text-sec:   rgba(255,255,255,.54);
  --text-dim:   rgba(255,255,255,.28);
}

* { margin: 0; padding: 0; box-sizing: border-box; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent; }
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
body {
  background: var(--bg-page); color: var(--text-main);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px; position: relative;
}

/* Ambient glow */
body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 120% 80% at 30% 0%, rgba(60,120,220,.28) 0%, transparent 55%),
    radial-gradient(ellipse 100% 70% at 85% 15%, rgba(90,60,180,.22) 0%, transparent 50%),
    radial-gradient(ellipse 90% 60% at 60% 100%, rgba(38,200,254,.12) 0%, transparent 45%);
}

/* Z-index layering */
.topbar, .main-layout { position: relative; z-index: 1; }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: rgba(11, 17, 32, .65);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}
.topbar .title {
  font-size: 16px; font-weight: 700; letter-spacing: -.02em;
  background: var(--gradient); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-sec); }
.topbar-right a { color: var(--blue); text-decoration: none; transition: color .2s; }
.topbar-right a:hover { color: var(--cyan); }

.auto-refresh-toggle {
  display: flex; align-items: center; gap: 4px; cursor: pointer; user-select: none;
  color: var(--text-sec);
}
.auto-refresh-toggle input { cursor: pointer; accent-color: var(--cyan); }

/* ---- Layout ---- */
.main-layout { display: flex; height: calc(100vh - 56px); overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 16px 24px; }
.sidebar {
  width: 220px; border-left: 1px solid var(--line); overflow-y: auto;
  background: rgba(19, 29, 46, .5);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

/* ---- Section header with help btn ---- */
.section-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.section-label {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600;
}
.inline-help-btn {
  width: 20px; height: 20px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line);
  color: var(--text-dim); font-size: 11px; font-weight: 800;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: all .25s; font-family: inherit; padding: 0; line-height: 1;
}
.inline-help-btn:hover { border-color: rgba(38,254,254,.3); color: var(--cyan); }
.sidebar-help { margin: 0 8px 8px; border-radius: 10px; padding: 12px 14px; font-size: 11px; }

/* ---- Sector Cards ---- */
.sector-cards { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.sector-card {
  flex: 1; min-width: 100px; padding: 12px 16px; border-radius: 14px;
  text-align: center;
  background: rgba(19, 29, 46, .5); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: all .25s;
}
.sector-card:hover { border-color: var(--line-hover); transform: translateY(-2px); }
.sector-card .sector-name { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.sector-card .sector-label {
  font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 6px; display: inline-block;
}
.sector-card .sector-label.bull { background: rgba(220,70,60,.15); color: #ff8a80; }
.sector-card .sector-label.bear { background: rgba(40,180,100,.15); color: #70e0a0; }
.sector-card .sector-label.neutral { background: rgba(255,255,255,.06); color: var(--text-sec); }

/* ---- Combo filter ---- */
.combo-filter {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
  padding: 10px 16px; border-radius: 12px;
  background: rgba(11, 17, 32, .5);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
}
.filter-label {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600;
}
.combo-btn {
  background: transparent; color: var(--text-sec);
  border: 1px solid var(--line); padding: 4px 14px;
  border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 500;
  transition: all .25s ease; font-family: inherit;
}
.combo-btn:hover { border-color: rgba(38,254,254,.3); color: var(--text-main); }
.combo-btn.active {
  background: rgba(38,254,254,.08); color: var(--cyan);
  border-color: rgba(38,254,254,.4);
}
.filter-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

/* Help button & panel */
.help-btn { font-weight: 800; min-width: 28px; text-align: center; }
.combo-help {
  background: rgba(19, 29, 46, .6); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 16px 20px; margin-bottom: 14px; font-size: 12px; color: var(--text-sec); line-height: 1.8;
}
.combo-help .help-title { font-size: 13px; font-weight: 700; color: var(--text-main); margin: 10px 0 4px; }
.combo-help .help-title:first-child { margin-top: 0; }
.combo-help ul { padding-left: 18px; margin: 4px 0; }
.combo-help li { margin: 2px 0; }
.combo-help b { color: var(--cyan); }

/* ---- Matrix Table ---- */
.matrix-wrap { overflow-x: auto; position: relative; }
.matrix { width: 100%; border-collapse: separate; border-spacing: 0 2px; font-size: 13px; }
.matrix th {
  background: var(--bg-card); color: var(--text-dim);
  padding: 10px 12px; text-align: center;
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--line);
}
.matrix th:first-child, .matrix th:nth-child(2) { text-align: left; }
.matrix td { padding: 0; text-align: center; }

.matrix tbody tr { transition: background .2s; }
.matrix tbody tr:hover td { background: rgba(255,255,255,.02); }

.matrix .sector-group {
  background: var(--bg-card); color: var(--text-dim); font-weight: 700;
  text-align: left; vertical-align: middle; padding: 10px 16px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  border-right: 1px solid var(--line);
}
.matrix .sym-name {
  text-align: left; color: var(--text-sec); white-space: nowrap;
  padding: 10px 16px; background: transparent;
  font-weight: 500; font-size: 13px; transition: color .2s;
}
.matrix tbody tr:hover .sym-name { color: var(--text-main); }

/* ---- State cells ---- */
.state-td { padding: 0 !important; position: relative; }
.state-cell {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; min-height: 42px;
  font-weight: 700; border-left: 1px solid rgba(0,0,0,.15);
  transition: transform .15s;
}
.state-cell .num { font-size: 18px; line-height: 1; }
.state-cell .desc { font-size: 10px; opacity: 0.7; white-space: nowrap; font-weight: 500; }

/* Desaturated translucent fills */
.state-1 { background: rgba(180, 60, 60, .25); color: #e87070; }
.state-3 { background: rgba(220, 70, 60, .30); color: #ff8a80; }
.state-B { background: rgba(180, 140, 70, .20); color: #e0c080; }
.state-2 { background: rgba(160, 140, 40, .20); color: #d0c060; }
.state-A { background: rgba(40, 160, 90, .20); color: #70d0a0; }
.state-C { background: rgba(50, 140, 80, .25); color: #60c890; }
.state-none { background: transparent; color: var(--text-dim); }

/* Resonance: cyan glow */
.resonance {
  outline: 1.5px solid rgba(38, 254, 254, .5);
  outline-offset: -1.5px;
  box-shadow: inset 0 0 12px rgba(38, 254, 254, .08);
}

/* ---- Gate badges ---- */
.gate-badge {
  position: absolute; top: 3px; right: 4px;
  font-size: 9px; padding: 1px 4px; border-radius: 4px;
  font-weight: 700; line-height: 1; cursor: default;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.gate-badge.di  { background: rgba(255,100,100,.35); color: #ffaaaa; }
.gate-badge.tian { background: rgba(100,255,160,.30); color: #a0ffc0; }

/* ---- Extra frequency columns ---- */
.extra-freq { display: none; }
body.show-extra-freq .extra-freq { display: table-cell; }

/* ---- Transitions sidebar ---- */
.sidebar-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; font-size: 13px; font-weight: 700; color: var(--text-main);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 17, 32, .5);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.trans-list { padding: 4px 0; }
.trans-item {
  padding: 8px 16px; border-bottom: 1px solid var(--line);
  transition: background .2s;
}
.trans-item:hover { background: rgba(255,255,255,.03); }
.trans-time { font-size: 11px; color: var(--text-dim); }
.trans-name { font-size: 12px; color: var(--text-sec); margin: 2px 0; }
.trans-label { font-size: 11px; font-weight: 700; }
.trans-label.bull { color: #ff8a80; }
.trans-label.bear { color: #70e0a0; }

.empty-msg { padding: 20px; text-align: center; color: var(--text-dim); font-size: 12px; }
