  :root{ --bg:#0f172a; --card:#0b1220; --muted:#94a3b8; --text:#e5e7eb; --brand:#6366f1; --brand2:#22d3ee; --radius:16px; --content-max: 720px; 
          --hist-gap: 6px;
          --hist-cols: minmax(0,2fr) minmax(0,1fr) minmax(0,1.5fr) minmax(0,1fr);
    }
    *{box-sizing:border-box}
    html,body{height:100%}
    body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;background:var(--bg);color:var(--text)}
    a{color:inherit;text-decoration:none}
    .container{max-width:var(--content-max);margin:0 auto;padding:0 16px}
    .containerx{max-width:var(--content-max);margin:0 auto;padding:0}

    .top{position:sticky;top:0;z-index:40;background:#0f172a;border-bottom:1px solid rgba(148,163,184,.18);backdrop-filter:blur(8px)}
    .top-wrap{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 16px}
    .brand{display:flex;align-items:center;gap:10px;font-weight:900;cursor:pointer}
    .avatar{width:25px;height:25px;border-radius:50%}

    .tabbar{position:sticky;text-align:center;top:0;z-index:39;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0;width:100%;padding:8px 0;background:rgba(15,23,42,.85);backdrop-filter:blur(8px);border-bottom:1px solid rgba(148,163,184,.18)}
    .tab-link{all:unset;cursor:pointer;font-size:0.85em;padding:10px 12px;background:#0b1220;color:#cbd5e1;font-weight:500}
    .tab-link.active{background:linear-gradient(135deg,var(--brand),var(--brand2));color:white}
    .tab-panel{display:none}
    .tab-panel.active{display:block}

    .summary{padding:12px 0}
    .cards{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}
    @media(min-width:560px){.cards{grid-template-columns:repeat(3,1fr)}}
    @media(min-width:860px){.cards{grid-template-columns:repeat(4,1fr)}}
    .card{background:#0b1220;border:1px solid rgba(148,163,184,.2);border-radius:14px;padding:12px}
    .card h4{margin:0 0 6px;font-size:12px;color:#93a4b8;font-weight:600}
    .card .val{font-variant-numeric:tabular-nums;font-size:16px;font-weight:800}
    .sub{font-size:12px;color:#93a4b8;margin-top:3px}

    .section-title{margin:8px 0 6px;color:#93a4b8;font-weight:700}
    .list{display:grid;grid-template-columns:1fr;gap:6px;margin-bottom:96px}
    .row{display:grid;grid-template-columns:1fr auto auto;column-gap:10px;align-items:center;background:#0b1220;border:1px solid rgba(148,163,184,.18);border-radius:12px;padding:10px 12px}
    .row .name{font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    .row .pnl,.row .ret{font-variant-numeric:tabular-nums;text-align:right}
    .meta{grid-column:1 / -1;color:#93a4b8;margin-top:6px;font-size:12px}
    .meta-grid{display:grid;grid-template-columns:3fr 3fr 4fr;gap:6px;padding-top:6px;font-size:13px;align-items:flex-start}
    .meta-grid b{color:#e5e7eb;font-weight:600;font-size:14px;white-space:nowrap}
    .meta-grid .lbl{font-size:11px;color:#93a4b8;opacity:.75}
    .meta-grid > div:last-child{text-align:right}

    .pos{color:#ef4444} .neg{color:#3b82f6}

    .footer{position:fixed;left:0;right:0;bottom:0;height:56px;background:#121822;border-top:1px solid #1f2937;display:flex;justify-content:center;align-items:center;z-index:1000}
    .nav{display:flex;justify-content:space-around;align-items:center;width:100%;max-width:480px}
    .nav a{color:#94a3b8;font-size:14px;font-weight:500;padding:8px 10px}
    .nav a.active{color:#10b981}
    main{padding-bottom:72px}

    ::-webkit-scrollbar{width:6px;height:6px}
    ::-webkit-scrollbar-track{background:rgba(255,255,255,.05);border-radius:4px}
    ::-webkit-scrollbar-thumb{background:rgba(148,163,184,.4);border-radius:4px}
    ::-webkit-scrollbar-thumb:hover{background:rgba(148,163,184,.7)}

    .pulse{animation:flash .4s ease-out}
    @keyframes flash{0%{box-shadow:0 0 0 0 rgba(34,211,238,.6)}100%{box-shadow:0 0 0 16px rgba(34,211,238,0)}}

/* PNL grid header & rows */
.pnl-head, .pnl-row{
  display:grid;

  grid-template-columns: 1.2fr 1.6fr 1.4fr 1fr; /* 날짜 / 잔액 / 수익 / 수익률 */
  column-gap:5px;
  align-items:center;
}
.pnl-head{
  position: sticky;
  top: 0;                /* 탭 내부 기준 */
  background:#0b1220;
  color:#cbd5e1;
  z-index: 2;
  font-weight:600;
  padding:10px 12px;
  border-bottom:1px solid rgba(148,163,184,.25);
  border-top-left-radius:12px;
  border-top-right-radius:12px;
  font-size:12px;
}
.pnl-row{
  background:#0b1220;
  border-bottom:1px solid rgba(148,163,184,.25);
  padding:10px 10px;

}
.cell-right{
  text-align:right;
  font-variant-numeric:tabular-nums;
}
/* ───────────── 헤더 ───────────── */
.history-head {
  position: sticky;
  top: 0;
  background:#0b1220;
  color:#cbd5e1;
  z-index:2;
  font-weight:600;
  font-size:12px;
  padding:8px 12px;
  border-bottom:1px solid rgba(148,163,184,.2);

  display:grid;
  grid-template-columns: 2fr 1fr 1.5fr 1fr; /* 코인 / 매수매도 / USDK / 상태 */
  column-gap: 8px;
  align-items:center;
}

/* ───────────── 단일 행(테이블형) ───────────── */
.history-row {
  background:#0b1220;
  border:1px solid rgba(148,163,184,.18);
  padding:12px 12px;
  font-size:12px;

  display:grid;
  grid-template-columns: 2fr 1fr 1.5fr 1fr;
  column-gap: 8px;
  align-items:center;
}

.history-row .cell-right { text-align:right; font-variant-numeric:tabular-nums; }
.history-row .buy { color:#ef4444; font-weight:600; }  /* 빨강 */
.history-row .sell { color:#3b82f6; font-weight:600; } /* 파랑 */

/* ───────────── 2줄 카드(상세형) ───────────── */
.history-row2 {
  background:#0b1220;
  border-bottom:1px solid rgba(148,163,184,.2);
  padding:14px 12px;
  display:flex;
  flex-direction:column;
  gap:2px;
  font-size:12px;

}

.history-top {
  display:grid;
  grid-template-columns: 2fr 1fr 1.5fr 1fr; /* 헤더와 동일 */
  column-gap: 8px;
  align-items:center;
}

.history-bottom {
  display:grid;
  grid-template-columns: 1fr 1.5fr;
  column-gap: 8px;
  color:#94a3b8;
  font-size:12px;
  padding:4px 0;
  margin-top:3px;
}

/* ───────────── 색상 / 정렬 ───────────── */
.history-top .buy { color:#ef4444; font-weight:600; }   /* 빨강 */
.history-top .sell { color:#3b82f6; font-weight:600; }  /* 파랑 */
.history-top .pos { color:#10b981; font-weight:600; }   /* DONE */
.history-top .neg { color:#facc15; font-weight:600; }   /* OPEN */
.cell-right { text-align:right; font-variant-numeric:tabular-nums; }


/* topup history */
/* ───────────── 헤더 ───────────── */
.topup-head {
  position: sticky;
  top: 0;
  background:#0b1220;
  color:#cbd5e1;
  z-index:2;
  font-weight:600;
  font-size:12px;
  padding:8px 12px;
  display:grid;
  grid-template-columns: 2fr 1fr 1.5fr; /* 코인 / 매수매도 / USDK / 상태 */
  column-gap: 8px;
}

/* ───────────── 단일 행(테이블형) ───────────── */
.topup-row {
  background:#0b1220;
  border:1px solid rgba(148,163,184,.18);
  padding:12px 12px;
  font-size:12px;
  display:grid;
  grid-template-columns: 2fr 1fr 1.5fr;
  column-gap: 8px;
  align-items:center;
}

.topup-row .cell-right { text-align:right; font-variant-numeric:tabular-nums; }
.topup-row .buy { color:#ef4444; font-weight:600; }  /* 빨강 */
.topup-row .sell { color:#3b82f6; font-weight:600; } /* 파랑 */

/* ------------모달 CSS ---------------- */
/* 모달 배경 */
  .modal {
    display: none; /* 기본 숨김 */
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    justify-content: center;
    align-items: center;
  }

  /* 모달 내부 박스 */
  .modal-content {
    background: #1e293b;
    border-radius: 12px;
    padding: 20px 24px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.4);
    color: #e5e7eb;
    max-width: 280px;
    width: 90%;
  }

  /* 버튼 영역 */
  .modal-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;

  }
  /* ⬇️ 이 부분을 추가하세요. 
    .modal-buttons 안의 모든 자식 요소(버튼)에 적용됩니다.
  */
  .modal-buttons > * {
    flex: 1; 
    /* flex: 1은 flex-grow: 1, flex-shrink: 1, flex-basis: 0% 와 같습니다. */
    /* 이렇게 하면 두 버튼이 1:1 비율로 공간을 나눠 가집니다. */
  }
/* 공통 버튼 기본값 */
  .btn {
    height: 40px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    box-sizing: border-box;
    transition: all 0.2s ease;
  }

  /* 초기화 (회색 계열) */
  .btn.ghost {
    background: #334155;                    /* 짙은 회색 배경 */
    color: #e5e7eb;                         /* 밝은 글씨 */
    border: 1px solid rgba(148,163,184,.35);
  }
  .btn.ghost:hover {
    filter: brightness(1.15);
  }

  /* 매수 (붉은 계열) */
  .btn.primary {
    background: linear-gradient(135deg, #ef4444, #b91c1c); /* 빨강 gradient */
    color: #fff;
    border: 1px solid #b91c1c;
  }
  .btn.primary:hover {
    filter: brightness(1.15);
  }

  /* CTA(충전) 카드 */
.card.cta {
  position: relative;
  background: #3b82f6; /*  rgb(65, 65, 250) rgb(52, 126, 20)  보라 #8b5cf6 */
  border: none;
  box-shadow: 0 6px 20px rgba(34,211,238,0.25);
  cursor: pointer;
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card.cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(34,211,238,0.35);
}
.card.cta:focus{
  outline: 2px solid rgba(34,211,238,.9);
  outline-offset: 3px;
}
.card .cta-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
}
/* 제목만 살짝 밝은 하늘색으로 대비 */
.card.cta h4 {
  color: #aaccfa;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.card.cta .val{ font-size:18px } /* 살짝 크게 */
  body {
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
  }
body:not(.app-ready) .container { visibility: hidden; }