:root {
  color-scheme: light dark;
  font: 100%/1.55 system-ui, sans-serif;
  --page: #f2f5f8;
  --surface: #fff;
  --soft: #f6f8fb;
  --today: #edf4ff;
  --ink: #182438;
  --muted: #526178;
  --line: #d4dde7;
  --control: #8797ac;
  --accent: #194c8c;
  --primary: #194c8c;
  --primary-hover: #123c73;
  --on-primary: #fff;
  --header: #15263c;
  --on-header: #eef4fc;
  --header-muted: #b4c5da;
  --header-line: #455974;
  --open-bg: #e1f1e9;
  --open-text: #234e3b;
  --closed-bg: #eceff4;
  --closed-text: #43536a;
  --error: #a23120;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #101822;
    --surface: #182434;
    --soft: #1f2b3d;
    --today: #1b304d;
    --ink: #edf3fc;
    --muted: #b3c3d8;
    --line: #394c63;
    --control: #8295ae;
    --accent: #a5caff;
    --primary: #a5caff;
    --primary-hover: #c2ddff;
    --on-primary: #13243b;
    --header: #0c1422;
    --on-header: #edf4ff;
    --header-muted: #b6c7e0;
    --header-line: #4b607c;
    --open-bg: #243d32;
    --open-text: #bae6ce;
    --closed-bg: #303e53;
    --closed-text: #d6e0ee;
    --error: #ffaf9e;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--page); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2.15rem, 4vw, 3.25rem); font-weight: 700; letter-spacing: -.055em; line-height: 1.1; }
h2 { font-size: 1.2rem; line-height: 1.25; letter-spacing: -.02em; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.site-header { color: var(--on-header); background: var(--header); border-bottom: 1px solid var(--header-line); }
.site-header-inner { max-width: 72rem; min-height: 3.8rem; margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.5rem); display: flex; align-items: center; gap: 1.5rem; }
.site-header a { color: var(--on-header); text-decoration: none; }
.site-header :focus-visible { outline-color: var(--on-header); }
.brand { white-space: nowrap; font-weight: 700; letter-spacing: -.025em; }
.brand .product { margin-left: .4rem; padding-left: .55rem; border-left: 1px solid var(--header-line); font-weight: 500; }
.brand-mark, .brand-divider { display: none; }
.site-header nav { display: flex; align-self: stretch; gap: 1rem; }
.site-header nav a { display: flex; align-items: center; border-bottom: 2px solid transparent; font-size: .925rem; }
.site-header nav a:hover, .site-header nav a[aria-current="page"] { border-bottom-color: var(--header-muted); }
.site-header form { margin-left: auto; }
button.quiet { color: var(--on-header); border-color: var(--header-line); background: transparent; white-space: nowrap; }
button.quiet:hover { color: var(--on-header); border-color: var(--header-muted); background: transparent; }

.workspace { width: 100%; max-width: 72rem; margin-inline: auto; padding: clamp(1.65rem, 5vw, 3.8rem) clamp(1rem, 4vw, 2.5rem) 3.5rem; }
.page-heading { margin-bottom: 1.7rem; }
.page-heading p { margin-top: .55rem; color: var(--muted); }
.calendar-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; gap: 1.25rem; }
.panel, article, dialog { border: 1px solid var(--line); border-radius: .75rem; background: var(--surface); color: var(--ink); }
.panel-heading, .service-heading, .toolbar { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.panel-heading, .service-heading { justify-content: space-between; }
.panel-heading { padding: 1.15rem 1.25rem; min-height: 4rem; }
.session-panel, .lookup-panel { padding: 1.25rem; }
.session-panel button, .session-panel a { margin-top: .65rem; }
.panel-status { padding: .9rem 1.25rem; color: var(--muted); border-top: 1px solid var(--line); }
.panel-retry { margin: 0 1.25rem 1.15rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; border-top: 1px solid var(--line); }
th, td { padding: .82rem 1.25rem; }
th { color: var(--muted); background: var(--soft); font-size: .875rem; font-weight: 650; }
tbody td { border-top: 1px solid var(--line); font-size: .95rem; }
tbody tr:last-child td:first-child { border-bottom-left-radius: .75rem; }
tbody tr:last-child td:last-child { border-bottom-right-radius: .75rem; }
tr.is-today td { background: var(--today); }
.date-cell { display: flex; align-items: baseline; gap: .3rem .65rem; flex-wrap: wrap; }
.today-label { color: var(--accent); font-size: .875rem; font-weight: 650; }
.market-status { display: inline-block; border-radius: 2rem; padding: .18rem .6rem; font-size: .875rem; font-weight: 650; white-space: nowrap; }
.market-status.open { background: var(--open-bg); color: var(--open-text); }
.market-status.closed { background: var(--closed-bg); color: var(--closed-text); }
.lookup-controls { display: flex; flex-wrap: wrap; align-items: stretch; gap: .65rem; margin-top: .3rem; }
.lookup-controls input { width: auto; flex: 1 1 9.25rem; min-width: 0; }
.lookup-result:not(:empty) { margin-top: 1.15rem; padding: .85rem .95rem; background: var(--soft); border-radius: .55rem; }
.lookup-result time { display: block; font-weight: 650; margin-bottom: .35rem; }
.lookup-result.error, #form-error { color: var(--error); }

button, .button { display: inline-block; border: 1px solid var(--control); background: var(--surface); color: var(--ink); padding: .42rem .8rem; border-radius: .42rem; font-size: .925rem; font-weight: 650; cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: var(--soft); }
button:disabled { opacity: .6; cursor: default; }
button.primary, .button.primary { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
button.primary:hover, .button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
label { font-weight: 650; display: block; margin-top: .85rem; font-size: .9375rem; }
input:not([type="checkbox"]), textarea, select { min-height: 2.4rem; width: 100%; color: var(--ink); background: var(--surface); border: 1px solid var(--control); border-radius: .4rem; padding: .4rem .55rem; }
.lookup-controls input:not([type="checkbox"]) { width: auto; }
textarea { overflow-wrap: anywhere; }
small, .muted, #status { color: var(--muted); }

.access-workspace { max-width: 62rem; }
#status:not(:empty) { margin-bottom: .75rem; }
article, dialog { padding: 1.15rem; }
article { margin-top: 1rem; }
article p, dialog p { margin-top: .55rem; }
article ul { list-style: none; padding: 0; }
article li { padding: .55rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
article li .toolbar { margin-top: .25rem; }
dialog { width: min(30rem, calc(100% - 2rem)); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog .toolbar { justify-content: flex-end; margin-top: 1rem; }
details summary { cursor: pointer; }

@media (max-width: 48rem) {
  .calendar-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 32rem) {
  .site-header-inner { flex-wrap: wrap; gap: .35rem .7rem; padding-block: .6rem 0; }
  .site-header-inner:has(nav[hidden]) { padding-bottom: .6rem; }
  .site-header nav { order: 3; width: 100%; min-height: 2.55rem; }
  .panel-heading, .lookup-panel, .session-panel { padding: .95rem; }
  th, td { padding-inline: .95rem; }
}

.skip { position: absolute; z-index: 2; top: .5rem; left: .5rem; padding: .65rem .85rem; background: var(--surface); transform: translateY(-155%); }
.skip:focus { transform: none; }
.workspace:focus { outline: 0; }

/* Match the Momentiv sign-in and service registry while the calendar keeps its own workspace. */
body:where(.registry-page, :has(#session-panel:not([hidden]))) {
  font-family: "Segoe UI", Arial, sans-serif;
  --page: #f5f8f8;
  --surface: #fff;
  --soft: #edf5f3;
  --ink: #14282d;
  --muted: #51666b;
  --line: #d9e2e3;
  --control: #738689;
  --accent: #00675c;
  --primary: #00675c;
  --primary-hover: #00574e;
  --on-primary: #fff;
  --header: #102b2e;
  --on-header: #e1f4ee;
  --header-muted: #a5c1bb;
  --header-line: #408c7e;
  --header-accent: #89d7c3;
  --open-bg: #e0f2ed;
  --open-text: #005c50;
  --closed-bg: #edf1f1;
  --closed-text: #40595d;
  --error: #a24434;
}

@media (prefers-color-scheme: dark) {
  body:where(.registry-page, :has(#session-panel:not([hidden]))) {
    --page: #10191c;
    --surface: #19262a;
    --soft: #223438;
    --ink: #e8f2f1;
    --muted: #a6babc;
    --line: #344a4d;
    --control: #789394;
    --accent: #89d9c6;
    --primary: #83d8c2;
    --primary-hover: #a3e7d6;
    --on-primary: #102925;
    --header: #102125;
    --header-line: #406b64;
    --open-bg: #203e36;
    --open-text: #a2e7d0;
    --closed-bg: #2a3c40;
    --closed-text: #c1d6d5;
    --error: #ffac98;
  }
}

body:where(.registry-page, :has(#session-panel:not([hidden]))) .site-header { border-bottom-width: 3px; }
body:where(.registry-page, :has(#session-panel:not([hidden]))) .site-header-inner {
  max-width: 76rem;
  min-height: 4.4rem;
  padding-inline: clamp(1rem, 4.4vw, 4rem);
  justify-content: space-between;
}
body:where(.registry-page, :has(#session-panel:not([hidden]))) .brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.18rem;
  font-weight: 650;
}
body:where(.registry-page, :has(#session-panel:not([hidden]))) .brand-mark {
  display: inline-flex;
  align-items: end;
  gap: 2px;
  height: 1.2rem;
}
.brand-mark i { width: 4px; background: var(--header-accent); transform: skew(-12deg); }
.brand-mark i:nth-child(1) { height: 47%; }
.brand-mark i:nth-child(2) { height: 75%; }
.brand-mark i:nth-child(3) { height: 100%; }
body:where(.registry-page, :has(#session-panel:not([hidden]))) .brand-divider { display: inline; color: var(--header-muted); font-weight: 400; }
body:where(.registry-page, :has(#session-panel:not([hidden]))) .brand .product { margin: 0; padding: 0; border: 0; font-weight: 400; }
body:where(.registry-page, :has(#session-panel:not([hidden]))) h1 { font-weight: 600; }
body:where(.registry-page, :has(#session-panel:not([hidden]))) .session-panel {
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border-radius: 10px;
  color: var(--muted);
}
.session-panel h2 { color: var(--ink); margin-bottom: .45rem; font-weight: 600; }
.session-panel:has(#login[hidden]) #sign-in-title { display: none; }

body:has(#session-panel:not([hidden])) .workspace {
  max-width: 76rem;
  padding: clamp(2rem, 6.5vw, 5rem) clamp(1rem, 4.4vw, 4rem) 4rem;
}
body:has(#session-panel:not([hidden])) .page-heading { margin-bottom: 2rem; }

.registry-page .access-workspace { max-width: 72rem; padding-top: clamp(2rem, 4vw, 3rem); }
.registry-page h1 { font-size: clamp(1.9rem, 4vw, 2.4rem); }
.registry-page .site-header nav { align-items: center; gap: clamp(.75rem, 2vw, 1.6rem); }
.registry-page .site-header nav a { align-self: stretch; white-space: nowrap; }
.registry-page .site-header nav a[aria-current="page"] { border-bottom-color: var(--header-accent); }
.registry-page button.quiet { padding-inline: .1rem; border-color: transparent; font-weight: 400; }
.registry-page button.quiet:hover { border-color: transparent; text-decoration: underline; }
.registry-heading, .registry-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.registry-heading { margin-bottom: 1.5rem; }
.registry-toolbar { color: var(--muted); justify-content: end; }
.registry-toolbar p { margin-right: auto; }
.registry-empty { margin-top: 1rem; padding: 2.25rem 1rem; text-align: center; color: var(--muted); }
.registry-page .button, .registry-page button { border-radius: 6px; }
.registry-page #status:not(:empty) { margin: 0; }

.service-record { min-width: 0; padding: clamp(1rem, 3vw, 1.4rem); border-radius: 12px; }
.service-title, .key-heading { display: flex; align-items: center; gap: .5rem .7rem; flex-wrap: wrap; overflow-wrap: anywhere; }
.service-title h2 { font-size: 1.25rem; font-weight: 600; }
.service-fields, .key-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .65rem 1.35rem; margin: 1rem 0 0; }
.service-fields dt, .key-fields dt { color: var(--muted); font-size: .875rem; }
.service-fields dd, .key-fields dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.service-tag { display: inline-block; padding: .15rem .55rem; border-radius: 1rem; font-size: .875rem; font-weight: 600; white-space: nowrap; }
.service-tag.active { background: var(--open-bg); color: var(--open-text); }
.service-tag.inactive { background: var(--closed-bg); color: var(--closed-text); }
.key-list { display: grid; gap: .65rem; margin: 1rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.key-row { padding: .85rem 1rem; border: 0; border-radius: 8px; background: var(--soft); }
.key-id, .registry-page #secret { font-family: ui-monospace, Consolas, monospace; }
.key-id { font-size: .9rem; }
.key-fields { margin: .65rem 0; font-size: .9rem; }
.service-record details { margin-top: .9rem; }
.service-record summary { width: fit-content; color: var(--accent); font-size: .9rem; }
.audit-list { margin: .45rem 0 0; color: var(--muted); font-size: .9rem; }
.audit-list li:last-child { padding-bottom: 0; }

.registry-page dialog { width: min(35.5rem, calc(100% - 2rem)); max-height: 90vh; padding: clamp(1.1rem, 4vw, 1.75rem); border-radius: 14px; box-shadow: 0 24px 70px rgb(0 0 0 / .22); }
.registry-page dialog h2 { font-size: 1.5rem; font-weight: 600; }
.registry-page dialog::backdrop { background: rgb(16 43 46 / .54); }
.registry-page .dialog-actions { margin-top: 1.35rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.registry-page label { margin-bottom: .3rem; }
.registry-page input[type="checkbox"] { accent-color: var(--accent); }
.registry-page #fields > div:has(input[type="checkbox"]) { display: flex; align-items: center; gap: .45rem; margin-top: .8rem; }
.registry-page #fields > div:has(input[type="checkbox"]) label { order: 1; margin: 0; }
.registry-page #secret { background: var(--soft); resize: vertical; }

@media (max-width: 39rem) {
  body:where(.registry-page, :has(#session-panel:not([hidden]))) .site-header-inner { min-height: 3.8rem; }
  .registry-page .site-header-inner { position: relative; align-items: flex-start; flex-wrap: wrap; gap: 0; padding-top: .8rem; }
  .registry-page .site-header nav { width: 100%; min-height: 2.8rem; }
  .registry-page .site-header form { position: absolute; top: .65rem; right: clamp(1rem, 4.4vw, 4rem); }
}
