:root {
  --v3-bg: #f4f6f8;
  --v3-surface: #ffffff;
  --v3-surface-soft: #f8fafb;
  --v3-header: #172126;
  --v3-header-line: #344148;
  --v3-text: #182126;
  --v3-text-soft: #607079;
  --v3-line: #d7dee2;
  --v3-line-strong: #bcc8ce;
  --v3-table-head-line: #9fc5f8;
  --v3-blue: #1769aa;
  --v3-teal: #087f73;
  --v3-orange: #a85b08;
  --v3-red: #b43b35;
  --v3-focus: #62a9df;
  --v3-signal-up: #c62828;
  --v3-signal-down: #1769aa;
  --v3-signal-positive: #047857;
  --v3-signal-negative: #b42318;
  --v3-signal-off: #64748b;
  --v3-radius: 6px;
  --v3-font: Arial, "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-width: 320px;
  background: var(--v3-bg);
  color: var(--v3-text);
  font-family: var(--v3-font);
  font-size: 14px;
}

body[data-v3-emergency-state="active"] {
  --v3-bg: #fff5f3;
  --v3-surface-soft: #fff9f8;
  --v3-line: #e6c8c4;
  --v3-line-strong: #cf9690;
  --v3-table-head-line: #d7655d;
  --v3-focus: #db746b;
}

body[data-v3-emergency-state="unknown"] {
  --v3-bg: #fff9ed;
  --v3-surface-soft: #fffcf5;
  --v3-line: #e2d0a9;
  --v3-line-strong: #c9a76a;
  --v3-table-head-line: #cf9440;
}

a {
  color: var(--v3-blue);
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--v3-focus);
  outline-offset: 2px;
}

.v3-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.v3-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--v3-header-line);
  background: var(--v3-header);
  color: #f7fbfc;
}

body[data-v3-emergency-state="active"] .v3-header {
  border-bottom-color: #b95049;
  background: #6f1d1b;
}

body[data-v3-emergency-state="unknown"] .v3-header {
  border-bottom-color: #9a6a24;
  background: #594217;
}

body[data-v3-emergency-state="active"] .v3-top-navigation a:hover,
body[data-v3-emergency-state="active"] .v3-top-navigation a.is-active {
  background: #963d37;
}

.v3-header-primary {
  display: grid;
  grid-template-columns: auto minmax(520px, 1fr) auto;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: 1920px;
  min-height: 66px;
  margin: 0 auto;
  padding: 10px 20px;
}

.v3-emergency-alert {
  border-bottom: 2px solid #c94840;
  background: #fff0ed;
  color: #6f1d1b;
}

.v3-emergency-alert[hidden] {
  display: none;
}

body[data-v3-emergency-state="unknown"] .v3-emergency-alert {
  border-bottom-color: #c47c18;
  background: #fff3d9;
  color: #68420c;
}

.v3-emergency-alert__inner {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding: 12px 20px;
}

.v3-emergency-alert__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.v3-emergency-alert__summary strong {
  font-size: 15px;
}

.v3-emergency-alert__summary span {
  color: #8f302b;
  font-size: 12px;
  font-weight: 700;
}

.v3-emergency-alert__items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.v3-emergency-alert__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 360px);
  padding: 5px 8px;
  border-left: 3px solid #c94840;
  color: #6f1d1b;
}

.v3-emergency-alert__item:hover {
  background: #ffddd8;
  color: #541310;
}

.v3-emergency-alert__detail {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  color: inherit;
}

.v3-emergency-alert__detail:focus-visible {
  outline: 2px solid #963d37;
  outline-offset: 2px;
}

.v3-emergency-alert__detail span {
  overflow-wrap: anywhere;
}

.v3-emergency-alert__action {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid #9d302b;
  border-radius: 4px;
  background: #fff;
  color: #7c211d;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.v3-emergency-alert__action:hover,
.v3-emergency-alert__action:focus-visible {
  background: #7c211d;
  color: #fff;
}

.v3-emergency-alert__action:disabled {
  cursor: wait;
  opacity: 0.65;
}

.v3-emergency-alert__resolution {
  margin: 0;
  color: #71302c;
  font-size: 12px;
  line-height: 1.5;
}

.v3-brand-row,
.v3-header-tools,
.v3-top-navigation,
.v3-symbol-search,
.v3-mode-row,
.v3-mode-switch {
  display: flex;
  align-items: center;
}

.v3-brand-row {
  gap: 12px;
  white-space: nowrap;
}

.v3-brand {
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.v3-top-navigation {
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.v3-top-navigation a {
  padding: 9px 11px;
  border-radius: var(--v3-radius);
  color: #d4dde1;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.v3-top-navigation a:hover,
.v3-top-navigation a.is-active {
  background: #304048;
  color: #ffffff;
}

.v3-top-strategies {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: 2px;
}

.v3-top-strategies a {
  min-width: 27px;
  padding: 9px 4px;
  color: #b9c8ce;
  text-align: center;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
}

.v3-top-strategies a:hover,
.v3-top-strategies a:focus-visible,
.v3-top-strategies a.is-active {
  background: #d9ece9;
  color: #075e56;
}

.v3-top-navigation a.is-management {
  margin-left: 8px;
  border-left: 1px solid #536168;
  border-radius: 0 var(--v3-radius) var(--v3-radius) 0;
}

.v3-header-tools {
  justify-content: flex-end;
  gap: 10px;
  white-space: nowrap;
}

.v3-resource-usage {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #536168;
  border-radius: var(--v3-radius);
  background: #202d33;
  color: #dbe5e9;
  cursor: default;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.v3-resource-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-weight: 700;
}

.v3-resource-metric output {
  min-width: 38px;
  color: #9ee6d1;
  text-align: right;
}

.v3-resource-usage[data-tone="warning"] output {
  color: #ffd27a;
}

.v3-resource-usage[data-tone="danger"] output,
.v3-resource-usage[data-tone="unavailable"] output {
  color: #ffaaa5;
}

.v3-resource-separator {
  width: 1px;
  height: 14px;
  background: #536168;
}

.v3-resource-tooltip {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  z-index: 40;
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 8px 10px;
  border: 1px solid #536168;
  border-radius: 4px;
  background: #0f171b;
  color: #ffffff;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  white-space: pre-line;
  transform: translate(-50%, -4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  visibility: hidden;
}

.v3-resource-tooltip::before {
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-top: 1px solid #536168;
  border-left: 1px solid #536168;
  background: #0f171b;
  content: "";
  transform: translate(-50%, 5px) rotate(45deg);
}

.v3-resource-usage:hover .v3-resource-tooltip,
.v3-resource-usage:focus .v3-resource-tooltip,
.v3-resource-usage:focus-within .v3-resource-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}

.v3-symbol-search {
  height: 34px;
}

.v3-symbol-search input {
  width: 108px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid #68757b;
  border-right: 0;
  border-radius: var(--v3-radius) 0 0 var(--v3-radius);
  background: #ffffff;
  color: var(--v3-text);
}

.v3-symbol-search button,
.v3-logout-button {
  height: 34px;
  border: 1px solid #68757b;
  background: #26343b;
  color: #ffffff;
  cursor: pointer;
}

.v3-symbol-search button {
  padding: 0 10px;
  border-radius: 0 var(--v3-radius) var(--v3-radius) 0;
}

.v3-logout-button {
  padding: 0 10px;
  border-radius: var(--v3-radius);
}

.v3-user-name {
  max-width: 110px;
  overflow: hidden;
  color: #d4dde1;
  text-overflow: ellipsis;
}

.v3-main {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  width: 100%;
  max-width: 1920px;
  min-height: calc(100vh - 111px);
  margin: 0 auto;
}

.v3-main.is-home {
  grid-template-columns: minmax(0, 1fr);
}

.v3-sidebar {
  padding: 18px 12px 28px;
  border-right: 1px solid var(--v3-line);
  background: #eef2f4;
}

body[data-v3-emergency-state="active"] .v3-sidebar {
  background: #fff0ed;
}

.v3-sidebar-title {
  padding: 4px 10px 14px;
  border-bottom: 1px solid var(--v3-line-strong);
  font-size: 15px;
  font-weight: 700;
}

.v3-sidebar-group {
  margin-top: 16px;
}

.v3-sidebar-group h2 {
  margin: 0 10px 6px;
  color: var(--v3-text-soft);
  font-size: 11px;
  font-weight: 700;
}

.v3-sidebar-group nav {
  display: grid;
  gap: 2px;
}

.v3-sidebar-group a {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: var(--v3-radius);
  color: #334047;
  line-height: 18px;
}

.v3-sidebar-group a:hover {
  background: #ffffff;
}

.v3-sidebar-group a.is-active {
  background: #d9ece9;
  color: #075f56;
  font-weight: 700;
}

body[data-v3-emergency-state="active"] .v3-sidebar-group a:hover {
  background: #fff9f8;
}

body[data-v3-emergency-state="active"] .v3-sidebar-group a.is-active {
  background: #ffd9d4;
  color: #7f211c;
}

.v3-content {
  min-width: 0;
  padding: 24px;
}

.v3-content.is-home {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
}

.v3-content.is-review {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
}

.v3-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.v3-breadcrumb {
  margin-bottom: 6px;
  color: var(--v3-text-soft);
  font-size: 12px;
}

.v3-page-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.v3-build-state,
.v3-status-neutral {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid #d2b78e;
  border-radius: var(--v3-radius);
  background: #fff6e8;
  color: var(--v3-orange);
  font-size: 12px;
  font-weight: 700;
}

.v3-build-state[data-tone="ready"] {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.v3-build-state[data-tone="error"] {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.v3-mode-row {
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 12px;
  padding: 7px 10px;
  border: 1px solid var(--v3-line);
  background: var(--v3-surface-soft);
  font-size: 12px;
  font-weight: 700;
}

.v3-mode-switch {
  overflow: hidden;
  border: 1px solid var(--v3-line-strong);
  border-radius: var(--v3-radius);
}

.v3-mode-switch button {
  min-width: 82px;
  height: 30px;
  border: 0;
  border-right: 1px solid var(--v3-line-strong);
  background: #ffffff;
  color: var(--v3-text-soft);
}

.v3-mode-switch button:last-child {
  border-right: 0;
}

.v3-work-surface {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-radius);
  background: var(--v3-surface);
}

.v3-surface-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--v3-line);
}

.v3-surface-header h2 {
  margin: 0;
  font-size: 15px;
}

.v3-surface-header span {
  color: var(--v3-text-soft);
  font-size: 12px;
}

.v3-empty-state {
  display: grid;
  place-content: center;
  min-height: 84px;
  box-sizing: border-box;
  padding: 20px 14px;
  color: var(--v3-text-soft);
  text-align: center;
}

.v3-empty-state[hidden] {
  display: none;
}

.v3-empty-state strong {
  color: #46555d;
  font-size: 15px;
}

.v3-empty-state span {
  margin-top: 7px;
  font-family: "Courier New", monospace;
  font-size: 11px;
}

.v3-table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.v3-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.v3-table th,
.v3-table td {
  min-width: 0;
  height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--v3-line);
  overflow-wrap: anywhere;
  text-align: left;
  white-space: normal;
}

.v3-table th {
  background: var(--v3-surface-soft);
  color: var(--v3-text-soft);
  font-size: 12px;
}

.v3-content table thead th {
  border-bottom: 2px solid var(--v3-table-head-line);
}

.v3-content table th,
.v3-content table td {
  text-align: left;
}

.v3-content table th[data-v3-align="numeric"],
.v3-content table td[data-v3-align="numeric"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
  white-space: nowrap;
}

.v3-content table td[data-v3-symbol-code] {
  overflow-wrap: anywhere;
  white-space: normal;
}

.v3-stock-detail-link {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.v3-stock-detail-link:hover,
.v3-stock-detail-link:focus-visible {
  color: var(--v3-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.v3-content table td[data-v3-symbol-name-state="missing"] {
  color: var(--v3-text-soft);
}

/* Signed market/money values are shared by trading and reporting screens.
   Keep these in the always-loaded shell, not the data-page stylesheet. */
.v3-value--up {
  color: #d92d20;
  font-weight: 700;
}

.v3-value--down {
  color: #175cd3;
  font-weight: 700;
}

.v3-content [data-v3-text-tone="up"],
.v3-content [data-v3-text-tone="buy"] {
  color: var(--v3-signal-up);
  font-weight: 700;
}

.v3-content [data-v3-text-tone="down"],
.v3-content [data-v3-text-tone="sell"] {
  color: var(--v3-signal-down);
  font-weight: 700;
}

.v3-content [data-v3-text-tone="positive"],
.v3-content [data-v3-text-tone="on"] {
  color: var(--v3-signal-positive);
  font-weight: 700;
}

.v3-content [data-v3-text-tone="negative"] {
  color: var(--v3-signal-negative);
  font-weight: 700;
}

.v3-content [data-v3-text-tone="off"] {
  color: var(--v3-signal-off);
  font-weight: 700;
}

.v3-content [data-v3-text-tone="warning"] {
  color: var(--v3-orange);
  font-weight: 700;
}

/* Three-line cards use top-left/right, centered value, and bottom-right. */
.v3-card--three-line {
  display: grid;
  grid-template-rows: auto minmax(28px, 1fr) auto;
  gap: 8px;
  min-width: 0;
  min-height: 112px;
}

.v3-card--three-line__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  text-align: left;
}

.v3-card--three-line__middle {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  text-align: center;
  font-weight: 700;
}

.v3-card--three-line__bottom {
  min-width: 0;
  min-height: 1.3em;
  text-align: right;
}

.v3-status-neutral {
  border-color: var(--v3-line-strong);
  background: #f0f3f4;
  color: var(--v3-text-soft);
}

.v3-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 45px;
  padding: 14px 20px;
  border-top: 1px solid var(--v3-line);
  background: #ffffff;
  color: var(--v3-text-soft);
  font-size: 11px;
}

@media (max-width: 1440px) {
  .v3-header-primary {
    grid-template-columns: 1fr auto;
  }

  .v3-top-navigation {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
  }
}

@media (max-width: 760px) {
  .v3-header-primary {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .v3-header-tools,
  .v3-top-navigation {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .v3-header-tools {
    flex-wrap: wrap;
    overflow: visible;
  }

  .v3-emergency-alert__inner {
    padding: 12px;
  }

  .v3-emergency-alert__summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .v3-emergency-alert__items {
    display: grid;
  }

  .v3-emergency-alert__item {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
  }

  .v3-emergency-alert__detail {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .v3-emergency-alert__action {
    align-self: flex-start;
  }

  .v3-user-name {
    display: none;
  }

  .v3-main {
    grid-template-columns: 1fr;
  }

  .v3-sidebar {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--v3-line);
  }

  .v3-sidebar-title {
    display: none;
  }

  .v3-sidebar-group {
    flex: 0 0 auto;
    margin: 0;
  }

  .v3-sidebar-group h2 {
    display: none;
  }

  .v3-sidebar-group nav {
    display: flex;
  }

  .v3-content {
    padding: 18px 12px;
  }

  .v3-page-header {
    align-items: flex-start;
  }

  .v3-page-header h1 {
    font-size: 20px;
  }

  .v3-mode-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .v3-mode-switch {
    width: 100%;
  }

  .v3-mode-switch button {
    flex: 1 1 0;
    min-width: 0;
  }
}
