/* ============================================================
 * apple.css — 基础类（reset / typography / utilities / color）
 * Apple 风格系统：白底、系统蓝、SF Pro 字体栈、圆角、阴影
 * ============================================================ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --c-bg: #ffffff;
    --c-bg-soft: #f5f5f7;
    --c-bg-muted: #fbfbfd;
    --c-bg-elevated: #ffffff;
    --c-text: #1d1d1f;
    --c-text-soft: #424245;
    --c-text-muted: #6e6e73;
    --c-text-faint: #86868b;
    --c-border: #d2d2d7;
    --c-border-soft: #e8e8ed;
    --c-primary: #0071e3;
    --c-primary-hover: #0077ed;
    --c-primary-soft: rgba(0, 113, 227, 0.1);
    --c-success: #34c759;
    --c-warning: #ff9500;
    --c-danger: #ff3b30;
    --c-info: #5ac8fa;
    --c-purple: #af52de;

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --r-2xl: 28px;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.04);
    --shadow-3: 0 12px 32px rgba(0, 0, 0, 0.08), 0 24px 60px rgba(0, 0, 0, 0.06);

    --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast: 150ms;
    --t-base: 250ms;
    --t-slow: 400ms;

    --container-max: 1140px;
}

html, body {
    background: var(--c-bg);
    color: var(--c-text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--c-primary);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}

a:hover { color: var(--c-primary-hover); }

img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--c-text);
}

h1 { font-size: 36px; line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 24px; line-height: 1.25; font-weight: 600; }
h3 { font-size: 19px; line-height: 1.3; font-weight: 600; }
h4 { font-size: 17px; line-height: 1.4; font-weight: 600; }

p { color: var(--c-text-soft); line-height: 1.55; }

code, pre {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

/* ===== Layout ===== */
.app-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

.app-main {
    flex: 1;
    padding: 32px 0 64px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--c-border-soft);
}

.app-header-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--c-text);
    font-size: 17px;
    letter-spacing: -0.01em;
}

.app-brand:hover { color: var(--c-text); }

.app-brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-primary), var(--c-purple));
    box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.15);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    margin-left: 16px;
}

.app-nav-link {
    color: var(--c-text-soft);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--r-sm);
    transition: all var(--t-fast) var(--ease);
}

.app-nav-link:hover {
    color: var(--c-text);
    background: var(--c-bg-soft);
}

.app-nav-link.active {
    color: var(--c-primary);
    background: var(--c-primary-soft);
}

.app-nav-link.admin-link {
    color: var(--c-text-soft);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
}

.app-nav-link.admin-link:hover {
    color: var(--c-text);
    background: var(--c-bg-soft);
}

.app-nav-link.admin-link.active,
.app-nav-dropdown.open > .app-nav-link.admin-link {
    color: var(--c-primary);
    background: var(--c-primary-soft);
}

.app-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--c-text-soft);
}

.app-user-name { font-weight: 500; }

.app-user-role {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.role-superadmin { background: rgba(255, 59, 48, 0.12); color: var(--c-danger); }
.role-admin { background: rgba(175, 82, 222, 0.12); color: var(--c-purple); }
.role-staff { background: var(--c-bg-soft); color: var(--c-text-muted); }

.app-user-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--c-bg-soft);
    transition: background var(--t-fast) var(--ease);
}

.app-user-action:hover { background: var(--c-border-soft); }

.app-user-logout { display: inline; }

.app-logout-btn {
    background: transparent;
    border: 0;
    color: var(--c-text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    font-family: inherit;
}

.app-logout-btn:hover { color: var(--c-danger); background: rgba(255, 59, 48, 0.08); }

.app-footer {
    text-align: center;
    padding: 24px 16px 32px;
    color: var(--c-text-faint);
    font-size: 12px;
    border-top: 1px solid var(--c-border-soft);
    margin-top: 32px;
}

.app-footer a { color: var(--c-text-faint); }
.app-footer a:hover { color: var(--c-text-muted); }
.app-footer p + p { margin-top: 4px; }

body.no-nav .app-main { padding-top: 0; }

/* ===== Cards ===== */
.card {
    background: var(--c-bg-elevated);
    border: 1px solid var(--c-border-soft);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-1);
    transition: box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}

.card.elevated { box-shadow: var(--shadow-2); }

.card-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--c-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    background: var(--c-primary-soft);
    color: var(--c-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.card-section { padding: 16px 0; }
.card-section + .card-section { border-top: 1px solid var(--c-border-soft); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border: 0;
    border-radius: var(--r-md);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--t-fast) var(--ease);
    text-decoration: none;
    background: var(--c-bg-soft);
    color: var(--c-text);
    white-space: nowrap;
}

.btn:hover { background: var(--c-border-soft); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--c-primary);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 113, 227, 0.3);
}

.btn-primary:hover { background: var(--c-primary-hover); color: white; }

.btn-secondary {
    background: var(--c-bg-soft);
    color: var(--c-text);
}

.btn-danger {
    background: var(--c-danger);
    color: white;
}

.btn-danger:hover { background: #ff453a; color: white; }

.btn-ghost {
    background: transparent;
    color: var(--c-primary);
}

.btn-ghost:hover { background: var(--c-primary-soft); }

/* v2.32.38: 透明底 + 红色文字 icon button (用于表格里的删除按钮) */
.btn-ghost-danger {
    background: transparent;
    color: #ff3b30;
    border: 1px solid transparent;
}
.btn-ghost-danger:hover { background: rgba(255, 59, 48, 0.1); }

.btn-large {
    padding: 14px 24px;
    font-size: 16px;
    border-radius: var(--r-lg);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--r-sm);
}

.btn-block { display: flex; width: 100%; }

.btn-group {
    display: inline-flex;
    gap: 8px;
}

/* ===== Form ===== */
.form-row { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-soft);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    font-family: inherit;
    transition: all var(--t-fast) var(--ease);
    -webkit-appearance: none;
    appearance: none;
}

/* 下拉项居中（仅顶部筛选器；表单主体内左对齐） */
.form-select { text-align-last: center; }
.form-row .form-select,
.form-grid .form-select { text-align: start; text-align-last: start; }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 4px var(--c-primary-soft);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--c-text-faint); }

.form-textarea { min-height: 80px; resize: vertical; }

.form-help {
    font-size: 12px;
    color: var(--c-text-muted);
    margin-top: 4px;
}

.form-error {
    color: var(--c-danger);
    font-size: 12px;
    margin-top: 4px;
}

.form-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--c-text-soft);
}

.form-checkbox input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--c-primary); }

.form-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.form-switch-track {
    width: 38px;
    height: 22px;
    background: var(--c-border);
    border-radius: 11px;
    position: relative;
    transition: background var(--t-fast) var(--ease);
}

.form-switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform var(--t-fast) var(--ease);
}

.form-switch input:checked ~ .form-switch-track { background: var(--c-success); }
.form-switch input:checked ~ .form-switch-track::after { transform: translateX(16px); }

/* ===== Tables ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th, .table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--c-border-soft);
    vertical-align: middle;
}

.table th {
    font-weight: 600;
    color: var(--c-text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--c-bg-soft);
}

.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--c-bg-muted); }
.table tbody tr:last-child td { border-bottom: 0; }

.table-empty {
    text-align: center;
    color: var(--c-text-muted);
    padding: 40px;
    font-size: 14px;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--c-bg-soft);
    color: var(--c-text-muted);
    letter-spacing: 0.02em;
}

.badge-success { background: rgba(52, 199, 89, 0.12); color: #1f8a3c; }
.badge-danger { background: rgba(255, 59, 48, 0.12); color: #d70015; }
.badge-warning { background: rgba(255, 149, 0, 0.12); color: #b75c00; }
.badge-info { background: rgba(0, 113, 227, 0.12); color: var(--c-primary); }
.badge-purple { background: rgba(175, 82, 222, 0.12); color: var(--c-purple); }
.badge-gray { background: var(--c-bg-soft); color: var(--c-text-muted); }

/* ===== Utilities ===== */
.text-muted { color: var(--c-text-muted); }
.text-faint { color: var(--c-text-faint); }
.text-danger { color: var(--c-danger); }
.text-success { color: var(--c-success); }
.text-warning { color: var(--c-warning); }
.text-primary { color: var(--c-primary); }
.text-purple { color: var(--c-purple); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-small { font-size: 12px; }
.text-tiny { font-size: 11px; }
.text-bold { font-weight: 600; }
.text-mono { font-family: ui-monospace, SFMono-Regular, monospace; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { flex-direction: column; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.w-full { width: 100%; }
.w-auto { width: auto; }

/* ===== Page header ===== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--c-text);
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--c-text-muted);
    font-size: 14px;
}

.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ===== Stat cards ===== */
.stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--c-bg);
    border: 1px solid var(--c-border-soft);
    border-radius: var(--r-lg);
    transition: all var(--t-base) var(--ease);
}

.stat:hover { box-shadow: var(--shadow-1); transform: translateY(-1px); }

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background: var(--c-primary-soft);
    color: var(--c-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--c-text);
}

.stat-label {
    font-size: 12px;
    color: var(--c-text-muted);
    margin-top: 2px;
}

.stat-content { flex: 1; min-width: 0; }

/* ===== Alert ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    white-space: pre-wrap; /* v2.32.15: 支持错误提示的多行 \n 换行 */
    word-break: break-word;
}

.alert-success { background: rgba(52, 199, 89, 0.1); border-color: rgba(52, 199, 89, 0.3); color: #1f8a3c; }
.alert-danger { background: rgba(255, 59, 48, 0.1); border-color: rgba(255, 59, 48, 0.3); color: #d70015; }
.alert-warning { background: rgba(255, 149, 0, 0.1); border-color: rgba(255, 149, 0, 0.3); color: #b75c00; }
.alert-info { background: rgba(0, 113, 227, 0.08); border-color: rgba(0, 113, 227, 0.2); color: var(--c-primary); }

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 200;
    background: rgba(29, 29, 31, 0.92);
    color: white;
    padding: 12px 18px;
    border-radius: var(--r-md);
    font-size: 13px;
    box-shadow: var(--shadow-3);
    display: none;            /* 默认隐藏，避免在页面上占用位置 */
    align-items: center;
    gap: 6px;
    max-width: 360px;
    backdrop-filter: blur(20px);
    animation: toastSlideIn var(--t-base) var(--ease-out);
}

.toast.show { display: inline-flex; }

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(-8px) translateX(0); }
    to   { opacity: 1; transform: translateY(0)    translateX(0); }
}
.toast.toast-success { background: rgba(52, 199, 89, 0.95); }
.toast.toast-error { background: rgba(255, 59, 48, 0.95); }
.toast.toast-warning { background: rgba(255, 149, 0, 0.95); }

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--c-text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state-title { font-size: 17px; color: var(--c-text-soft); margin-bottom: 4px; }
.empty-state-desc { font-size: 13px; }

/* ===== Mobile ===== */
@media (max-width: 720px) {
    .app-header-inner { gap: 12px; padding: 0 16px; }
    .app-nav { display: none; }
    .app-container { padding: 0 16px; }
    h1 { font-size: 28px; }
    .page-title { font-size: 22px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn var(--t-slow) var(--ease-out); }

/* 页面内容入场动画（全局加载/跳转） */
.page-fade {
    animation: pageFadeIn 0.35s var(--ease-out) both;
}
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 顶部进度条（点击链接、表单提交时） */
.page-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--c-primary), #5ac8fa);
    z-index: 9999;
    transition: width 0.4s var(--ease-out);
    box-shadow: 0 0 8px var(--c-primary);
}
.page-progress.active { width: 100%; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
