:root {
    color-scheme: light dark;
    --bg: #f7f8fb;
    --surface: #ffffff;
    --surface-2: #eef3f8;
    --ink: #17202a;
    --muted: #637083;
    --line: #d9e1ea;
    --accent: #0f9f7a;
    --accent-soft: #e2f7f0;
    --danger: #c2413a;
    --shadow: 0 16px 44px rgba(23, 32, 42, .10);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101419;
        --surface: #171d24;
        --surface-2: #202832;
        --ink: #f4f7fb;
        --muted: #a7b3c2;
        --line: #2f3946;
        --accent: #48c4a3;
        --accent-soft: #14342e;
        --danger: #ff7b72;
        --shadow: 0 18px 48px rgba(0, 0, 0, .28);
    }
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, a { font: inherit; }

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background: #101419;
    color: #f4f7fb;
}
.login-card {
    width: min(400px, 100%);
    padding: 40px;
    border: 1px solid #2f3946;
    border-radius: 8px;
    background: #171d24;
    text-align: center;
    box-shadow: 0 22px 70px rgba(0, 0, 0, .24);
}
.login-logo {
    width: 52px;
    height: 52px;
    margin: 0 auto 22px;
    display: block;
}
.login-card h1 {
    margin: 0 0 8px;
    font-size: 28px;
    letter-spacing: 0;
}
.login-subtitle {
    margin: 0 0 30px;
    color: #a7b3c2;
    font-size: 14px;
}
.kakao-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 14px;
    border-radius: 8px;
    background: #fee500;
    color: #191919;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
}
.kakao-btn:hover { background: #f0d800; }
.kakao-btn svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}
.login-notice {
    margin: 22px 0 0;
    color: #a7b3c2;
    font-size: 12px;
    line-height: 1.6;
}
.denied-title {
    color: #f87171;
}
.denied-link {
    display: inline-block;
    margin-top: 20px;
    color: #48c4a3;
    text-decoration: none;
    font-weight: 700;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 256px minmax(0, 1fr);
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 8px 18px;
    border-bottom: 1px solid var(--line);
}
.logo {
    width: 40px;
    height: 40px;
    display: block;
}
.brand-name {
    display: grid;
    gap: 2px;
    font-weight: 800;
    letter-spacing: 0;
}
.brand-name small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.side-nav {
    display: grid;
    gap: 8px;
    margin-top: 22px;
}
.nav-group {
    display: grid;
    gap: 6px;
}
.nav-group .nav-item {
    list-style: none;
}
.nav-group .nav-item::-webkit-details-marker {
    display: none;
}
.nav-caret {
    margin-left: auto;
    transition: transform .16s ease;
}
.nav-group[open] .nav-caret {
    transform: rotate(180deg);
}
.nav-submenu {
    display: grid;
    gap: 4px;
    padding-left: 32px;
}
.nav-subitem {
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
}
.nav-subitem[aria-current="page"] {
    background: var(--surface-2);
    color: var(--accent);
}
.nav-item {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    text-decoration: none;
    text-align: left;
}
.nav-item svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}
.nav-item[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 800;
}
.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 14px;
    padding: 16px 8px 0;
    border-top: 1px solid var(--line);
}
.profile-menu {
    position: relative;
}
.profile-menu .user {
    list-style: none;
    cursor: pointer;
}
.profile-menu .user::-webkit-details-marker {
    display: none;
}
.user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 14px;
}
.user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--line);
    object-fit: cover;
}
.user strong {
    display: block;
    overflow: hidden;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.profile-actions {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 30;
    min-width: 132px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.topbar .profile-actions {
    top: calc(100% + 8px);
    bottom: auto;
}
.profile-actions a {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--danger);
    text-decoration: none;
    font-weight: 700;
}
.profile-actions a:hover {
    background: var(--surface-2);
}
.content {
    min-width: 0;
    padding: 28px 32px 40px;
}
.topbar {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.topbar h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: 0;
}
.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}
.section { display: none; }
.section.is-active { display: block; }
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: end;
    padding: 24px;
    margin-bottom: 18px;
}
.hero-panel h2 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
    letter-spacing: 0;
}
.hero-panel p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.6;
}
.hero-badge {
    min-width: 96px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}
.hero-badge strong {
    display: block;
    margin-top: 3px;
    color: var(--ink);
    font-size: 20px;
}
.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.metric {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}
.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
    letter-spacing: 0;
}
.metric em {
    display: block;
    margin-top: 6px;
    color: var(--accent);
    font-size: 12px;
    font-style: normal;
    font-weight: 700;
}
.table-panel {
    margin-top: 14px;
    overflow: hidden;
}
.table-row {
    display: grid;
    grid-template-columns: 1.4fr .9fr .9fr;
    gap: 12px;
    align-items: center;
    min-height: 52px;
    padding: 0 18px;
    border-top: 1px solid var(--line);
}
.table-row:first-child {
    border-top: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.stat-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
}
.period-controls {
    display: inline-flex;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}
.period-controls button {
    min-height: 38px;
    padding: 0 14px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 700;
}
.period-controls button:last-child {
    border-right: 0;
}
.period-controls button[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent);
}
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}
.chart-panel {
    min-width: 0;
    padding: 18px;
}
.chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 12px;
}
.chart-head strong {
    color: var(--ink);
    font-size: 14px;
}
.chart-panel canvas {
    width: 100% !important;
    height: 230px !important;
}
.table-row.stats-row {
    grid-template-columns: 1.1fr .9fr .9fr 1fr;
}
.table-row.table-head {
    border-top: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.status {
    width: fit-content;
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}
.bottom-nav {
    display: none;
}

@media (max-width: 820px) {
    body {
        padding-bottom: calc(78px + env(safe-area-inset-bottom));
    }
    .app {
        display: block;
    }
    .sidebar {
        display: none;
    }
    .content {
        padding: 18px 16px 28px;
    }
    .topbar {
        min-height: 48px;
        margin-bottom: 16px;
    }
    .topbar h1 {
        font-size: 21px;
    }
    .topbar .user img {
        width: 34px;
        height: 34px;
    }
    .topbar .user div {
        display: none;
    }
    .hero-panel {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 20px;
        margin-bottom: 14px;
    }
    .hero-panel h2 {
        font-size: 22px;
    }
    .hero-badge {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }
    .metrics {
        grid-template-columns: 1fr;
    }
    .chart-grid {
        grid-template-columns: 1fr;
    }
    .stat-toolbar,
    .period-controls {
        width: 100%;
    }
    .period-controls button {
        flex: 1 1 0;
        padding: 0 8px;
    }
    .chart-panel canvas {
        height: 210px !important;
    }
    .metric {
        padding: 16px;
    }
    .table-row {
        grid-template-columns: 1fr auto;
        min-height: 62px;
    }
    .table-row > :nth-child(2) {
        display: none;
    }
    .table-row.stats-row {
        grid-template-columns: 1fr auto;
    }
    .table-row.stats-row > :nth-child(3) {
        display: none;
    }
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
        padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: color-mix(in srgb, var(--surface) 96%, transparent);
        box-shadow: 0 -12px 28px rgba(23, 32, 42, .12);
    }
    .bottom-nav .bottom-nav-group {
        position: relative;
        min-width: 0;
    }
    .bottom-nav .nav-item {
        min-height: 58px;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        padding: 0;
        text-align: center;
        font-size: 12px;
    }
    .bottom-nav .nav-item svg {
        width: 23px;
        height: 23px;
    }
    .bottom-nav .nav-item .bottom-caret {
        width: 12px;
        height: 12px;
        margin-top: -3px;
    }
    .bottom-nav .nav-submenu {
        position: absolute;
        left: 50%;
        bottom: calc(100% + 10px);
        min-width: 108px;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        box-shadow: var(--shadow);
        transform: translateX(-50%);
    }
    .bottom-nav .nav-subitem {
        justify-content: center;
        padding: 0 12px;
        white-space: nowrap;
    }
}
