:root {
    --primary-color: #2563eb;
    --bg-color: #ffffff;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 240px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
}

body.menu-lock {
    overflow: hidden;
}

/* Header & Horizontal Menu */
header {
    background: #f1f5f9;
    border-bottom: none;
    border-radius: 5px;
    margin: 0.6rem 1.5rem;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0.6rem;
    z-index: 100;
    gap: 1.5rem;
}

header > * {
    background: transparent;
    border-radius: 0;
    padding: 0;
    display: flex;
    align-items: center;
}

header .logo {
    padding: 0;
}

header .header-right {
    padding: 0;
}

.logo {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
    text-decoration: none;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: -0.5px;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
}

.menu-toggle:hover {
    background: #eff6ff;
    color: var(--primary-color);
}

.menu-backdrop {
    display: none;
}

.mobile-nav-top {
    display: none;
}

.nav-menu {
    display: flex;
    gap: 0.25rem;
    flex: 1;
    justify-content: center;
    padding: 0.3rem 0.5rem;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.45rem 1rem;
    border-radius: 2rem;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 0.92rem;
}

.nav-menu a:hover {
    color: var(--primary-color);
    background: #eff6ff;
}

.nav-menu a.active {
    background: var(--primary-color);
    color: #ffffff;
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f1f5f9;
    border-radius: 2rem;
    padding: 0.45rem 1rem;
    border: 1px solid var(--border-color);
}

.search-bar .search-icon {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-bar input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.875rem;
    color: var(--text-main);
    width: 160px;
}

.search-bar input::placeholder {
    color: #94a3b8;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

.notify-btn {
    position: relative;
}

.notify-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #ddd;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
}

.logout-btn:hover {
    border-color: #94a3b8;
    background: #f8fafc;
    color: #1e293b;
}

/* Layout */
/* 2단 레이아웃 래퍼 */
.page-layout {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - 80px);
}

.container {
    padding: 1.5rem 1.5rem;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    flex: 1;
    min-width: 0;
}

/* 서브메뉴 사이드바 */
.submenu-sidebar {
    width: 240px;
    min-width: 240px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1.5rem 1rem 2rem;
    min-height: calc(100vh - 80px);
    box-sizing: border-box;
    position: sticky;
    top: 60px;
    margin: 1.5rem 0 1.5rem 1.5rem;
    align-self: flex-start;
}

.submenu-sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    padding: 0 0.5rem 1.1rem;
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
}

.submenu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.submenu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s;
}

.submenu-item a:hover {
    background: #f1f5f9;
}

.submenu-item.active a {
    background: #f1f5f9;
    font-weight: 600;
}

.submenu-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    color: #64748b;
    transition: background 0.15s, color 0.15s;
}

.submenu-item.active .submenu-icon {
    background: #ede9fe;
    color: #6d28d9;
}

.submenu-item a:hover .submenu-icon {
    background: #e2e8f0;
    color: var(--text-main);
}

/* Top Summary Bar */
.top-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem 2rem;
    margin-bottom: 1.5rem;
    gap: 2rem;
}

.welcome-block h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
}

.welcome-block p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.summary-stats {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    justify-content: flex-end;
}

.summary-stat-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0 2rem;
}

.summary-divider {
    width: 1px;
    height: 48px;
    background: var(--border-color);
    flex-shrink: 0;
}

.summary-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.summary-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.summary-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.summary-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.summary-badge.up {
    background: #dcfce7;
    color: #16a34a;
}

.summary-badge.down {
    background: #fee2e2;
    color: #dc2626;
}

.summary-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    white-space: nowrap;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Charts & Widgets */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.widget {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.widget-title {
    font-weight: 700;
    font-size: 1.125rem;
}

/* Responsive */
@media (max-width: 1280px) {
    header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .nav-menu {
        order: 4;
        flex: 1 1 100%;
        padding: 0.25rem 0;
        flex-wrap: wrap;
    }

    .top-summary-bar {
        flex-direction: column;
        align-items: flex-start;
        padding: 1.1rem 1.25rem;
    }

    .summary-stats {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .summary-divider {
        display: none;
    }

    .summary-stat-item {
        border: 1px solid var(--border-color);
        border-radius: 10px;
        padding: 0.75rem;
        min-width: 280px;
        flex: 1 1 calc(50% - 0.75rem);
    }
}

@media (max-width: 992px) {
    .container {
        padding: 1rem;
    }

    header {
        margin: 0.5rem 1rem;
        padding: 0.6rem 0.9rem;
        top: 0.5rem;
    }

    .logo {
        font-size: 1.35rem;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 1.15rem;
    }

    .header-right {
        display: none;
    }

    .menu-toggle {
        display: inline-flex;
        margin-left: auto;
        order: 2;
        position: relative;
        z-index: 170;
    }

    .menu-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.28);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
        z-index: 150;
    }

    .nav-menu {
        order: 4;
        position: fixed;
        top: 0;
        right: 0;
        width: min(82vw, 320px);
        height: 100dvh;
        padding: 4.75rem 0.9rem 1rem;
        background: #ffffff;
        border-left: 1px solid var(--border-color);
        box-shadow: -14px 0 30px rgba(2, 8, 23, 0.14);
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        transform: translateX(100%);
        pointer-events: none;
        transition: transform 0.28s ease;
        overflow-y: auto;
        z-index: 160;
    }

    .mobile-nav-top {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 0.45rem;
        padding-bottom: 0.8rem;
        margin-bottom: 0.55rem;
        border-bottom: 1px solid var(--border-color);
    }

    header.menu-open .menu-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    header.menu-open .nav-menu {
        transform: translateX(0);
        pointer-events: auto;
    }

    .nav-menu a {
        border-radius: 10px;
        padding: 0.6rem 0.8rem;
    }

    .search-bar input {
        width: 120px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .top-summary-bar {
        margin-bottom: 1rem;
        border-radius: 10px;
    }

    .welcome-block h1 {
        font-size: 1.25rem;
        white-space: normal;
        line-height: 1.25;
    }

    .welcome-block p {
        font-size: 0.8rem;
    }

    .summary-stat-item {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .summary-value {
        font-size: 1.2rem;
    }

    .summary-sub {
        white-space: normal;
    }

    .widget {
        padding: 1rem;
    }

    .widget-header {
        margin-bottom: 1rem;
    }

    .widget-title {
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    header {
        margin: 0.35rem 0.65rem;
        padding: 0.55rem 0.7rem;
        border-radius: 8px;
    }

    .container {
        padding: 0.75rem;
    }

    .nav-menu a {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    .search-bar {
        display: none;
    }

    .menu-toggle {
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }

    .icon-btn,
    .user-avatar {
        width: 32px;
        height: 32px;
    }

    .top-summary-bar {
        padding: 0.9rem;
    }

    .summary-icon {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }
}
