/* Polaris modal kit.
   Every dialog in the app uses this look, taken from the Fleet inventory
   equipment editor: a light header with an optional eyebrow and description,
   a quiet borderless close button, a scrolling body and a grey action bar.

   Markup:
     <dialog class="pm-card">                    (or any element that is the card)
       <header class="pm-head">
         <div><span class="pm-eyebrow">Group</span>
              <h2 class="pm-title">Title</h2>
              <p class="pm-desc">One sentence about the task.</p></div>
         <button type="button" class="pm-close" aria-label="Close">×</button>
       </header>
       <div class="pm-body">…</div>
       <footer class="pm-foot">
         <button class="btn btn-danger pm-foot-start">Delete</button>
         <button class="btn btn-secondary">Cancel</button>
         <button class="btn btn-primary">Save</button>
       </footer>
     </dialog>
   A <div> overlay that holds the card takes .pm-overlay for the backdrop. */

:root {
  --pm-surface: #fff;
  --pm-text: var(--navy-900, #0d1b2a);
  --pm-muted: #637384;
  --pm-eyebrow: #527077;
  --pm-border: #d8e0e8;
  --pm-accent: #006175;
  --pm-radius: 20px;
  --pm-shadow: 0 24px 80px rgba(9, 31, 51, .24);
  --pm-backdrop: rgba(9, 31, 51, .48);
  --pm-head-bg: linear-gradient(120deg, #eff8f8, #f8fafc);
  --pm-foot-bg: #f8fafb;
  --pm-close-hover: #e2ecf0;
}

/* Sizing has no specificity so each modal's own width and height win. */
:where(.pm-card) {
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 40px);
}
.pm-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius);
  background: var(--pm-surface);
  color: var(--pm-text);
  box-shadow: var(--pm-shadow);
}
dialog.pm-card:not([open]) { display: none; }
dialog.pm-card::backdrop,
.pm-overlay {
  background: var(--pm-backdrop);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
/* A form that wraps the head, body and foot keeps the column layout. */
.pm-card > form:only-child,
.pm-card > .pm-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}

.pm-card .pm-head {
  position: static;
  display: flex;
  flex-shrink: 0;
  align-items: flex-start;
  gap: 14px;
  margin: 0;
  padding: 24px;
  border: 0;
  border-bottom: 1px solid var(--pm-border);
  border-radius: 0;
  background: var(--pm-head-bg);
  color: var(--pm-text);
}
.pm-card .pm-head::before,
.pm-card .pm-head::after { content: none; display: none; }
.pm-card .pm-head > :first-child:not(.pm-close) { flex: 1 1 auto; min-width: 0; }
.pm-card .pm-eyebrow {
  display: block;
  margin: 0 0 5px;
  color: var(--pm-eyebrow);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .1em;
  line-height: 1.4;
  text-transform: uppercase;
}
.pm-card .pm-title {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--pm-text);
  font-family: inherit;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.2;
  text-transform: none;
}
.pm-card .pm-desc {
  max-width: 420px;
  margin: 7px 0 0;
  color: var(--pm-muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
}

.pm-card .pm-close {
  display: grid;
  flex: 0 0 32px;
  place-items: center;
  width: 32px;
  height: 32px;
  min-width: 0;
  min-height: 0;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: #657789;
  font-family: inherit;
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.pm-card .pm-close:hover { background: var(--pm-close-hover); color: var(--pm-text); }
.pm-card .pm-close:focus-visible { outline: 2px solid var(--pm-accent); outline-offset: 2px; }
.pm-card .pm-close svg { width: 18px; height: 18px; }

.pm-card .pm-body {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 24px;
  overflow-y: auto;
  background: var(--pm-surface);
}

.pm-card .pm-foot {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 18px 24px;
  border: 0;
  border-top: 1px solid var(--pm-border);
  border-radius: 0;
  background: var(--pm-foot-bg);
}
.pm-card .pm-foot > .pm-foot-start { margin-right: auto; }
/* Footers that group buttons in a wrapper keep the group on the right. */
.pm-card .pm-foot > div { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Field labels inside modals read like the equipment editor's:
   12px, bold, sentence case. */
.pm-card .ops-field > label,
.pm-card .ops-field > .ops-field-title,
.pm-card .billing-form label > span,
.pm-card .invoice-meta-grid label > span,
.pm-card .billing-textarea > span {
  color: var(--pm-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

@media (max-width: 520px) {
  :where(.pm-card) { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .pm-card .pm-head, .pm-card .pm-body { padding: 20px; }
  .pm-card .pm-head { gap: 10px; }
  .pm-card .pm-title { font-size: 21px; }
  .pm-card .pm-foot { padding: 16px 20px; }
  .pm-card .pm-foot .btn { flex: 1 1 auto; }
}

/* Compact variant for modals that open inside a small panel, such as the
   chat widget. Same look, tighter spacing. */
.pm-card.pm-compact { border-radius: 16px; }
.pm-card.pm-compact .pm-head { gap: 10px; padding: 16px 18px; }
.pm-card.pm-compact .pm-title { font-size: 17px; }
.pm-card.pm-compact .pm-body { padding: 16px 18px; }
.pm-card.pm-compact .pm-foot { padding: 14px 18px; }
