*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --bg: #edf2f8;
  --surface: rgba(255, 255, 255, 0.96);
  --surface2: #f4f7fb;
  --surface3: #edf2f8;

  --line: #d9e1ec;
  --line2: #bec9da;

  --brand: #1a72e8;
  --brand2: #1558b0;

  --t1: #121b2d;
  --t2: #4f6078;
  --t3: #8a99b0;
  --t-inv: rgba(255, 255, 255, 0.92);
  --t-inv2: rgba(255, 255, 255, 0.62);

  --rise: #d62828;
  --fall: #1957c2;
  --rise-bg: #fff0f0;
  --fall-bg: #eef4ff;
  --rise-bd: #efc2c2;
  --fall-bd: #c5d8fb;

  --on: #12a84a;
  --on-bg: rgba(18, 168, 74, 0.18);
  --off: #cf3643;

  --shadow: 0 12px 30px rgba(20, 31, 58, 0.08);
  --shadow2: 0 18px 44px rgba(10, 20, 42, 0.16);

  --col-pnl: 102px;
  --col-rate: 62px;
}

html, body {
  height: 100%;
  background:
    radial-gradient(circle at top left, rgba(70, 111, 196, 0.08), transparent 26%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 240px, #f4f7fb 100%);
  color: var(--t1);
  font-family: "Pretendard Variable", "Pretendard", -apple-system,
    BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 14px;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#main-screen {
  background: #f4f7fb;
}

.login-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 32px 24px;
  gap: 12px;
  background:
    radial-gradient(circle at top, rgba(58, 101, 187, 0.1), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.login-box input,
.login-box button {
  width: 100%;
  max-width: 320px;
}

.login-box input {
  min-height: 50px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line2);
  border-radius: 14px;
  color: var(--t1);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.login-box input:focus {
  border-color: #8cb4ff;
  box-shadow: 0 0 0 4px rgba(79, 141, 255, 0.16);
  background: #fff;
}

.login-box input::placeholder { color: var(--t3); }

.login-box button {
  min-height: 50px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, #1b4aa0, #153d86);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s, box-shadow 0.12s;
  box-shadow: 0 10px 20px rgba(20, 63, 134, 0.18);
}

.login-box button:active { opacity: 0.9; transform: translateY(1px); }
.login-box button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.login-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--rise);
  text-align: center;
}

.top-bar {
  min-height: 52px;
  padding: max(14px, env(safe-area-inset-top, 0px)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  flex-shrink: 0;
}

.top-bar-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--t1);
  letter-spacing: -0.4px;
}

.top-bar-side-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.top-bar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--t2);
  cursor: pointer;
  padding: 4px;
}

.top-bar-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.top-bar-status-ok {
  background: #e8f8ee;
  color: #0a7a4a;
  border-color: #b3e6c8;
}

.top-bar-status-bad {
  background: #fff0f2;
  color: #c83c4f;
  border-color: #f5c0c8;
}

.top-bar-status-unknown {
  background: #f4f6f9;
  color: var(--t3);
  border-color: var(--line);
}

.top-tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  flex-shrink: 0;
}

.top-tab-group {
  display: flex;
  align-items: center;
  gap: 0;
}

.top-tab-btn {
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: var(--t3);
  padding: 8px 14px 9px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.top-tab-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.top-tab-meta-chip {
  font-size: 10px;
  text-align: right;
}

.top-tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.portfolio-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 0 calc(var(--tab-h) + var(--safe-b) + 14px);
}

.status-panel,
.ctrl-section,
.log-section {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
}

.summary-section {
  padding: 10px 16px 11px;
  background: #eef4ff;
  border: none;
  box-shadow: none;
  border-radius: 0;
  margin: 0;
  border-bottom: 1px solid #d4e1fb;
}

.summary-topline {
  display: block;
}

.summary-main-block {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-row1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1.08;
}

.summary-row-market {
  display: flex;
  align-items: baseline;
  line-height: 1.08;
}

.summary-row0 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1.08;
}

.summary-row2 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.08;
}

.summary-main-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--t2);
  white-space: nowrap;
  min-width: 58px;
}

.summary-pnl {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
}

.summary-pnl.pos { color: var(--rise); }
.summary-pnl.neg { color: var(--fall); }

.summary-chip {
  font-size: 11px;
  color: var(--t3);
  line-height: 1.15;
  white-space: nowrap;
  text-align: right;
}

.summary-time-chip {
  letter-spacing: 0.2px;
  color: #8090a8;
}

.summary-market-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 11px;
  color: #61728c;
  line-height: 1.08;
}

.summary-market-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.summary-market-label {
  color: #6f819b;
  font-weight: 700;
  white-space: nowrap;
}

.summary-market-value {
  color: #4b5c75;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.summary-market-value.pos { color: var(--rise); }
.summary-market-value.neg { color: var(--fall); }
.summary-market-value.neutral { color: #6a7c95; }

.summary-market-sep {
  color: #9fb2cd;
}

.summary-subvalue {
  display: none;
}

.summary-rate-label {
  font-size: 12px;
  color: var(--t3);
}

.summary-rate-sep {
  font-size: 12px;
  color: var(--t3);
  margin: 0 2px;
}

.summary-rate-value {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
}

.summary-rate-value.pos { color: var(--rise); }
.summary-rate-value.neg { color: var(--fall); }

.portfolio-card {
  background: #fff;
  border: none;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

.portfolio-headline {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(217, 225, 236, 0.72);
}

.section-kicker {
  font-size: 10px;
  font-weight: 800;
  color: var(--brand2);
  letter-spacing: 1.8px;
}

.section-title {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--t1);
}

.portfolio-head-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--t3);
  text-align: right;
  line-height: 1.4;
}

.section-header,
.inventory-grid {
  display: grid;
  align-items: center;
  gap: 6px;
}

.section-header {
  grid-template-columns: 44px minmax(0, 1fr) var(--col-pnl);
}

.section-header {
  padding: 8px 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #f2f6fb 100%);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  color: var(--t3);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.section-pnl { text-align: right; }

.inventory-item {
  border-bottom: 1px solid rgba(217, 225, 236, 0.5);
  background: #fff;
}

.inventory-item:last-child { border-bottom: none; }

.inventory-item.watch-only {
  background: linear-gradient(180deg, rgba(247, 249, 252, 0.9), rgba(243, 246, 250, 0.9));
}

.inventory-item.watch-only .inv-name,
.inventory-item.watch-only .inv-pnl,
.inventory-item.watch-only .inv-rate {
  color: #96a2b4;
}

.inventory-item.watch-only .inv-avatar {
  opacity: 0.45;
}

.inventory-item.watch-only .inv-hold {
  background: #f2f5f9;
  border-color: #dde5ef;
  color: #98a4b6;
}

.inventory-grid {
  grid-template-columns: 46px minmax(0, 1fr) auto;
  grid-template-areas: "avatar identity summary";
  padding: 12px 14px;
  column-gap: 12px;
  align-items: center;
}

.inv-avatar {
  grid-area: avatar;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
  align-self: center;
  letter-spacing: -0.3px;
}

.inv-identity {
  grid-area: identity;
  min-width: 0;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.inv-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.inv-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 800;
  color: var(--t1);
  letter-spacing: -0.2px;
}

.inv-hold {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: #edf3fb;
  border: 1px solid #d6e0ef;
  color: #7286a5;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.inv-code {
  font-size: 11px;
  color: var(--t3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

.inv-summary,
.inv-pnl,
.inv-rate {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.inv-summary {
  grid-area: summary;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  justify-self: end;
  align-self: center;
}

.inv-time {
  font-size: 11px;
  color: var(--t3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.inv-pnl {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.1px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.inv-rate { display: none; }

.inv-summary-dot { display: none; }

.inv-actions {
  display: none;
  justify-self: end;
  width: 98px;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.inv-btn {
  height: 32px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  font-family: inherit;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: opacity 0.1s, transform 0.1s, box-shadow 0.1s;
}

.inv-btn.buy {
  background: linear-gradient(180deg, #fff6f6, #fff0f0);
  color: var(--rise);
  border: 1px solid var(--rise-bd);
}

.inv-btn.sell {
  background: linear-gradient(180deg, #f4f8ff, #eef4ff);
  color: var(--fall);
  border: 1px solid var(--fall-bd);
}

.inventory-item.manual-off .inv-summary {
  grid-column: 2;
}

.inventory-item.manual-on .inventory-grid {
  grid-template-columns: 44px minmax(0, 1fr) 98px;
  grid-template-areas:
    "avatar identity actions"
    "avatar summary  actions";
  row-gap: 3px;
}

.inventory-item.manual-on .inv-avatar {
  grid-area: avatar;
}

.inventory-item.manual-on .inv-identity {
  grid-area: identity;
}

.inventory-item.manual-on .inv-summary {
  grid-area: summary;
  flex-direction: row;
  justify-self: start;
  justify-content: flex-start;
  align-items: center;
  gap: 4px;
}

.inventory-item.manual-on .inv-rate::before {
  content: '· ';
  color: var(--t3);
  font-weight: 400;
}

.inventory-item.manual-on .inv-actions {
  display: grid;
  grid-area: actions;
  align-self: center;
}

.pos { color: var(--rise); }
.neg { color: var(--fall); }

.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--t3);
  font-size: 13px;
}

.empty-state.compact {
  padding: 12px 10px;
  font-size: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.dot-pos { background: var(--on); }

.dot-pos::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--on-bg);
  animation: blink 2.2s ease-in-out infinite;
}

.dot-neg { background: var(--off); }
.dot-gray { background: var(--t3); }

@keyframes blink {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.8); opacity: 0; }
}

/* ── 제어탭 아웃룩 리스트 스타일 ── */
.control-shell {
  display: flex;
  flex-direction: column;
  background: #f4f7fb;
  padding: 0 0 calc(var(--tab-h) + var(--safe-b) + 14px);
}

.ctrl-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  gap: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.ctrl-row-item:active { background: #f0f4ff; }

.ctrl-row-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 14px 0;
}

.ctrl-row-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  line-height: 1;
}

.ctrl-row-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--t1);
  white-space: nowrap;
}

.ctrl-row-meta {
  font-size: 12px;
  color: var(--t3);
  flex-shrink: 0;
}

.ctrl-row-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  flex-shrink: 0;
  margin-left: 8px;
}

.ctrl-value-on { color: var(--on); }

.ctrl-row-chevron {
  font-size: 18px;
  color: #c0cad8;
  line-height: 1;
  margin-left: 6px;
  flex-shrink: 0;
}

.ctrl-row-status {
  background: #fff;
  min-height: 56px;
}

.ctrl-row-action .ctrl-row-title { color: var(--brand); font-weight: 600; }
.ctrl-icon-start { color: var(--on); }
.ctrl-icon-stop  { color: var(--t2); font-size: 11px; }
.ctrl-icon-restart { color: #c83c4f; }

.ctrl-row-title-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--t3);
}

.ctrl-title-danger { color: #c83c4f; }
.ctrl-chevron-danger { color: #c83c4f; opacity: 0.5; }

.ctrl-row-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.ctrl-divider {
  height: 10px;
  background: #f4f7fb;
}

.ctrl-log-section {
  background: #fff;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.ctrl-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
}


.inv-btn:active,
.modal-btn:active,
.log-refresh-btn:active {
  opacity: 0.78;
  transform: translateY(1px);
}

.log-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.log-refresh-btn {
  height: 30px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid #d7e0ee;
  background: #f4f7fb;
  color: var(--t2);
  font-size: 11px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.log-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 16px 12px;
}

.log-level-chip {
  position: relative;
}

.log-level-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.log-level-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #dde5f0;
  background: #f6f8fb;
  color: #aab4c4;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

/* 미선택 상태는 흐리게, 선택 시 레벨 색상 */
.log-level-chip input:not(:checked) + span {
  opacity: 0.45;
}

.log-level-chip.critical input:checked + span { background: #fff2f4; color: #c83c4f; border-color: #f5c0c8; opacity: 1; }
.log-level-chip.error    input:checked + span { background: #fff4ee; color: #c9683f; border-color: #f5cdb8; opacity: 1; }
.log-level-chip.warning  input:checked + span { background: #fff8ea; color: #b9882f; border-color: #f0d898; opacity: 1; }
.log-level-chip.info     input:checked + span { background: #eef5ff; color: #3a68c0; border-color: #b8d0f8; opacity: 1; }
.log-level-chip.important input:checked + span { background: #fff7e7; color: #ae8a2d; border-color: #f0d898; opacity: 1; }
.log-level-chip.debug    input:checked + span { background: #f4f1ff; color: #7a63b8; border-color: #cfc8f0; opacity: 1; }

.log-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* 아웃룩 이메일 행 스타일 로그 */
.log-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.log-row:last-child { border-bottom: none; }

.log-row-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  align-self: center;
}

.log-row-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.log-row-source {
  font-size: 13px;
  font-weight: 700;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-row-time {
  font-size: 11px;
  color: var(--t3);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.log-row-message {
  font-size: 12px;
  color: var(--t2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: center;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--t3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 10px;
}

.tab-btn.active { color: var(--brand); }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--tab-h) + var(--safe-b) + 14px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26, 114, 232, 0.38);
  z-index: 99;
  -webkit-tap-highlight-color: transparent;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-b) + 12px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(14, 24, 44, 0.94);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 10px 20px rgba(12, 20, 39, 0.18);
}

.toast.show { opacity: 1; }

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 20, 40, 0.5);
  backdrop-filter: blur(4px);
  z-index: 300;
}

.modal {
  width: 100%;
  max-width: 320px;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(190, 201, 218, 0.72);
  box-shadow: var(--shadow2);
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--t1);
}

.modal-body {
  margin: 10px 0 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--t2);
  white-space: pre-line;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  min-height: 44px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.12s;
}

.modal-btn.cancel {
  background: var(--surface2);
  border: 1px solid var(--line2);
  color: var(--t2);
}

.modal-btn.confirm {
  background: linear-gradient(180deg, #1b4aa0, #153d86);
  border: none;
  color: #fff;
}


@media (max-width: 390px) {
  :root {
    --col-pnl: 80px;
    --col-rate: 52px;
  }

  .portfolio-shell {
    gap: 8px;
    padding: 8px 8px calc(var(--tab-h) + var(--safe-b) + 10px);
  }

  .top-bar {
    min-height: 52px;
    padding: 8px 12px 9px;
  }

  .top-bar-main-group,
  .top-bar-side-group { gap: 6px; }

  .top-bar-market-button,
  .top-bar-manual-toggle { height: 30px; padding: 0 10px; }
  .top-bar-market-button { min-width: 64px; }
  .top-bar-manual-toggle { min-width: 72px; }
  .top-bar-time { font-size: 11px; }

  .top-tab-bar {
    gap: 6px;
    padding: 0 12px;
  }

  .top-tab-meta {
    gap: 4px;
  }

  .summary-section,
  .status-panel,
  .ctrl-section,
  .log-section,
  .portfolio-card {
    border-radius: 16px;
  }

  .summary-section { padding: 10px 12px; }
  .summary-pnl { font-size: 30px; }
  .summary-rate-badge { font-size: 20px; }
  .summary-row { margin-top: 10px; padding-top: 10px; }
  .summary-item-value { font-size: 15px; }

  .portfolio-headline {
    padding: 10px 12px 9px;
  }

  .section-title { font-size: 16px; }
  .portfolio-head-meta { font-size: 10px; }

  .section-header,
  .inventory-grid {
    gap: 4px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .inventory-grid { padding-top: 10px; padding-bottom: 10px; }
  .inv-name { font-size: 14px; }
  .inv-pnl { font-size: 13px; }
  .inv-rate { font-size: 11px; }
  .inv-actions { width: 92px; gap: 5px; }
  .inv-btn { height: 30px; font-size: 11px; }

  .log-level-chip span { min-height: 26px; padding: 0 9px; }
}

@media (max-width: 560px) {
  .summary-main-label {
    min-width: 54px;
  }

  .summary-chip {
    font-size: 10px;
  }

  .top-bar {
    min-height: 50px;
    padding: max(8px, env(safe-area-inset-top, 0px)) 12px 8px;
    gap: 8px;
  }

  .top-bar-main-group,
  .top-bar-side-group {
    min-width: 0;
    gap: 6px;
  }

  .top-bar-time {
    font-size: 11px;
    letter-spacing: 0.2px;
  }

  .top-tab-bar {
    gap: 6px;
    padding: 0 12px;
  }

  .top-tab-meta {
    gap: 4px;
  }

  .inventory-grid-head {
    display: none;
  }

  .inventory-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    padding: 9px 12px;
  }

  .inv-identity,
  .inv-name-row {
    min-width: 0;
  }

  .inv-name-row {
    align-items: center;
    gap: 5px;
  }

  .inv-name {
    display: block;
    line-height: 1.08;
  }

  .inventory-item.manual-off .inventory-grid {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-areas: "avatar identity summary";
    column-gap: 8px;
  }

  .inventory-item.manual-off .inv-avatar {
    grid-area: avatar;
    width: 36px;
    height: 36px;
    font-size: 11px;
  }

  .inventory-item.manual-off .inv-identity {
    grid-area: identity;
  }

  .inventory-item.manual-off .inv-summary {
    grid-area: summary;
  }

  .inventory-item.manual-off .inv-pnl {
    font-size: 12px;
  }

  .inventory-item.manual-off .inv-rate {
    font-size: 11px;
  }

  .inventory-item.manual-on .inventory-grid {
    grid-template-columns: 36px minmax(0, 1fr) 92px;
    grid-template-areas:
      "avatar identity actions"
      "avatar summary  actions";
    row-gap: 3px;
    column-gap: 8px;
  }

  .inventory-item.manual-on .inv-avatar {
    grid-area: avatar;
    width: 36px;
    height: 36px;
    font-size: 11px;
  }

  .inventory-item.manual-on .inv-summary {
    gap: 4px;
  }

  .inventory-item.manual-on .inv-pnl {
    font-size: 12px;
  }

  .inventory-item.manual-on .inv-rate {
    font-size: 11px;
  }

}
