/* ==========================================================================
   Admin area. Loaded after site.css, so it inherits the same tokens,
   buttons, form controls and notices.
   ========================================================================== */

body.admin { background: var(--sand-2); }

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

/* ------------------------------------------------------------- sidebar */
.admin-side {
  background: var(--ink); color: #cfc8ba;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-brand { display: block; text-decoration: none; }
.admin-brand img { width: 100%; border-radius: 8px; margin-bottom: 10px; }
.admin-brand span {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--sun); font-size: .84rem; font-weight: 700;
}

.admin-side nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.admin-side nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: 10px;
  color: #cfc8ba; text-decoration: none; font-weight: 650; font-size: .96rem;
}
.admin-side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.admin-side nav a[aria-current="page"] { background: var(--brand); color: #fff; }
.admin-side nav svg { flex: none; opacity: .9; }
.pill {
  margin-left: auto; background: var(--sun); color: var(--ink);
  border-radius: 999px; padding: 2px 9px; font: 800 .76rem/1.5 var(--sans); font-style: normal;
}
.admin-side nav a[aria-current="page"] .pill { background: #fff; }

.admin-side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px; font-size: .88rem; }
.admin-side-foot p { margin: 0 0 10px; }
.admin-side-foot strong { color: #fff; }
.admin-side-foot .btn-outline { color: #cfc8ba; border-color: rgba(255,255,255,.3); }
.admin-side-foot .btn-outline:hover { background: #fff; color: var(--ink); border-color: #fff; }

/* ---------------------------------------------------------------- body */
.admin-body { display: flex; flex-direction: column; min-width: 0; }

.admin-top {
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 22px clamp(18px, 3vw, 36px);
  display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; justify-content: space-between;
}
.admin-top h1 { font-size: 1.65rem; margin: 0; }
.admin-top p { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.admin-top-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.admin-main { padding: clamp(20px, 3vw, 34px); max-width: 1180px; width: 100%; }

/* --------------------------------------------------------------- cards */
.panel {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(20px, 2.5vw, 30px); margin-bottom: 22px;
}
.panel > h2 { font-size: 1.18rem; margin-bottom: 6px; }
.panel > h2 + .panel-hint { color: var(--muted); font-size: .93rem; margin: 0 0 20px; }
.panel-hint { color: var(--muted); font-size: .93rem; }
.panel-split { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ----------------------------------------------------------- dashboard */
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 24px; }
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; text-decoration: none; color: inherit; display: block;
}
.stat:hover { border-color: var(--brand); color: inherit; }
.stat strong { display: block; font: 800 2.1rem/1.1 var(--sans); letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .92rem; }
.stat.is-alert { border-left: 5px solid var(--brand); }

.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.todo li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border: 1px solid var(--line); border-left: 4px solid var(--sun);
  border-radius: 10px; background: #fffdf5; font-size: .95rem;
}
.todo svg { color: var(--sun-dark); flex: none; margin-top: 2px; }
.todo a { font-weight: 700; }

/* --------------------------------------------------------------- table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 640px; }
table.data th, table.data td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data thead th { background: var(--sand-2); font-size: .8rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fdfbf7; }
table.data .row-title { font-weight: 750; }
table.data .row-title a { color: inherit; text-decoration: none; }
table.data .row-title a:hover { color: var(--brand-dark); }
table.data .thumb { width: 74px; height: 56px; object-fit: cover; border-radius: 7px; background: var(--sand-2); }
table.data .actions { white-space: nowrap; text-align: right; }
table.data .actions .btn { margin-left: 6px; }

.state {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font: 700 .78rem/1.6 var(--sans);
}
.state-on  { background: #e7f7ed; color: #12683a; }
.state-off { background: #f1ece2; color: #6f6759; }
.state-new { background: var(--brand-soft); color: var(--brand-dark); }

/* --------------------------------------------------------------- forms */
.form-grid { display: grid; gap: 0 22px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-actions {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  position: sticky; bottom: 0; z-index: 5;
  background: var(--sand-2); padding: 16px 0; margin-top: 8px;
  border-top: 1px solid var(--line);
}
.form-actions .spacer { margin-left: auto; }

.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 650; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }

.help {
  background: #fffaf0; border: 1px solid #f0e2bd; border-radius: 10px;
  padding: 14px 16px; font-size: .9rem; color: #6a5320; margin-bottom: 20px;
}
.help p:last-child { margin-bottom: 0; }
.help code { background: #f6ecd4; padding: 1px 5px; border-radius: 4px; }

/* --------------------------------------------------------- media strip */
.media-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.media-item { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.media-item.is-primary { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.media-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--sand-2); }
.media-item.is-plan img { object-fit: contain; background: #fff; }
.media-foot { padding: 10px 12px 12px; display: grid; gap: 8px; }
.media-foot input[type=text] { padding: 8px 10px; font-size: .88rem; }
.media-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.media-tools button {
  border: 1px solid var(--line); background: var(--sand); color: var(--ink-2);
  border-radius: 8px; padding: 6px 10px; font: 650 .8rem var(--sans); cursor: pointer;
}
.media-tools button:hover { border-color: var(--brand); color: var(--brand-dark); }
.media-tools .danger:hover { border-color: #c62b45; color: #c62b45; }
.media-flag {
  display: inline-block; background: var(--brand); color: #fff;
  border-radius: 999px; padding: 3px 10px; font: 700 .72rem/1.6 var(--sans);
}

.dropzone {
  border: 2px dashed #d5c9b2; border-radius: 12px; background: #fffdf8;
  padding: 22px; text-align: center; margin-bottom: 18px;
}
.dropzone p { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.dropzone input[type=file] { display: block; margin: 0 auto; max-width: 100%; }

/* ------------------------------------------------------------ enquiry */
.enquiry { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); margin-bottom: 14px; overflow: hidden; }
.enquiry.is-unread { border-left: 5px solid var(--brand); }
.enquiry summary {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  padding: 16px 20px; cursor: pointer; list-style: none;
}
.enquiry summary::-webkit-details-marker { display: none; }
.enquiry .who { font-weight: 750; }
.enquiry .when { color: var(--muted); font-size: .88rem; margin-left: auto; }
.enquiry-body { padding: 0 20px 20px; }
.enquiry-body dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; font-size: .94rem; }
.enquiry-body dt { color: var(--muted); }
.enquiry-body dd { margin: 0; font-weight: 650; }
.enquiry-message { background: var(--sand); border-radius: 10px; padding: 16px 18px; white-space: pre-wrap; }

/* -------------------------------------------------------------- login */
body.admin-login { display: grid; place-items: center; min-height: 100vh; padding: 30px 16px; background: var(--ink); }
.login-card {
  width: min(100%, 440px); background: var(--paper);
  border-radius: 18px; border-top: 6px solid var(--brand);
  padding: clamp(26px, 4vw, 38px); box-shadow: var(--shadow-lg);
}
.login-card img { width: 220px; margin-bottom: 22px; border-radius: 6px; }
.login-card h1 { font-size: 1.5rem; }

/* ----------------------------------------------------------- the guide */
.help-layout { display: grid; gap: 26px; grid-template-columns: 230px minmax(0, 1fr); align-items: start; }

.help-toc {
  position: sticky; top: 20px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px;
}
.help-toc h2 { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.help-toc ol { margin: 0; padding-left: 20px; display: grid; gap: 7px; font-size: .92rem; }
.help-toc a { color: var(--ink-2); text-decoration: none; }
.help-toc a:hover { color: var(--brand-dark); text-decoration: underline; }

.help-body .panel { scroll-margin-top: 20px; }
.help-body h2 { font-size: 1.35rem; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 3px solid var(--sun); }
.help-body h3 { font-size: 1.05rem; margin: 26px 0 10px; }
.help-body .panel > h3:first-of-type { margin-top: 18px; }
.help-body ol { padding-left: 22px; display: grid; gap: 8px; }
.help-body ol li { padding-left: 4px; }
.help-body .spec-table { margin: 6px 0 4px; }
.help-body .spec-table th { width: 34%; font-weight: 700; color: var(--ink-2); }
.help-body .feature-list { margin: 10px 0 4px; }
.help-body code {
  background: var(--sand-2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 5px; font-size: .92em;
}

@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; }
}

@media print {
  .admin-side, .admin-top-actions, .help-toc { display: none !important; }
  .admin-shell { display: block; }
  .help-layout { display: block; }
  .panel { break-inside: avoid; border: 0; padding: 0 0 18px; }
  body.admin { background: #fff; }
}

/* --------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; flex-direction: column; }
  .admin-side nav ul { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); display: grid; }
  .admin-brand img { max-width: 220px; }
  .admin-side-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .admin-side-foot p { margin: 0; }
  .form-actions { position: static; }
}
