:root {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --line: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #14b8a6;
    --accent-hover: #0d9488;
    --danger: #f43f5e;
    --card: #ffffff;
    --card-text: #0f172a;
    --card-muted: #64748b;
    --input: #f8fafc;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--card-text);
    background: #f1f5f9;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0f172a 0%, #134e4a 100%);
}
.login-card {
    width: 380px;
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.login-card h1 {
    margin: 0 0 8px;
    font-size: 22px;
}
.login-card p.sub {
    margin: 0 0 24px;
    color: var(--card-muted);
    font-size: 14px;
}

.layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 232px;
    background: var(--bg);
    color: var(--text);
    padding: 24px 16px;
    flex-shrink: 0;
}
.brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0 12px 28px;
}
.brand span { color: var(--accent); }
.nav a {
    display: block;
    color: var(--muted);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
}
.nav a:hover, .nav a.active {
    background: var(--bg-soft);
    color: #fff;
}
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}
.topbar .who { color: var(--card-muted); font-size: 14px; }
.topbar .who a { margin-left: 12px; }
.content { padding: 28px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}
.page-head h2 { margin: 0; font-size: 22px; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.stat {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.stat .label { color: var(--card-muted); font-size: 13px; }
.stat .num { font-size: 32px; font-weight: 700; margin-top: 8px; }

.card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}
.toolbar form { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.toolbar-sep {
    color: var(--muted, #64748b);
    font-size: 13px;
    line-height: 38px;
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
    height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0 12px;
    background: var(--input);
    font-size: 14px;
    color: var(--card-text);
    min-width: 160px;
}
textarea { height: 100px; padding: 10px 12px; width: 100%; resize: vertical; }
.form-grid { max-width: 640px; }
.form-item { margin-bottom: 16px; }
.form-item label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--card-muted); }
.form-item input:not([type="radio"]):not([type="checkbox"]),
.form-item select,
.form-item textarea { width: 100%; min-width: 0; }
.input-with-action {
    display: flex;
    gap: 8px;
    align-items: center;
}
.input-with-action input {
    flex: 1;
    min-width: 0;
}
.input-with-action .btn {
    flex-shrink: 0;
}
.gen-password-plain {
    flex-shrink: 0;
    font-size: 13px;
    color: var(--card-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    user-select: all;
}
.radio-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 28px;
    align-items: center;
    min-height: 38px;
}
.radio-row label {
    color: var(--card-text);
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin: 0;
    width: auto;
    white-space: nowrap;
    flex: none;
    cursor: pointer;
    font-size: 14px;
}
.radio-row input[type="radio"],
.radio-row input[type="checkbox"] {
    width: auto;
    min-width: 0;
    height: auto;
    margin: 0;
    flex: none;
    accent-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    background: var(--accent);
    color: #fff;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost {
    background: #e2e8f0;
    color: var(--card-text);
}
.btn-ghost:hover { background: #cbd5e1; color: var(--card-text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #e11d48; color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-link { background: transparent; color: var(--danger); padding: 0; height: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
th { color: var(--card-muted); font-weight: 600; font-size: 13px; }
.text-clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
}
.badge-on { background: #ccfbf1; color: #0f766e; }
.badge-off { background: #fee2e2; color: #b91c1c; }
.badge-action {
    cursor: pointer;
    border: none;
    font: inherit;
    line-height: inherit;
}

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-ok { background: #ccfbf1; color: #115e59; }
.alert-err { background: #ffe4e6; color: #9f1239; }

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding-top: 16px;
}
.pagination-total {
    color: var(--card-muted);
    font-size: 13px;
    white-space: nowrap;
}
.pagination {
    display: flex;
    gap: 6px;
    list-style: none;
    padding: 16px 0 0;
    margin: 0;
    flex-wrap: wrap;
}
.pagination-bar .pagination {
    padding: 0;
}
.pagination li a, .pagination li span {
    display: inline-flex;
    min-width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 0 8px;
    color: var(--card-text);
    background: #e2e8f0;
}
.pagination .active span { background: var(--accent); color: #fff; }
.empty { text-align: center; color: var(--card-muted); padding: 32px 0; }
.form-hint { margin-top: 6px; font-size: 12px; color: var(--card-muted); }
.text-clip {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.article-body {
    max-height: 480px;
    overflow: auto;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    line-height: 1.6;
}
.meta-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 12px;
    margin-bottom: 16px;
    font-size: 14px;
}
.meta-grid .label { color: var(--card-muted); }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.photo-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.photo-thumb {
    width: 300px;
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #e2e8f0;
    position: relative;
}
.photo-thumb img {
    display: block;
    width: 300px;
    max-width: 100%;
    height: auto;
}
.photo-missing {
    display: none;
    width: 300px;
    max-width: 100%;
    min-height: 180px;
    align-items: center;
    justify-content: center;
    color: var(--card-muted);
    font-size: 13px;
}
.photo-meta {
    font-size: 13px;
    color: var(--card-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.photo-id {
    font-weight: 600;
    color: var(--card-text);
}
.photo-alt { color: var(--card-text); }
.photo-status { margin-top: 2px; }

.page-loading-mask {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
}
.page-loading-mask[hidden] {
    display: none !important;
}
.page-loading-card {
    background: #fff;
    border-radius: 12px;
    padding: 28px 36px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 240px;
}
.page-loading-card p {
    margin: 0;
    color: var(--card-text);
    font-size: 14px;
}
.page-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: page-loading-spin 0.8s linear infinite;
}
@keyframes page-loading-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 960px) {
    .stats { grid-template-columns: 1fr 1fr; }
    .sidebar { width: 200px; }
}
