@import "./tokens.css";
@import "./chrome.css";
@import "./home.css";

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header) + 12px); scrollbar-gutter: stable; scrollbar-color: var(--outline) var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5; font-synthesis: none; caret-color: var(--ink); -webkit-font-smoothing: antialiased; }
::selection { background: var(--lime); color: var(--ink); }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { text-wrap: balance; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--lime); flex: none; }
/* What scrolling content must leave clear at the bottom: the toast band (and, with a dock, the dock under it). */
.suite { --dock-pad: calc(var(--toast-bottom) + var(--toast-band) + 8px); }
.suite.has-dock {
  /* The toast stacks above the dock (dock bottom 12px + its height + 14px); the band under it is reserved from scrolling content. */
  --toast-bottom: calc(12px + var(--dock-height) + 14px + env(safe-area-inset-bottom));
}
.main { width: min(1120px, calc(100% - 56px)); margin: 0 auto; padding: 32px 0 calc(var(--dock-pad) + 24px); }
.main :focus-visible { scroll-margin-bottom: calc(var(--dock-pad) + 8px); }
.main h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; }
.main :is(h1, h2, h3, [tabindex="-1"]):focus { outline: none; }
.scope-line, .help, .status { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.page { max-width: 72ch; }
.page.wide { max-width: none; }
.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 20px;
}
.card > h2:first-child, .card > header h2 { margin: 0; font-size: 18px; line-height: 1.35; font-weight: 650; letter-spacing: -0.01em; }
.card > p { margin: 8px 0 0; }
.reserve { min-height: 180px; }
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; font-size: 14px; font-weight: 650; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.row p { margin: 0; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; font-weight: 650; }
.shell-state { display: grid; gap: 8px; max-width: 320px; margin: 0 0 24px; }
.shell-state label { font-size: 12px; font-weight: 650; color: var(--muted); }
.notice { margin-top: 16px; color: var(--ink); }

.pd-input, .pd-select, .shell-state select {
  width: 100%;
  min-width: 0;
  height: var(--control);
  min-height: var(--control);
  padding: 0 16px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 450;
}
.pd-select {
  appearance: none;
  padding-right: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23171B12' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}
.pd-textarea { width: 100%; min-height: 96px; padding: 10px 16px; border: 1px solid var(--outline); border-radius: var(--radius-textarea); background: var(--surface); color: var(--ink); font-size: 15px; }
.pd-input:focus-visible, .pd-select:focus-visible, .pd-textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
.pd-input:disabled, .pd-select:disabled { background: var(--paper); color: var(--muted); cursor: not-allowed; }
.pd-input[readonly] { border-style: dashed; background: var(--paper); }
.pd-input[aria-invalid="true"], .pd-select[aria-invalid="true"] { background: var(--danger-surface); border-color: var(--danger); }
.pd-input::placeholder { color: var(--muted); }
.pd-field { display: grid; gap: 6px; min-width: 0; }
.pd-field > label, .pd-label { font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.pd-help { margin: 0; color: var(--muted); font-size: 13px; font-weight: 450; }
.pd-error { display: flex; gap: 6px; align-items: flex-start; margin: 0; color: var(--danger); font-size: 13px; font-weight: 650; }
.pd-error svg { width: 16px; height: 16px; flex: none; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.pd-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  min-height: var(--control);
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-control);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--duration-micro) var(--ease);
}
.pd-button:disabled, .pd-button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.pd-button[aria-busy="true"] { opacity: 1; cursor: progress; }
.pd-button-primary { background: var(--lime); color: var(--on-lime); }
.pd-button-primary:hover:not(:disabled) { background: var(--press); }
.pd-button-secondary { background: var(--quiet); color: var(--ink); }
.pd-button-secondary:hover:not(:disabled) { background: #DAD6CE; }
.pd-button-tertiary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--outline); }
.pd-button-tertiary:hover:not(:disabled) { background: var(--tint); }
.pd-button-danger { background: var(--danger); color: var(--on-danger); }
.pd-button-danger:hover:not(:disabled) { background: #7A2424; }
.pd-button-link { min-height: 44px; padding: 0; background: transparent; color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.pd-button-icon { width: 44px; min-width: 44px; padding: 0; }
/* Marketing pages: the large size is for page-level actions only; on-ink is the outline button on an ink surface. */
.pd-button-lg { min-height: 48px; padding: 12px 22px; font-size: 16px; }
.pd-button-on-ink { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 1px rgb(246 245 242 / .5); }
.pd-button-on-ink:hover:not(:disabled) { background: var(--ink-raised); }
.pd-button-on-ink:focus-visible { outline-color: var(--paper); }
.pd-button.wrap { white-space: normal; }
.pd-spinner { width: 16px; height: 16px; flex: none; border: 2px solid currentColor; border-right-color: transparent; border-radius: 999px; animation: pd-spin .8s linear infinite; }
@keyframes pd-spin { to { transform: rotate(360deg); } }

.pd-stack { display: grid; gap: 24px; min-width: 0; }
.pd-stack-sm { display: grid; gap: 12px; min-width: 0; }
.pd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pd-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin: 0 0 24px; }
.pd-page-head > div { display: grid; gap: 6px; min-width: 0; }
.pd-page-head p { margin: 0; color: var(--muted); font-size: 15px; max-width: 68ch; overflow-wrap: anywhere; }
.pd-back { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; margin-bottom: 4px; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.pd-back:hover { color: var(--ink); }
.pd-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pd-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.pd-card-head > div { display: grid; gap: 4px; min-width: 0; }
.pd-card-head h2, .pd-card-head h3 { margin: 0; font-size: 18px; line-height: 1.35; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.pd-card-head p { margin: 0; color: var(--muted); font-size: 14px; }
.pd-section-title { margin: 8px 0 0; font-size: 20px; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; }

.pd-banner { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: start; padding: 14px 16px; border-radius: var(--radius-item); background: var(--tint); color: var(--ink); font-size: 14px; }
.pd-banner[data-tone="warning"] { background: var(--warning-surface); color: var(--on-warning); }
.pd-banner[data-tone="error"] { background: var(--danger-surface); color: var(--danger); }
.pd-banner > svg { grid-row: span 2; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pd-banner strong { font-weight: 650; overflow-wrap: anywhere; }
.pd-banner > div { display: grid; gap: 8px; min-width: 0; }
.pd-banner p { margin: 0; overflow-wrap: anywhere; }
.pd-banner .pd-actions { margin-top: 4px; }
.pd-status { min-height: 0; margin: 0; color: var(--muted); font-size: 14px; }
.pd-status:empty { display: none; }

.pd-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: 999px; background: var(--quiet); color: var(--ink); font-size: 12px; font-weight: 650; line-height: 1.4; white-space: nowrap; }
.pd-badge::after { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--outline); }
.pd-badge[data-tone="live"] { background: var(--tint); }
.pd-badge[data-tone="live"]::after { background: #5B6B00; }
.pd-badge[data-tone="warning"] { background: var(--warning-surface); color: var(--on-warning); }
.pd-badge[data-tone="warning"]::after { background: var(--on-warning); }
.pd-badge[data-tone="danger"] { background: var(--danger-surface); color: var(--danger); }
.pd-badge[data-tone="danger"]::after { background: var(--danger); }
.pd-badge[data-tone="plain"]::after { display: none; }

.pd-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius-card); }
.pd-kpis > div { display: grid; align-content: start; gap: 6px; min-width: 0; padding: 18px 20px; }
.pd-kpis > div + div { border-left: 1px solid var(--line); }
.pd-kpis dt { color: var(--muted); font-size: 13px; font-weight: 650; }
.pd-kpis dd { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pd-kpis dd small, .pd-kpis .kpi-note { display: block; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }

.pd-dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 16px; margin: 0; }
.pd-dl > dt, .pd-dl > dd { padding: 10px 0; border-top: 1px solid var(--line); }
.pd-dl > dt:first-of-type, .pd-dl > dt:first-of-type + dd { border-top: 0; }
.pd-dl > dt { color: var(--muted); font-size: 14px; font-weight: 550; }
.pd-dl > dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.pd-table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.pd-table-wrap:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pd-table, .card table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pd-table caption, .card table caption { padding: 0 0 12px; color: var(--muted); font-size: 13px; text-align: left; }
.pd-table th, .pd-table td, .card th, .card td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.pd-table thead th, .card thead th { padding-top: 8px; padding-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; border-bottom-color: var(--outline); }
.pd-table tbody th, .card tbody th { font-weight: 600; }
.pd-table td.num, .pd-table th.num, .card td.num, .card th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pd-table tbody tr:last-child > *, .card tbody tr:last-child > * { border-bottom: 0; }
.pd-table th:first-child, .pd-table td:first-child, .card th:first-child, .card td:first-child { padding-left: 0; }
.pd-table th:last-child, .pd-table td:last-child, .card th:last-child, .card td:last-child { padding-right: 0; }
.card tbody tr:hover > * { background: color-mix(in srgb, var(--tint) 45%, transparent); }

.pd-skeleton { display: block; border-radius: var(--radius-chip); background: var(--skeleton); }
.pd-skeleton.line { height: 14px; margin: 8px 0; }
@media (prefers-reduced-motion: no-preference) {
  .pd-skeleton { animation: pd-pulse 1.4s ease-in-out infinite; }
}
@keyframes pd-pulse { 50% { opacity: .55; } }

.pd-list { display: grid; margin: 0; padding: 0; list-style: none; }
.pd-list > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; min-width: 0; padding: 14px 0; border-top: 1px solid var(--line); }
.pd-list > li:first-child { border-top: 0; padding-top: 0; }
.pd-list > li:last-child { padding-bottom: 0; }
.pd-list .item-main { display: grid; gap: 2px; min-width: 0; flex: 1 1 220px; }
.pd-list .item-main strong { overflow-wrap: anywhere; font-weight: 650; }
.pd-list .item-main span { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.pd-link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.pd-link-grid a { display: grid; gap: 2px; min-height: 72px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-item); background: var(--surface); color: var(--ink); text-decoration: none; }
.pd-link-grid a:hover { border-color: var(--outline); background: color-mix(in srgb, var(--tint) 40%, var(--surface)); }
.pd-link-grid a strong { font-weight: 650; }
.pd-link-grid a span { color: var(--muted); font-size: 13px; }

.pd-disclosure { border-top: 1px solid var(--line); }
.pd-disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-weight: 650; list-style: none; cursor: pointer; overflow-wrap: anywhere; }
.pd-disclosure > summary::-webkit-details-marker { display: none; }
.pd-disclosure > summary::after { content: ""; width: 8px; height: 8px; flex: none; margin-right: 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform var(--duration-micro) var(--ease); }
.pd-disclosure[open] > summary::after { transform: rotate(225deg); }
.pd-disclosure > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 8px; }
.pd-disclosure > .pd-disclosure-body { display: grid; gap: 16px; padding: 4px 0 16px; }

.page:has(> .pd-auth) { max-width: none; }
.page:has(> .pd-auth) > :not(.pd-auth) { justify-self: center; width: min(440px, 100%); }
.pd-auth { display: grid; justify-items: center; padding-top: 24px; }
.pd-auth > * { width: min(440px, 100%); }
.pd-auth .card { padding: 28px; }
.pd-auth h1 { margin: 0 0 6px; }
.pd-auth .lede { margin: 0 0 20px; color: var(--muted); font-size: 15px; }
.pd-auth .pd-button-primary { width: 100%; }
.pd-auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 20px; font-size: 14px; }
.pd-auth-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }

@media (max-width: 800px) {
  .main { width: min(1120px, calc(100% - 32px)); padding-top: 24px; }
  .main h1 { font-size: 24px; }
  .pd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pd-kpis > div:nth-child(3) { border-left: 0; }
  .pd-kpis > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .card { padding: 16px; }
  .pd-auth { padding-top: 0; }
  .pd-auth .card { padding: 20px; }
  .pd-kpis > div { padding: 14px 16px; }
  .pd-kpis dd { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Dialog: native dialog + showModal(), as specified in docs/postdeploy-design-system.md and shown in the reference. */
:is(dialog, [popover]).pd-dialog { margin: auto; width: min(520px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); overflow: auto; border: 0; border-radius: var(--radius-sheet); padding: 24px; background: var(--surface); color: var(--ink); box-shadow: var(--elev-3); }
:is(dialog, [popover]).pd-dialog::backdrop { background: rgb(23 27 18 / .44); }
.pd-dialog-body { display: grid; gap: 16px; min-width: 0; }
.pd-dialog-body h2 { margin: 0; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.pd-dialog-description { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.pd-dialog-description p { margin: 0; }
/* In flow, never sticky: a bar pinned over a long review hides its last lines and shows the confirm button before the fields that gate it.
   At the end of the scroll the fields and the confirm button are in view together, in reading order. */
.pd-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 4px; }
