/* ===== APP SHELL ===== */
.app-shell {
    display: grid;
    grid-template-columns: 72px 1fr;
    grid-template-rows: 52px 1fr;
    min-height: 100vh;
}

/* ===== TOPBAR ===== */
.topbar {
    grid-column: 1/-1;
    grid-row: 1;
    background: linear-gradient(180deg, #1d1b2e 0%, var(--dark2) 100%);
    border-bottom: 1px solid rgba(155,114,245,0.25);
    box-shadow: 0 1px 24px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    width: 72px;
    height: 52px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
}

.logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: 0.14em;
    line-height: 1;
    background: linear-gradient(135deg, #d4bcff 0%, #9B72F5 60%, #7c5cbf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-size: 8px;
    color: var(--muted);
    margin-top: 2px;
    letter-spacing: 0.04em;
}

.topbar-spacer {
    flex: 1;
}

.db-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--muted);
    padding: 0 12px;
    overflow-x: auto;
    white-space: nowrap;
}

.db-status-item {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.db-status-count {
    color: var(--gold);
    font-weight: 700;
}

.db-status-sep {
    color: var(--border);
    margin: 0 2px;
}

/* ===== SIDEBAR ===== */
.sidebar {
    grid-column: 1;
    grid-row: 2;
    background: linear-gradient(180deg, #151323 0%, var(--dark2) 40%, #13121e 100%);
    border-right: 1px solid rgba(155,114,245,0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    gap: 2px;
    position: sticky;
    top: 52px;
    height: calc(100vh - 52px);
    overflow-y: auto;
}

/* ===== SIDEBAR NAV ITEM ===== */
.snav {
    width: 56px;
    height: 52px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.15s;
    user-select: none;
}

.snav:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.snav.active {
    background: linear-gradient(135deg, rgba(155,114,245,0.22) 0%, rgba(124,92,191,0.12) 100%);
    color: var(--gold);
    box-shadow: inset 0 0 0 1px rgba(155,114,245,0.3), 0 2px 12px rgba(155,114,245,0.12);
}

.snav-icon {
    font-size: 18px;
    line-height: 1;
}

.snav-label {
    font-size: 9px;
    letter-spacing: 0.02em;
    font-weight: 500;
}

.snav-sep {
    width: 32px;
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ===== MAIN CONTENT ===== */
.app-main {
    grid-column: 2;
    grid-row: 2;
    padding: 24px 28px 80px;
    min-width: 0;
    overflow-y: auto;
    width: 100%;
}

/* ===== PAGE ===== */
.page {
    display: none;
    width: 100%;
    max-width: 100%;
}

.page.active {
    display: block;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #f0ecf8 0%, #c4a8ff 60%, #9B72F5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 13px;
}

.page-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

/* ===== DASHBOARD GRID ===== */
.dash-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.dash-stat {
    background: var(--dark2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.dash-stat-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 4px;
}

.dash-stat-label {
    font-size: 11px;
    color: var(--muted);
}

.dash-chart-card {
    background: var(--dark2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.dash-chart-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.dash-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 150px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.dash-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 36px;
}

.dash-bar {
    background: linear-gradient(180deg, rgba(155,114,245,0.55) 0%, rgba(124,92,191,0.25) 100%);
    border-radius: 4px 4px 0 0;
    width: 28px;
    min-height: 2px;
    transition: all 0.3s;
    cursor: default;
}

.dash-bar:hover {
    background: linear-gradient(180deg, #c4a8ff 0%, #9B72F5 100%);
    box-shadow: 0 0 12px rgba(155,114,245,0.45);
}

.dash-bar-label {
    font-size: 9px;
    color: var(--muted);
    white-space: nowrap;
}

.dash-bar-amount {
    font-size: 9px;
    color: var(--gold);
    white-space: nowrap;
}

.dash-top-products {
    background: var(--dark2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.dash-top-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.dash-top-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.dash-top-row:last-child {
    border-bottom: none;
}

.dash-top-rank {
    width: 20px;
    color: var(--muted);
    font-weight: 700;
    flex-shrink: 0;
}

.dash-top-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.dash-top-sales {
    color: var(--gold);
    font-weight: 700;
    white-space: nowrap;
}

/* ===== PVIEW COMPAT (legacy) ===== */
.pview {
    display: none;
}

.pview.active {
    display: block;
}

/* ===== RESPONSIVE: TABLET (< 768px) ===== */
@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 52px 1fr 68px;
    }

    .topbar {
        grid-column: 1;
    }

    /* ===== BOTTOM NAV ===== */
    .sidebar {
        grid-column: 1;
        grid-row: 3;
        flex-direction: row;
        height: 68px;
        width: 100%;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        padding: 4px 6px;
        overflow-x: auto;
        overflow-y: hidden;
        align-items: center;
        justify-content: flex-start;
        gap: 2px;
        border-right: none;
        border-top: 1px solid rgba(155,114,245,0.25);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
        z-index: 100;
        /* スムーズスクロール */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .sidebar::-webkit-scrollbar { display: none; }

    .snav {
        width: 60px;
        height: 60px;
        min-width: 60px;      /* shrink防止 */
        flex-shrink: 0;       /* shrink防止 */
        border-radius: 12px;
    }

    .snav-icon {
        font-size: 20px;
    }

    .snav-label {
        font-size: 10px;
    }

    .snav-sep {
        display: none;
    }

    .app-main {
        grid-column: 1;
        grid-row: 2;
        padding: 16px 12px 84px;  /* 68px nav + 余白 */
    }

    .dash-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .db-status .db-status-sep {
        display: none;
    }

    .topbar-brand {
        width: 56px;
    }
}

/* ===== RESPONSIVE: MOBILE (< 480px) ===== */
@media (max-width: 480px) {
    .dash-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .dash-chart-card {
        padding: 14px;
    }

    .app-main {
        padding: 12px 8px 72px;
    }

    .page-title {
        font-size: 16px;
    }

    .db-status {
        display: none;
    }
}

/* ===== DASHBOARD ACTION PLAN AREA ===== */
.dash-action-area {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

.dash-kgi-panel {
    flex: 1;
    min-width: 200px;
}

.dash-schedule-panel {
    flex: 2;
    min-width: 0;
}

/* Daily Management table scroll on small screens */
.daily-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.daily-table-wrap table {
    min-width: 600px;
}

@media (max-width: 768px) {
    .dash-action-area {
        flex-direction: column;
    }

    .dash-kgi-panel {
        flex: none;
        width: 100%;
    }

    .dash-schedule-panel {
        flex: none;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .dash-kgi-panel .dash-chart-title {
        font-size: 12px;
    }

    .dash-action-area {
        gap: 12px;
    }

    .dash-kgi-inner-grid {
        grid-template-columns: 1fr !important;
    }
}