/* Bracbort admin: a tool, so it has its own quiet look. */
:root {
  --bg: #f3f6f8; --panel: #ffffff; --ink: #0d1114; --muted: #5b6b75; --line: #dde4e9; --line-2: #c8d2d9;
  --side: #0b0f12; --side-ink: #cfe3ef; --side-muted: #7f939e; --side-hover: #161d22;
  --accent: #b0298f; --accent-ink: #fff; --ok: #1d7a4f; --warn: #a15c00; --bad: #b42318;
  --r: 10px; --r-sm: 7px; --font: "Outfit", system-ui, sans-serif; --mono: "DM Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 48px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* sign-in */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% 0%, #d7ecf7 0%, transparent 60%), var(--bg); }
.auth__card { width: min(100%, 420px); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: grid; gap: 16px; }
.auth__card h1 { margin: 0; font-size: 26px; font-weight: 500; letter-spacing: -0.02em; }
.auth__card p { margin: 0; color: var(--muted); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; font-size: 18px; text-decoration: none; color: inherit; }
.logo img { width: 24px; height: 24px; }

/* shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 6px 10px 18px; color: #fff; }
.side nav { display: grid; gap: 2px; }
.side h2 { font-size: 12px; font-weight: 500; color: var(--side-muted); margin: 16px 10px 6px; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--side-ink); text-decoration: none; }
.side a.nav:hover { background: var(--side-hover); }
.side a.nav[aria-current="page"] { background: #1c262d; color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.side a.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side .badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; line-height: 20px; }
.side__foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #1c262d; font-size: 13px; color: var(--side-muted); display: grid; gap: 8px; }
.side__foot button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; text-align: left; }
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 12px 28px; min-height: 64px; }
.top h1 { font-size: 20px; font-weight: 500; margin: 0; letter-spacing: -0.01em; }
.top .crumb { color: var(--muted); text-decoration: none; }
.top .spacer { flex: 1; }
.content { padding: 24px 28px 64px; max-width: 1360px; }
.menu-btn { display: none; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; font-weight: 500; font-size: 14px; }
.btn:hover { border-color: var(--ink); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn--danger { color: var(--bad); }
.btn--danger:hover { border-color: var(--bad); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 1px solid transparent; background: none; border-radius: var(--r-sm); cursor: pointer; color: var(--muted); }
.icon-btn:hover { border-color: var(--line-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent); }
.field { margin-bottom: 18px; }
.field--title input { height: 52px; font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 400; margin: 0; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* cards and panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel__head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 500; }
.panel__body { padding: 16px; }
.grid-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 18px; }
.stat b { display: block; font-size: 30px; font-weight: 500; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat a { text-decoration: none; color: inherit; display: block; }
.dash { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick a { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); text-decoration: none; color: inherit; background: #fbfcfd; }
.quick a:hover { border-color: var(--accent); }
.notice { padding: 12px 16px; border-radius: var(--r-sm); background: #fff6e5; border: 1px solid #f3d59b; color: #5e3b00; margin-bottom: 16px; font-size: 14px; }

/* lists */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-row:hover td { background: #f8fafb; }
.table .title-cell a { font-weight: 500; color: var(--ink); text-decoration: none; }
.table .title-cell a:hover { color: var(--accent); }
.table .sub { color: var(--muted); font-size: 13px; }
.table .actions { text-align: right; white-space: nowrap; }
.table tr.dragging { opacity: .4; }
.table tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }
.handle { cursor: grab; color: var(--muted); width: 28px; }
.thumb { width: 56px; height: 40px; border-radius: 6px; object-fit: cover; background: #e9eef2; display: block; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, transparent); }
.pill--warn { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 40%, transparent); }
.empty { padding: 48px; text-align: center; color: var(--muted); }

/* editor layout */
.edit { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.edit__side { display: grid; gap: 16px; position: sticky; top: 84px; }
.publish .panel__body { display: grid; gap: 12px; }
.publish .meta { font-size: 13px; color: var(--muted); }
.publish .actions { display: flex; gap: 8px; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 var(--r) var(--r); }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: none; }
.is-dirty .dirty-dot { display: inline-block; }
.slug { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-top: -10px; margin-bottom: 18px; }
.slug input { height: 30px; font-family: var(--mono); font-size: 13px; max-width: 360px; }

/* rich text editor */
.rte { border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; }
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent); }
.rte__bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); position: sticky; top: 64px; background: #fff; z-index: 2; border-radius: var(--r-sm) var(--r-sm) 0 0; }
.rte__bar button { height: 30px; min-width: 30px; padding: 0 8px; border: 1px solid transparent; background: none; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--ink); display: inline-grid; place-items: center; }
.rte__bar button:hover { border-color: var(--line-2); }
.rte__bar button.is-on { background: #eef3f6; }
.rte__bar .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.rte__bar svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rte__area { min-height: 220px; padding: 16px 18px; outline: none; line-height: 1.7; font-size: 16px; }
.rte__area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rte__area h2 { font-size: 24px; font-weight: 500; margin: 20px 0 8px; letter-spacing: -0.01em; }
.rte__area h3 { font-size: 19px; font-weight: 500; margin: 16px 0 6px; }
.rte__area p { margin: 0 0 12px; }
.rte__area blockquote { margin: 12px 0; padding-left: 14px; border-left: 3px solid var(--accent); color: #333; }
.rte__area pre { background: #f2f5f7; padding: 12px; border-radius: 6px; font: 13px/1.6 var(--mono); white-space: pre-wrap; }
.rte__area img { max-width: 100%; height: auto; border-radius: 6px; }
.rte__area a { color: var(--accent); }
.rte__html { width: 100%; min-height: 260px; border: 0; border-radius: 0 0 var(--r-sm) var(--r-sm); font: 13px/1.6 var(--mono); padding: 14px; display: none; }
.rte.is-html .rte__html { display: block; }
.rte.is-html .rte__area { display: none; }
.rte__count { font-size: 12px; color: var(--muted); padding: 6px 12px; border-top: 1px solid var(--line); text-align: right; }

/* list and repeater fields */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; min-height: 42px; align-items: center; }
.chips input { border: 0 !important; box-shadow: none !important; flex: 1; min-width: 140px; height: 28px; padding: 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #eef3f6; border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); width: 20px; height: 20px; border-radius: 50%; }
.chip button:hover { background: #dce5ea; color: var(--ink); }
.chip img { width: 16px; height: 16px; }
.repeater { display: grid; gap: 10px; }
.rep-item { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fbfcfd; }
.rep-item .handle { padding-top: 8px; }
.rep-item .rep-fields { display: grid; gap: 8px; }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; max-height: 280px; overflow-y: auto; padding: 8px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; }
.icon-pick label { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; font-weight: 400; cursor: pointer; text-align: center; margin: 0; }
.icon-pick label:has(input:checked) { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 8%, #fff); }
.icon-pick input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick img { width: 28px; height: 28px; object-fit: contain; }
.checks-list { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; }
.checks-list label { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 0; font-size: 14px; }

/* image field and media */
.imgfield { display: grid; gap: 8px; }
.imgfield__preview { aspect-ratio: 16 / 9; border-radius: var(--r-sm); border: 1px dashed var(--line-2); background: #f7f9fa center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.imgfield__btns { display: flex; gap: 8px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.media-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: grid; }
.media-item img, .media-item .file { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #eef2f5; display: grid; place-items: center; color: var(--muted); }
.media-item .meta { padding: 8px 10px; font-size: 12px; color: var(--muted); display: grid; gap: 6px; }
.media-item .meta b { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item .row { display: flex; gap: 4px; }
.media-item.is-pick { cursor: pointer; }
.media-item.is-pick:hover { border-color: var(--accent); }
.drop { border: 2px dashed var(--line-2); border-radius: var(--r); padding: 28px; text-align: center; color: var(--muted); margin-bottom: 16px; background: #fbfcfd; }
.drop.is-over { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 6%, #fff); color: var(--ink); }

/* messages */
.msg { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; }
.msg-list { display: grid; gap: 0; max-height: calc(100vh - 160px); overflow-y: auto; }
.msg-list button { text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 12px 14px; cursor: pointer; display: grid; gap: 2px; }
.msg-list button:hover, .msg-list button.is-on { background: #f3f7fa; }
.msg-list button.is-unread b::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 8px; vertical-align: middle; }
.msg-body dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; margin: 0 0 16px; }
.msg-body dt { color: var(--muted); font-size: 13px; }
.msg-body dd { margin: 0; }
.msg-body .text { white-space: pre-wrap; background: #f7f9fa; border-radius: var(--r-sm); padding: 14px; }

/* modal and toasts */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(960px, calc(100% - 32px)); max-height: calc(100vh - 64px); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(8, 12, 15, .45); }
.modal__head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 500; }
.modal__head .spacer { flex: 1; }
.modal__body { padding: 18px; overflow-y: auto; max-height: calc(100vh - 180px); }
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 360px; }
.toast--bad { background: var(--bad); }
.err { color: var(--bad); font-size: 14px; margin: 0; }

@media (max-width: 1100px) { .edit { grid-template-columns: 1fr; } .edit__side { position: static; } .dash { grid-template-columns: 1fr; } .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .shell.is-menu .side { transform: none; }
  .menu-btn { display: inline-grid; }
  .content { padding: 16px; }
  .top { padding: 10px 16px; }
  .msg { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .table .hide-sm { display: none; }
}
