:root {
  --hmj-admin-shell-max: 1420px;
  --hmj-admin-panel-radius: 22px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(63, 102, 199, 0.07), transparent 30%),
    linear-gradient(180deg, rgba(63, 102, 199, 0.03), transparent 24%),
    var(--bg, transparent);
  color: var(--ink, inherit);
}

img,
svg,
canvas {
  max-width: 100%;
  height: auto;
}

.row,
.bar,
.toolbar,
.filters,
.filters-row,
.section-head,
.summary-head,
.status-row,
.hero-main,
.hero-actions,
.toggle-line,
.range-controls,
.actions,
.progress-meta,
.narrative-head,
.history-top,
.note-card header,
.drawer-head,
.drawer-foot,
.editor__head,
.editor__foot,
.notice-shell__head,
.warning-actions,
.small-btns,
.shortlink-panel__head,
.shortlink-history__head,
.shortlink-item__top,
.shortlink-actions,
.shortlink-item__actions {
  flex-wrap: wrap;
}

.row > *,
.bar > *,
.toolbar > *,
.filters > *,
.filters-row > *,
.section-head > *,
.summary-head > *,
.status-row > *,
.hero-main > *,
.hero-actions > * {
  min-width: 0;
}

.wrap,
main,
.panel,
.card,
.layout,
.workspace,
.grid-main,
.hero,
.summary-grid,
.summary-splits,
.results-summary-strip,
.info-strip,
.metric-grid,
.notice-grid,
.board,
.table-card,
.form-grid,
.grid,
.control-grid,
.intake-layout,
.result-grid,
.match-grid,
.evidence-grid,
.profile,
.drawer,
.editor,
.hero-shell,
.shortlink-form,
.shortlink-result,
.shortlink-history,
.shortlink-fields,
.shortlink-result__row,
.quick-grid,
.module-grid,
.module-grid--active {
  min-width: 0;
}

.wrap,
main {
  width: min(100%, calc(100% - 40px));
  max-width: var(--hmj-admin-shell-max);
  margin-inline: auto;
}

.top,
header {
  backdrop-filter: blur(14px);
}

.panel,
.card,
.summary-card,
.metric,
.metric-card,
.notice-card,
.hero-card,
.control-card,
.warning-card,
.status-card,
.match-card,
.table-card,
.status-shell {
  border-radius: var(--hmj-admin-panel-radius);
}

.btn {
  min-height: 42px;
  border-radius: 14px;
}

.btn.small,
.btn.tiny {
  min-height: 38px;
  border-radius: 12px;
}

input,
select,
textarea {
  border-radius: 14px;
}

.row,
.bar,
.toolbar,
.filters,
.filters-row,
.section-head,
.summary-head,
.status-row,
.hero-main,
.hero-actions,
.toggle-line,
.range-controls,
.actions,
.progress-meta,
.narrative-head,
.history-top,
.note-card header,
.drawer-head,
.drawer-foot,
.editor__head,
.editor__foot,
.notice-shell__head,
.warning-actions,
.small-btns {
  column-gap: 12px;
  row-gap: 10px;
}

.hero,
.workspace,
.grid-main,
.layout,
.summary-grid,
.summary-splits,
.results-summary-strip,
.info-strip,
.metric-grid,
.notice-grid,
.board,
.table-card,
.form-grid,
.grid,
.control-grid,
.intake-layout,
.result-grid,
.match-grid,
.evidence-grid,
.profile {
  gap: clamp(14px, 2vw, 20px);
}

.sidebar,
.qv,
.brief-sidebar {
  align-self: start;
}

.drawer-foot,
.editor__foot {
  align-items: center;
}

.drawer-foot .btn,
.editor__foot .btn {
  flex: 0 1 auto;
  min-width: 0;
}

.hmj-admin-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.hmj-admin-top-actions > * {
  min-width: 0;
}

.hmj-admin-mobile-heading,
.hmj-admin-mobile-trigger,
.hmj-admin-mobile-backdrop {
  display: none;
}

input,
select,
textarea,
button {
  max-width: 100%;
}

.table-scroll,
.vscroll,
.table-viewport,
.rows-inner,
.drawer-body,
.editor__body,
.audit-list,
.activity-list,
.dbg-logs {
  overflow: auto;
}

.toolbar input,
.search,
.search input,
.filters input,
.filters select,
.filters-grid .search {
  min-width: 0;
}

.pill,
.chip,
.badge,
.status-chip,
.hero-meta,
.counter,
.tag,
.status-pill {
  max-width: 100%;
  white-space: normal;
}

body:not(.public-page):not(.clients-body) :is(
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  p,
  small,
  label,
  legend,
  dt,
  dd,
  th,
  td,
  button,
  a,
  .muted,
  .pill,
  .chip,
  .badge,
  .status-chip,
  .status-pill,
  .tag,
  .hero-copy__intro,
  .shortlink-item__url
) {
  overflow-wrap: anywhere;
}

.view-panel {
  max-width: min(320px, calc(100vw - 32px));
}

@media (max-width: 1320px) {
  .row,
  .bar,
  .wrap,
  main {
    padding-left: clamp(16px, 2vw, 20px);
    padding-right: clamp(16px, 2vw, 20px);
  }

  .panel,
  .card {
    border-radius: 18px;
  }

  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters-grid .search {
    grid-column: 1 / -1;
  }

  .board {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .hero-shell {
    grid-template-columns: minmax(0, 1.24fr) minmax(320px, 0.9fr);
  }

  .grid-main {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .hero-meta,
  .results-summary-strip,
  .info-strip,
  .metric-grid,
  .summary-splits {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1280px) {
  .workspace,
  .layout,
  .grid-main,
  .hero,
  .hero-shell,
  .toggle-panel,
  .image-panel,
  .intake-layout,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .qv,
  .brief-sidebar {
    position: static;
    top: auto;
  }

  .status-detail,
  .hero-meta,
  .results-summary-strip,
  .info-strip,
  .metric-grid,
  .summary-splits,
  .two-step-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-cluster {
    justify-items: stretch;
  }

  .action-cluster .btn,
  .control-note {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .control-note {
    max-width: none;
  }

  .shortlink-fields,
  .shortlink-result__row {
    grid-template-columns: 1fr;
  }

  .shortlink-result__row > *,
  .shortlink-actions > *,
  .shortlink-item__actions > * {
    min-width: 0;
  }

  .shortlink-item__top {
    align-items: stretch;
  }
}

@media (max-width: 1180px) {
  .workspace,
  .layout,
  .grid-main,
  .hero,
  .hero-shell,
  .toggle-panel,
  .image-panel,
  .intake-layout,
  .control-grid,
  .client-contact-page .contact-content {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .qv,
  .brief-sidebar {
    position: static;
    top: auto;
  }

  .form-grid,
  .grid,
  .result-grid,
  .match-grid,
  .evidence-grid,
  .public-visibility__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .notice-card {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .table-header,
  .table-row {
    min-width: 1040px;
  }

  .thead,
  .trow {
    min-width: 1080px;
  }

  #tableWrap,
  #listWrap,
  #clientList,
  #reportTable {
    overflow: auto;
  }

  #tableWrap table,
  #clientList table,
  #reportTable {
    min-width: 920px;
  }

  .drawer,
  .editor {
    width: min(720px, calc(100vw - 20px));
  }
}

@media (max-width: 900px) {
  .row,
  .bar,
  .wrap,
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .wrap,
  main {
    width: min(100%, calc(100% - 28px));
  }

  .form-grid,
  .grid,
  .hero-meta,
  .info-strip,
  .results-summary-strip,
  .metric-grid,
  .summary-splits,
  .result-grid,
  .match-grid,
  .evidence-grid,
  .public-visibility__grid,
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .notice-card,
  .file-card,
  .match-head,
  .shortlink-result__row {
    grid-template-columns: 1fr;
  }

  .status-detail,
  .two-step-grid {
    grid-template-columns: 1fr;
  }

  .shortlink-item__top {
    flex-direction: column;
    align-items: flex-start;
  }

  .match-metrics,
  .action-cluster,
  .toggle-controls {
    justify-items: start;
  }

  .view-panel {
    position: fixed;
    left: 14px;
    right: 14px;
    top: 74px;
    min-width: 0;
  }

  .drawer,
  .editor {
    width: 100vw;
    max-width: 100vw;
  }

  .table-header,
  .table-row {
    min-width: 980px;
  }

  .thead,
  .trow {
    min-width: 980px;
  }

  #tableWrap table,
  #clientList table,
  #reportTable {
    min-width: 860px;
  }

  .bulk-bar,
  .bulkbar {
    padding: 12px 14px;
  }
}

@media (max-width: 720px) {
  .panel,
  .card,
  .summary-card,
  .split,
  .metric,
  .metric-card,
  .notice-card,
  .hero-card,
  .control-card,
  .warning-card,
  .status-card,
  .match-card {
    padding: 16px;
  }

  .drawer-head,
  .drawer-body,
  .drawer-foot,
  .editor__head,
  .editor__body,
  .editor__foot,
  .d-head,
  .d-body,
  .d-foot {
    padding-left: 16px;
    padding-right: 16px;
  }

  .row,
  .bar {
    gap: 10px;
  }

  .btn,
  .btn.small,
  .btn.tiny {
    min-height: 40px;
  }

  .toolbar > .btn,
  .toolbar > a,
  .filters-row .btn,
  .actions .btn,
  .hero-actions .btn,
  .small-btns .btn {
    flex: 1 1 180px;
  }

  .drawer-foot .btn,
  .editor__foot .btn {
    flex: 1 1 0;
  }

  .kv,
  dl {
    grid-template-columns: 1fr;
  }

  #toast,
  .toast-zone {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 560px) {
  .toolbar,
  .filters,
  .filters-row,
  .actions,
  .range-controls,
  .toggle-line,
  .small-btns,
  .control-actions,
  .hero-actions,
  .notice-card__actions,
  .editor-actions,
  .editor__foot {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar > *,
  .filters > *,
  .filters-row > *,
  .actions > *,
  .range-controls > *,
  .toggle-line > *,
  .small-btns > *,
  .control-actions > *,
  .hero-actions > *,
  .notice-card__actions > *,
  .editor-actions > *,
  .editor__foot > * {
    width: 100%;
  }

  .brand,
  .row .brand {
    width: 100%;
  }

  .bulk-bar,
  .bulkbar {
    flex-direction: column;
    align-items: stretch;
  }

  .table-header,
  .table-row,
  .thead,
  .trow {
    min-width: 920px;
  }
}

@media (max-width: 900px) {
  body.hmj-admin-mobile-menu-open {
    overflow: hidden;
  }

  body.hmj-admin-mobile-menu-open .top {
    z-index: 230;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .top .row.hmj-admin-mobile-nav-ready {
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
  }

  .top .row.hmj-admin-mobile-nav-ready .brand,
  .top .row.hmj-admin-mobile-nav-ready .row .brand {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .top .row.hmj-admin-mobile-nav-ready .pill {
    flex: 0 0 auto;
  }

  .top .row.hmj-admin-mobile-nav-ready .sp {
    flex: 0 0 auto;
    width: 0;
  }

  .top .row.hmj-admin-mobile-nav-ready > .hmj-admin-top-actions {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 68px);
    left: 14px;
    right: 14px;
    z-index: 12;
    display: grid;
    gap: 10px;
    padding: 16px;
    border-radius: 22px;
    border: 1px solid rgba(47, 78, 162, 0.16);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.995), rgba(247, 249, 255, 0.99));
    box-shadow: 0 24px 48px rgba(15, 27, 63, 0.24);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px) scale(0.98);
    transform-origin: top right;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 100px);
    overflow: auto;
    isolation: isolate;
  }

  .top .row.hmj-admin-mobile-nav-ready.hmj-admin-mobile-nav-open > .hmj-admin-top-actions {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .hmj-admin-mobile-heading {
    display: grid;
    gap: 4px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(47, 78, 162, 0.12);
  }

  .hmj-admin-mobile-heading strong {
    font-size: 16px;
    line-height: 1.2;
    color: var(--ink, #0f1b3f);
  }

  .hmj-admin-mobile-heading span {
    font-size: 13px;
    line-height: 1.45;
    color: var(--muted, #5d6f9e);
  }

  .hmj-admin-top-actions > :not(.hmj-admin-mobile-heading) {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    min-height: 46px;
  }

  .hmj-admin-mobile-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 44px;
    height: 44px;
    padding: 0;
    min-height: 44px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: 0 14px 28px rgba(15, 27, 63, 0.18);
    flex: 0 0 auto;
    transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  }

  .hmj-admin-mobile-trigger:hover,
  .hmj-admin-mobile-trigger:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.32);
    box-shadow: 0 18px 34px rgba(15, 27, 63, 0.24);
    outline: none;
    transform: translateY(-1px);
  }

  .hmj-admin-mobile-nav-open .hmj-admin-mobile-trigger {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.34);
  }

  .hmj-admin-mobile-trigger__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .hmj-admin-mobile-trigger__icon {
    position: relative;
    width: 20px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .hmj-admin-mobile-trigger__icon::before,
  .hmj-admin-mobile-trigger__icon::after,
  .hmj-admin-mobile-trigger__icon span {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transform-origin: center;
    transition: top 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
  }

  .hmj-admin-mobile-trigger__icon::before {
    top: 0;
  }

  .hmj-admin-mobile-trigger__icon span {
    top: 7px;
  }

  .hmj-admin-mobile-trigger__icon::after {
    top: 14px;
  }

  .hmj-admin-mobile-nav-open .hmj-admin-mobile-trigger__icon::before {
    top: 7px;
    transform: rotate(45deg);
  }

  .hmj-admin-mobile-nav-open .hmj-admin-mobile-trigger__icon span {
    opacity: 0;
    transform: scaleX(0.6);
  }

  .hmj-admin-mobile-nav-open .hmj-admin-mobile-trigger__icon::after {
    top: 7px;
    transform: rotate(-45deg);
  }

  .hmj-admin-mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 220;
    border: 0;
    padding: 0;
    background: rgba(12, 18, 42, 0.26);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .hmj-admin-mobile-backdrop[hidden] {
    display: none;
  }
}

@media (max-width: 560px) {
  .drawer-foot,
  .editor__foot {
    flex-direction: row;
    align-items: center;
  }

  .drawer-foot > *,
  .editor__foot > * {
    width: auto;
  }

  .top .row.hmj-admin-mobile-nav-ready .brand,
  .top .row.hmj-admin-mobile-nav-ready .row .brand {
    width: auto;
  }

  .top .row.hmj-admin-mobile-nav-ready > .hmj-admin-top-actions {
    left: 12px;
    right: 12px;
    top: calc(env(safe-area-inset-top, 0px) + 64px);
    padding: 14px;
    border-radius: 20px;
  }
}
