:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --primary:#0ea5e9;
  --danger:#ef4444;
  --ok:#16a34a;
  --warn:#f59e0b;

  --shadow: 0 10px 28px rgba(15, 23, 42, .08);
  --radius:16px;

  --content-max: 1140px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
  font-size:15px;
  line-height:1.45;
}

a{color:inherit}
.mono{font-variant-numeric: tabular-nums; font-feature-settings:"tnum" 1;}
.muted{color:var(--muted)}
.hidden{display:none !important}

/* ---- Progress (top) ---- */
.top-progress{
  position:fixed;
  top:0; left:0; right:0;
  height:34px;
  background:#fff;
  border-bottom:1px solid var(--line);
  z-index:999;
  overflow:hidden;
}
.top-progress-bar{
  position:absolute;
  left:-40%;
  top:0;
  height:3px;
  width:40%;
  background: rgba(14,165,233,1);
  animation: slide 1.05s ease-in-out infinite;
}
@keyframes slide{
  0%{left:-40%}
  50%{left:35%}
  100%{left:100%}
}
.top-progress-text{
  position:absolute;
  left:12px;
  bottom:6px;
  font-size:12px;
  font-weight:900;
  color:#0369a1;
}

/* ---- Layout ---- */
.topbar{
  position:sticky; top:0;
  background:#fff;
  border-bottom:1px solid var(--line);
  z-index:10;
}
.topbar-inner{
  max-width: var(--content-max);
  margin:0 auto;
  padding:14px 14px;
  display:flex; align-items:flex-start; justify-content:space-between;
  gap:12px;
}
.app-title{font-size:18px; font-weight:950; letter-spacing:-0.2px}
.subline{font-size:12px; color:var(--muted); margin-top:3px}
.subline b{color:#0f172a}
.btnrow{display:flex; gap:8px; align-items:center; flex-wrap:wrap}

.container{
  max-width: var(--content-max);
  margin:0 auto;
  padding:14px 14px 24px;
}

@media (max-width: 420px){
  body{font-size:14px}
}

/* ---- Buttons / Inputs ---- */
.btn{
  appearance:none;
  border:1px solid var(--line);
  background:#fff;
  border-radius:999px;
  padding:10px 12px;
  font-weight:900;
  font-size:13px;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  gap:8px;
}
.btn:hover{background: rgba(100,116,139,.06)}
.btn:active{transform: translateY(1px)}
.btn:disabled{opacity:.55; cursor:not-allowed}
.btn.primary{
  border-color: rgba(14,165,233,.25);
  background: rgba(14,165,233,.12);
  color:#0369a1;
}
.btn.ghost{
  border-color: rgba(100,116,139,.25);
  background: rgba(100,116,139,.08);
  color:#334155;
}
.btn.danger{
  border-color: rgba(239, 68, 68, .25);
  background: rgba(239, 68, 68, .08);
  color:#991b1b;
}
.btn.is-off{ opacity: .65; }

.ctl-select, .ctl-input{
  border:1px solid var(--line);
  background:#fff;
  border-radius:999px;
  padding:8px 12px;
  font-weight:900;
  font-size:12px;
  color:#0f172a;
}
.ctl-input{
  font-weight:700;
  min-width: 220px;
}
@media (max-width: 520px){
  .ctl-input{min-width: 140px; flex: 1;}
}

/* ---- Controls ---- */
.controls{
  display:flex;
  flex-wrap:wrap;
  gap:10px 12px;
  align-items:center;
  padding:12px 12px;
  margin: 10px 0 14px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .05);
}
.ctl{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  font-weight:900;
  color:#0f172a;
}
.ctl input[type="checkbox"]{
  width:18px;
  height:18px;
  accent-color: var(--primary);
}
.ctl-label{ color: var(--muted); font-weight:900; }

/* ---- Theme cards (index) ---- */
.grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:12px;
}
@media (max-width: 760px){
  .grid{grid-template-columns: 1fr}
}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  cursor:pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.card:hover{transform: translateY(-1px); box-shadow: 0 14px 32px rgba(15,23,42,.10);}
.card:active{transform: translateY(0px)}

.card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 12px;
  background: linear-gradient(135deg, rgba(14,165,233,.18), rgba(14,165,233,.05));
  border-bottom:1px solid rgba(226,232,240,.8);
}
.card-title{
  font-size:14px;
  font-weight:950;
  line-height:1.25;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient: vertical;
  overflow:hidden;
}
.card-badges{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:6px;
  flex: 0 0 auto;
}
.badge{
  font-size:12px;
  font-weight:950;
  color:#0369a1;
  background: rgba(14,165,233,.12);
  padding:4px 10px;
  border-radius:999px;
  white-space:nowrap;
}
.badge.muted{
  color:#334155;
  background: rgba(100,116,139,.10);
}

.rows{padding:10px 12px 12px}
.srow{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:10px 0;
  border-bottom:1px dashed rgba(226,232,240,.95);
}
.srow:last-child{border-bottom:none}
.sleft{min-width:0}
.sname{
  font-weight:950;
  font-size:13px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.ssub{
  margin-top:4px;
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  font-size:12px;
  color:var(--muted);
}
.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(226,232,240,.95);
  background: rgba(148,163,184,.08);
  color:#334155;
  font-weight:850;
}
.chip strong{font-weight:950; color:#0f172a}
.sright{
  flex: 0 0 92px;
  text-align:right;
  white-space:nowrap;
}
.rate{
  font-weight:950;
  font-size:14px;
  letter-spacing:-0.2px;
}
.rate.pos{color: var(--ok);}
.rate.neg{color: #dc2626;}
.rate.neu{color:#334155;}
.small{
  margin-top:4px;
  font-size:11px;
  color:var(--muted);
  font-weight:850;
}

/* ---- Theme detail ---- */
.detail-title{
  font-size:18px;
  font-weight:950;
  letter-spacing:-0.2px;
  margin: 2px 0 4px;
}
.detail-meta{
  font-size:12px;
  color:var(--muted);
  margin-bottom:12px;
}
.detail-list{
  background:#fff;
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.drow{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:14px 14px;
  border-bottom:1px solid rgba(226,232,240,.9);
}
.drow:last-child{border-bottom:none}
.dleft{min-width:0}
.dname{
  font-weight:950;
  font-size:14px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.dchips{
  margin-top:8px;
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.dflow{
  margin-top:10px;
  font-size:12px;
  color:var(--muted);
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.dright{
  flex: 0 0 auto;
  text-align:right;
  white-space:nowrap;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:8px;
}
.action-row{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.link{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  font-weight:950;
  color:#0369a1;
  text-decoration:none;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(14,165,233,.22);
  background: rgba(14,165,233,.08);
}
.link:hover{background: rgba(14,165,233,.12)}

/* ---- Record page ---- */
.record-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  padding:12px 12px;
  margin: 10px 0 10px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .05);
}
.record-toolbar-left{display:flex; gap:8px; align-items:center; flex-wrap:wrap; flex: 1;}
.record-toolbar-right{display:flex; gap:8px; align-items:center; flex-wrap:wrap;}
.record-meta{font-size:12px; color:var(--muted); margin: 6px 2px 10px;}
.record-wrap{
  background:#fff;
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:auto;
}
.record-empty{padding:14px; color:var(--muted); font-weight:900;}

.record-table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
  min-width: 980px;
}
.record-table thead th{
  position:sticky;
  top:0;
  background:#fff;
  z-index:2;
  text-align:left;
  padding:12px 12px;
  border-bottom:1px solid var(--line);
  font-size:12px;
  color:#334155;
  white-space:nowrap;
}
.record-table thead th.clickable{cursor:pointer}
.record-table thead th.clickable:hover{background: rgba(100,116,139,.06)}
.record-table tbody td{
  padding:12px 12px;
  border-bottom:1px solid rgba(226,232,240,.85);
  vertical-align:top;
}
.record-table tbody tr:nth-child(2n){
  background: rgba(148,163,184,.06);
}
.record-table tbody tr:hover{
  background: rgba(14,165,233,.06);
}

.td-num{ text-align:right; font-variant-numeric: tabular-nums; }
.td-center{ text-align:center; }
.record-theme{
  font-weight:950;
  color:#0369a1;
  text-decoration:none;
}
.record-stock{font-weight:950;}
.record-sub{font-size:11px; color:var(--muted); margin-top:4px}
.record-link{font-weight:950; color:#0369a1; text-decoration:none}
.record-link:hover{text-decoration:underline}
.btn-del{padding:8px 10px; font-size:12px}

/* ---- Footer note ---- */
.footer-note{
  margin-top:12px;
  font-size:11px;
  color:var(--muted);
  padding:10px 2px;
  line-height:1.45;
}

/* ---- Toast ---- */
.toast-host{
  position:fixed;
  left:12px;
  right:12px;
  bottom:14px;
  display:flex;
  flex-direction:column;
  gap:8px;
  z-index:1000;
  pointer-events:none;
}
.toast{
  pointer-events:auto;
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow: var(--shadow);
  padding:10px 12px;
}
.toast-title{
  font-size:13px;
  font-weight:950;
}
.toast-sub{
  margin-top:4px;
  font-size:12px;
  color:var(--muted);
  line-height:1.35;
  white-space:pre-line;
}
.toast.error{
  border-color: rgba(239, 68, 68, .25);
  background: rgba(239, 68, 68, .06);
}
