:root {
  --bg: #f5f6f8; --panel: #fff; --line: #e3e6ea; --text: #1c1e21; --muted: #65676b;
  --blue: #1877f2; --blue-soft: #e7f0fd; --green: #1e8e3e; --red: #c5221f; --amber: #b06000;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
code { background: #eef0f3; padding: 0 4px; border-radius: 4px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 8px; }
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand h1 { margin: 0; font-size: 20px; }
.top-actions { display: flex; gap: 8px; }

.btn { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #166fe5; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.xs { padding: 1px 7px; font-size: 11px; border-radius: 4px; }
.btn.fb { background: var(--blue); color: #fff; border: 0; }

.toolbar { display: flex; gap: 10px; align-items: center; padding: 4px 16px 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.tab b { font-weight: 400; color: var(--muted); margin-left: 6px; }
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.tab.active b { color: #dce8fb; }
.search { flex: 1; min-width: 220px; max-width: 420px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; }
.select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

.bulk { display: flex; gap: 8px; align-items: center; padding: 0 16px 10px; }

.table-wrap { margin: 0 16px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: calc(100vh - 140px); }
table { border-collapse: collapse; width: max-content; min-width: 100%; }
th, td { border-bottom: 1px solid var(--line); border-right: 1px solid #f0f1f3; padding: 8px; vertical-align: top; text-align: left; }
th { position: sticky; top: 0; background: #fafbfc; z-index: 2; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #fbfcfe; }
.c-chk { width: 34px; } .c-stt { width: 42px; text-align: center; }
.c-code { width: 150px; } .c-link { width: 170px; } .c-img { width: 86px; }
.c-text { width: 230px; } .c-work { width: 130px; } .c-note { width: 170px; }
.c-blog { width: 120px; } .c-status { width: 150px; } .c-date { width: 110px; }
td.stt { text-align: center; color: var(--muted); }
.code { color: var(--blue); font-family: ui-monospace, Consolas, monospace; font-size: 12px; cursor: pointer; }
.link { color: var(--blue); text-decoration: none; word-break: break-all; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; display: block; background: #eee; }
.dl { display: block; text-align: center; font-size: 11px; color: var(--blue); cursor: pointer; margin-top: 3px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; white-space: pre-line; }
.clamp:hover { color: var(--blue); }
.meta { font-size: 11px; color: var(--muted); margin: 3px 0; }
.tags { font-size: 11px; color: var(--blue); margin-top: 4px; }
.placeholder { color: #aab; font-style: italic; }
td select, td input, td textarea { width: 100%; border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; background: #fff; }
td textarea { resize: vertical; min-height: 36px; background: #fffef5; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: #fff; }
.b-DONE { background: var(--green); } .b-ERROR { background: var(--red); }
.b-READY { background: #5f6368; } .b-PROCESSING { background: var(--blue); }
.b-CAPTION_REQUIRED { background: var(--amber); }
.err { color: var(--red); font-size: 11px; margin-top: 4px; max-height: 60px; overflow: auto; word-break: break-word; }
.acts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.wh { font-size: 11px; margin-top: 3px; }
.wh.ok { color: var(--green); } .wh.bad { color: var(--red); }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: sp 1s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes sp { to { transform: rotate(360deg); } }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: #fff; border-radius: 10px; width: min(560px, 94vw); max-height: 92vh; display: flex; flex-direction: column; }
.modal-box.wide { width: min(1100px, 96vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.x { border: 0; background: none; font-size: 18px; cursor: pointer; }
.modal-body { padding: 12px 16px; overflow: auto; }
.modal-body label { display: block; font-weight: 600; margin: 10px 0 4px; }
.modal-body label.chk { font-weight: 400; display: flex; gap: 6px; align-items: center; }
.modal-body input:not([type=checkbox]), .modal-body select, .modal-body textarea { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.modal-body h3 { margin: 16px 0 4px; font-size: 14px; }
.modal-body h3:first-child { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.modal-foot .muted { margin-right: auto; }
.settings-grid, .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
#dImg { width: 100%; max-height: 280px; object-fit: contain; background: #f0f2f5; border-radius: 6px; }
#dLink { display: block; margin-top: 6px; word-break: break-all; color: var(--blue); }
pre { background: #f6f8fa; padding: 8px; border-radius: 6px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; font-size: 11px; }
.err-box { background: #fdecea; color: var(--red); padding: 8px; border-radius: 6px; white-space: pre-wrap; }
@media (max-width: 800px) { .settings-grid, .detail-grid { grid-template-columns: 1fr; } }

#toast { position: fixed; right: 16px; bottom: 16px; background: #323232; color: #fff; padding: 9px 14px; border-radius: 6px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; z-index: 99; }
#toast.show { opacity: 1; transform: none; }

/* ---- Site ---- */
a.btn { text-decoration: none; display: inline-block; }
.top-actions { align-items: center; }
.c-by { width: 100px; }
.table-wrap { max-height: calc(100vh - 130px); }
.err-text { color: var(--red); margin-top: 8px; min-height: 18px; }

.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 420px; }
.login-box h1 { font-size: 30px; margin: 0 0 24px; }
.login-box label { display: block; margin-bottom: 8px; font-size: 15px; }
.login-box input { width: 100%; padding: 11px 12px; border: 1px solid #8a8d91; border-radius: 3px; font-size: 15px; background: #fff; }
.login-box .btn { margin-top: 12px; padding: 8px 16px; font-size: 14px; font-weight: 600; }
.login-box .btn:disabled { background: #93b9f4; border-color: #93b9f4; cursor: default; }
.login-box p { font-size: 14px; line-height: 1.6; margin-top: 30px; }
.login-box a { color: var(--blue); text-decoration: none; font-size: 15px; display: inline-block; margin-top: 18px; }

.admin { padding: 0 16px 30px; display: grid; gap: 16px; max-width: 1400px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card label { display: block; font-weight: 600; margin: 8px 0 4px; }
.card input { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; }
.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input { flex: 1; margin: 0; }
.token-box { background: #e6f4ea; border: 1px solid #b7e1c1; border-radius: 6px; padding: 10px; margin-bottom: 12px; display: grid; gap: 6px; }
.token-box code { font-size: 14px; word-break: break-all; background: #fff; padding: 6px; }
.token-box .btn { justify-self: start; }
table.simple { width: 100%; }
table.simple th { position: static; }
table.simple td.acts { display: table-cell; }
table.simple td.acts .btn { margin-right: 4px; }
.card ul { padding-left: 18px; line-height: 2; }
@media (max-width: 700px) {
  .top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .top-actions { flex-wrap: wrap; }
}

.cta-bar { display: flex; gap: 8px; align-items: center; padding: 0 16px 10px; }
.cta-bar label { font-weight: 600; white-space: nowrap; }
.cta-bar textarea { flex: 1; max-width: 640px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.c-blog { width: 210px; }
td textarea[data-field="blog_link"] { background: #fff; font-size: 12px; }
.btn.xs.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn:disabled { opacity: .6; cursor: default; }
select.inline { width: auto; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.card .chk { font-weight: 400; display: flex; gap: 6px; align-items: center; }
.card .chk input { width: auto; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.card textarea.full { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; }
.card select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; width: 100%; }
.card select.inline, td select.inline { width: auto; margin: 0; }
.add-box { margin-top: 12px; }
.add-box summary { list-style: none; display: inline-block; margin-bottom: 8px; }
.add-box summary::-webkit-details-marker { display: none; }
.card h3 { margin: 16px 0 6px; font-size: 14px; }
.card details summary { cursor: pointer; margin: 8px 0; }

.c-sl { width: 90px; }
td.sl input { width: 46px; padding: 2px 4px; }
.pay-box { background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 12px; }
.pay-box .amount { font-size: 22px; font-weight: 700; }
.pay-box code { font-size: 13px; word-break: break-all; }
.balance-big { font-size: 28px; font-weight: 700; }
.ok-text { color: var(--green); } .warn-text { color: var(--amber); }
table.simple td, table.simple th { font-size: 12px; }
.center-page { max-width: 560px; margin: 40px auto; padding: 0 16px; }

.spin.dark { border-color: var(--blue); border-top-color: transparent; }

.c-folder { width: 200px; }
.paths { font-size: 12px; margin-top: 6px; word-break: break-all; }
.paths div { padding: 2px 0; }
td details.meta div { word-break: break-all; font-size: 11px; }

tr.noted td, tr.noted:hover td { background: var(--notebg); }
.note-color { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin: 0 4px; white-space: nowrap; }
.note-color input { width: 34px; height: 26px; padding: 0; border: 1px solid #ccd; border-radius: 6px; cursor: pointer; }

.sample-out { font-size: 13px; margin: 4px 0 12px; color: #667; }
.sample-out.ok { color: #137333; }
.sample-out.bad { color: #c5221f; }
