/* VBI CMS — tông Dark Tech nhẹ (màu theo Documents/Thiet-ke/Mockup-DarkTech-v2, dịu hơn để ngồi soạn lâu). Không cần build. */
:root {
  --bg: #0a0f22; --bg2: #0f1630; --card: #121a38; --card2: #182246; --navy: #12345b;
  --ink: #e8ebf6; --muted: #98a2c3; --dim: #5d6789;
  --red: #e74042; --red2: #ff6b5e; --blue: #4d7cff; --green: #2fbf8f;
  --line: rgba(255, 255, 255, .08); --line2: rgba(255, 255, 255, .16);
  --r: 10px; --f: 'Be Vietnam Pro', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--f); -webkit-font-smoothing: antialiased; }
a { color: #8fb0ff; text-decoration: none; }
a:hover { color: #fff; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: rgba(255, 255, 255, .06); padding: 1px 5px; border-radius: 4px; color: #c9d3f5; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; } .mt { margin-top: 20px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* khung */
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; flex: none; background: linear-gradient(180deg, #0c1330, #080c1d); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--ink); font-weight: 700; letter-spacing: .12em; font-size: 12px; }
.brand span { padding: 2px 8px; border: 1px solid var(--line2); border-radius: 999px; color: var(--muted); }
.nav-group { margin: 16px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); }
.nav-link:hover { background: rgba(255, 255, 255, .04); color: var(--ink); }
.nav-link.active { background: linear-gradient(90deg, rgba(231, 64, 66, .18), rgba(231, 64, 66, .02)); color: #fff; box-shadow: inset 2px 0 0 var(--red); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: rgba(10, 15, 34, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.crumb { color: var(--muted); flex: 1; min-width: 0; }
.top-right { display: flex; align-items: center; gap: 10px; }
.top-right form { margin: 0; }
.me { color: var(--muted); font-size: 13px; }
.content { padding: 24px; max-width: 1400px; width: 100%; }
.only-mobile { display: none; }

/* thẻ, nút */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.card-flush { padding: 0; overflow-x: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line2);
  background: var(--card2); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: rgba(255, 255, 255, .3); color: #fff; }
.btn-primary { background: linear-gradient(135deg, var(--red), #c9302f); border-color: transparent; color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, var(--red2), var(--red)); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: #ff8a80; border-color: rgba(231, 64, 66, .4); }
.btn-danger:hover { background: rgba(231, 64, 66, .15); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn.active { border-color: var(--red); color: #fff; }
.btn.disabled { opacity: .4; pointer-events: none; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; display: inline-flex; font-size: 16px; }
.icon-btn:hover { color: #fff; }
form.inline { display: inline; margin: 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: rgba(77, 124, 255, .14); color: #a9c0ff; white-space: nowrap; }
.badge-red { background: rgba(231, 64, 66, .16); color: #ff9c94; }
.badge-green { background: rgba(47, 191, 143, .15); color: #74e0bb; }
.badge-blue { background: rgba(77, 124, 255, .2); color: #b9cbff; }
.badge-dim { background: rgba(255, 255, 255, .06); color: var(--muted); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-ok { background: rgba(47, 191, 143, .1); border-color: rgba(47, 191, 143, .35); color: #9ef0d2; }
.alert-err { background: rgba(231, 64, 66, .1); border-color: rgba(231, 64, 66, .4); color: #ffb3ad; }

/* bảng */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: rgba(255, 255, 255, .02); }
.table tbody tr:hover { background: rgba(255, 255, 255, .025); }
.table td.empty { text-align: center; padding: 40px; }
.table-list td { font-size: 13.5px; }
.w-id { width: 56px; } .w-act { width: 1%; text-align: right; } .w-drag { width: 28px; color: var(--dim); cursor: grab; }
tr.dragging { opacity: .4; } tr.drop-target td { box-shadow: inset 0 2px 0 var(--red); }
.sort { color: inherit; } .sort.on.asc::after { content: ' ↑'; } .sort.on.desc::after { content: ' ↓'; }
.thumb { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; display: block; background: var(--bg2); }
.thumb-round { width: 40px; border-radius: 50%; } .thumb-portrait { width: 40px; height: 50px; }
.thumb-empty { border: 1px dashed var(--line2); }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { width: 280px; }
.pager { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }

/* form */
input[type=text], input[type=email], input[type=url], input[type=search], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; background: var(--bg2); color: var(--ink); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 11px; font: inherit; }
.toolbar input, .toolbar select { width: auto; height: 36px; padding: 0 11px; }
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus, .rte-area:focus { outline: none; border-color: rgba(231, 64, 66, .7); box-shadow: 0 0 0 3px rgba(231, 64, 66, .15); }
input[type=datetime-local] { color-scheme: dark; }
input[type=file] { color: var(--muted); font-size: 12.5px; max-width: 100%; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: #cfd5ea; }
.req { color: var(--red2); margin-left: 3px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.err { font-size: 12.5px; color: #ff8a80; margin-top: 5px; }
.has-error input, .has-error textarea, .has-error select, .has-error .rte-area { border-color: rgba(231, 64, 66, .8); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { accent-color: var(--red); width: 16px; height: 16px; }
.checklist { max-height: 180px; overflow-y: auto; border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; background: var(--bg2); display: grid; gap: 6px; }
.static { padding: 8px 0; }
.counter { float: right; font-size: 11.5px; color: var(--dim); font-weight: 400; } .counter.over { color: var(--red2); }
.crud-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.crud-form.with-side { grid-template-columns: minmax(0, 1fr) 320px; }
.crud-form .form-main.card, .crud-form .form-side.card { margin: 0; }
.form-side { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.form-bar { grid-column: 1 / -1; position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: rgba(15, 22, 48, .92); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--r); }
.danger-zone { margin-top: 24px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 18px; }
.tab { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: #fff; border-bottom-color: var(--red); }
.tab-err::after { content: ''; display: inline-block; width: 7px; height: 7px; background: var(--red2); border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.tab-pane { display: none; } .tab-pane.active { display: block; }

/* trình soạn thảo */
.rte { border: 1px solid var(--line2); border-radius: 8px; background: var(--bg2); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); position: sticky; top: 57px; z-index: 5; background: var(--card2); border-radius: 8px 8px 0 0; }
.rte-bar button { background: none; border: 1px solid transparent; color: var(--muted); border-radius: 6px; min-width: 30px; height: 30px; padding: 0 7px; cursor: pointer; font: 600 13px var(--f); }
.rte-bar button:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.rte-bar button.on { color: #fff; border-color: var(--line2); }
.rte-bar .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.rte-area { min-height: 320px; max-height: 70vh; overflow-y: auto; padding: 16px 20px; border: 1px solid transparent; border-radius: 0 0 8px 8px; font-size: 15px; line-height: 1.7; }
.rte-source { border: 0 !important; border-radius: 0 0 8px 8px; font-family: var(--mono); font-size: 12.5px; min-height: 320px; }
.rte-area h2 { font-size: 21px; margin: 1.2em 0 .5em; } .rte-area h3 { font-size: 17px; margin: 1em 0 .4em; }
.rte-area img { max-width: 100%; height: auto; border-radius: 6px; } .rte-area img.sel { outline: 2px solid var(--red); }
.rte-area blockquote { border-left: 3px solid var(--red); margin: 1em 0; padding: 4px 16px; color: #cdd3ea; background: rgba(255, 255, 255, .03); }
.rte-area a { text-decoration: underline; } .rte-area table { border-collapse: collapse; display: block; max-width: 100%; width: auto !important; overflow-x: auto; }
.rte-area td, .rte-area th { width: auto !important; }
/* bài CKEditor cũ: style inline chữ đen / nền trắng / Arial → theo màu nền tối của CMS (nội dung lưu không đổi) */
.rte-area [style] { color: inherit !important; background-color: transparent !important; font-family: inherit !important; } .rte-area td, .rte-area th { border: 1px solid var(--line2); padding: 6px; }
.rte-area iframe { max-width: 100%; }
.rte-area:empty::before { content: 'Nhập nội dung…'; color: var(--dim); }

/* ô media */
.media-preview { width: 100%; max-width: 420px; aspect-ratio: 1.9; background: var(--bg2) center/cover; border: 1px dashed var(--line2); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 8px; }
.media-preview img { width: 100%; height: 100%; object-fit: cover; }
.media-row { display: flex; gap: 6px; margin-bottom: 6px; }
.media-row input { min-width: 0; }

/* JSON form trang tĩnh */
.i18n-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.i18n-pair.stack { grid-template-columns: 1fr; }
.i18n-cell { position: relative; }
.i18n-cell .lang { position: absolute; top: -8px; right: 8px; font: 700 10px var(--mono); color: var(--dim); background: var(--card); padding: 0 4px; z-index: 1; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 4px; margin: 0 0 16px; }
legend { padding: 0 6px; font-weight: 600; color: #cfd5ea; }
.rep-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 0; margin-bottom: 10px; background: rgba(255, 255, 255, .015); }
.rep-tools { display: flex; gap: 4px; align-items: center; margin-bottom: 8px; }
.rep-no { font: 700 12px var(--mono); color: var(--dim); margin-right: auto; }
.repeater > .btn { margin-bottom: 12px; }
.advanced summary { cursor: pointer; font-weight: 600; color: var(--muted); }

/* tổng quan */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; right: -20px; top: -20px; width: 60px; height: 60px; background: radial-gradient(circle, rgba(231, 64, 66, .25), transparent 70%); }
.kpi-n { font: 700 26px var(--mono); letter-spacing: -.02em; }
.kpi-l { color: var(--muted); font-size: 12.5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 .table td { padding: 8px 4px; }

/* thư viện media */
.uploader { display: flex; gap: 12px; align-items: center; }
.drop { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px dashed var(--line2); border-radius: 8px; cursor: pointer; color: var(--muted); }
.drop.over { border-color: var(--red); background: rgba(231, 64, 66, .06); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.media-tile { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tile-pick { display: block; width: 100%; aspect-ratio: 1.4; padding: 0; border: 0; background: var(--bg2); cursor: default; }
.picker .tile-pick { cursor: pointer; } .picker .media-tile:hover { border-color: var(--red); }
.tile-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-file { display: flex; height: 100%; align-items: center; justify-content: center; font: 700 18px var(--mono); color: var(--red2); }
.media-tile figcaption { padding: 8px 10px; }
.tile-more input { margin: 6px 0 4px; padding: 5px 8px; font-size: 12px; }
.tile-more form { margin: 0 0 4px; }

/* modal chọn media */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(3, 6, 18, .75); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-box { width: min(1100px, 100%); height: min(780px, 100%); background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.modal iframe { flex: 1; border: 0; width: 100%; }
body.picker .side, body.picker .top { display: none; }
body.picker .content { padding: 16px; }

/* liên hệ */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0 0 16px; } .dl dt { color: var(--muted); } .dl dd { margin: 0; }
.message { padding: 14px; background: var(--bg2); border-radius: 8px; white-space: normal; line-height: 1.7; }
.empty { text-align: center; padding: 48px 20px; }

/* đăng nhập */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(ellipse at 20% 0%, rgba(231, 64, 66, .18), transparent 50%), radial-gradient(ellipse at 100% 100%, rgba(42, 89, 220, .2), transparent 55%), var(--bg); }
.login-card { width: 380px; max-width: 100%; background: rgba(18, 26, 56, .8); border: 1px solid var(--line2); border-radius: 16px; padding: 32px 28px; backdrop-filter: blur(12px); }
.login-card h1 { margin: 18px 0 2px; } .login-card > p { margin: 0 0 20px; }
.login-card .field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.login-card .check { margin: 4px 0 18px; color: var(--muted); }

@media (max-width: 1100px) { .crud-form.with-side { grid-template-columns: minmax(0, 1fr); } .form-side { position: static; max-height: none; } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  .side { position: fixed; left: -260px; z-index: 50; transition: left .2s; } .side.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); }
  .only-mobile { display: inline-flex; } .me { display: none; } .content { padding: 16px; } .i18n-pair { grid-template-columns: 1fr; }
  .toolbar input[type=search] { width: 100%; } .rte-bar { top: 53px; }
  .uploader { flex-wrap: wrap; } .drop input[type=file] { min-width: 0; max-width: 100%; }
}
