/* Admin panel */
:root { --navy: #0b2545; --navy2: #13315c; --gold: #e0a526; --bg: #f4f6fa; --line: #e2e6ee; --ink: #1b2433; --muted: #667085; --ok: #1f8a5b; --err: #c0392b; --warn: #b7791f; --r: 12px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .8rem; line-height: 1.25; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; margin-top: 1.5rem; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ic.big { width: 36px; height: 36px; }
.muted { color: var(--muted); }
.sm { font-size: .85rem; }
code { background: #eef1f6; padding: .1rem .35rem; border-radius: 5px; font-size: .85em; }

.btn { display: inline-flex; align-items: center; gap: .45rem; justify-content: center; padding: .62rem 1.1rem; border-radius: 9px; background: var(--navy); color: #fff; border: 1px solid var(--navy); font: 600 .9rem system-ui, sans-serif; cursor: pointer; text-decoration: none !important; }
.btn:hover { background: var(--navy2); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: #b8c0cf; }
.btn.danger { background: #fff; color: var(--err); border-color: #f0c4be; }
.btn.danger:hover { background: var(--err); color: #fff; }
.btn.green { background: #25d366; border-color: #25d366; }
.btn.sm { padding: .4rem .75rem; font-size: .82rem; }
.btn.block { width: 100%; }

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #c8d3e6; padding: 1rem .8rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; gap: .7rem; align-items: center; color: #fff; padding: .4rem .5rem 1.2rem; text-decoration: none !important; }
.side-brand > span { width: 38px; height: 38px; border-radius: 10px; background: var(--gold); color: var(--navy); display: grid; place-items: center; font-weight: 800; font-family: Georgia, serif; flex: none; }
.side-brand strong { display: block; font-size: .92rem; line-height: 1.2; }
.side-brand small { color: var(--gold); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.side nav a { display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border-radius: 8px; color: #c8d3e6; font-size: .9rem; text-decoration: none !important; }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.on { background: rgba(224,165,38,.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: #7d8ca8; margin: 1.1rem .7rem .3rem; }
.pill { margin-left: auto; background: var(--gold); color: var(--navy); font-size: .7rem; padding: .05rem .45rem; border-radius: 999px; }
.main { min-width: 0; }
.bar { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.6rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar h1 { font-size: 1.2rem; margin: 0; flex: 1; }
.bar-r { display: flex; gap: .6rem; align-items: center; }
.bar-r form { margin: 0; }
.who { font-size: .85rem; color: var(--muted); }
.side-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: .4rem; cursor: pointer; }
.content { padding: 1.6rem; max-width: 1280px; }

.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.alert.success { background: #e9f7ef; border-color: #b6e2c8; color: #155d3d; }
.alert.error { background: #fdecea; border-color: #f5c2bc; color: #8a2a1f; }
.alert.warn { background: #fff7e6; border-color: #f6d99b; color: #7a5310; }
.intro { color: var(--muted); margin: -.3rem 0 1rem; max-width: 820px; }
.crumb { margin: 0 0 1rem; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 1.4rem; margin-bottom: 1.2rem; }
.panel.flush { padding: 0; overflow-x: auto; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
.stat { display: flex; gap: 1rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem; color: var(--ink); text-decoration: none !important; }
.stat:hover { border-color: var(--gold); }
.stat > span { width: 46px; height: 46px; border-radius: 12px; background: #eef3fb; color: var(--navy2); display: grid; place-items: center; }
.stat strong { display: block; font-size: 1.6rem; line-height: 1; }
.stat small { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
.grid-2.wide-l { grid-template-columns: 2fr 1fr; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.quick-actions .btn { justify-content: flex-start; background: #f4f6fa; color: var(--ink); border-color: var(--line); }
.quick-actions .btn:hover { border-color: var(--gold); background: #fff; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search { display: flex; gap: .4rem; }
.search input { padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 9px; min-width: 240px; font: inherit; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .tabs { margin: 0; }
.tabs a { padding: .5rem .9rem; border-radius: 9px; color: var(--ink); background: #fff; border: 1px solid var(--line); font-size: .88rem; font-weight: 600; text-decoration: none !important; display: inline-flex; gap: .35rem; align-items: center; }
.tabs a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tabs small { opacity: .6; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .75rem 1rem; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
.tbl td { padding: .7rem 1rem; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
.tbl tr[data-href] { cursor: pointer; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl tr.unread td { font-weight: 600; background: #fffbf0; }
.tbl .tcell-img { width: 64px; }
.tbl .tcell-img img, .noimg { width: 48px; height: 48px; border-radius: 9px; object-fit: cover; display: grid; place-items: center; background: #e8edf5; color: var(--navy2); font-weight: 700; font-size: .8rem; }
.tbl .actions { text-align: right; white-space: nowrap; }
.panel .tbl td:first-child, .panel .tbl th:first-child { padding-left: 1.2rem; }
.empty-msg { padding: 2rem; text-align: center; color: var(--muted); margin: 0; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px; }
.badge.ok { background: #e3f4ea; color: #17683f; }
.badge.mute { background: #eef0f4; color: #5b6475; }
.badge.warn { background: #fff1d6; color: #8a5a00; }

.edit-form { max-width: 980px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.2rem; }
.field { grid-column: 1 / -1; display: grid; gap: .35rem; align-content: start; }
.field.half { grid-column: auto; }
.field > label { font-weight: 600; font-size: .86rem; }
.field > label i { color: var(--err); font-style: normal; }
.field input[type=text], .field input[type=email], .field input[type=url], .field input[type=number], .field input[type=date], .field input[type=datetime-local], .field input[type=password], .field input:not([type]), .field select, .field textarea, .inline-form select {
  width: 100%; padding: .65rem .8rem; border: 1px solid #cfd6e2; border-radius: 9px; font: inherit; background: #fff; }
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: #3b6fd8; box-shadow: 0 0 0 3px rgba(59,111,216,.15); }
.help, .upl small { color: var(--muted); font-size: .8rem; }
.chk { display: inline-flex; gap: .45rem; align-items: center; font-weight: 600; font-size: .9rem; cursor: pointer; }
.chk.sm { font-size: .8rem; font-weight: 500; }
.slug { display: flex; border: 1px solid #cfd6e2; border-radius: 9px; overflow: hidden; }
.slug span { background: #f1f4f9; padding: .65rem .7rem; color: var(--muted); font-size: .82rem; white-space: nowrap; border-right: 1px solid #cfd6e2; }
.slug input { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
.upl { display: flex; gap: 1rem; align-items: flex-start; padding: .8rem; border: 1px dashed #cfd6e2; border-radius: 10px; background: #fbfcfe; }
.upl > div { display: grid; gap: .4rem; }
.upl-prev { width: 110px; height: 82px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.upl-file { display: inline-flex; gap: .4rem; align-items: center; padding: .4rem .7rem; background: #eef3fb; border-radius: 8px; }
.icon-pick { display: flex; flex-wrap: wrap; gap: .35rem; }
.icon-pick label { cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; }
.icon-pick span { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; color: var(--navy2); }
.icon-pick input:checked + span { background: var(--navy); color: var(--gold); border-color: var(--navy); }
.save-bar { position: sticky; bottom: 0; display: flex; gap: .6rem; padding: .9rem 0; background: linear-gradient(transparent, var(--bg) 30%); z-index: 3; }
.danger-zone { margin: .5rem 0 1.5rem; }
.inline-form { display: flex; gap: .5rem; margin: 1rem 0; }

/* Rich text editor */
.rte { border: 1px solid #cfd6e2; border-radius: 10px; background: #fff; }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: .4rem; background: #f4f6fa; border-bottom: 1px solid #cfd6e2; position: sticky; top: 62px; z-index: 2; border-radius: 10px 10px 0 0; }
.rte-bar button { border: 1px solid transparent; background: none; padding: .3rem .55rem; border-radius: 6px; cursor: pointer; font-size: .82rem; color: var(--ink); min-width: 32px; }
.rte-bar button:hover { background: #fff; border-color: var(--line); }
.rte-bar button.on { background: var(--navy); color: #fff; }
.rte-area { min-height: 260px; padding: 1rem 1.2rem; outline: none; max-height: 70vh; overflow-y: auto; }
.rte-area img { max-width: 100%; height: auto; }
.rte-area table { border-collapse: collapse; width: 100%; }
.rte-area td, .rte-area th { border: 1px solid #ccd; padding: .4rem; }
.rte-area blockquote { border-left: 4px solid var(--gold); margin: 1em 0; padding: .3em 1em; background: #fbf8f2; }
.rte-src { border-radius: 0 0 10px 10px; width: 100%; min-height: 300px; border: 0; padding: 1rem; font: 13px/1.5 ui-monospace, Menlo, monospace; display: block; }

/* Gallery manager */
.dropzone { border: 2px dashed #b9c4d6; border-radius: 12px; padding: 1.6rem; text-align: center; background: #fafbfe; margin-bottom: 1.2rem; transition: .2s; }
.dropzone.over { border-color: var(--gold); background: #fffaf0; }
.dropzone .ic { color: #8a99b3; }
.dropzone p { margin: .4rem 0; }
.dropzone .link { color: #1d4ed8; cursor: pointer; text-decoration: underline; }
.dz-list { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin: .8rem 0; }
.dz-list img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .9rem; }
.ph-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.ph-item.is-cover { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.ph-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.ph-item > input { width: 100%; border: 0; border-top: 1px solid var(--line); padding: .5rem .6rem; font: inherit; font-size: .82rem; }
.ph-row { display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: center; padding: .4rem .6rem; border-top: 1px solid var(--line); font-size: .8rem; }
.ph-row input[type=number] { width: 52px; padding: .2rem .3rem; border: 1px solid var(--line); border-radius: 6px; }
.ph-row .del { color: var(--err); margin-left: auto; }

.dl { display: grid; grid-template-columns: 160px 1fr; gap: .6rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; }

/* Auth & installer */
body.auth { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(800px 400px at 80% 0%, rgba(224,165,38,.18), transparent 60%), var(--navy); padding: 1rem; }
.auth-card { background: #fff; border-radius: 16px; padding: 2rem; width: min(400px, 100%); box-shadow: 0 30px 60px rgba(0,0,0,.3); }
.auth-card.wide { width: min(520px, 100%); }
.auth-card h1 { font-size: 1.35rem; margin-bottom: .2rem; }
.auth-logo { width: 52px; height: 52px; border-radius: 14px; background: var(--navy); color: var(--gold); display: grid; place-items: center; font: 800 1.2rem Georgia, serif; margin-bottom: 1rem; }
.auth-card form { display: grid; gap: .9rem; margin: 1.2rem 0; }
.auth-card label { display: grid; gap: .3rem; font-weight: 600; font-size: .86rem; }
.auth-card input { padding: .7rem .8rem; border: 1px solid #cfd6e2; border-radius: 9px; font: inherit; }
.checks { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .3rem; font-size: .9rem; }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--err); font-weight: 700; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.4); }
  .side-toggle { display: inline-flex; }
  .cards { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-2.wide-l { grid-template-columns: 1fr; }
  .who, .bar-r .ghost:first-child { display: none; }
}
@media (max-width: 600px) {
  .content { padding: 1rem; }
  .fields { grid-template-columns: 1fr; }
  .field.half { grid-column: 1 / -1; }
  .tbl th:nth-child(n+4), .tbl td:nth-child(n+4):not(.actions) { display: none; }
  .search input { min-width: 0; }
  .quick-actions { grid-template-columns: 1fr; }
}
