/* =========================================================================
 * WSB Estate theme — tokens, shell, regions, primary menu, forms, tables.
 * Mirrors the mock styling in /themes/custom/wsb_public/mocks/
 * ========================================================================= */

/* -------- Design tokens -------- */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-muted: #667085;
  --text-subtle: #98a2b3;
  --brand: #1f6b3a;
  --brand-2: #195930;
  --brand-soft: #e9f3ec;
  --brand-soft-border: #c6e3cf;
  --accent-1: #2ca89a;
  --accent-2: #4478c9;
  --accent-3: #f4a536;
  --accent-4: #d64545;
  --accent-5: #7c5aa8;
  --accent-6: #8f5a3c;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;

  --container: 1560px;
  --topbar-h: 56px;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-md: 0 4px 12px rgba(16,24,40,.05), 0 2px 4px rgba(16,24,40,.04);
  --shadow-pop: 0 8px 24px rgba(16,24,40,.08), 0 2px 6px rgba(16,24,40,.05);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;

  /* Admin view palette */
  --navy: #0f2b4a;
  --navy-light: #1a3d62;
  --accent-green: #2a7d3f;
  --accent-green-hover: #1e6230;
  --white: #ffffff;
  --row-hover: #f6f8fb;
  --radius: 6px;
  --red: #c62828;
  --red-bg: #fce4ec;
  --green: #1a7431;
  --green-bg: #e6f4ea;
  --amber: #f57c00;
  --amber-bg: #fff3e0;
  --teal: #00796b;
  --teal-light: #e0f2f1;
}

/* -------- Base -------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 var(--sp-3); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.9rem; }
p { margin: 0 0 var(--sp-3); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-5) 0; }
img { max-width: 100%; height: auto; }

/* -------- Page shell -------- */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: var(--container); margin: 0 auto; padding: 0 1.5rem; width: 100%; }

/* =========================================================================
 * Region: HEADER — logo + sitename (left) · primary menu (middle) · user (right)
 * ========================================================================= */
.region-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
/* Push page content below Drupal/Gin admin toolbar when present */
body.toolbar-fixed { padding-top: 39px; }
body.toolbar-fixed .region-header { top: 39px; }
body.toolbar-fixed.toolbar-horizontal.toolbar-tray-open { padding-top: 79px; }
body.toolbar-fixed.toolbar-horizontal.toolbar-tray-open .region-header { top: 79px; }
.region-header__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

/* --- Brand (when the branding BLOCK is placed in header_brand) --- */
.region-header-brand > div,
.region-header-brand > div > div { display: contents; }
.region-header-brand #block-wsb-estate-branding,
.region-header-brand [id^="block-"] {
  display: inline-flex; align-items: center; gap: 0.55rem;
  padding-right: 0.75rem; border-right: 1px solid var(--border);
  height: 100%;
}
/* Logo link (Drupal emits <a rel="home"><img></a>) */
.region-header-brand a[rel="home"] {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--text); font-weight: 700; font-size: 0.95rem;
  text-decoration: none; letter-spacing: -0.01em;
}
.region-header-brand a[rel="home"]:hover { text-decoration: none; color: var(--text); }
.region-header-brand a[rel="home"] img {
  width: 28px; height: 28px; border-radius: 7px; display: block; object-fit: cover;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent-1) 100%);
}
.region-header-brand .site-name a,
.region-header-brand .block-system-branding-block a + a {
  font-weight: 700; color: var(--text); text-decoration: none; font-size: 0.95rem;
}
.region-header-brand .site-slogan { font-size: 0.7rem; color: var(--text-muted); }

/* --- Brand (Twig fallback, when no block is placed) --- */
.site-brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-weight: 700; font-size: 0.95rem; color: var(--text);
  letter-spacing: -0.01em; text-decoration: none;
  padding-right: 0.75rem;
  border-right: 1px solid var(--border);
  height: 100%;
}
.site-brand:hover { text-decoration: none; color: var(--text); }
.site-brand__mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent-1) 100%);
  display: inline-grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 0.82rem;
  flex: none;
}
.site-brand__mark img { width: 22px; height: 22px; display: block; }
.site-brand__name { white-space: nowrap; }
.site-brand__slogan {
  display: block; font-size: 0.7rem; font-weight: 500;
  color: var(--text-muted); margin-top: 0.05rem;
}

/* --- Primary menu -------------------------------------------------------- */
.primary-menu { display: flex; align-items: center; gap: 0.15rem; min-width: 0; }
/* Reset list styles at every depth (Drupal nests the <ul> inside a <div><nav>) */
.primary-menu ul,
.primary-menu ol,
.primary-menu li { list-style: none; padding: 0; margin: 0; }
/* Hide the visually-hidden H2 from the main-menu block */
.primary-menu h2.visually-hidden,
.primary-menu .visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* The block itself and any wrapping div/nav should not add layout */
.primary-menu > div,
.primary-menu > nav,
.primary-menu > div > nav,
.primary-menu > div > div { display: contents; }
/* Hide the contextual-region wrappers' own styling */
.primary-menu .contextual { position: absolute; }
/* Top-level menu UL (direct child of nav/div under .primary-menu) — horizontal row */
.primary-menu > ul:not(.contextual-links),
.primary-menu > * > ul:not(.contextual-links),
.primary-menu > * > * > ul:not(.contextual-links) {
  display: flex; align-items: center; gap: 0.15rem; flex-wrap: wrap;
}
/* Nested submenus — hidden flyouts (override the above with !important) */
.primary-menu li ul:not(.contextual-links) {
  display: none !important;
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.35rem;
  box-shadow: var(--shadow-pop);
  flex-direction: column;
  z-index: 60;
}
.primary-menu li.is-open > ul:not(.contextual-links) { display: flex !important; }
/* Keep contextual-links really hidden */
.primary-menu ul.contextual-links,
.primary-menu [hidden] { display: none !important; }
.primary-menu li { position: relative; }

.primary-menu a {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text); border-radius: 8px;
  text-decoration: none; white-space: nowrap;
  transition: background 80ms ease, color 80ms ease;
}
.primary-menu a:hover {
  background: var(--surface-2); color: var(--brand); text-decoration: none;
}
.primary-menu a.is-active,
.primary-menu .menu-item--active-trail > a,
.primary-menu li.is-active-trail > a {
  background: var(--brand-soft); color: var(--brand);
}

.primary-menu .pending-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.primary-menu .pending-nav-link .pending-nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #c62828;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.primary-menu .pending-nav-link.is-active .pending-nav-badge {
  background: var(--brand);
}

/* Dropdown caret on items with children */
.primary-menu li.menu-item--expanded > a::after,
.primary-menu li.has-children > a::after {
  content: "▾"; font-size: 0.65rem; opacity: 0.55; margin-left: 0.1rem;
}

/* Flyout submenu link styling (flyout show/hide handled above) */
.primary-menu li > ul a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-weight: 500;
  color: var(--text);
}
.primary-menu li > ul a:hover { background: var(--surface-2); color: var(--brand); }

/* --- User / account cluster --------------------------------------------- */
.region-header__user {
  display: flex; align-items: center; gap: 0.45rem;
  justify-self: end;
}
/* Neutralise the account-menu block's list markup */
.region-header__user ul,
.region-header__user li { list-style: none; padding: 0; margin: 0; }
.region-header__user > div,
.region-header__user > nav,
.region-header__user > div > nav,
.region-header__user > div > div { display: contents; }
.region-header__user ul:not(.contextual-links):not([hidden]) { display: flex; align-items: center; gap: 0.35rem; }
.region-header__user ul.contextual-links, .region-header__user [hidden] { display: none !important; }
.region-header__user h2.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.region-header__user a,
.region-header__user .button {
  font-size: 0.82rem; font-weight: 500; color: var(--text);
  padding: 0.4rem 0.7rem; border-radius: 7px;
  text-decoration: none; white-space: nowrap;
}
.region-header__user a:hover { background: var(--surface-2); color: var(--brand); text-decoration: none; }
.icon-btn {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text-muted);
  cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-5));
  color: #fff; font-weight: 600; font-size: 0.78rem;
  display: inline-grid; place-items: center;
  cursor: pointer;
}

/* =========================================================================
 * Region: TOP — three equal blocks
 * ========================================================================= */
.region-row--top {
  max-width: var(--container); margin: 0 auto; padding: 1.25rem 1.5rem 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
}

/* =========================================================================
 * Region: BREADCRUMB / HIGHLIGHTED / HELP (optional, above main)
 * ========================================================================= */
.region-breadcrumb, .region-highlighted, .region-help {
  max-width: var(--container); margin: 0 auto; padding: 0 1.5rem;
  width: 100%;
}
.region-breadcrumb {
  position: relative;
  z-index: 1;
  margin-top: var(--topbar-h);
}
/* Highlighted region hosts status messages — make sure they clear the
   sticky site header and stand out as a system notification. */
.region-highlighted { position: relative; z-index: 1; }
.region-highlighted:has(.messages) { padding-top: 1rem; }
.region-breadcrumb ol:not(.contextual-links),
.region-breadcrumb ul:not(.contextual-links):not([hidden]),
.breadcrumb, .breadcrumb ol, .breadcrumb ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; color: var(--text-muted);
}
.region-breadcrumb ul.contextual-links, .region-breadcrumb [hidden] { display: none !important; }
.region-breadcrumb li, .breadcrumb li { list-style: none; }
.region-breadcrumb a, .breadcrumb a { color: var(--text-muted); }
.region-breadcrumb a:hover, .breadcrumb a:hover { color: var(--brand); }
.region-breadcrumb li + li::before,
.breadcrumb li + li::before {
  content: "/"; margin-right: 0.35rem; color: var(--border-strong);
}

/* =========================================================================
 * Region: CONTENT row — sidebar left · content · sidebar right
 * ========================================================================= */
.region-row--content {
  width: 100%;
  max-width: var(--container); margin: 0 auto;
  padding: 1rem 1.5rem;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 240px;
  gap: 1rem;
  flex: 1;
  align-items: start;
}
/* Ensure the content column has a usable width on admin pages. */
.region-row--content .region-content { min-width: 0; }
.region-row--content.no-sides { min-width: min(1200px, 100%); }
.region-row--content.no-left { grid-template-columns: minmax(0, 1fr) 240px; }
.region-row--content.no-right { grid-template-columns: 240px minmax(0, 1fr); }
.region-row--content.no-sides { grid-template-columns: minmax(0, 1fr); }

.region-sidebar-first, .region-sidebar-second {
  position: sticky; top: calc(var(--topbar-h) + 12px);
}

/* =========================================================================
 * Region: BOTTOM — three equal blocks
 * ========================================================================= */
.region-row--bottom {
  max-width: var(--container); margin: 0 auto; padding: 0 1.5rem 1.25rem;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
}

/* =========================================================================
 * Region: FOOTER — full width
 * ========================================================================= */
.region-row--footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}
.region-row--footer .region-footer {
  max-width: var(--container); margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

/* =========================================================================
 * Responsive breakpoints
 * ========================================================================= */
@media (max-width: 1100px) {
  .region-row--top,
  .region-row--bottom { grid-template-columns: 1fr; }
  .region-row--content,
  .region-row--content.no-left,
  .region-row--content.no-right { grid-template-columns: 1fr; }
  .region-sidebar-first, .region-sidebar-second { position: static; }
}
@media (max-width: 800px) {
  .region-header__inner { grid-template-columns: auto 1fr auto; }
  .primary-menu { display: none; } /* Collapsed; mobile toggle lives in the JS */
  .region-header.is-mobile-open .primary-menu {
    display: flex; flex-direction: column; align-items: stretch;
    position: absolute; top: var(--topbar-h); left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem; z-index: 55;
  }
}

/* =========================================================================
 * Blocks — give every block a card look by default
 * ========================================================================= */
.block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 0.9rem 1rem 1rem;
  margin: 0;
}
/* Block title */
.block > h2, .block > h3, .block__title {
  margin: 0 0 0.5rem;
  font-size: 0.92rem; font-weight: 600; letter-spacing: -0.005em;
}

/* Do NOT wrap the header/menu/user/footer blocks in a card background */
.region-header .block,
.region-footer .block {
  background: transparent;
  border: 0;
  padding: 0;
}
/* Primary-menu block and brand block inside header have no titles */
.region-header .block > h2,
.region-header .block > h3 { display: none; }

/* Content region: page itself is already the card — don't double-wrap */
.region-content > .block {
  background: transparent;
  border: 0;
  padding: 0;
}
.region-content > .block + .block { margin-top: 1rem; }
.main-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.25rem 1.25rem;
}

/* =========================================================================
 * Forms (mirrors mocks)
 * ========================================================================= */
input[type="text"], input[type="email"], input[type="number"],
input[type="tel"], input[type="url"], input[type="password"],
input[type="search"], input[type="date"], input[type="time"],
input[type="datetime-local"],
select, textarea {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font: inherit; font-size: 0.88rem;
  background: var(--surface); color: var(--text);
  transition: border-color 80ms, box-shadow 80ms;
}
/* Only stretch form controls inside proper Drupal form-items. Bare controls
   (filter bars, inline tools) keep their natural width. */
.form-item > input[type="text"],
.form-item > input[type="email"],
.form-item > input[type="number"],
.form-item > input[type="tel"],
.form-item > input[type="url"],
.form-item > input[type="password"],
.form-item > input[type="search"],
.form-item > input[type="date"],
.form-item > input[type="time"],
.form-item > input[type="datetime-local"],
.form-item > select,
.form-item > textarea {
  width: 100%;
  max-width: 560px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31,107,58,.12);
}
input[disabled], select[disabled], textarea[disabled] {
  background: var(--surface-2); color: var(--text-muted); cursor: not-allowed;
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 600; font-size: 0.82rem; margin-bottom: 0.3rem; }
.form-item { margin-bottom: 1rem; }
.description { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.25rem; }

.button, button, input[type="submit"] {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: var(--brand); color: #fff;
  border: 1px solid var(--brand); border-radius: 8px;
  font: inherit; font-size: 0.82rem; font-weight: 500;
  cursor: pointer;
  transition: background 80ms ease, border-color 80ms ease;
}
.button:hover, button:hover, input[type="submit"]:hover {
  background: var(--brand-2); border-color: var(--brand-2);
  color: #fff; text-decoration: none;
}
.button--secondary, button.secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong);
}
.button--secondary:hover { background: var(--surface-2); color: var(--text); }
.button--danger { background: #fff; color: var(--accent-4); border-color: #fecdca; }
.button--danger:hover { background: #fef3f2; color: var(--accent-4); border-color: #fecdca; }

.wsb-back-link-wrap {
  margin-top: 1.25rem;
}

/* =========================================================================
 * Tables
 * ========================================================================= */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left;
  padding: 0.55rem 0.7rem;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-strong);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); }
tbody tr:hover td { background: var(--surface-2); }

/* =========================================================================
 * Messages
 * ========================================================================= */
.messages {
  padding: 0.7rem 1rem 0.7rem 2.4rem;
  border-radius: var(--r-md);
  margin: 0 0 0.75rem;
  border: 1px solid #bfe5cc;
  border-left: 4px solid #12b76a;
  background: #e8f5ec; color: #11421f;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.messages::before {
  content: "✓";
  position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%);
  color: #12b76a; font-weight: 700;
}
.messages--error   { border-color: #f5c7c4; border-left-color: var(--accent-4); background: #fbe8e7; color: #5a1714; }
.messages--error::before   { content: "!"; color: var(--accent-4); }
.messages--warning { border-color: #f3e1bd; border-left-color: var(--accent-3); background: #fdf3e0; color: #5a3a08; }
.messages--warning::before { content: "!"; color: var(--accent-3); }
.messages__list { list-style: none; margin: 0; padding: 0; }
.messages__item + .messages__item { margin-top: 0.25rem; }

/* =========================================================================
 * Page title
 * ========================================================================= */
.page-title, h1.title, .block-page-title-block h1 {
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.4rem;
}

/* =========================================================================
 * Keep Drupal contextual links hidden (not flexed inline)
 * ========================================================================= */
.contextual-links[hidden] { display: none !important; }

/* =========================================================================
 * WSB Admin Views — page headers, filter bars, tables, badges, pager, modals
 * Ported from mockups/admin-common.css, adapted for Drupal Views markup.
 * ========================================================================= */

/* --- Page header (used via views header area or custom blocks) --- */
.wsb-admin-view .page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.wsb-admin-view .page-header h1 { font-size: 24px; font-weight: 700; color: var(--navy); margin: 0; }
.wsb-admin-view .page-header .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Page title styling on admin/wsb views */
.wsb-admin-view .page-title,
.wsb-admin-view .block-page-title-block h1 {
  font-size: 24px; font-weight: 700; color: var(--navy);
  border-bottom: none; padding-bottom: 0; margin-bottom: 6px;
}

/* Position "Add" button (from view header) to the right of the title.
   Scoped via :has() — without it, view-headers carrying stats grids or
   other content get pulled up over the subtitle / page title. */
.wsb-admin-view .view-header:has(.btn-add) { text-align: right; margin: -40px 0 12px; }
.wsb-admin-view .view-header .btn-add { float: right; }

/* Pager styling */
.wsb-admin-view .pager { margin-top: 16px; }
.wsb-admin-view .pager__items { display: flex; align-items: center; justify-content: flex-end; gap: 4px; list-style: none; padding: 0; }
.wsb-admin-view .pager__item a,
.wsb-admin-view .pager__item span {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--border, #e4e7ec);
  border-radius: var(--radius, 6px); font-size: 13px; color: var(--text, #101828);
  text-decoration: none; background: var(--white, #fff); transition: all 0.15s;
}
.wsb-admin-view .pager__item a:hover { background: var(--brand-soft, #e9f3ec); border-color: var(--brand, #1f6b3a); }
.wsb-admin-view .pager__item--active a,
.wsb-admin-view .pager__item--active span {
  background: var(--accent-green, #1f6b3a); color: #fff; border-color: var(--accent-green, #1f6b3a);
}
.wsb-admin-view .pager__item--first a,
.wsb-admin-view .pager__item--last a,
.wsb-admin-view .pager__item--previous a,
.wsb-admin-view .pager__item--next a { font-size: 12px; }

/* Result summary (Showing 1-15 of N) */
.wsb-admin-view .views-summary,
.wsb-admin-view .pager__summary { font-size: 13px; color: var(--text-muted, #667085); margin-top: 12px; }

/* View header — add button floats right alongside page title */

/* --- Add / action buttons --- */
.btn-add { background: var(--accent-green); color: #fff; padding: 10px 20px; border: none; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; box-shadow: var(--shadow-sm); transition: background 0.15s; }
.btn-add:hover { background: var(--accent-green-hover); text-decoration: none; color: #fff; }
.btn-add svg { width: 14px; height: 14px; fill: currentColor; }

/* --- View header actions --- */
.wsb-admin-view .wsb-view-header-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.wsb-admin-view .wsb-view-header-actions .views-data-export-feed {
  display: block;
}
.wsb-admin-view .wsb-view-header-actions .feed-icon,
.wsb-admin-view .wsb-view-header-actions .wsb-print-report-action {
  display: inline-flex;
  width: auto;
  min-height: 36px;
  align-items: center;
  overflow: visible;
  padding: 8px 14px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-indent: 0;
  text-decoration: none;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 4px;
}
.wsb-admin-view .wsb-view-header-actions .feed-icon:hover,
.wsb-admin-view .wsb-view-header-actions .feed-icon:focus-visible,
.wsb-admin-view .wsb-view-header-actions .wsb-print-report-action:hover,
.wsb-admin-view .wsb-view-header-actions .wsb-print-report-action:focus-visible {
  color: #fff;
  text-decoration: none;
  background: var(--brand-2);
  border-color: var(--brand-2);
}

/* --- Filter bar (Drupal Views exposed form) --- */
.wsb-admin-view .views-exposed-form {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
}
.wsb-admin-view .views-exposed-form .form-item {
  display: flex; flex-direction: column; gap: 5px; margin-bottom: 0;
}
.wsb-admin-view .views-exposed-form label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 0;
}
.wsb-admin-view .views-exposed-form input[type="text"],
.wsb-admin-view .views-exposed-form input[type="search"],
.wsb-admin-view .views-exposed-form input[type="date"],
.wsb-admin-view .views-exposed-form input[type="number"],
.wsb-admin-view .views-exposed-form select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; font-family: inherit; min-width: 155px;
  background: var(--white); color: var(--text); transition: border-color 0.15s;
  width: auto; max-width: none;
}
.wsb-admin-view .views-exposed-form input:focus,
.wsb-admin-view .views-exposed-form select:focus {
  outline: none; border-color: var(--navy-light); box-shadow: none;
}
/* Cap native date inputs so they don't outgrow the rest of the bar. */
.wsb-admin-view .views-exposed-form input[type="date"] {
  width: 155px;
}
/* Autolookup: magnifying-glass icon overlaid on text filters
   (matches .filter-group.autolookup in mockups/admin-common.css). */
.wsb-admin-view .views-exposed-form .js-form-type-textfield,
.wsb-admin-view .views-exposed-form .form-type--textfield {
  position: relative;
}
.wsb-admin-view .views-exposed-form .js-form-type-textfield > input[type="text"],
.wsb-admin-view .views-exposed-form .form-type--textfield > input[type="text"] {
  padding-right: 30px;
}
.wsb-admin-view .views-exposed-form .js-form-type-textfield::after,
.wsb-admin-view .views-exposed-form .form-type--textfield::after {
  content: '';
  position: absolute;
  right: 10px; bottom: 10px;
  width: 14px; height: 14px;
  background: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 10-1.397 1.398h-.001l3.85 3.85a1 1 0 001.415-1.414l-3.85-3.85zm-5.242.156a4.5 4.5 0 110-9 4.5 4.5 0 010 9z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 10-1.397 1.398h-.001l3.85 3.85a1 1 0 001.415-1.414l-3.85-3.85zm-5.242.156a4.5 4.5 0 110-9 4.5 4.5 0 010 9z'/%3E%3C/svg%3E") no-repeat center / contain;
  opacity: 0.5;
  pointer-events: none;
}
.wsb-admin-view .views-exposed-form .form-actions {
  display: flex; gap: 8px; align-items: flex-end; margin-bottom: 0;
}
.wsb-admin-view .views-exposed-form .form-actions .button:not(.button--secondary),
.wsb-admin-view .views-exposed-form .form-actions input[type="submit"]:not(.button--secondary) {
  background: var(--navy); color: #fff; padding: 8px 18px; border: none;
  border-radius: 4px; font-size: 13px; cursor: pointer; font-weight: 600;
  transition: background 0.15s;
}
.wsb-admin-view .views-exposed-form .form-actions .button:not(.button--secondary):hover,
.wsb-admin-view .views-exposed-form .form-actions input[type="submit"]:not(.button--secondary):hover {
  background: var(--navy-light);
}
.wsb-admin-view .views-exposed-form .form-actions .button--secondary,
.wsb-admin-view .views-exposed-form .form-actions button.secondary {
  background: transparent; color: var(--text-muted); padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 4px; font-size: 13px;
  cursor: pointer; transition: border-color 0.15s;
}
.wsb-admin-view .views-exposed-form .form-actions .button--secondary:hover {
  border-color: #aaa;
}

/* --- Table (Drupal Views table display) --- */
.wsb-admin-view .view-content {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.wsb-admin-view table { width: 100%; border-collapse: collapse; }
.wsb-admin-view thead th {
  background: #f7f8fa; padding: 11px 16px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 2px solid var(--border); border-top: none;
}
.wsb-admin-view tbody td {
  padding: 12px 16px; border-bottom: 1px solid #f2f3f5; font-size: 13px;
}
.wsb-admin-view tbody tr:last-child td { border-bottom: none; }
.wsb-admin-view tbody tr:hover td { background: var(--row-hover); }
.wsb-admin-view tbody td a { color: var(--navy-light); text-decoration: none; font-weight: 600; }
.wsb-admin-view tbody td a:hover { text-decoration: underline; color: var(--navy); }

/* --- Badges --- */
.badge { display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 12px; font-weight: 600; }
.badge-active, .badge-signed, .badge-clear { background: var(--green-bg); color: var(--green); }
.badge-inactive, .badge-expired, .badge-closed, .badge-past { background: #f3f3f5; color: #888; }
.badge-pending, .badge-submitted, .badge-new { background: var(--amber-bg); color: #bf5600; }
.badge-validated, .badge-upcoming, .badge-assigned { background: #e3f2fd; color: #0d5baf; }
.badge-granted, .badge-approved { background: var(--green); color: #fff; }
.badge-denied, .badge-flagged { background: var(--red-bg); color: #b71c1c; }
.badge-consent-denied { background: #f3e5f5; color: #6a1b9a; }
.badge-investigating { background: #e3f2fd; color: #0d5baf; }
.badge-resolved { background: var(--green-bg); color: var(--green); }
.badge-in-progress { background: #fff3e0; color: #e65100; }

/* --- Operations column --- */
.ops { white-space: nowrap; }
.ops a { font-size: 12px; color: var(--navy-light); text-decoration: none; padding: 4px 8px; border: 1px solid transparent; border-radius: 3px; transition: all 0.15s; }
.ops a:hover { background: #eef1f6; border-color: var(--border); text-decoration: none; }
.ops a svg { width: 12px; height: 12px; fill: currentColor; vertical-align: -1px; margin-right: 3px; }

/* --- Pager (mini-pager from Views) --- */
.wsb-admin-view nav[role="navigation"] {
  display: flex; justify-content: center; align-items: center;
  margin-top: 18px; font-size: 13px; color: var(--text-muted);
}
.wsb-admin-view .js-pager__items {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 4px; align-items: center;
}
.wsb-admin-view .js-pager__items li {
  display: inline-flex; align-items: center; font-size: 13px; color: var(--text-muted);
}
.wsb-admin-view .js-pager__items a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; border: 1px solid var(--border);
  border-radius: 4px; color: var(--navy-light); text-decoration: none;
  font-size: 13px; font-weight: 500; transition: all 0.15s;
}
.wsb-admin-view .js-pager__items a:hover {
  background: var(--row-hover); border-color: #bbb; text-decoration: none;
}

/* --- Stat cards --- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.stat-card.flagged .num { color: #b71c1c; }

/* --- Severity badges --- */
.sev { display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 12px; font-weight: 600; }
.sev-low { background: var(--green-bg); color: var(--green); }
.sev-medium { background: var(--amber-bg); color: #bf5600; }
.sev-high { background: var(--red-bg); color: #b71c1c; }
.sev-critical { background: #b71c1c; color: #fff; }

/* --- Flagged rows --- */
.row-flagged { background: #fef8f8; }
.row-flagged:hover { background: #fef0f0; }
.ops a.unflag { color: #b71c1c; }
.retention { font-size: 11px; color: var(--text-muted); }

/* --- Access note banner --- */
.access-note { background: #fff8e6; border: 1px solid #f0d9a8; border-radius: var(--radius); padding: 12px 18px; font-size: 13px; color: #6b4908; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.access-note svg { width: 18px; height: 18px; fill: #c79100; flex-shrink: 0; }

/* --- Modal --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--white); border-radius: var(--radius); max-width: 600px; width: 100%; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; color: var(--navy); margin: 0; }
.modal-header .subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; }
.modal-body { padding: 0; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-footer .btn-save { background: var(--accent-green); color: #fff; padding: 8px 20px; border: none; border-radius: 4px; font-size: 13px; font-weight: 600; cursor: pointer; }
.modal-footer .btn-cancel { background: transparent; color: var(--text-muted); padding: 8px 16px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; cursor: pointer; }
.modal-footer .hint { font-size: 11px; color: var(--text-muted); }

/* --- Contact row (modal contact list) --- */
.contact-row { display: grid; grid-template-columns: 28px 1fr 1fr 1fr auto; gap: 12px; align-items: center; padding: 14px 24px; border-bottom: 1px solid #f2f3f5; }
.contact-row:last-child { border-bottom: none; }
.contact-row:hover { background: var(--row-hover); }
.drag-handle { cursor: grab; color: #bbb; font-size: 16px; text-align: center; user-select: none; }
.drag-handle:hover { color: #888; }
.contact-name { font-weight: 600; font-size: 13px; color: var(--navy); }
.contact-role { font-size: 11px; color: var(--text-muted); }
.contact-detail { font-size: 12px; color: var(--text-muted); }
.contact-priority { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 10px; font-weight: 700; }
.contact-ops { display: flex; gap: 10px; }
.contact-ops a { font-size: 12px; color: var(--navy-light); text-decoration: underline; display: inline-flex; align-items: center; gap: 4px; }
.contact-ops a:hover { color: var(--navy); }
.contact-ops a svg { width: 12px; height: 12px; fill: currentColor; flex-shrink: 0; }

/* =========================================================================
 * jQuery UI Dialog overrides — cascade to ALL modal dialogs in wsb_estate.
 * Uses !important on background/color to beat Gin admin-theme styles.
 * Structural/spacing rules use .wsb-dialog specificity (set via dialogClass).
 * ========================================================================= */
.ui-dialog {
  border: 0 !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-pop), 0 0 0 1px var(--border) !important;
  padding: 0 !important;
  font-family: var(--font-sans) !important;
  font-size: 14px !important;
  background: #ffffff !important;
  overflow: hidden !important;
  color: var(--text) !important;
}
.ui-dialog .ui-dialog-titlebar {
  padding: 18px 24px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  border-top: 0 !important;
  border-radius: 0 !important;
  background: #ffffff !important;
  color: var(--navy) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}
.ui-dialog .ui-dialog-title {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--navy) !important;
  letter-spacing: -0.01em;
  padding: 0 !important;
  margin: 0 !important;
  float: none !important;
  flex: 1;
}
.ui-dialog .ui-dialog-titlebar-close {
  position: static !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  transform: none !important;
  opacity: 1 !important;
  margin: 0 !important;
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 6px !important;
  background: none !important;
  color: var(--text-muted) !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: none;
}
/* Gin uses an SVG-mask icon (`.ui-icon-closethick`) that paints over our text glyph.
   Disable the mask so our × character is visible and styled. */
.ui-dialog .ui-dialog-titlebar-close .ui-icon,
.ui-dialog .ui-dialog-titlebar-close .ui-icon-closethick {
  -webkit-mask-image: none !important;
  mask-image: none !important;
  background: none !important;
}
.ui-dialog .ui-dialog-titlebar-close:hover { background: var(--surface-2) !important; }
.ui-dialog .ui-dialog-titlebar-close .ui-icon {
  background-image: none !important;
  text-indent: 0 !important;
  width: auto !important;
  height: auto !important;
  font-size: 20px;
  margin: 0 !important;
  overflow: visible !important;
  inset-block-start: auto !important;
  inset-inline-start: auto !important;
}
.ui-dialog .ui-dialog-titlebar-close .ui-icon::before { content: '\00d7'; display: block; line-height: 1; }
.ui-dialog .ui-dialog-content {
  padding: 0 !important;
  background: #ffffff !important;
  color: var(--text) !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
}
.ui-dialog .ui-dialog-buttonpane {
  padding: 14px 24px !important;
  border-top: 1px solid var(--border) !important;
  background: #ffffff !important;
  border-radius: 0 !important;
  margin-top: 0 !important;
}
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: none; display: flex; gap: 8px; justify-content: flex-end; }
.ui-widget-overlay { background: rgba(0,0,0,0.45) !important; opacity: 1 !important; }

/* =========================================================================
 * WSB Admin pages — page-header layout
 * Local actions block (Add button) is positioned absolute (top-right of
 * main-content) to appear beside the <h1>, matching the mockup layout.
 * Applies to ALL wsb admin view pages via .wsb-admin-view class.
 * ========================================================================= */
.main-content { position: relative; }

.main-content:has(.wsb-admin-view) #block-wsb-estate-local-actions {
  position: absolute;
  top: 1.1rem;
  right: 1.25rem;
  margin: 0;
}
.main-content:has(.wsb-admin-view) #block-wsb-estate-local-actions nav {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
}
.main-content:has(.wsb-admin-view) #block-wsb-estate-local-actions li {
  list-style: none;
}
.main-content:has(.wsb-admin-view) #block-wsb-estate-local-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--accent-green);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}
.main-content:has(.wsb-admin-view) #block-wsb-estate-local-actions a::before {
  content: '+';
  font-size: 16px;
  line-height: 1;
  font-weight: 400;
}
.main-content:has(.wsb-admin-view) #block-wsb-estate-local-actions a:hover {
  background: var(--accent-green-hover);
  text-decoration: none;
  color: #fff;
}

/* Page title on wsb admin view pages — remove bottom border, tighten margin */
.main-content:has(.wsb-admin-view) .page-title,
.main-content:has(.wsb-admin-view) .block-page-title-block h1 {
  margin-bottom: 2px;
  border-bottom: none;
  padding-bottom: 0;
}

/* Subtitle injected via views preprocess + views-view.html.twig */
.wsb-view-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

/* Operations column — keep both links on one line; let the column size to its
   content. The mockup's max-width: 100px on the <th> is only a hint with
   table-layout: auto; on live we don't enforce it because the two
   icon+text links need ~115px to fit without overflow. */
.wsb-admin-view tbody td:last-child,
.wsb-admin-view thead th:last-child { white-space: nowrap; }

/* Counter (#) column — narrow row counter, never sized to content. */
.wsb-admin-view .views-field-counter { width: 48px; max-width: 48px; white-space: nowrap; }

/* =========================================================================
 * Quantity badges — Contacts / Complaints columns on admin views
 * Emitted by wsb_related_count Views field plugin.
 * ========================================================================= */
.wsb-admin-view .qty-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 26px; padding: 0 8px;
  background: #eef1f6; border: 1px solid var(--border);
  border-radius: 4px; font-size: 12px; font-weight: 700;
  color: var(--navy-light); cursor: pointer; text-decoration: none;
}
.wsb-admin-view .qty-link:hover {
  background: #dde3ed; border-color: #aaa; text-decoration: none;
}
.wsb-admin-view .qty-link.qty-zero {
  background: #f8f8f8; color: #bbb; border-color: #eee; cursor: default;
}
.wsb-admin-view .qty-complaints {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 26px; padding: 0 8px;
  background: #f8f8f8; border: 1px solid #eee;
  border-radius: 4px; font-size: 12px; font-weight: 700;
  color: #bbb; cursor: default; text-decoration: none;
}
.wsb-admin-view .qty-complaints.has-complaints {
  background: #fef0f0; border-color: #e0b0b0; color: #b71c1c; cursor: pointer;
}
.wsb-admin-view .qty-complaints.has-complaints:hover {
  background: #fce4e4; border-color: #c98080; text-decoration: none;
}

/* =========================================================================
 * Complaints view — column widths so all 10 columns fit on standard admin width.
 * Subject (free-text) wraps to two lines with ellipsis; status/badge/date
 * columns stay nowrap so they don't waste space.
 * ========================================================================= */
.view-wsb-admin-complaints .views-field-subject {
  min-width: 220px; max-width: 320px;
}
.view-wsb-admin-complaints .views-field-subject a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.35;
}
.view-wsb-admin-complaints .views-field-property,
.view-wsb-admin-complaints .views-field-complainant,
.view-wsb-admin-complaints .views-field-category,
.view-wsb-admin-complaints .views-field-severity,
.view-wsb-admin-complaints .views-field-state,
.view-wsb-admin-complaints .views-field-source,
.view-wsb-admin-complaints .views-field-created { white-space: nowrap; }
.wsb-admin-view tbody td:last-child a {
  font-size: 12px;
  color: var(--navy-light);
  text-decoration: none;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  transition: all 0.15s;
}
.wsb-admin-view tbody td:last-child a:hover {
  background: #eef1f6;
  border-color: var(--border);
  text-decoration: none;
}

/* =========================================================================
 * Full badge palette — covers all WSB workflow states and list_string values
 * ========================================================================= */

/* Access form */
.badge-link-issued { background: var(--amber-bg); color: #bf5600; }
.badge-voided { background: #f3f3f5; color: #888; }

/* Visitor approval */
.badge-arrived { background: #e8f4fd; color: #0a6498; }
.badge-departed { background: #f3f3f5; color: #888; }
.badge-cancelled { background: #f3f3f5; color: #888; }

/* Complaint workflow */
.badge-submitted { background: var(--amber-bg); color: #bf5600; }
.badge-acknowledged { background: #e8f4fd; color: #0a6498; }
.badge-under-investigation { background: #fff3e0; color: #e65100; }
.badge-resolved { background: var(--green-bg); color: var(--green); }
.badge-dismissed { background: #f3f3f5; color: #888; }
.badge-escalated { background: var(--red-bg); color: #b71c1c; }

/* WhatsApp messages */
.badge-inbound { background: #e8f4fd; color: #0a6498; }
.badge-outbound { background: #f3e8fd; color: #6a1b9a; }
.badge-received { background: #f3f3f5; color: #667085; }
.badge-processed { background: var(--green-bg); color: var(--green); }
.badge-silent-drop--unknown-sender- { background: #fff3e0; color: #e65100; }

/* Property contacts */
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-inactive { background: #f3f3f5; color: #888; }

/* Legacy / unknown state fallbacks */
.badge-pending_signature { background: var(--amber-bg); color: #bf5600; }

/* --- Responsive admin views --- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .wsb-admin-view .views-exposed-form { flex-direction: column; align-items: stretch; }
}
@media (max-width: 800px) {
  .stats { grid-template-columns: 1fr; }
  .wsb-admin-view table { font-size: 12px; }
  .wsb-admin-view thead th,
  .wsb-admin-view tbody td { padding: 8px 10px; }
}
