:root {
  --ink: #080b2a;
  --muted: #62708c;
  --line: #dbe5ff;
  --line-strong: #c3d2fb;
  --panel: rgba(255, 255, 255, .84);
  --white: #ffffff;
  --blue: #4059df;
  --blue-2: #1f83c8;
  --green: #18a86b;
  --amber: #c58514;
  --red: #cf3e5f;
  --violet: #6755d8;
  --shadow: 0 18px 48px rgba(33, 52, 115, .11);
  --shadow-soft: 0 8px 24px rgba(33, 52, 115, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 6%, rgba(50, 136, 214, .16), transparent 30%),
    radial-gradient(circle at 92% 18%, rgba(103, 85, 216, .13), transparent 32%),
    linear-gradient(145deg, #f7fbff 0%, #eef4ff 45%, #ffffff 100%);
}

button, input, textarea, select { font: inherit; }

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 4.4vw, 58px);
  line-height: .98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.16;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 0 12px;
  margin-bottom: 10px;
}

.brand img {
  display: block;
  width: 166px;
  height: auto;
}

.side-nav {
  display: grid;
  gap: 4px;
  overflow: auto;
  padding-right: 4px;
}

.nav-group {
  margin: 12px 10px 3px;
  color: #8490aa;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.side-link,
.menu-button,
.ghost-button,
.primary-button,
.text-button,
.filter-pill,
.modal-close {
  border: 0;
  cursor: pointer;
}

.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  color: #34405b;
  text-align: left;
  border-radius: 12px;
  background: transparent;
}

.side-link:hover,
.side-link.is-active {
  color: var(--ink);
  background: #edf3ff;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.sidebar-note span,
.eyebrow {
  display: block;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-note strong {
  display: block;
  margin-top: 6px;
}

.main {
  min-width: 0;
  padding: 20px 28px 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  margin-bottom: 16px;
}

.topbar > div:first-of-type {
  min-width: 230px;
}

.topbar-actions,
.filter-row,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-actions {
  justify-content: flex-end;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 440px;
}

.search-box input {
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 12px 34px rgba(33, 52, 115, .08);
  outline: none;
}

.search-box input:focus {
  border-color: #a9bcff;
}

.search-results {
  position: absolute;
  z-index: 15;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.search-result {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.search-result:hover {
  background: #f2f6ff;
}

.search-result span {
  color: var(--muted);
  font-size: 13px;
}

.menu-button {
  display: none !important;
}

.ghost-button,
.primary-button,
.filter-pill,
.text-button,
.menu-button,
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.ghost-button,
.filter-pill,
.modal-close {
  color: #35425f;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .78);
}

.filter-pill.is-active {
  color: var(--blue);
  border-color: #b9c9ff;
  background: #edf3ff;
}

.primary-button {
  color: #fff;
  font-weight: 800;
  background: var(--blue);
  box-shadow: 0 14px 34px rgba(64, 89, 223, .22);
}

.text-button {
  min-height: 34px;
  padding-inline: 0;
  color: var(--blue);
  background: transparent;
}

.compact-action {
  padding-inline: 13px;
}

[data-nav-icon]::before,
[data-button-icon]::before,
[data-button-icon]::after {
  display: none !important;
}

.ui-icon {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.side-link .ui-icon {
  width: 19px;
  height: 19px;
  color: var(--blue);
}

.primary-button .ui-icon {
  color: #fff;
}

.icon-label {
  min-width: 0;
}

.view { display: none; }
.view.is-visible { display: block; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric,
.panel,
.data-table-wrap,
.pipeline-column,
.client-card,
.document-card,
.timeline-item,
.ticket-column,
.report-card,
.automation-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 112px;
  padding: 15px;
  border-radius: 18px;
}

.metric strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 28px;
  line-height: 1;
}

.metric-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.trend {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  background: #eafaf2;
}

.trend.warn {
  color: var(--amber);
  background: #fff6df;
}

.trend.danger {
  color: var(--red);
  background: #fff0f4;
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.insight-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 16px 40px rgba(33, 52, 115, .09);
}

.insight-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  font-weight: 900;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
}

.insight-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.metric p,
.data-table td,
.client-card p,
.project-card p,
.document-card p,
.timeline-item p,
.ticket-card p,
.report-lines p,
.risk-list p,
.automation-card p,
.handoff-item p,
.cash-card p,
.priority-item p {
  color: var(--muted);
}

.owner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  gap: 12px;
}

.wide { grid-row: span 2; }

.split-layout,
.report-layout,
.finance-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
  gap: 14px;
}

.payments-stack {
  grid-template-columns: 1fr;
}

.payments-stack .finance-chart {
  min-height: 260px;
}

.payments-stack .data-table-wrap {
  width: 100%;
}

.panel {
  padding: 18px;
  border-radius: 20px;
}

.panel-accent {
  background:
    linear-gradient(145deg, rgba(64, 89, 223, .08), rgba(31, 131, 200, .06)),
    rgba(255, 255, 255, .88);
}

.panel-header,
.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.priority-list,
.cash-stack,
.health-stack,
.handoff-list,
.activity-list,
.report-lines,
.risk-list {
  display: grid;
  gap: 10px;
}

.priority-item,
.cash-card,
.health-item,
.handoff-item,
.activity-item,
.project-card,
.ticket-card {
  border: 1px solid #e7edff;
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.priority-item,
.health-item,
.activity-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.activity-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cash-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cash-card strong {
  font-size: 24px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  background: #edf3ff;
  white-space: nowrap;
}

.status.green { color: var(--green); background: #eafaf2; }
.status.amber { color: var(--amber); background: #fff6df; }
.status.red { color: var(--red); background: #fff0f4; }
.status.violet { color: var(--violet); background: #f0edff; }

.progress {
  grid-column: 1 / -1;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eeff;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--blue-2));
}

.directory-grid,
.document-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.client-card,
.document-card {
  min-height: 160px;
  padding: 16px;
  border-radius: 18px;
}

.card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.pipeline-column,
.ticket-column {
  min-height: 420px;
  padding: 12px;
  border-radius: 18px;
}

.pipeline-column > div,
.ticket-column > div {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.data-table-wrap {
  overflow: auto;
  border-radius: 18px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #fff;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #edf2ff;
}

.data-table th {
  color: #15203d;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 12px;
  border-radius: 18px;
}

.date-block {
  padding: 16px;
  border-radius: 18px;
  background: #edf3ff;
}

.date-block strong {
  display: block;
  font-size: 24px;
}

.finance-chart {
  min-height: 320px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(64, 89, 223, .08), transparent),
    #fff;
  box-shadow: var(--shadow);
}

.bar-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 80px;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.bar {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8efff;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.support-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.message-inbox {
  display: grid;
  gap: 12px;
}

.message-card {
  display: grid;
  grid-template-columns: minmax(220px, .36fr) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
}

.message-person {
  display: grid;
  gap: 8px;
}

.message-person h3,
.message-body p {
  margin-bottom: 0;
}

.message-person a {
  color: var(--blue);
  text-decoration: none;
}

.message-body {
  display: grid;
  gap: 10px;
}

.message-body p,
.message-meta {
  color: var(--muted);
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 13px;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
}

.contact-reply-preview {
  display: grid;
  gap: 8px;
  margin: 18px 24px 0;
  padding: 14px;
  color: #35425f;
  border: 1px solid #e1e9ff;
  border-radius: 16px;
  background: #f8fbff;
}

.contact-reply-preview strong {
  color: var(--ink);
}

.report-card {
  padding: 18px;
  border-radius: 20px;
}

.automation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.automation-card {
  min-height: 170px;
  padding: 18px;
  border-radius: 20px;
}

.settings-form {
  display: grid;
  gap: 14px;
  max-width: 1120px;
}

.form-grid,
.toggle-grid {
  display: grid;
  gap: 12px;
}

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

.form-grid.compact {
  margin: 18px 0 12px;
}

.form-grid .full-label {
  grid-column: 1 / -1;
}

.form-field,
.form-grid label,
.full-label {
  display: grid;
  gap: 7px;
  color: #2d3955;
}

.form-field span,
.form-grid label,
.full-label span {
  font-size: 13px;
  font-weight: 750;
  color: #1d2844;
}

.form-grid input,
.form-grid select,
.full-label textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid #cddaff;
  border-radius: 13px;
  background: #f8fbff;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.form-grid input:focus,
.form-grid select:focus,
.full-label textarea:focus {
  border-color: #8fa7ff;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(64, 89, 223, .1);
}

.full-label textarea {
  min-height: 104px;
  padding-top: 12px;
  resize: vertical;
}

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

.toggle-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px;
  color: #2d3955;
  border: 1px solid #e1e9ff;
  border-radius: 14px;
  background: #fff;
}

.save-state {
  min-height: 22px;
  color: var(--green);
}

.admin-modal {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  box-shadow: 0 30px 90px rgba(8, 11, 42, .25);
  overflow: hidden;
}

.admin-modal::backdrop {
  background: rgba(8, 11, 42, .48);
}

.modal-card {
  display: grid;
  max-height: calc(100dvh - 28px);
  padding: 0;
  background: #fff;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid #edf2ff;
}

.modal-head h2 {
  margin-top: 5px;
}

.modal-help {
  max-width: 560px;
  margin: 8px 0 0;
  color: var(--muted);
}

.modal-card .form-grid {
  overflow: auto;
  padding: 0 24px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px 24px;
  border-top: 1px solid #edf2ff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-close {
  flex: 0 0 auto;
  min-width: auto;
  min-height: 40px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  align-self: flex-start;
}

.modal-close .ui-icon {
  width: 16px;
  height: 16px;
}

.record-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.record-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  color: #45516f;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid #dce5ff;
  border-radius: 999px;
  background: #f7faff;
  cursor: pointer;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 180px;
  padding: 26px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(245,248,255,.88));
}

.is-empty-panel {
  overflow: visible;
  border-style: dashed;
  background: rgba(255, 255, 255, .7);
}

.is-empty-panel .empty-state {
  min-height: 260px;
  border: 0;
  background: transparent;
}

.finance-empty {
  display: grid;
  align-content: center;
  min-height: 210px;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, .72);
}

.finance-empty strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.finance-empty p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
}

.empty-state h3 {
  margin-bottom: 0;
}

.empty-state p {
  max-width: 520px;
  margin-bottom: 4px;
  color: var(--muted);
}

.empty-mark {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background:
    linear-gradient(135deg, rgba(64, 89, 223, .95), rgba(31, 131, 200, .9));
  box-shadow: var(--shadow-soft);
}

.column-empty {
  min-height: 86px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed #d4defd;
  border-radius: 14px;
  background: #f8fbff;
}

.data-table td .empty-state {
  margin: 10px;
}

.record-actions button:hover {
  color: var(--blue);
  border-color: #b8c8ff;
}

.record-actions button:last-child:hover {
  color: var(--red);
  border-color: #ffc5d0;
}

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 22px;
}

.auth-card {
  width: min(520px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow);
}

.auth-card img {
  display: block;
  width: 180px;
  margin-bottom: 28px;
}

.auth-card h1 {
  margin: 10px 0 20px;
  font-size: 42px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: #2d3955;
}

.auth-form input {
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid #cddaff;
  border-radius: 16px;
  background: #f8fbff;
}

.auth-error {
  padding: 12px 14px;
  color: var(--red);
  border: 1px solid #ffc9d4;
  border-radius: 14px;
  background: #fff0f4;
}

@media (max-width: 1260px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .insight-strip { grid-template-columns: 1fr; }
  .directory-grid,
  .document-grid,
  .compact-grid,
  .support-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .message-card { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1440px) {
  .admin-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .main { padding: 18px 22px 38px; }
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(300px, 1fr) auto;
    align-items: center;
  }
  .topbar .search-box {
    max-width: none;
  }
  .topbar-actions {
    justify-content: flex-end;
  }
  .ghost-button,
  .primary-button,
  .filter-pill,
  .text-button,
  .menu-button,
  .modal-close {
    min-height: 38px;
    padding-inline: 13px;
  }
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 20;
    width: 292px;
    transform: translateX(-104%);
    transition: transform .2s ease;
  }
  .admin-shell.is-menu-open .sidebar { transform: translateX(0); }
  .admin-shell.is-menu-open::after {
    content: "";
    position: fixed;
    z-index: 10;
    inset: 0;
    background: rgba(8, 11, 42, .36);
  }
  .admin-shell.is-menu-open .main {
    pointer-events: none;
  }
  .menu-button {
    display: inline-flex !important;
    align-items: center;
    width: 42px;
    padding: 0;
    background: #fff;
    border: 1px solid var(--line);
  }
  .menu-button .icon-label { display: none; }
  .search-box {
    order: 3;
    width: 100%;
    max-width: none;
  }
  .topbar {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
  }
  .topbar > div:first-of-type {
    min-width: 0;
  }
  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .search-box {
    grid-column: 1 / -1;
  }
  .owner-grid,
  .split-layout,
  .report-layout,
  .finance-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .directory-grid,
  .document-grid,
  .compact-grid,
  .support-board,
  .pipeline,
  .automation-grid {
    grid-template-columns: 1fr;
  }
  .pipeline-column,
  .ticket-column {
    min-height: auto;
  }
  .data-table {
    min-width: 760px;
  }
}

@media (max-width: 720px) {
  .main { padding: 14px; }
  .topbar h1 {
    font-size: clamp(34px, 11vw, 48px);
  }
  .topbar,
  .panel-header,
  .toolbar { align-items: stretch; flex-direction: column; }
  .topbar {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
  }
  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .topbar-actions .ghost-button,
  .topbar-actions .primary-button {
    width: 100%;
    min-width: 0;
  }
  .ghost-button,
  .primary-button { flex: initial; }
  .metric-grid,
  .insight-strip,
  .directory-grid,
  .document-grid,
  .pipeline,
  .support-board,
  .automation-grid,
  .form-grid,
  .toggle-grid { grid-template-columns: 1fr; }
  .pipeline-column,
  .ticket-column { min-height: auto; }
  .timeline-item { grid-template-columns: 1fr; }
  .data-table {
    min-width: 680px;
  }
  .admin-modal {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 22px 22px 0 0;
    margin: auto 0 0;
  }
  .modal-card {
    max-height: 100dvh;
  }
  .modal-head,
  .modal-foot {
    padding-inline: 18px;
  }
  .modal-card .form-grid {
    padding-inline: 18px;
  }
  .modal-foot {
    align-items: stretch;
    flex-direction: column;
  }
  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .brand img { width: 148px; }
  .sidebar { width: min(286px, 88vw); }
  .topbar-actions {
    grid-template-columns: 1fr;
  }
  .metric strong {
    font-size: 24px;
  }
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .panel,
  .metric,
  .insight-card,
  .client-card,
  .document-card {
    border-radius: 16px;
  }
  .empty-state {
    min-height: 150px;
    padding: 20px;
  }
  .modal-actions {
    grid-template-columns: 1fr;
  }
  .data-table {
    min-width: 620px;
  }
}
