    :root {
      --bg: #f8fafc;
      --panel: #ffffff;
      --text: #0f172a;
      --muted: #64748b;
      --line: #e2e8f0;
      --primary: #2563eb;
      --primary-soft: #dbeafe;
      --danger: #dc2626;
      --danger-soft: #fee2e2;
      --warn: #ca8a04;
      --warn-soft: #fef3c7;
      --ok: #16a34a;
      --ok-soft: #dcfce7;
      --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
      --radius: 18px;
      --tabbar-h: 62px;
      --safe-top: env(safe-area-inset-top, 0px);
      --safe-bottom: env(safe-area-inset-bottom, 0px);
    }

    * { box-sizing: border-box; }
    html, body {
      margin: 0;
      padding: 0;
      background: var(--bg);
      color: var(--text);
      font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", sans-serif;
    }
    body { -webkit-font-smoothing: antialiased; }
    button, input, textarea, select { font: inherit; }
    button { border: 0; background: none; color: inherit; cursor: pointer; }
    input, textarea, select {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 14px 16px;
      background: #fff;
      color: var(--text);
      outline: none;
    }
    input:focus, textarea:focus, select:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    }
    textarea { min-height: 108px; resize: vertical; }

    .app {
      max-width: 520px;
      margin: 0 auto;
      min-height: 100dvh;
      background: var(--bg);
      position: relative;
    }

    .screen {
      display: none;
      min-height: 100dvh;
      padding: calc(var(--safe-top) + 16px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
    }
    .screen.active { display: block; }

    .header-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 16px;
    }
    .title {
      margin: 0;
      font-size: 28px;
      font-weight: 800;
      letter-spacing: -0.02em;
    }
    .subtitle {
      margin: 6px 0 0;
      color: var(--muted);
      font-size: 14px;
    }

    .row {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .wrap { flex-wrap: wrap; }
    .space {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }
    .stack-8 > * + * { margin-top: 8px; }
    .stack-10 > * + * { margin-top: 10px; }
    .stack-12 > * + * { margin-top: 12px; }

    .card {
      background: var(--panel);
      border: 1px solid rgba(226, 232, 240, 0.8);
      border-radius: var(--radius);
      padding: 16px;
      box-shadow: var(--shadow);
      margin-bottom: 12px;
    }
    .clickable { cursor: pointer; }
    .divider {
      height: 1px;
      background: var(--line);
      margin: 14px 0;
    }

    .section-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 18px 0 12px;
    }
    .section-title h2 {
      margin: 0;
      font-size: 17px;
      font-weight: 800;
    }
    .section-title span,
    .small, .tiny, .muted {
      color: var(--muted);
    }
    .small { font-size: 13px; }
    .tiny { font-size: 12px; }
    .mono { font-variant-numeric: tabular-nums; }

    .icon-btn {
      width: 40px;
      height: 40px;
      border-radius: 12px;
      background: #fff;
      border: 1px solid var(--line);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex: 0 0 auto;
    }
    .icon-glyph { font-size: 20px; line-height: 1; }

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 46px;
      border-radius: 14px;
      padding: 0 16px;
      border: 1px solid transparent;
      font-weight: 700;
      width: 100%;
    }
    .btn.primary {
      background: var(--primary);
      color: #fff;
    }
    .btn.secondary {
      background: var(--primary-soft);
      color: var(--primary);
    }
    .btn.ghost {
      background: #fff;
      border-color: var(--line);
      color: var(--text);
    }
    .btn.danger {
      background: var(--danger);
      color: #fff;
    }
    .btn.text {
      width: auto;
      min-height: auto;
      padding: 0;
      border: 0;
      color: var(--primary);
      background: transparent;
      font-weight: 700;
    }
    .btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    .chip-group {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 12px;
    }
    .chip {
      padding: 10px 14px;
      border-radius: 999px;
      background: #fff;
      border: 1px solid var(--line);
      color: var(--text);
      font-weight: 700;
      white-space: nowrap;
    }
    .chip.active {
      background: var(--primary);
      border-color: var(--primary);
      color: #fff;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      height: 30px;
      border-radius: 999px;
      padding: 0 12px;
      font-size: 12px;
      font-weight: 800;
      white-space: nowrap;
    }
    .badge.tag { background: #f1f5f9; color: #334155; }
    .badge.keep { background: #e0f2fe; color: #0369a1; }
    .badge.shaky { background: #fef3c7; color: #b45309; }
    .badge.invalid { background: #fee2e2; color: #b91c1c; }
    .badge.hold { background: #dcfce7; color: #15803d; }
    .badge.watch { background: #ede9fe; color: #6d28d9; }
    .badge.closed { background: #e2e8f0; color: #334155; }
    .badge.buy { background: #fee2e2; color: #dc2626; }
    .badge.sell { background: #dbeafe; color: #2563eb; }
    .badge.holdings { background: #e0f2fe; color: #0369a1; }
    .badge.totalcost { background: #ede9fe; color: #6d28d9; }
    .badge.avgprice { background: #f1f5f9; color: #334155; }
    .badge.earned { background: #fef3c7; color: #b45309; }
    .badge.due-pre { background: #dbeafe; color: #1d4ed8; }
    .badge.due-today { background: #fee2e2; color: #b91c1c; }
    .badge.due-soon { background: #fef3c7; color: #b45309; }
    .badge.due-late { background: #ede9fe; color: #6d28d9; }

    .metric-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .metric {
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 12px;
      background: #fff;
    }
    .metric .v {
      margin-top: 6px;
      font-size: 18px;
      font-weight: 800;
    }

    .search-box {
      position: relative;
      margin-bottom: 10px;
    }
    .search-icon {
      position: absolute;
      left: 14px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--muted);
    }
    .search-box input {
      padding-left: 40px;
    }

    .list-item {
      padding: 12px 0;
      border-bottom: 1px solid var(--line);
    }
    .list-item:last-child { border-bottom: 0; }

    .note-line {
      line-height: 1.55;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .pnl-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }
    .pnl-profit, .pnl-rate {
      display: inline-flex;
      align-items: center;
      min-height: 30px;
      border-radius: 999px;
      padding: 0 12px;
      font-size: 12px;
      font-weight: 800;
    }
    .pnl-positive {
      background: #fee2e2;
      color: #dc2626;
    }
    .pnl-negative {
      background: #dbeafe;
      color: #2563eb;
    }
    .pnl-neutral {
      background: #f1f5f9;
      color: #334155;
    }

    .fields > * + * { margin-top: 12px; }
    .field label {
      display: block;
      margin-bottom: 8px;
      font-size: 13px;
      color: var(--muted);
      font-weight: 700;
    }
    .field.two {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .inline-field {
      display: grid;
      grid-template-columns: 1fr 108px;
      gap: 8px;
    }

    .warning-box, .danger-box, .ok-box {
      border-radius: 14px;
      padding: 14px;
      font-size: 14px;
      line-height: 1.5;
    }
    .warning-box { background: var(--warn-soft); color: #92400e; }
    .danger-box { background: var(--danger-soft); color: #991b1b; }
    .ok-box { background: var(--ok-soft); color: #166534; }

    .empty {
      text-align: center;
      padding: 28px 18px;
      border: 1px dashed var(--line);
      border-radius: 18px;
      background: rgba(255,255,255,0.7);
    }
    .empty h3 {
      margin: 0 0 8px;
      font-size: 18px;
    }
    .empty p {
      margin: 0 0 14px;
      color: var(--muted);
      line-height: 1.5;
    }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(15,23,42,0.46);
      z-index: 90;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      padding: 12px;
    }
    .modal {
      width: min(520px, 100%);
      max-height: 92dvh;
      overflow: auto;
      background: #fff;
      border-radius: 24px;
      padding: 16px;
      box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
    }
    .modal.center {
      align-self: center;
    }
    .modal-handle {
      width: 46px;
      height: 5px;
      border-radius: 999px;
      background: #cbd5e1;
      margin: 0 auto 12px;
    }
    .modal-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
    }
    .modal-title {
      margin: 0;
      font-size: 20px;
      font-weight: 800;
      letter-spacing: -0.02em;
    }

    .tabbar {
      position: fixed;
      left: 50%;
      bottom: 0;
      transform: translateX(-50%);
      width: min(520px, 100%);
      height: calc(var(--tabbar-h) + var(--safe-bottom));
      padding-bottom: var(--safe-bottom);
      background: rgba(255,255,255,0.96);
      backdrop-filter: blur(10px);
      border-top: 1px solid var(--line);
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      z-index: 40;
    }
    .tab {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 800;
      min-height: 46px;
    }
    .tab .tab-ico {
      display: block;
      font-size: 23px;
      line-height: 1;
    }
    .tab.active { color: var(--primary); }

    .fab {
      position: fixed;
      right: max(20px, calc((100vw - min(520px, 100vw)) / 2 + 20px));
      bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
      width: 58px;
      height: 58px;
      border-radius: 50%;
      background: var(--primary);
      color: #fff;
      box-shadow: 0 18px 30px rgba(37, 99, 235, 0.28);
      z-index: 45;
      font-size: 28px;
      line-height: 1;
    }

    .toast {
      position: fixed;
      left: 50%;
      transform: translateX(-50%) translateY(16px);
      bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 90px);
      background: rgba(15,23,42,0.92);
      color: #fff;
      border-radius: 999px;
      padding: 12px 16px;
      font-size: 13px;
      font-weight: 700;
      opacity: 0;
      pointer-events: none;
      transition: 0.22s ease;
      z-index: 99;
      white-space: nowrap;
      max-width: calc(100vw - 24px);
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .toast.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    .inline-actions-2 {
      display: grid;
      gap: 10px;
      grid-template-columns: 1fr 1fr;
    }

    .trash-icon {
      width: 18px;
      height: 18px;
      display: block;
    }

    @media (max-width: 420px) {
      .field.two,
      .inline-actions-2,
      .metric-grid {
        grid-template-columns: 1fr;
      }
      .inline-field {
        grid-template-columns: 1fr;
      }
    }
  
