/* ==========================================================================
   Pembrokeshire Hands — application UI
   Page shell, auth, dashboards, tables, filters, messaging, admin
   ========================================================================== */

/* Page shell --------------------------------------------------------------- */
.page-hero { padding-block: clamp(30px, 4.5vw, 64px) clamp(24px, 3vw, 40px); }
.page-hero--tint { background: var(--paper-deep); }
.page-hero h1 {
  font-size: clamp(2.15rem, 4.6vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  max-width: 24ch;
}
.page-hero h1 em { font-style: italic; font-weight: 400; color: var(--clay); }
.page-hero p { margin-top: var(--space-md); max-width: 62ch; color: var(--ink-soft); font-size: var(--t-lead); }
.page-hero__meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: var(--space-md); font-size: .85rem; color: var(--ink-soft); }

.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .8rem; color: var(--ink-soft); margin-bottom: var(--space-md); }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.section--tight { padding-block: clamp(44px, 6vw, 76px); }
.section--paper { background: var(--paper-deep); }

/* Auth --------------------------------------------------------------------- */
.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: stretch;
  padding-block: clamp(28px, 4vw, 56px) clamp(48px, 6vw, 88px);
}
.auth-card {
  width: 100%;
  max-width: 560px;
  padding: clamp(22px, 3.4vw, 38px);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.auth-card h1 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); letter-spacing: -0.03em; }
.auth-card__lead { margin-block: 8px var(--space-lg); color: var(--ink-soft); font-size: .96rem; }
.auth-card__foot { margin-top: var(--space-lg); padding-top: var(--space-md); border-top: 1px solid var(--line); font-size: .9rem; color: var(--ink-soft); }
.auth-aside {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 420px;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--forest);
}
.auth-aside img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.auth-aside__panel {
  position: relative;
  margin: 16px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--forest-deep) 78%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--paper);
}
.auth-aside__panel h2 { font-size: 1.35rem; }
.auth-aside__panel p { margin-top: 6px; font-size: .9rem; color: rgba(247, 242, 231, .8); }
.auth-aside__list { display: grid; gap: 6px; margin-top: 12px; font-size: .85rem; color: rgba(247, 242, 231, .85); }
.auth-aside__list li::before { content: "→  "; color: var(--lime); }

/* App shell ---------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 40px);
  align-items: start;
  padding-block: clamp(20px, 3vw, 36px) clamp(56px, 7vw, 96px);
}
.app-sidebar { position: sticky; top: 96px; display: grid; gap: 14px; }
.app-nav { display: grid; gap: 3px; }
.app-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: .93rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.app-nav a:hover { background: rgba(21, 33, 28, .06); }
.app-nav a.is-active { background: var(--forest); color: var(--paper); }
.app-nav a.is-active:hover { background: var(--forest-deep); }
.app-nav .count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding-inline: 6px;
  border-radius: var(--r-pill);
  background: var(--lime);
  color: var(--forest-deep);
  font-size: .7rem;
  font-weight: 700;
}
.app-sidebar__label {
  padding: 6px 14px 2px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.app-sidebar__foot { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.app-main { display: grid; gap: var(--space-lg); min-width: 0; }
.app-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.app-head h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -0.03em; }
.app-head p { margin-top: 4px; color: var(--ink-soft); font-size: .92rem; }

/* Panels, cards and stats -------------------------------------------------- */
.panel {
  min-width: 0;
  padding: clamp(16px, 2.4vw, 24px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--white);
}
.panel--flush { padding: 0; overflow: hidden; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: var(--space-md); }
.panel__head h2 { font-size: 1.12rem; letter-spacing: -0.015em; }
.panel__head a { font-size: .85rem; font-weight: 600; color: var(--forest); }
.stack { display: grid; gap: var(--space-md); }
.stack--lg { gap: var(--space-lg); }
.muted { color: var(--ink-soft); font-size: .9rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--white); }
.stat__label { font-size: .68rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-soft); }
.stat__value { margin-top: 6px; font-family: var(--font-display); font-size: 2rem; line-height: 1.05; letter-spacing: -0.03em; }
.stat__hint { margin-top: 4px; font-size: .78rem; color: var(--ink-soft); }
.stat--accent { background: var(--forest); border-color: var(--forest); color: var(--paper); }
.stat--accent .stat__label, .stat--accent .stat__hint { color: rgba(247, 242, 231, .7); }
.stat--lime { background: var(--lime); border-color: rgba(7, 38, 31, .15); color: var(--forest-deep); }
.stat--lime .stat__label, .stat--lime .stat__hint { color: rgba(7, 38, 31, .7); }

/* Tables ------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: collapse; font-size: .89rem; }
.table th {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  text-align: left;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur) var(--ease-out); }
.table__title { display: block; max-width: 34ch; font-weight: 600; color: var(--ink); text-decoration: none; line-height: 1.35; }
.table__title:hover { text-decoration: underline; }
.table__sub { display: block; margin-top: 2px; font-size: .76rem; color: var(--ink-soft); }
.table__actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.table td:last-child, .table th:last-child { text-align: right; }

/* Badges ------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid rgba(21, 33, 28, .08);
  border-radius: var(--r-pill);
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge--live { background: rgba(220, 243, 111, .55); color: #24401a; border-color: rgba(80, 110, 40, .2); }
.badge--pending { background: #fbe6c4; color: #6b4a12; border-color: #ecd2a2; }
.badge--hidden { background: #e6e6e2; color: #4a4a44; }
.badge--featured { background: var(--forest); color: var(--lime); border-color: var(--forest); }
.badge--swap { background: rgba(207, 227, 218, .7); color: #14453a; }
.badge--paid { background: var(--paper-deep); color: var(--forest-deep); }
.badge--admin { background: var(--clay); color: #fff7f1; border-color: var(--clay); }
.badge--plus { background: var(--lime); color: var(--forest-deep); }
.badge--business { background: var(--forest); color: var(--paper); border-color: var(--forest); }
.badge--free { background: var(--paper-deep); color: var(--ink-soft); }
.badge--open { background: #fbe6dd; color: #7a2f14; border-color: #eec9b9; }

/* Alerts and empty states -------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: var(--space-md);
  padding: 13px 16px;
  border: 1px solid;
  border-radius: var(--r-md);
  font-size: .9rem;
  line-height: 1.5;
}
.alert--success { background: #e9f4d8; border-color: #c9e0a8; color: #27401a; }
.alert--error { background: #fbe6dd; border-color: #efc7b5; color: #6b2a14; }
.alert--info { background: #e4efec; border-color: #c2d8d1; color: var(--forest); }
.alert__close { margin-left: auto; padding: 0 2px; border: 0; background: none; font-size: 1.1rem; line-height: 1; cursor: pointer; opacity: .6; }
.alert__close:hover { opacity: 1; }

.empty {
  padding: clamp(28px, 5vw, 48px) var(--space-lg);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: rgba(255, 253, 247, .6);
  text-align: center;
  color: var(--ink-soft);
}
.empty h2 { margin-bottom: 6px; color: var(--ink); font-size: 1.2rem; }
.empty p { max-width: 44ch; margin-inline: auto; font-size: .92rem; }
.empty .btn { margin-top: var(--space-md); }

/* Forms -------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-md); }
.form-grid .field--full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: var(--space-sm); }
.form-actions .muted { font-size: .82rem; }
.field__hint { font-size: .78rem; color: var(--ink-soft); }
.field select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none' stroke='%234a5a52' stroke-width='2'%3E%3Cpath d='m5 7 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.check-row { display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; color: var(--ink-soft); }
.check-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--forest); }
.mono-note { padding: 2px 6px; border-radius: 5px; background: var(--paper); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }

/* Extra buttons ------------------------------------------------------------ */
.btn--sm { min-height: 38px; padding: 7px 13px; font-size: .82rem; }
.btn--danger { --btn-bg: #f7e1d7; --btn-fg: #7a2f14; --btn-border: #eac6b6; }
.btn--danger:hover { --btn-bg: #f1d3c5; }
.btn--quiet { --btn-bg: transparent; --btn-fg: var(--ink-soft); --btn-border: var(--line); }
.btn--quiet:hover { --btn-bg: var(--paper); }

/* Pagination --------------------------------------------------------------- */
.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: var(--space-xl); }
.pagination a,
.pagination > span {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding-inline: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--white);
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
}
.pagination a:hover { border-color: var(--ink); }
.pagination > span.is-current { background: var(--forest); border-color: var(--forest); color: var(--paper); }

/* Filters ------------------------------------------------------------------ */
.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px 150px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: var(--space-lg);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--white);
}
.filters .field { margin-bottom: 0; }
.filters__count { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: var(--space-md); font-size: .88rem; color: var(--ink-soft); }

/* Listing cards as links --------------------------------------------------- */
.listing { position: relative; }
.listing__owner { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 10px; font-size: .78rem; color: var(--ink-soft); }

/* Listing detail ----------------------------------------------------------- */
.listing-detail { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, .6fr); gap: clamp(20px, 3vw, 36px); align-items: start; }
.listing-detail__body { white-space: pre-line; color: var(--ink); font-size: 1.02rem; line-height: 1.7; }
.listing-detail__title { font-size: clamp(1.8rem, 3.4vw, 2.6rem); line-height: 1.05; letter-spacing: -0.03em; }
.detail-list { display: grid; gap: 0; }
.detail-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--ink-soft); }
.detail-list dd { margin: 0; text-align: right; font-weight: 600; }
.owner-card { display: grid; gap: 10px; }
.owner-card__top { display: flex; align-items: center; gap: 12px; }
.owner-card__name { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.owner-card__meta { font-size: .8rem; color: var(--ink-soft); }
.owner-card__bio { font-size: .9rem; color: var(--ink-soft); }
.report-box { margin-top: var(--space-md); padding-top: var(--space-md); border-top: 1px solid var(--line); }
.report-box summary { font-size: .82rem; color: var(--ink-soft); cursor: pointer; }
.report-box summary:hover { color: var(--clay); }
.avatar--lg { width: 54px; height: 54px; font-size: .95rem; }

/* Messages ----------------------------------------------------------------- */
.thread-list { display: grid; }
.thread {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease-out);
}
.thread:last-child { border-bottom: 0; }
.thread:hover { background: rgba(21, 33, 28, .03); }
.thread--unread { background: rgba(220, 243, 111, .16); }
.thread__name { font-size: .93rem; font-weight: 700; }
.thread__listing { font-size: .76rem; color: var(--ink-soft); }
.thread__snippet { overflow: hidden; margin-top: 2px; font-size: .84rem; color: var(--ink-soft); text-overflow: ellipsis; white-space: nowrap; }
.thread__meta { font-size: .72rem; color: var(--ink-soft); text-align: right; white-space: nowrap; }
.thread__dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; background: var(--clay); }
.bubbles { display: grid; gap: 10px; max-height: 540px; overflow-y: auto; padding: clamp(14px, 2vw, 22px); background: var(--paper); }
.bubble { max-width: min(80%, 560px); padding: 11px 15px; border-radius: 16px; font-size: .94rem; line-height: 1.55; }
.bubble--theirs { justify-self: start; border: 1px solid var(--line); border-bottom-left-radius: 5px; background: var(--white); }
.bubble--mine { justify-self: end; border-bottom-right-radius: 5px; background: var(--forest); color: var(--paper); }
.bubble__meta { margin-top: 5px; font-size: .68rem; opacity: .65; }
.reply-form { padding: clamp(14px, 2vw, 20px); border-top: 1px solid var(--line); background: var(--white); }
.reply-form .field { margin-bottom: 8px; }

/* Header account bits ------------------------------------------------------ */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 12px 4px 4px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
}
.user-chip:hover { background: rgba(21, 33, 28, .06); }
.user-chip .avatar { width: 32px; height: 32px; font-size: .68rem; }
.header-form { display: inline; margin: 0; }

/* Plan helpers ------------------------------------------------------------- */
.plan--current { outline: 2px solid var(--forest); outline-offset: 3px; }
.plan__current-flag {
  position: absolute;
  top: -12px;
  right: 20px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: var(--lime);
  color: var(--forest-deep);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* Responsive --------------------------------------------------------------- */
@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { position: static; }
  .app-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-nav a { min-height: 44px; padding: 9px 14px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--white); white-space: nowrap; }
  .app-nav a.is-active { border-color: var(--forest); }
  .app-sidebar__label, .app-sidebar__foot { display: none; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .listing-detail { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field--search { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .table th, .table td { padding: 11px 12px; }
  .site-header__actions .btn { padding-inline: 12px; }
  .user-chip__name { display: none; }
}

/* Dashboard split layouts */
.dash-split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.6fr); gap: 16px; align-items: start; }
.dash-split-side { display: grid; gap: 16px; align-content: start; }
@media (max-width: 900px) {
  .dash-split { grid-template-columns: 1fr; }
}

/* Even two-column dashboard split */
.dash-split--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .dash-split--even { grid-template-columns: 1fr; } }

/* Keep the mobile header to brand + account chip + menu button */
@media (max-width: 620px) {
  .site-header__actions .header-form { display: none; }
  .site-header__actions .btn--quiet { display: none; }
  .site-header__actions .user-chip { padding-right: 4px; }
}

/* Prevent wide children from stretching grid columns */
.app-sidebar { min-width: 0; }
.thread > span { min-width: 0; }
@media (max-width: 1000px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-nav { max-width: 100%; }
}
@media (max-width: 900px) {
  .dash-split { grid-template-columns: minmax(0, 1fr); }
  .dash-split--even { grid-template-columns: minmax(0, 1fr); }
}

/* Inline spans need block display to clip their nowrap text */
.thread__snippet { display: block; }
.thread__name, .thread__listing { display: block; }
