:root {
    --navy: #0b2545;
    --navy-2: #13315c;
    --teal: #0f8b8d;
    --accent: #e8a33d;
    --ink: #1a2433;
    --muted: #6b7788;
    --line: #e4e9f0;
    --bg: #f3f6fa;
    --card: #fff;
    --danger: #c0392b;
    --success: #1f8a5b;
    --warn: #a86b00;
    --radius: 12px;
    --shadow: 0 10px 28px rgba(11, 37, 69, .08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    font-size: 14px;
    line-height: 1.6;
}
a { color: var(--navy-2); text-decoration: none; }
a:hover { color: var(--teal); }
code { background: #eef2f7; border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }
.muted { color: var(--muted); }
.inline-form { display: inline-flex; margin: 0; }

.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 232px;
    flex: none;
    background: linear-gradient(180deg, #071a33, #0b2545 55%, #0c2c4a);
    color: rgba(255, 255, 255, .78);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #1d5aa6, var(--teal));
    color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .5px;
}
.sidebar-brand strong { display: block; color: #fff; font-size: 16px; letter-spacing: 1px; }
.sidebar-brand small { display: block; font-size: 11px; color: #8fb3c9; letter-spacing: 2px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav a { color: rgba(255, 255, 255, .72); padding: 10px 12px; border-radius: 9px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-nav a.active { background: linear-gradient(90deg, rgba(15, 139, 141, .38), rgba(15, 139, 141, .08)); color: #fff; box-shadow: inset 2px 0 0 var(--teal); }
.sidebar-nav .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-sep { margin: 18px 12px 6px; font-size: 10.5px; letter-spacing: 2px; color: #6d8ba3; text-transform: uppercase; }
.sidebar-foot { margin-top: auto; padding: 18px 10px 4px; display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: #6d8ba3; border-top: 1px solid rgba(255, 255, 255, .1); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { min-height: 66px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left strong { font-size: 16px; color: var(--navy); white-space: nowrap; }
.topbar-left .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.admin-content { padding: 24px 28px 44px; }

.flash-wrap { padding: 0 28px; }
.alert { border-radius: 9px; padding: 11px 14px; margin-top: 14px; font-size: 13.5px; border: 1px solid transparent; }
.alert-success { background: #eaf7f0; border-color: #b7e3cb; color: #176b47; }
.alert-error { background: #fdecea; border-color: #f3c3bd; color: #922f25; }
.alert-warn { background: #fff7e6; border-color: #f1d9a8; color: #7a4d00; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 22px; box-shadow: 0 1px 2px rgba(15, 23, 42, .03); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.panel-head h2::before { content: ""; display: inline-block; width: 4px; height: 16px; border-radius: 2px; background: var(--teal); margin-right: 9px; vertical-align: -2px; }
.page-title { margin: 0 0 2px; font-size: 21px; color: var(--navy); }
.toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat-card .stat-label { font-size: 12.5px; color: var(--muted); letter-spacing: .4px; }
.stat-card strong { font-size: 24px; color: var(--navy); line-height: 1.25; }
.stat-card a { font-size: 12.5px; color: var(--teal); }
.stat-card.accent { background: linear-gradient(135deg, #0f8b8d, #116b7a); border: 0; color: #fff; }
.stat-card.accent .stat-label, .stat-card.accent a { color: rgba(255, 255, 255, .8); }
.stat-card.accent strong { color: #fff; font-size: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .3px; background: #f8fafc; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdff; }
.table .title-cell { max-width: 420px; }
.table .title-cell a { font-weight: 600; }
.table .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.table .actions form button { background: none; border: 0; padding: 0; cursor: pointer; font-size: 13.5px; }

.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--navy-2); font-size: 13.5px; }
.link:hover { color: var(--teal); }
.link.danger { color: var(--danger); }
.link.danger:hover { color: #8e271d; }
.ghost-btn, .primary-btn {
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; padding: 9px 15px; font-size: 13.5px; cursor: pointer;
    border: 1px solid var(--line); background: #fff; color: var(--navy-2); font-weight: 600;
    transition: .15s;
}
.ghost-btn:hover { border-color: #b9c7d6; background: #f7fafc; color: var(--navy); }
.ghost-btn.danger { color: var(--danger); }
.primary-btn { background: var(--navy); border-color: var(--navy); color: #fff; }
.primary-btn:hover { background: var(--navy-2); color: #fff; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; background: #eef2f7; color: #536174; }
.badge-success, .badge-published { background: #e6f6ee; color: #176b47; }
.badge-running, .badge-queued { background: #fff4dc; color: #8a5a00; }
.badge-failed, .badge-partial, .badge-offline { background: #fdecea; color: #922f25; }
.badge-draft { background: #eef2f7; color: #536174; }
.badge-muted { background: #f1f4f8; color: #7b8796; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-grid .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #425063; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url],
input[type=datetime-local], select, textarea {
    width: 100%; border: 1px solid #d8e0e9; border-radius: 8px; padding: 9px 11px;
    font: inherit; font-weight: 400; color: var(--ink); background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 139, 141, .13); }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; padding-top: 6px; }
label.check input { width: auto; }
.form-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-section h3 { margin: 0 0 14px; font-size: 15px; color: var(--navy); }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-panel { max-width: 980px; }
.narrow-panel { max-width: 620px; }

.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.filter-bar select, .filter-bar input[type=text] { width: auto; min-width: 140px; }
.pager-row { display: flex; align-items: center; gap: 14px; justify-content: flex-end; margin-top: 16px; }

.content-editor-form { display: flex; flex-direction: column; gap: 18px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.editor-actions { display: flex; gap: 10px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 20px; align-items: start; }
.editor-main { display: flex; flex-direction: column; gap: 14px; }
.editor-side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 82px; }
.title-input { font-size: 18px !important; font-weight: 700 !important; color: var(--navy) !important; }
.form-grid.single label { font-size: 12.5px; }

.image-field { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.image-field:last-of-type { border-bottom: 0; }
.image-field img { max-width: 100%; max-height: 120px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }
.attachment-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.attachment-row { display: flex; align-items: center; gap: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.attachment-name { font-weight: 600; color: var(--navy-2); }
.attachment-row .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-list { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: #f8fafc; font-size: 13px; }

.login-body { background: radial-gradient(1000px 500px at 80% 10%, #0f6c7a, transparent 60%), linear-gradient(135deg, #06172d, #0b2545 60%, #0b3c4c); min-height: 100vh; display: grid; place-items: center; }
.login-wrap { width: min(900px, calc(100% - 40px)); display: grid; grid-template-columns: 1fr 380px; gap: 40px; align-items: center; }
.login-brand { color: #fff; }
.login-brand .brand-mark { width: 54px; height: 54px; border-radius: 14px; margin-bottom: 18px; font-size: 17px; }
.login-brand h1 { margin: 0 0 6px; font-size: 34px; letter-spacing: 2px; }
.login-brand p { margin: 0 0 22px; color: #8fd3d4; letter-spacing: 3px; font-size: 12px; }
.login-brand ul { margin: 0; padding-left: 18px; color: rgba(255, 255, 255, .72); line-height: 2; }
.login-card { background: #fff; border-radius: 18px; padding: 30px; box-shadow: 0 30px 60px rgba(0, 0, 0, .28); }
.login-card h2 { margin: 0 0 18px; color: var(--navy); font-size: 21px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card .primary-btn { width: 100%; padding: 11px; margin-top: 4px; }
.login-hint { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.login-body .alert { margin-bottom: 12px; }

.trumbowyg-box, .trumbowyg-editor { border-color: #d8e0e9 !important; border-radius: 8px; }
.trumbowyg-box { margin: 6px 0 0 !important; }
.trumbowyg-editor { min-height: 320px; }
.trumbowyg-button-pane { background: #f8fafc !important; border-radius: 8px 8px 0 0; }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col, .editor-layout { grid-template-columns: 1fr; }
    .editor-side { position: static; }
}
@media (max-width: 760px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .admin-shell { flex-direction: column; }
    .sidebar { position: static; height: auto; width: 100%; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-sep, .sidebar-foot { display: none; }
    .topbar { padding: 0 16px; }
    .admin-content { padding: 18px 16px 36px; }
    .form-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr; }
    .table { font-size: 13px; }
    .table th, .table td { padding: 8px 6px; }
}
