/* SUM Associates — admin panel */
:root {
  --ink: #2a2522; --ink-2: #3b3430; --taupe: #8b7f77; --taupe-lt: #b9b0a9;
  --bg: #f3f3f2; --paper: #fff; --line: #e0deda; --red: #d8232a; --red-dk: #b01b21;
  --gold: #f2c12e; --ok: #1f7a4a; --muted: #6b625c; --r: 6px;
  --f: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--f); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--ink); }
a:hover { color: var(--red); }
h1, h2 { margin: 0 0 14px; line-height: 1.2; }
h2 { font-size: 1.08rem; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { display: block; color: var(--muted); font-size: .83rem; font-weight: 400; margin: 4px 0 0; }
code { background: #f1efec; padding: 1px 5px; border-radius: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Layout */
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #eee; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 22px; text-decoration: none; color: #fff; }
.side-brand img { background: #fff; border-radius: 6px; padding: 2px; }
.side-brand span { font-weight: 800; line-height: 1.15; }
.side-brand small { display: block; font-weight: 400; color: var(--taupe-lt); font-size: .8rem; }
.side nav { display: flex; flex-direction: column; padding: 0 10px; gap: 2px; }
.side nav a { color: #e8e4e1; text-decoration: none; padding: 10px 12px; border-radius: var(--r); display: flex; justify-content: space-between; align-items: center; }
.side nav a:hover { background: var(--ink-2); color: #fff; }
.side nav a[aria-current="page"] { background: var(--red); color: #fff; }
.badge { background: var(--gold); color: var(--ink); font-weight: 800; font-size: .75rem; border-radius: 20px; padding: 1px 8px; }
.side-foot { margin-top: auto; padding: 16px 22px 22px; display: grid; gap: 8px; border-top: 1px solid var(--ink-2); }
.side-foot a, .linklike { color: var(--taupe-lt); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: left; text-decoration: underline; }
.side-foot a:hover, .linklike:hover { color: #fff; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 1.35rem; margin: 0; }
.menu-btn { display: none; }
.content { padding: 24px 28px 80px; max-width: 1280px; }
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .menu-btn { display: inline-block; background: var(--ink); color: #fff; border: 0; border-radius: var(--r); padding: 8px 12px; font: inherit; font-weight: 600; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 80px; }
}

/* Cards & grids */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.cols-7-5 { grid-template-columns: 7fr 5fr; }
.cols-8-4 { grid-template-columns: minmax(0, 8fr) minmax(280px, 4fr); }
@media (max-width: 1000px) { .cols, .cols-7-5, .cols-8-4 { grid-template-columns: 1fr; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.sticky-col { position: sticky; top: 84px; }
@media (max-width: 1000px) { .sticky-col { position: static; } }
.narrow { max-width: 520px; }
.muted-card { background: transparent; border-style: dashed; color: var(--muted); }
.empty-card { text-align: center; padding: 40px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; text-decoration: none; }
.stat strong { display: block; font-size: 2rem; line-height: 1; }
.stat span { color: var(--muted); }
.stat.hot { border-color: var(--gold); background: #fff8e1; }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; } }
.todo { border-left: 4px solid var(--gold); }
.todo ul { margin: 0; padding-left: 20px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.list li:last-child { border-bottom: 0; }
.list li.unread strong::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--red); border-radius: 50%; margin-right: 6px; }
.list .small { width: 100%; }

/* Forms */
.form label, .field { display: grid; gap: 5px; font-weight: 600; margin-bottom: 14px; font-size: .92rem; }
.form .label { font-weight: 600; font-size: .92rem; }
input[type=text], input:not([type]), input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], select, textarea {
  font: inherit; font-weight: 400; width: 100%; padding: 9px 11px; border: 1px solid #cfccc7; border-radius: var(--r); background: #fff; color: var(--ink); min-height: 40px;
}
textarea { resize: vertical; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242,193,46,.45); }
.form .check, .check { display: flex !important; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: 18px; height: 18px; min-height: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }
input[type=range] { width: 100%; accent-color: var(--red); }
.slug-wrap { display: flex; align-items: stretch; }
.slug-pre { background: #f1efec; border: 1px solid #cfccc7; border-right: 0; padding: 9px 4px 9px 11px; border-radius: var(--r) 0 0 var(--r); color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.slug-wrap input { border-radius: 0 var(--r) var(--r) 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--red); background: var(--red); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--red-dk); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border-color: #cfccc7; }
.btn.ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: .85rem; }
.btn.danger { background: #fff; color: var(--red-dk); border-color: #f0b7b9; }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 32px; height: 32px; border: 1px solid #cfccc7; background: #fff; border-radius: var(--r); cursor: pointer; font-size: 1rem; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-actions form { margin: 0; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 10px; background: linear-gradient(rgba(243,243,242,0), var(--bg) 35%); padding: 22px 0 14px; z-index: 4; }
.savebar .btn { min-height: 46px; padding: 0 28px; font-size: 1rem; }
.side-save .btn { width: 100%; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--line); }
.crumb { color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.alert { padding: 11px 14px; border-radius: var(--r); margin-bottom: 14px; font-weight: 500; }
.alert.ok { background: #e3f3ea; color: var(--ok); }
.alert.err { background: #fde8e8; color: var(--red-dk); }

.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: #eee; color: var(--ink); }
.p-ongoing { background: #fff1c4; }
.p-completed { background: #d9f0e3; color: var(--ok); }
.p-upcoming { background: #fde1e2; color: var(--red-dk); }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--red); }
[data-tabs].js .tab-panel { display: none; }
[data-tabs].js .tab-panel.active { display: block; }

/* Media */
.media-row { display: flex; gap: 14px; align-items: flex-start; }
.preview { width: 120px; height: 90px; flex: none; border: 1px solid var(--line); border-radius: var(--r); background: #f6f5f3 repeating-conic-gradient(#eee 0 25%, transparent 0 50%) 0 0 / 14px 14px; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: .8rem; font-weight: 400; }
.preview img { width: 100%; height: 100%; object-fit: contain; }
.vid-preview { max-width: 360px; width: 100%; border-radius: var(--r); background: #000; }
.dropzone { display: grid !important; gap: 4px; place-items: center; text-align: center; border: 2px dashed #cfccc7; border-radius: var(--r); padding: 26px 16px; cursor: pointer; font-weight: 400 !important; background: #fafaf9; }
.dropzone:hover, .dropzone.over { border-color: var(--red); background: #fff6f6; }
.dropzone input { width: 100%; max-width: 320px; }
.new-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-bottom: 14px; }
.new-previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.img-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.img-grid li { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fafaf9; }
.img-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.img-grid input:not([type=radio]):not([type=checkbox]) { border-radius: 0; border-width: 0 0 1px; min-height: 34px; font-size: .85rem; }
.img-tools { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 8px; }
.form .mini { display: flex; gap: 4px; align-items: center; font-size: .8rem; font-weight: 500; margin: 0; }
.mini input[type=number] { width: 54px; min-height: 28px; padding: 2px 6px; }
.mini.del { color: var(--red-dk); }
.img-grid li:has(.del input:checked) { opacity: .45; outline: 2px solid var(--red); }
.video-row { display: grid; grid-template-columns: 2fr 1.2fr 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
@media (max-width: 640px) { .video-row { grid-template-columns: 1fr 32px; } .video-row input:nth-child(2) { grid-row: 2; } }

/* Items manager */
.sortable { list-style: none; margin: 0; padding: 0; }
.sortable li { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sortable li.off { opacity: .6; }
.it-ic svg { width: 26px; height: 26px; color: var(--red); }
.it-body { display: grid; }
.it-actions { display: flex; gap: 6px; align-items: center; }
.it-actions form { margin: 0; }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.icon-pick label { margin: 0 !important; display: block !important; cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; }
.icon-pick svg { width: 44px; height: 44px; padding: 9px; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); }
.icon-pick input:checked + svg { border-color: var(--red); background: #fff1f1; color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.icon-pick input:focus-visible + svg { outline: 3px solid var(--gold); }

/* Tables */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar p { margin: 0; }
.filters-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.filters-inline select, .filters-inline input { width: auto; }
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #faf9f8; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.off td { background: #fbfafa; color: var(--muted); }
.t-proj { display: flex; gap: 12px; align-items: center; min-width: 260px; }
.t-proj > div:last-child { display: grid; }
.thumb { width: 72px; height: 54px; border-radius: 4px; overflow: hidden; background: #eee; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.t-actions { white-space: nowrap; }
.t-actions form { display: inline; }
.order-in { width: 64px !important; }

/* Enquiries */
.enq header { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.enq header strong { font-size: 1.05rem; margin-right: 6px; }
.enq.unread { border-left: 4px solid var(--red); }
.enq-meta { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0; }
.enq-meta dt { font-size: .78rem; color: var(--muted); }
.enq-meta dd { margin: 0; font-weight: 600; }
.enq-msg { margin: 12px 0 0; padding: 12px 14px; background: #f7f6f4; border-radius: var(--r); }
.pager { display: flex; gap: 6px; flex-wrap: wrap; }
.pager a { padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; background: #fff; }
.pager a[aria-current] { background: var(--ink); color: #fff; }

/* Login / install */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: var(--ink); }
.auth-box { background: #fff; border-radius: 10px; padding: 32px; width: 100%; max-width: 400px; }
.auth-box.wide { max-width: 620px; }
.auth-logo { width: 84px; height: 84px; display: block; margin: 0 auto 12px; }
.auth h1 { text-align: center; font-size: 1.4rem; }
.auth .btn { width: 100%; min-height: 46px; }
.auth .row-actions .btn { width: auto; }
.auth p.small { text-align: center; margin-top: 16px; }
.media-row > div { min-width: 0; flex: 1; }
.media-row input[type=file] { max-width: 100%; }
@media (max-width: 420px) { .media-row { flex-direction: column; } }
