/* ==========================================================================
   PBSE CMS — admin panel
   ========================================================================== */
:root {
  --brand: #b91c1c;
  --brand-dark: #7f1d1d;
  --brand-deep: #3d0a0c;
  --brand-soft: #fdecec;
  --accent: #c8a24a;
  --ink: #1b1416;
  --muted: #6d6167;
  --line: #e6dcde;
  --soft: #faf6f6;
  --ok: #15803d;
  --warn: #b45309;
  --sidebar: #2a0d10;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--soft);
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0 0 .8rem; }
p:last-child { margin-bottom: 0; }

/* ---------- shell ---------- */
.admin-shell { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, #33090c 0%, var(--sidebar) 100%);
  color: #f1dedf; padding: 22px 16px 26px;
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 16px; }
.sidebar-brand img { max-height: 38px; width: auto; }
.sidebar-brand span { display: grid; line-height: 1.15; }
.sidebar-brand strong { font-size: .95rem; letter-spacing: .04em; color: #fff; }
.sidebar-brand small { font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: rgba(241,222,223,.6); margin-top: 3px; }
.sidebar-nav { display: grid; gap: 3px; }
.sidebar-nav p.nav-label { margin: 16px 8px 6px; font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(241,222,223,.45); }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  font-size: .87rem; font-weight: 600; color: rgba(241,222,223,.82);
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: var(--brand); color: #fff; box-shadow: 0 8px 20px rgba(185,28,28,.35); }
.sidebar-nav a .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-nav a .pill { margin-left: auto; background: var(--accent); color: #3d0a0c; font-size: .68rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 30px; background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.12rem; }
.topbar .crumb { font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-actions .who { font-size: .8rem; color: var(--muted); }
.content { padding: 28px 30px 60px; }

/* ---------- pieces ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card + .card { margin-top: 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-head h2 { font-size: 1.02rem; }
.card-head .sub { font-size: .82rem; color: var(--muted); }
.card-head .grow { flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat-card span { display: block; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat-card strong { display: block; font-size: 1.9rem; line-height: 1.2; margin-top: 6px; }
.stat-card.brand { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); border: 0; color: #fff; }
.stat-card.brand span { color: rgba(255,255,255,.75); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font: inherit; font-size: .85rem; font-weight: 700; color: var(--ink);
  cursor: pointer; transition: .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { color: #b91c1c; border-color: #f3c9c9; background: #fff5f5; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .78rem; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.data th {
  text-align: left; padding: 11px 12px; font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 12px; border-bottom: 1px solid #f2eaeb; vertical-align: middle; }
table.data tr:hover td { background: #fdf8f8; }
table.data .thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
table.data .actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-title { font-weight: 700; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .7rem; font-weight: 800; letter-spacing: .02em; }
.badge.ok { background: #e8f7ee; color: var(--ok); }
.badge.draft { background: #fdf1e3; color: var(--warn); }
.badge.new { background: var(--brand-soft); color: var(--brand); }

.alert { padding: 13px 17px; border-radius: 11px; font-size: .86rem; margin-bottom: 18px; }
.alert-success { background: #e8f7ee; color: #14663a; border: 1px solid #c3ebd2; }
.alert-error { background: #fdecec; color: #991b1b; border: 1px solid #f5c9c9; }
.alert-error ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- forms ---------- */
.form-grid { display: grid; gap: 16px; }
.form-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.field { display: grid; gap: 6px; }
.field > label,
.field > span.label { font-size: .8rem; font-weight: 700; color: #3f3237; }
.field .hint { font-size: .75rem; color: var(--muted); }
.field input[type=text], .field input[type=email], .field input[type=url], .field input[type=password],
.field input[type=number], .field input[type=date], .field input[type=datetime-local],
.field input[type=search], .field select, .field textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font: inherit; font-size: .89rem; transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(185,28,28,.1);
}
.field input[type=color] { width: 100%; height: 42px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.field input[type=file] { width: 100%; font-size: .82rem; padding: 8px; border: 1px dashed var(--line); border-radius: 9px; background: var(--soft); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.check { display: flex; align-items: center; gap: 9px; font-size: .85rem; font-weight: 600; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 20px; }
legend { padding: 0 8px; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }

/* ---------- gallery admin ---------- */
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.gal-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.gal-card .pic { position: relative; aspect-ratio: 4/3; background: var(--soft); }
.gal-card .pic img { width: 100%; height: 100%; object-fit: cover; }
.gal-card .pic .off { position: absolute; inset: 0; background: rgba(43,13,16,.62); color: #fff; display: grid; place-items: center; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.gal-card .meta { padding: 12px 13px; display: grid; gap: 3px; flex: 1; }
.gal-card .meta strong { font-size: .87rem; line-height: 1.35; }
.gal-card .meta small { color: var(--muted); font-size: .75rem; }
.gal-card .ops { display: flex; gap: 6px; padding: 0 13px 13px; }

/* ---------- inbox ---------- */
.msg-list { display: grid; gap: 10px; }
.msg-row { display: flex; gap: 14px; align-items: flex-start; padding: 15px 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.msg-row.unread { border-left: 4px solid var(--brand); background: #fffaf9; }
.msg-row .who { font-weight: 700; font-size: .9rem; }
.msg-row .snippet { color: var(--muted); font-size: .83rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg-row time { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.msg-row .grow { flex: 1; min-width: 0; }

dl.detail { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px 16px; margin: 0; font-size: .89rem; }
dl.detail dt { color: var(--muted); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; padding-top: 2px; }
dl.detail dd { margin: 0; font-weight: 600; }
.msg-body { margin-top: 18px; padding: 18px; border-radius: 12px; background: var(--soft); border: 1px solid var(--line); white-space: pre-wrap; font-size: .9rem; }

.empty-state { padding: 46px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: #fff; }
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.pager a, .pager span {
  min-width: 34px; text-align: center; padding: 7px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font-size: .82rem; font-weight: 600;
}
.pager .active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .disabled { opacity: .45; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, #4a1114 0%, #1d0809 65%); padding: 24px; }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 34px; box-shadow: 0 40px 90px rgba(0,0,0,.4); }
.login-card .brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-card .brand-row img { max-height: 44px; }
.login-card h1 { font-size: 1.24rem; margin-bottom: 6px; }
.login-card p.muted { color: var(--muted); font-size: .86rem; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .form-cols { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 16px; }
  .sidebar-nav { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .sidebar-nav p.nav-label { display: none; }
  .topbar { padding: 12px 18px; }
  .content { padding: 20px 18px 48px; }
}
@media (max-width: 640px) {
  .two, .three { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 1rem; }
  .card { padding: 16px; }
  dl.detail { grid-template-columns: 1fr; gap: 4px; }
  dl.detail dd { margin-bottom: 10px; }
}
