:root {
    --bg: #f3efe5;
    --surface: rgba(255, 251, 244, 0.86);
    --surface-strong: #fffaf2;
    --ink: #142033;
    --ink-soft: #5f6b7a;
    --ink-inverse: #f7f5ef;
    --border: rgba(20, 32, 51, 0.12);
    --accent: #0d8a75;
    --accent-strong: #0b5e73;
    --danger: #c64b48;
    --success: #148362;
    --warning: #b97a18;
    --shadow: 0 20px 50px rgba(16, 28, 45, 0.12);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --grid-gap: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans KR", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(13, 138, 117, 0.18), transparent 34%),
        radial-gradient(circle at top right, rgba(214, 140, 63, 0.18), transparent 30%),
        linear-gradient(180deg, #f8f4eb 0%, #f1ecdf 46%, #ece6d8 100%);
}

body::before,
body::after {
    content: "";
    position: fixed;
    pointer-events: none;
    z-index: -1;
    filter: blur(30px);
}

body::before {
    width: 340px;
    height: 340px;
    top: 40px;
    right: 6vw;
    background: rgba(13, 138, 117, 0.15);
    border-radius: 50%;
}

body::after {
    width: 280px;
    height: 280px;
    bottom: 40px;
    left: 5vw;
    background: rgba(214, 140, 63, 0.15);
    border-radius: 44%;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

#app {
    min-height: 100vh;
}

.shell {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    padding: 28px 20px 24px;
    color: var(--ink-inverse);
    background:
        linear-gradient(210deg, rgba(255, 255, 255, 0.08), transparent 38%),
        linear-gradient(180deg, #102036 0%, #132844 48%, #18385f 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
    padding: 14px 16px 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.brand__eyebrow,
.sidebar__footer-title,
.topbar__eyebrow,
.field__label,
.metric-kicker,
thead th,
.stat-card__label {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
}

.brand__eyebrow {
    color: rgba(247, 245, 239, 0.62);
}

.brand__title,
.topbar__heading,
.stat-card__value,
.metric-highlight,
.modal__title,
.empty-state__title,
.loading-state__title,
.error-state__title {
    font-family: "Space Grotesk", sans-serif;
}

.brand__title {
    margin-top: 10px;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.05;
}

.brand__subtitle,
.sidebar__footer p,
.topbar__summary,
.panel__description,
.field__hint,
.footnote,
.notice__body,
.modal__section-body {
    line-height: 1.6;
    font-size: 13px;
    color: var(--ink-soft);
}

.brand__subtitle,
.sidebar__footer p {
    color: rgba(247, 245, 239, 0.78);
}

.sidebar__meta {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.meta-chip {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px;
}

.meta-chip strong {
    color: #ffffff;
}

.nav {
    display: grid;
    gap: 6px;
    margin-top: 26px;
}

.nav__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 14px;
    color: rgba(247, 245, 239, 0.82);
    background: transparent;
    text-align: left;
    transition: transform 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.nav__item:hover,
.nav__item.is-active {
    color: #fff;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
    transform: translateX(4px);
}

.nav__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 14px;
}

.nav__label {
    font-size: 14px;
    font-weight: 600;
}

.nav__hint {
    margin-left: auto;
    font-size: 11px;
    color: rgba(247, 245, 239, 0.52);
}

.sidebar__footer {
    margin-top: 26px;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.workspace {
    padding: 22px 22px 40px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.topbar__title {
    min-width: 0;
}

.topbar__eyebrow {
    color: var(--ink-soft);
}

.topbar__heading {
    margin: 6px 0 0;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1;
    letter-spacing: -0.04em;
}

.topbar__summary {
    margin-top: 12px;
    max-width: 640px;
    font-size: 14px;
}

.topbar__actions {
    display: grid;
    justify-items: end;
    gap: 10px;
}

.pill-row,
.action-row,
.tag-list,
.toolbar__group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill-row,
.action-row {
    justify-content: flex-end;
}

.pill,
.tag,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    font-weight: 700;
}

.pill,
.tag {
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(20, 32, 51, 0.08);
    background: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.pill {
    min-height: 36px;
    padding: 0 14px;
    box-shadow: 0 8px 24px rgba(20, 32, 51, 0.08);
}

.pill--danger,
.tag--danger,
.value-negative {
    color: var(--danger);
}

.pill--success,
.tag--success,
.value-positive {
    color: var(--success);
}

.pill--warning,
.tag--warning,
.value-warning {
    color: var(--warning);
}

.pill--accent {
    color: var(--accent-strong);
    background: rgba(13, 138, 117, 0.1);
}

.tag--muted,
.muted {
    color: var(--ink-soft);
}

.button {
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid transparent;
    background: var(--surface-strong);
    color: var(--ink);
    box-shadow: 0 8px 20px rgba(20, 32, 51, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(20, 32, 51, 0.12);
}

.button--accent,
.button--warm,
.button--danger {
    color: #fff;
}

.button--accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
}

.button--warm {
    background: linear-gradient(135deg, #d68c3f 0%, #b9651e 100%);
}

.button--danger {
    background: linear-gradient(135deg, #d76159 0%, #b33d3b 100%);
}

.button--ghost {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.45);
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.view,
.stack,
.sidebar__meta,
.modal__body,
.form-grid,
.inline-fields,
.grid-2,
.grid-3,
.grid-4,
.hero-grid,
.split {
    display: grid;
    gap: var(--grid-gap);
}

.hero-grid,
.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2,
.split,
.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-fields {
    grid-template-columns: 1.2fr 1fr auto;
}

.panel,
.modal,
.stat-card,
.notice,
.modal__section {
    position: relative;
    border: 1px solid rgba(20, 32, 51, 0.08);
    box-shadow: var(--shadow);
}

.panel,
.modal {
    overflow: hidden;
    backdrop-filter: blur(20px);
    animation: rise-in 0.28s ease;
}

.panel {
    padding: 22px;
    border-radius: var(--radius-xl);
    background: var(--surface);
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.34), transparent 24%);
    pointer-events: none;
}

.panel__header,
.toolbar,
.notice,
.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.panel__header {
    margin-bottom: 16px;
}

.panel__title,
.notice__title,
.modal__section-title {
    margin: 0;
    font-size: 18px;
}

.stat-card {
    display: grid;
    gap: 12px;
    min-height: 188px;
    padding: 20px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(250, 245, 236, 0.94));
}

.stat-card__label,
.field__label,
.metric-kicker,
thead th {
    color: var(--ink-soft);
}

.stat-card__value {
    font-size: 34px;
    line-height: 1;
    letter-spacing: -0.05em;
}

.stat-card__sub {
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.5;
}

.notice,
.modal__section {
    padding: 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.58);
}

.notice--danger {
    border-color: rgba(198, 75, 72, 0.22);
    background: rgba(198, 75, 72, 0.08);
}

.notice--locked {
    border-color: rgba(13, 138, 117, 0.2);
    background: rgba(13, 138, 117, 0.08);
}

.metric-highlight {
    font-size: 28px;
    letter-spacing: -0.05em;
}

.field {
    display: grid;
    gap: 8px;
}

.input,
.textarea,
.select {
    width: 100%;
    min-height: 48px;
    border: 1px solid rgba(20, 32, 51, 0.12);
    border-radius: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--ink);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.textarea {
    min-height: 140px;
    resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: rgba(13, 138, 117, 0.4);
    box-shadow: 0 0 0 4px rgba(13, 138, 117, 0.12);
    transform: translateY(-1px);
}

.table-wrap {
    overflow: hidden;
    border-radius: 22px;
    border: 1px solid rgba(20, 32, 51, 0.08);
    background: rgba(255, 255, 255, 0.7);
}

.table-scroll {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 14px 16px;
    background: #f4eee0;
    font-size: 12px;
    text-align: left;
}

tbody td {
    padding: 14px 16px;
    border-top: 1px solid rgba(20, 32, 51, 0.08);
    font-size: 14px;
    vertical-align: top;
}

tbody tr:hover td {
    background: rgba(13, 138, 117, 0.045);
}

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

.align-center {
    text-align: center;
}

.market {
    display: grid;
    gap: 4px;
}

.market__name {
    font-weight: 700;
}

.market__code,
.footnote,
.field__hint {
    color: var(--ink-soft);
    font-size: 12px;
}

.score {
    display: grid;
    gap: 8px;
}

.score__value {
    font-weight: 700;
}

.score__bar {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(20, 32, 51, 0.08);
    overflow: hidden;
}

.score__bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-strong), var(--accent));
}

.mini-candle {
    width: 34px;
    height: 24px;
    display: block;
    margin: 0 auto;
}

.mini-candle .wick {
    stroke: rgba(20, 32, 51, 0.48);
    stroke-width: 1.3;
}

.mini-candle .bull {
    fill: var(--success);
}

.mini-candle .bear {
    fill: var(--danger);
}

.mini-candle .neutral {
    fill: var(--ink-soft);
}

.empty-state,
.loading-state,
.error-state {
    display: grid;
    place-items: center;
    min-height: 240px;
    padding: 28px;
    border-radius: var(--radius-xl);
    border: 1px dashed rgba(20, 32, 51, 0.14);
    background: rgba(255, 255, 255, 0.4);
    text-align: center;
}

.empty-state__title,
.loading-state__title,
.error-state__title {
    margin: 14px 0 0;
    font-size: 24px;
}

.empty-state__body,
.loading-state__body,
.error-state__body {
    margin-top: 8px;
    color: var(--ink-soft);
    line-height: 1.6;
}

.spinner {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 4px solid rgba(20, 32, 51, 0.08);
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

.toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 70;
    display: grid;
    gap: 10px;
}

.toast {
    min-width: 280px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(20, 32, 51, 0.1);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 34px rgba(20, 32, 51, 0.16);
    animation: toast-in 0.18s ease;
}

.toast__title {
    font-size: 14px;
    font-weight: 700;
}

.toast__body {
    margin-top: 4px;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.55;
}

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 80;
    pointer-events: none;
}

.modal-root.is-open {
    pointer-events: auto;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 20, 32, 0.45);
    backdrop-filter: blur(12px);
}

.modal {
    position: relative;
    width: min(640px, calc(100vw - 24px));
    margin: 54px auto;
    padding: 22px;
    border-radius: 30px;
    background: linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(246, 239, 227, 0.96));
}

.modal__close {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 0;
    background: rgba(20, 32, 51, 0.08);
}

.mono {
    font-family: "Space Grotesk", monospace;
}

.hidden {
    display: none !important;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1180px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .hero-grid,
    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .workspace {
        padding: 18px 14px 34px;
    }

    .topbar {
        display: grid;
    }

    .topbar__actions {
        justify-items: stretch;
    }

    .pill-row,
    .action-row {
        justify-content: flex-start;
    }

    .hero-grid,
    .grid-4,
    .grid-3,
    .grid-2,
    .form-grid,
    .split,
    .inline-fields {
        grid-template-columns: 1fr;
    }

    .modal {
        margin: 18px auto;
    }
}
