:root {
    --bg: #f3f5f9;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --border: #e5e7eb;
    --danger: #dc2626;
    --radius: 14px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(180deg, #e8eef9 0%, var(--bg) 180px);
    color: var(--text);
    min-height: 100vh;
}
.app { max-width: 920px; margin: 0 auto; padding: 16px 14px 40px; }
.topbar { margin-bottom: 14px; }
.brand { display: flex; gap: 10px; align-items: flex-start; }
.brand-icon { font-size: 28px; line-height: 1.2; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.user-bar { margin-top: 8px; display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; }
.inline { display: inline; }

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    padding: 16px;
    margin-bottom: 14px;
}
.card h2 {
    margin: 0 0 14px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: #374151; }
.req { color: var(--danger); }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 15px;
    background: #fff;
    outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.field textarea { min-height: 88px; resize: vertical; }

.upload-box {
    border: 1.5px dashed #cbd5e1;
    border-radius: 12px;
    padding: 22px 12px;
    text-align: center;
    color: var(--muted);
    background: #f8fafc;
    cursor: pointer;
}
.upload-box strong { display: block; color: #334155; margin-top: 6px; }
.upload-box input { display: none; }
.preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.preview img, .preview video {
    width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: none; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
    text-decoration: none;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: #eef2ff; color: #3730a3; }
.btn-danger { background: #fee2e2; color: var(--danger); padding: 6px 10px; font-size: 12px; border-radius: 8px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 10px; }
.toolbar .field { margin: 0; flex: 1; min-width: 140px; }
.stats-line { color: var(--muted); font-size: 13px; margin: 8px 0 12px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 680px; }
table.data th, table.data td {
    border-bottom: 1px solid var(--border);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
table.data .deduction { color: var(--danger); font-weight: 700; }

.alert { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }

.login-wrap { max-width: 400px; margin: 40px auto; }
.nav-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.nav-links a { font-size: 13px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-item { background: #f8fafc; border-radius: 10px; padding: 10px; text-align: center; }
.stat-item .n { font-size: 20px; font-weight: 700; color: var(--primary); }
.stat-item .l { font-size: 12px; color: var(--muted); }

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.media-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.media-thumb {
    display: block;
    aspect-ratio: 1;
    background: #f1f5f9;
    overflow: hidden;
}
.media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.media-video-cover {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #1e3a8a;
    background: linear-gradient(160deg, #dbeafe, #eff6ff);
    padding: 8px;
    text-align: center;
}
.media-video-cover span { font-size: 18px; font-weight: 700; }
.media-video-cover small { font-size: 11px; color: #64748b; word-break: break-all; }
.media-meta { padding: 8px 10px 10px; font-size: 12px; line-height: 1.4; }
.media-meta .muted { color: var(--muted); margin-top: 2px; }
.media-actions {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.media-actions a { color: var(--primary); text-decoration: none; }
.link-danger {
    background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; font-size: 12px;
}

@media (max-width: 640px) {
    .brand h1 { font-size: 18px; }
    .stat-grid { grid-template-columns: 1fr 1fr 1fr; }
    .media-grid { grid-template-columns: repeat(2, 1fr); }
}
