/*
 * Temporary structural compatibility for templates that still use the historic
 * semantic class names. Visual values come only from the current --sm-* design
 * tokens. Selectors deliberately use :where(.sm-main) so page-specific modules
 * always win even though this file is injected late in the authenticated shell.
 */

:where(.sm-main) .section-card {
  min-width: 0;
  margin: 0 0 18px;
  overflow: hidden;
  border: 1px solid var(--sm-border);
  border-radius: var(--sm-radius-lg);
  background: var(--sm-surface);
  color: var(--sm-text);
  box-shadow: var(--sm-shadow-sm);
}

:where(.sm-main) .section-head {
  min-width: 0;
  min-height: 58px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--sm-border);
}

:where(.sm-main) .section-head > div { min-width: 0; }
:where(.sm-main) .section-head h2 { margin: 0; color: var(--sm-text); font-size: 1rem; font-weight: 720; }
:where(.sm-main) .section-head p { margin: 4px 0 0; color: var(--sm-text-muted); }
:where(.sm-main) .section-head small { display: block; margin-top: 3px; color: var(--sm-text-muted); line-height: 1.4; }
:where(.sm-main) .section-body { min-width: 0; padding: 18px; }

:where(.sm-main) .data-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

:where(.sm-main) .data-cell {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--sm-border);
  border-radius: var(--sm-radius);
  background: var(--sm-surface-muted);
}

:where(.sm-main) .data-cell > span { color: var(--sm-text-muted); font-size: .7rem; font-weight: 680; }
:where(.sm-main) .data-cell > strong { min-width: 0; overflow-wrap: anywhere; color: var(--sm-text); }
:where(.sm-main) .data-cell > small { min-width: 0; color: var(--sm-text-muted); line-height: 1.4; overflow-wrap: anywhere; }

:where(.sm-main) .listitem {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--sm-border);
  color: var(--sm-text);
  text-decoration: none;
}

:where(.sm-main) .listitem:first-child { padding-top: 0; }
:where(.sm-main) .listitem:last-child { padding-bottom: 0; border-bottom: 0; }
:where(.sm-main) .listitem:hover { color: var(--sm-text); }
:where(.sm-main) .listitem > span:first-child,
:where(.sm-main) .listitem > div:first-child { min-width: 0; flex: 1 1 auto; display: grid; gap: 3px; }
:where(.sm-main) .listitem strong { min-width: 0; overflow-wrap: anywhere; }
:where(.sm-main) .listitem small { display: block; min-width: 0; color: var(--sm-text-muted); line-height: 1.4; overflow-wrap: anywhere; }
:where(.sm-main) .listitem > .actions { flex: 0 0 auto; }

:where(.sm-main) .content-columns,
:where(.sm-main) .dashboard-columns {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

:where(.sm-main) .dashboard-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
:where(.sm-main) .dashboard-search-form label { min-width: 0; margin: 0; }

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

:where(.sm-main) .notice,
:where(.sm-main) .info-strip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--sm-border);
  border-radius: var(--sm-radius);
  background: var(--sm-surface-muted);
  color: var(--sm-text);
}
:where(.sm-main) .notice > span,
:where(.sm-main) .info-strip > span { min-width: 0; }

:where(.sm-main) .entry-editor,
:where(.sm-main) .compact-details {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--sm-border);
  border-radius: var(--sm-radius);
  background: var(--sm-surface);
}
:where(.sm-main) .entry-editor > summary,
:where(.sm-main) .compact-details > summary { padding: 10px 12px; cursor: pointer; font-weight: 680; }
:where(.sm-main) .entry-editor[open] > summary,
:where(.sm-main) .compact-details[open] > summary { border-bottom: 1px solid var(--sm-border); background: var(--sm-surface-muted); }
:where(.sm-main) .entry-editor-body,
:where(.sm-main) .details-body { min-width: 0; padding: 14px; }

@media (max-width: 991.98px) {
  :where(.sm-main) .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :where(.sm-main) .content-columns,
  :where(.sm-main) .dashboard-columns { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
  :where(.sm-main) .section-head { align-items: stretch; flex-direction: column; padding: 14px; }
  :where(.sm-main) .section-head > .button-link,
  :where(.sm-main) .section-head > .navbutton,
  :where(.sm-main) .section-head > .btn { align-self: flex-start; }
  :where(.sm-main) .section-body { padding: 14px; }
  :where(.sm-main) .data-grid { grid-template-columns: 1fr; }
  :where(.sm-main) .listitem { align-items: stretch; flex-direction: column; gap: 10px; }
  :where(.sm-main) .listitem > .actions { width: 100%; justify-content: flex-start; }
  :where(.sm-main) .dashboard-search-form { grid-template-columns: 1fr; }
  :where(.sm-main) .dashboard-search-form button { width: 100%; }

  .planning-edit-dialog {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
    margin: auto;
  }
  .planning-edit-dialog form { padding: 14px !important; }
  .planning-edit-dialog .dialog-head { gap: 10px !important; margin-bottom: 14px !important; }
  .planning-edit-dialog .row { grid-template-columns: minmax(0, 1fr) !important; gap: 10px !important; }
  .planning-edit-dialog .actions { display: grid !important; grid-template-columns: minmax(0, 1fr) !important; gap: 8px !important; }
  .planning-edit-dialog .actions > button,
  .planning-edit-dialog .actions > .button-link,
  .planning-edit-dialog .actions > .navbutton { width: 100%; min-height: 44px; white-space: normal; }
}

@media (max-width: 430px) {
  :where(.sm-main) .metric-grid { grid-template-columns: 1fr; }
}
