* {
    box-sizing: border-box;
}

:root {
    --bg: #e9eef6;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --line: #d9e2ec;
    --line-soft: #e7edf4;
    --text: #172033;
    --muted: #6b778c;
    --price-line: #4b5563;
    --sell-blue: #2563eb;
    --profit-red: #ef4444;
    --loss-blue: #2563eb;
}

body {
    margin: 0;
    font-family: "Malgun Gothic", "Noto Sans KR", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 28%),
        linear-gradient(180deg, #f8fafc 0%, var(--bg) 46%, #edf2f7 100%);
    color: var(--text);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 28px;
    background: linear-gradient(135deg, #0f172a 0%, #172033 58%, #1e293b 100%);
    border-bottom: 1px solid #22304a;
    color: #f8fafc;
}

.page-header h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0;
}

.page-header p {
    margin: 6px 0 0;
    color: #aeb9c9;
    font-size: 13px;
}

button {
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    background: #273449;
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
}

button:hover {
    background: #334155;
}

.header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.login-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border-radius: 8px;
    padding: 8px 13px;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.google-login {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #d1d5db;
}

.apple-login {
    background: #020617;
    color: #ffffff;
    border: 1px solid #475569;
}

.logout-button {
    background: #334155;
    color: #ffffff;
    border: 1px solid #64748b;
}

.user-badge {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #dbeafe;
    font-size: 13px;
    font-weight: 700;
}

.secondary-button {
    border: 1px solid var(--line);
    background: #ffffff;
    color: #334155;
}

#languageToggle {
    min-height: 36px;
    font-weight: 800;
}

.secondary-button:hover {
    background: #f1f5f9;
}

main {
    padding: 20px 28px 40px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.card,
.chart-card,
.table-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.card {
    padding: 14px 16px;
}

.card-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 7px;
}

.card-value {
    font-size: 19px;
    font-weight: 800;
}

.trend-card {
    overflow: hidden;
}

.trend-card::after {
    content: "";
    display: block;
    height: 3px;
    margin: 12px -16px -14px;
}

.trend-up .trend-value {
    color: #dc2626;
}

.trend-up::after {
    background: #dc2626;
}

.trend-down .trend-value {
    color: #2563eb;
}

.trend-down::after {
    background: #2563eb;
}

.trend-flat .trend-value {
    color: #ca8a04;
}

.trend-flat::after {
    background: #eab308;
}

.private-card {
    position: relative;
}

.private-value {
    transition: filter 0.15s ease, opacity 0.15s ease;
}

.private-hint {
    display: none;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

body.is-anonymous .private-value {
    filter: blur(6px);
    opacity: 0.55;
    user-select: none;
}

body.is-anonymous .private-hint {
    display: block;
}

body.is-authenticated .private-hint {
    display: none;
}

.chart-lock-notice {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    color: #9a3412;
    font-size: 13px;
}

.chart-lock-notice span {
    color: #7c2d12;
}

.chart-lock-notice a {
    margin-left: auto;
    color: #ffffff;
    background: #ea580c;
    border-radius: 7px;
    padding: 7px 10px;
    text-decoration: none;
    font-weight: 800;
    white-space: nowrap;
}

body.is-anonymous .chart-lock-notice {
    display: flex;
}

.chart-card,
.table-card {
    padding: 16px;
    margin-bottom: 14px;
}

.status-footer {
    color: var(--muted);
    font-size: 12px;
    padding: 4px 2px 0;
    text-align: right;
}

.section-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.section-title h2 {
    margin: 0;
    font-size: 17px;
}

.section-title p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.chart-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: flex-end;
    padding: 8px;
    margin: 0 0 10px;
    background: var(--panel-soft);
    border: 1px solid var(--line-soft);
    border-radius: 8px;
}

canvas {
    width: 100%;
    height: 320px;
    max-height: 40vh;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th,
td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--line-soft);
    text-align: right;
    white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(3),
td:nth-child(3),
th:nth-child(4),
td:nth-child(4) {
    text-align: left;
}

th {
    color: var(--muted);
    font-weight: 700;
    background: var(--panel-soft);
}

@media (max-width: 1000px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 640px) {
    main {
        padding: 14px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .chart-lock-notice {
        align-items: flex-start;
        flex-direction: column;
    }

    .chart-lock-notice a {
        margin-left: 0;
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    canvas {
        height: 300px;
    }
}

@media (min-width: 900px) and (min-height: 1000px) {
    canvas {
        height: 280px;
        max-height: 30vh;
    }
}
