/* ================================================================
   工科资料分享 — Apple glass-morphism design system
   Light / Dark adaptive · Responsive (desktop & mobile)
   ================================================================ */

/* ── Reset & base ─────────────────────────────────────────────────── */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "SF Mono", "Menlo", "Consolas", "Courier New", monospace;

    /* Light glass theme (liquid glass) */
    --bg: linear-gradient(165deg, #e9eefc 0%, #f6f6fa 45%, #eeeefb 100%);
    --surface: rgba(255, 255, 255, 0.5);
    --surface-solid: #ffffff;
    --surface-secondary: #f5f5f7;
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.14);
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #aeaeb2;

    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-light: rgba(0, 113, 227, 0.1);

    --green: #34c759;
    --green-light: rgba(52, 199, 89, 0.12);
    --green-text: #1a7d36;
    --red: #ff3b30;
    --red-light: rgba(255, 59, 48, 0.1);
    --red-text: #c41e1a;
    --orange: #ff9500;
    --orange-light: rgba(255, 149, 0, 0.12);
    --orange-text: #b35300;
    --purple: #af52de;
    --blue-text: #005bb5;

    --glass-bg: rgba(255, 255, 255, 0.42);
    --glass-border: rgba(255, 255, 255, 0.68);
    --glass-shadow: 0 10px 34px rgba(80, 90, 140, 0.16);
    --navbar-bg: rgba(250, 250, 253, 0.55);
    --input-bg: rgba(0, 0, 0, 0.03);
    --input-bg-focus: rgba(255, 255, 255, 0.9);
    --code-bg: rgba(0, 0, 0, 0.05);
    --progress-track: #e5e5ea;
    --row-hover: rgba(0, 0, 0, 0.025);
    --overlay: rgba(0, 0, 0, 0.35);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);

    --navbar-height: 52px;
    --max-width: 1100px;

    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-slow: 0.45s cubic-bezier(0.22, 1, 0.36, 1);

    color-scheme: light;
}


html {
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-stack);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.35s ease, color 0.35s ease;
}

/* Ambient aurora background — Apple-style soft gradient blobs */
body::before {
    content: "";
    position: fixed;
    inset: -20%;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(38% 32% at 18% 22%, rgba(0, 113, 227, 0.22), transparent 70%),
        radial-gradient(34% 30% at 82% 18%, rgba(175, 82, 222, 0.2), transparent 70%),
        radial-gradient(40% 36% at 50% 88%, rgba(52, 199, 89, 0.16), transparent 70%),
        radial-gradient(28% 26% at 88% 72%, rgba(255, 149, 0, 0.14), transparent 70%);
    filter: blur(60px);
    animation: auroraFloat 26s ease-in-out infinite alternate;
}

@keyframes auroraFloat {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(2%, -2%, 0) scale(1.05); }
    100% { transform: translate3d(-2%, 2%, 0) scale(1.02); }
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
}

code {
    background: var(--code-bg) !important;
    color: var(--text);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.92em;
}

::selection {
    background: rgba(0, 113, 227, 0.25);
}
/* Sleek scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ── Navbar — frosted glass ───────────────────────────────────────── */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--navbar-height);
    background: var(--navbar-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.35s ease, box-shadow var(--transition);
}

.navbar.scrolled {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 6px 24px rgba(0, 0, 0, 0.08);
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 18px;
    color: var(--text);
    letter-spacing: -0.3px;
    flex-shrink: 0;
    transition: transform var(--transition);
}
.nav-logo:hover {
    color: var(--accent);
    transform: scale(1.02);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 18px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap;
}
.nav-links::-webkit-scrollbar {
    display: none;
}

.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--transition);
    flex-shrink: 0;
}
.nav-link:hover {
    color: var(--text);
}

.nav-user {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    padding: 4px 10px;
    background: var(--code-bg);
    border-radius: 20px;
    flex-shrink: 0;
}

.nav-logout {
    color: var(--text-tertiary) !important;
}
.nav-logout:hover {
    color: var(--red) !important;
}


/* ── Layout ───────────────────────────────────────────────────────── */

.main {
    flex: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 24px 80px;
    width: 100%;
}

/* Entrance animation — gentle staggered fade-up */
.main > * {
    animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.main > *:nth-child(2) { animation-delay: 0.05s; }
.main > *:nth-child(3) { animation-delay: 0.1s; }
.main > *:nth-child(4) { animation-delay: 0.15s; }
.main > *:nth-child(5) { animation-delay: 0.2s; }
.main > *:nth-child(6) { animation-delay: 0.25s; }
.main > *:nth-child(n+7) { animation-delay: 0.3s; }

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.footer {
    text-align: center;
    padding: 24px;
    font-size: 13px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border);
}

/* ── Flash messages ───────────────────────────────────────────────── */

.flash-container {
    max-width: var(--max-width);
    margin: 16px auto 0;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flash {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid transparent;
    animation: slideDown 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.flash-hide {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.flash-success {
    background: var(--green-light);
    color: var(--green-text);
    border-color: rgba(52, 199, 89, 0.25);
}

.flash-info {
    background: var(--accent-light);
    color: var(--blue-text);
    border-color: rgba(0, 113, 227, 0.2);
}

.flash-warning {
    background: var(--orange-light);
    color: var(--orange-text);
    border-color: rgba(255, 149, 0, 0.25);
}

.flash-danger {
    background: var(--red-light);
    color: var(--red-text);
    border-color: rgba(255, 59, 48, 0.25);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Page header ──────────────────────────────────────────────────── */

.page-header {
    margin-bottom: 40px;
}

.page-title {
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -0.8px;
    line-height: 1.15;
    margin-bottom: 8px;
}

.page-subtitle {
    font-size: 19px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.back-link {
    display: inline-block;
    font-size: 15px;
    color: var(--accent);
    margin-bottom: 12px;
}
.back-link:hover {
    text-decoration: underline;
}

.account-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-secondary);
    background: var(--code-bg);
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
}

/* ── Cards — frosted glass ────────────────────────────────────────── */

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--glass-shadow);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    transition: box-shadow var(--transition-slow), transform var(--transition-slow),
        background-color 0.35s ease, border-color 0.35s ease;
}

.card:hover {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--shadow-lg);
}

.card-header {
    padding: 20px 24px 0;
    font-size: 18px;
    font-weight: 600;
}

.card-body {
    padding: 20px 24px;
}

.card + .card {
    margin-top: 20px;
}

/* ── Stats grid ───────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--glass-shadow);
    border: 1px solid var(--glass-border);
    text-align: center;
    transition: transform var(--transition-slow), box-shadow var(--transition-slow),
        background-color 0.35s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--shadow-lg);
}

.stat-number {
    display: block;
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card--green .stat-number {
    color: var(--green);
}
.stat-card--purple .stat-number {
    color: var(--purple);
}

/* ── Section ──────────────────────────────────────────────────────── */

.section {
    margin-bottom: 40px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-title {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.4px;
}

/* ── Table — glass ────────────────────────────────────────────────── */

.table-wrap {
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--glass-shadow);
    border: 1px solid var(--glass-border);
    overflow-x: auto;
    transition: background-color 0.35s ease;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 14px 20px;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background-color var(--transition);
}

.table tbody tr:hover {
    background: var(--row-hover);
}

.td-mono {
    font-family: var(--font-mono);
}
.td-bold {
    font-weight: 600;
}
.td-muted {
    color: var(--text-secondary);
}

/* ── Badges ───────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-green {
    background: var(--green-light);
    color: var(--green-text);
}

.badge-red {
    background: var(--red-light);
    color: var(--red-text);
}

/* ── Detail grid ──────────────────────────────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.info-list {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 10px 12px;
}

.info-list dt {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.info-list dd {
    font-size: 15px;
    font-weight: 500;
}

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-stack);
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
    box-shadow: 0 6px 16px rgba(0, 113, 227, 0.35);
    transform: translateY(-1px);
}

.btn-outline {
    background: var(--input-bg);
    color: var(--accent);
    border: 1.5px solid var(--border-strong);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.btn-outline:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.25);
}
.btn-danger:hover {
    background: #e02d25;
    color: #fff;
    box-shadow: 0 6px 16px rgba(255, 59, 48, 0.35);
    transform: translateY(-1px);
}

.btn-danger-outline {
    background: transparent;
    color: var(--red);
    border: 1.5px solid var(--border-strong);
    font-size: 13px;
    padding: 6px 14px;
}
.btn-danger-outline:hover {
    background: var(--red-light);
    border-color: var(--red);
}

.btn-success {
    background: var(--green);
    color: #fff;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.25);
}
.btn-success:hover {
    background: #2db84d;
    color: #fff;
    box-shadow: 0 6px 16px rgba(52, 199, 89, 0.35);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid transparent;
}
.btn-ghost:hover {
    background: var(--input-bg);
    color: var(--text);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 17px;
    border-radius: var(--radius);
}

.btn-block {
    width: 100%;
}

/* ── Auth pages ───────────────────────────────────────────────────── */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--navbar-height) - 160px);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--glass-bg);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    padding: 40px 36px;
    transition: background-color 0.35s ease, border-color 0.35s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.6px;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ── Role toggle ──────────────────────────────────────────────────── */

.role-toggle {
    display: flex;
    background: var(--input-bg);
    border-radius: var(--radius);
    padding: 3px;
    margin-bottom: 4px;
}

.role-option {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.role-option.active {
    background: var(--surface-solid);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* ── Form fields ──────────────────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.field-input {
    padding: 12px 16px;
    font-size: 16px;
    font-family: var(--font-stack);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--input-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--transition);
    outline: none;
    width: 100%;
}

.field-input:focus {
    border-color: var(--accent);
    background: var(--input-bg-focus);
    box-shadow: 0 0 0 3.5px var(--accent-light);
}

.field-input::placeholder {
    color: var(--text-tertiary);
}

select.field-input,
.field-input[is="select"] {
    appearance: none;
}

input[type="checkbox"] {
    accent-color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Widget builder inputs (admin client detail) */
.wg-input,
.wg-select {
    background: var(--input-bg) !important;
    color: var(--text) !important;
}

/* ── Search form ──────────────────────────────────────────────────── */

.search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    max-width: 260px;
}

/* ── Upload zone ──────────────────────────────────────────────────── */

.upload-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: scale(1.005);
}

.upload-zone p {
    font-size: 15px;
    color: var(--text-secondary);
    margin: 12px 0;
}

.upload-zone svg {
    opacity: 0.5;
}

.file-preview-list {
    margin-top: 16px;
    text-align: left;
}

.file-preview-item {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--surface-secondary);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    animation: fadeUp 0.3s ease both;
}

/* Upload progress bars (inline-styled in templates) */
[id$="progress-wrap"] > div {
    background: var(--progress-track) !important;
}
#pub-progress-bar,
#upload-progress-bar {
    background: var(--accent) !important;
}

/* ── Files grid (client) ──────────────────────────────────────────── */

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.file-card {
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 14px;
    transition: all var(--transition-slow);
}

.file-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px) scale(1.01);
    border-color: var(--accent);
}

.file-card-icon {
    font-size: 32px;
    flex-shrink: 0;
    transition: transform var(--transition-slow);
}

.file-card:hover .file-card-icon {
    transform: scale(1.12) rotate(-4deg);
}

.file-card-body {
    flex: 1;
    min-width: 0;
}

.file-card-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.file-card-action {
    flex-shrink: 0;
}

.file-card--public {
    border-color: var(--green);
    border-left: 3px solid var(--green);
}

/* ── Lock banner ──────────────────────────────────────────────────── */

.lock-banner {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 32px;
    box-shadow: var(--glass-shadow);
    transition: background-color 0.35s ease;
}

.lock-banner-icon {
    font-size: 40px;
    animation: gentleBob 3s ease-in-out infinite;
}

@keyframes gentleBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.lock-banner-text h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.lock-banner-text p {
    font-size: 14px;
    color: var(--text-secondary);
}

.lock-banner .btn {
    margin-left: auto;
    flex-shrink: 0;
}


/* ── Empty state ──────────────────────────────────────────────────── */

.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
    font-size: 15px;
}

.empty-state {
    text-align: center;
    padding: 64px 24px;
}

.empty-state svg {
    margin-bottom: 20px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 15px;
    color: var(--text-secondary);
}

/* ── Modal — deep frosted glass ───────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--overlay);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

.modal {
    background: var(--glass-bg);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--shadow-lg);
    max-width: 440px;
    width: 90%;
    padding: 32px;
    position: relative;
    animation: scaleIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--input-bg);
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--red-light);
    color: var(--red);
    transform: rotate(90deg);
}

.modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-body {
    margin-bottom: 24px;
}

.modal-footer {
    display: flex;
    gap: 10px;
}

.modal-footer .btn {
    flex: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ── QR code area ─────────────────────────────────────────────────── */

.qr-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.qr-placeholder {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: #fff;
}

.qr-note {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.qr-amount {
    font-size: 32px;
    font-weight: 700;
    color: var(--red);
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.qr-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

.text-center {
    text-align: center;
}

.modal-sm {
    max-width: 380px;
}

/* ── Registration success ─────────────────────────────────────────── */

.reg-success-icon {
    font-size: 48px;
    margin-bottom: 12px;
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.4);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.account-reveal {
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    margin: 8px 0;
}

.account-no-big {
    font-family: var(--font-mono);
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--accent);
}

.account-hint {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ── Admin login icon ─────────────────────────────────────────────── */

.admin-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

/* ── Cloud widgets ────────────────────────────────────────────────── */

.sensor-value {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -1px;
    text-align: center;
    padding: 16px;
    font-variant-numeric: tabular-nums;
    transition: color var(--transition);
}

.sensor-unit {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-tertiary);
}

.switch-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.switch-state {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: auto;
}

.threshold-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 15px;
}

.alarm-row {
    font-size: 15px;
}

.alarm-dot {
    transition: background var(--transition), box-shadow var(--transition);
    box-shadow: 0 0 8px rgba(52, 199, 89, 0.5);
}

/* ── Chat ─────────────────────────────────────────────────────────── */

.chat-container {
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 260px);
    min-height: 400px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-bubble {
    max-width: 75%;
    animation: fadeUp 0.3s ease both;
}

.chat-bubble--mine {
    align-self: flex-end;
}

.chat-bubble--theirs {
    align-self: flex-start;
}

.chat-bubble-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    padding: 0 4px;
}

.chat-bubble--mine .chat-bubble-meta {
    justify-content: flex-end;
}

.chat-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.chat-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

.chat-bubble-text {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    transition: all var(--transition);
}

.chat-bubble--mine .chat-bubble-text {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 113, 227, 0.3);
}

.chat-bubble--theirs .chat-bubble-text {
    background: var(--surface-secondary);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
}

.chat-input-bar {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--input-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 1.5px solid var(--border);
    border-radius: 24px;
    font-size: 15px;
    font-family: var(--font-stack);
    color: var(--text);
    background: var(--input-bg);
    outline: none;
    transition: all var(--transition);
}

.chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.chat-send-btn {
    border-radius: 24px !important;
    padding: 10px 24px !important;
}

/* ── Admin message list ───────────────────────────────────────────── */

.msg-client-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg-client-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    text-decoration: none;
    transition: all var(--transition-slow);
}

.msg-client-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--accent);
    transform: translateX(4px);
}

.msg-client-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

.msg-client-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.msg-client-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.msg-client-status {
    display: inline-flex;
}

.msg-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    background: var(--red);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 0 6px;
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.msg-arrow {
    font-size: 18px;
    color: var(--text-tertiary);
    transition: transform var(--transition);
}

.msg-client-card:hover .msg-arrow {
    transform: translateX(3px);
    color: var(--accent);
}

/* ── Batch actions ────────────────────────────────────────────────── */

.batch-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--red-light);
    border: 1px solid rgba(255, 59, 48, 0.2);
    border-radius: var(--radius);
    animation: fadeUp 0.25s ease both;
}

.batch-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--red);
}

.td-actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ── Inline-style harmonization for dark mode ─────────────────────── */
/* Templates contain a few hard-coded light backgrounds; remap them.  */

div[style*="background:#f5f5f7"],
form[style*="background:#f5f5f7"] {
    background: var(--surface-secondary) !important;
}

form[style*="background:#e8f8ed"] {
    background: var(--green-light) !important;
}

#cloud-form details {
    background: var(--surface-secondary) !important;
}

#json-preview {
    background: var(--input-bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .page-title { font-size: 26px; }
    .page-header { margin-bottom: 24px; }
    .page-subtitle { font-size: 15px; }
    .main { padding: 20px 12px 60px; }

    /* Stats */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 18px 12px; }
    .stat-number { font-size: 30px; }

    /* Cards */
    .card { border-radius: var(--radius); }
    .card-header { padding: 14px 16px 0; font-size: 16px; }
    .card-body { padding: 14px 16px; }

    /* Nav */
    .nav-inner { padding: 0 12px; gap: 8px; }
    .nav-links { gap: 12px; flex: 1; justify-content: flex-end; }
    .nav-link { font-size: 12px; }
    .nav-user { display: none; }

    /* Table - horizontal scroll */
    .table-wrap { border-radius: var(--radius); }
    .table th, .table td { padding: 10px 12px; font-size: 13px; }

    /* Auth */
    .auth-card { padding: 28px 20px; max-width: 100%; border-radius: var(--radius-lg); }
    .auth-title { font-size: 26px; }

    /* Files */
    .files-grid { grid-template-columns: 1fr; gap: 10px; }
    .file-card { padding: 12px 14px; gap: 10px; }

    /* Lock banner */
    .lock-banner { flex-direction: column; text-align: center; padding: 16px; }
    .lock-banner .btn { margin-left: 0; width: 100%; }

    /* Detail grid */
    .detail-grid { grid-template-columns: 1fr; gap: 16px; }

    /* Upload zone */
    .upload-zone { padding: 20px 12px; }

    /* Modal - full width on mobile */
    .modal { width: 95%; padding: 20px 16px; max-width: 100%; border-radius: var(--radius); }
    .modal-header h2 { font-size: 20px; }
    .modal-footer { flex-direction: column; }

    /* Chat */
    .chat-container { height: calc(100vh - 220px); min-height: 300px; }
    .chat-messages { padding: 12px 14px; gap: 10px; }
    .chat-bubble { max-width: 85%; }
    .chat-bubble-text { padding: 10px 12px; font-size: 14px; }
    .chat-input-bar { padding: 10px 12px; gap: 6px; }

    /* Search */
    .search-form { flex-wrap: wrap; }
    .search-input { max-width: 100%; flex: 1; }

    /* Section header */
    .section-header { flex-direction: column; align-items: flex-start; }

    /* Msg client list */
    .msg-client-card { padding: 10px 14px; }
    .msg-client-avatar { width: 32px; height: 32px; font-size: 14px; }

    /* Batch actions */
    .batch-actions { flex-wrap: wrap; }

    /* Cloud widgets */
    .sensor-value { font-size: 36px; }
    .switch-row, .threshold-row { flex-direction: column; align-items: flex-start; }
    .switch-state { margin-right: 0; }
    .wg-row, .wg-row-3 { grid-template-columns: 1fr; }
}

/* Extra small phones */
@media (max-width: 400px) {
    .page-title { font-size: 22px; }
    .stat-number { font-size: 26px; }
    .auth-card { padding: 20px 12px; }
    .auth-title { font-size: 22px; }
    .btn-lg { padding: 12px 20px; font-size: 15px; }
    .chat-bubble { max-width: 90%; }
    .nav-logo span { display: none; }
    .modal { padding: 16px 12px; }
    .qr-amount { font-size: 26px; }
    .account-no-big { font-size: 36px; letter-spacing: 4px; }
}

/* ── Accessibility: reduced motion ────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    body::before {
        animation: none;
    }
}

/* ── 手机浏览器专属适配（UA 识别 body.is-mobile）────────────────── */
/* 手机端导航：功能直接平铺右上角（横向排列，可左右滚动） */
body.is-mobile .nav-inner { gap: 10px; }
body.is-mobile .nav-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap;
    position: static;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}
body.is-mobile .nav-links::-webkit-scrollbar { display: none; }
body.is-mobile .nav-links .nav-link,
body.is-mobile .nav-links .nav-logout {
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text, #1d1d1f);
    border-radius: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}
body.is-mobile .nav-links .nav-link:hover,
body.is-mobile .nav-links .nav-logout:hover { background: rgba(255, 255, 255, 0.55); color: var(--text, #1d1d1f); }
body.is-mobile .nav-links .nav-user { display: none; }
body.is-mobile .nav-logo span { display: none; }

/* 页面紧凑化 */
body.is-mobile .main { padding: 16px 10px 50px; }
body.is-mobile .page-title { font-size: 22px; }
body.is-mobile .lock-banner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 22px 16px;
    gap: 12px;
}
body.is-mobile .lock-banner-text { text-align: center; }
body.is-mobile .lock-banner .btn { margin-left: 0; width: 100%; }
body.is-mobile .page-subtitle { font-size: 14px; }
body.is-mobile .page-header { margin-bottom: 16px; }
body.is-mobile .section { padding: 14px; margin-bottom: 14px; }
body.is-mobile .section-title { font-size: 17px; }
body.is-mobile .section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
body.is-mobile .card-body { padding: 12px 14px; }
body.is-mobile .field-label { font-size: 13px; }
body.is-mobile .btn { padding: 8px 12px; font-size: 13px; }

/* 宽表格 → 卡片列表（thead 隐藏，每行变卡片，td 显示列名） */
body.is-mobile table { display: block; width: 100%; }
body.is-mobile thead { display: none; }
body.is-mobile tbody { display: block; width: 100%; }
body.is-mobile tr {
    display: block;
    margin: 12px 0;
    padding: 10px 12px;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border, #e5e5ea);
    border-radius: 10px;
}
body.is-mobile td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 5px 0;
    border: none;
    font-size: 13px;
    text-align: right;
}
body.is-mobile td::before {
    content: attr(data-label);
    color: #888;
    font-size: 12px;
    flex-shrink: 0;
    text-align: left;
}
body.is-mobile td:first-child { display: block; text-align: left; }
body.is-mobile td:first-child::before { display: none; }
body.is-mobile td form { display: inline-flex; }
body.is-mobile .badge { font-size: 12px; }
body.is-mobile code { word-break: break-all; }

/* 卡密管理/客户列表的批量操作栏 */
body.is-mobile .batch-actions { flex-direction: column; align-items: stretch; gap: 8px; }
body.is-mobile .search-form { flex-direction: column; align-items: stretch; }
body.is-mobile .search-form .btn { width: 100%; }

/* 手机端玻璃加固：背景更实，保证可读性与性能 */
body.is-mobile .card,
body.is-mobile .table-wrap,
body.is-mobile .stat-card,
body.is-mobile .modal,
body.is-mobile .auth-card {
    background: rgba(255, 255, 255, 0.74);
}

