* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --bg-color: #f5f5f7;
    --surface-color: #ffffff;
    --header-height: 64px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --border-color: rgba(0, 0, 0, 0.05);
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --sidebar-width: 260px;
    --sidebar-width-md: 200px;
    --sidebar-width-collapsed: 72px;
}

[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: rgba(129, 140, 248, 0.15);
    --text-primary: #f1f1f3;
    --text-secondary: #a0a0a8;
    --text-tertiary: #606068;
    --bg-color: #0a0a0f;
    --surface-color: #1a1a1f;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --border-color: rgba(255, 255, 255, 0.05);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: "HarmonyOS Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
    transition: all 0.3s ease;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 90;
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 700;
}

.logo svg {
    width: 32px;
    height: 32px;
}

.sidebar-nav {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary-color);
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.header {
    height: var(--header-height);
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-color);
    border-radius: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.user-avatar svg {
    width: 20px;
    height: 20px;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.header-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.header-btn svg {
    width: 20px;
    height: 20px;
}

.header-btn--sidebar {
    display: inline-flex;
}

.content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.stat-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.stat-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

.stat-change svg {
    width: 16px;
    height: 16px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.charts-grid--single {
    grid-template-columns: 1fr;
}

.chart-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.chart-header {
    margin-bottom: 24px;
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 260px;
}

.chart-container.pie {
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seven-day-list {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.seven-day-item {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
}

.seven-day-item-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}

.seven-day-item-count {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.footer {
    padding: 24px 32px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    transition: border-color 0.3s ease;
}

.table-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.table-toolbar-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.table-title {
    font-weight: 700;
    color: var(--text-primary);
}

.table-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 220px;
}

.table-search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.table-search-input {
    width: 100%;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-primary);
    padding: 0 32px 0 36px;
    outline: none;
    font-size: 0.875rem;
}

.table-search-input::-webkit-search-cancel-button,
.table-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.table-search-input::-ms-clear,
.table-search-input::-ms-reveal {
    display: none;
    width: 0;
    height: 0;
}

.table-search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--surface-color);
}

.table-search-clear {
    position: absolute;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
}

.table-search-clear:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

[data-theme="dark"] .table-search-clear:hover {
    background: rgba(255, 255, 255, 0.08);
}

.table-page-size {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.table-page-size select {
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-primary);
    padding: 0 10px;
    outline: none;
}

.table-wrapper {
    position: relative;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
    background: var(--surface-color);
}

.data-table thead th {
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 12px 14px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9375rem;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--primary-light);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

.user-nickname {
    font-weight: 600;
    color: var(--text-primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge--member {
    color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.18);
}

.badge--nonmember {
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--border-color);
}

[data-theme="dark"] .badge--nonmember {
    background: rgba(255, 255, 255, 0.06);
}

.table-empty,
.table-loading,
.table-error {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    background: var(--surface-color);
}

.table-error {
    color: var(--danger-color);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.btn {
    height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
    background: var(--bg-color);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn--danger {
    color: var(--danger-color);
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.06);
}

[data-theme="dark"] .btn--danger {
    background: rgba(239, 68, 68, 0.12);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.settings-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.settings-card-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.settings-card-desc {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
}

.settings-item:first-of-type {
    border-top: none;
    padding-top: 0;
}

.settings-item-left {
    min-width: 0;
}

.settings-item-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.settings-item-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    word-break: break-word;
}

.settings-item-subtitle code {
    padding: 2px 6px;
    border-radius: 8px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.switch {
    width: 46px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    flex: 0 0 auto;
}

.switch-thumb {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    transition: left 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.switch.is-on {
    background: var(--primary-color);
    border-color: rgba(99, 102, 241, 0.25);
}

.switch.is-on .switch-thumb {
    left: 21px;
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar {
        width: var(--sidebar-width-md);
    }

    .main {
        margin-left: var(--sidebar-width-md);
        width: calc(100% - var(--sidebar-width-md));
    }
}

@media (max-width: 968px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .seven-day-list {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .header-btn--sidebar {
        display: inline-flex;
    }

    .main {
        margin-left: 0;
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .seven-day-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content {
        padding: 14px;
    }

    .header {
        padding: 0 14px;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .user-name {
        display: none;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .stat-card,
    .chart-card {
        padding: 16px;
        border-radius: 14px;
    }

    .stats-grid {
        gap: 12px;
        margin-bottom: 20px;
    }

    .chart-container {
        height: 220px;
    }

    .seven-day-item {
        padding: 8px 10px;
        border-radius: 10px;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .table-toolbar-right {
        justify-content: space-between;
        width: 100%;
    }

    .table-search {
        min-width: 0;
        width: 100%;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

body.sidebar-collapsed {
    --sidebar-width: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .sidebar-header {
    padding: 24px 16px;
}

body.sidebar-collapsed .logo span {
    display: none;
}

body.sidebar-collapsed .sidebar-nav {
    padding: 16px 10px;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

body.sidebar-collapsed .nav-item span {
    display: none;
}

@media (max-width: 640px) {
    body.sidebar-collapsed {
        --sidebar-width: 0px;
    }
}