:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #17212b;
  background: #f4f6f8;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f8; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef2f5; }
.login-panel { width: min(390px, 100%); padding: 32px; border: 1px solid #d9e0e5; border-radius: 6px; background: #fff; box-shadow: 0 16px 45px rgb(35 48 59 / 10%); }
.login-panel h1 { margin: 18px 0 8px; font-size: 24px; }
.login-panel p { margin: 0 0 24px; color: #66717c; line-height: 1.5; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 6px; background: #e30613; color: #fff; font-weight: 800; }
.brand-mark.small { width: 34px; height: 34px; font-size: 13px; }
.button { min-height: 38px; padding: 0 14px; border: 1px solid #cbd4da; border-radius: 5px; background: #fff; color: #24313c; font-weight: 600; }
.button:hover { background: #f2f5f7; }
.button-primary { width: 100%; border-color: #17212b; background: #17212b; color: #fff; }
.button-primary:hover { background: #293744; }
.button:disabled { cursor: default; opacity: .55; }
.login-status { min-height: 22px; margin-top: 16px; color: #596774; font-size: 14px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; background: #17212b; color: #fff; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px 22px; }
.brand > span:last-child { display: grid; line-height: 1.1; }
.brand small { margin-top: 3px; color: #94a2ae; font-size: 11px; }
.nav { display: grid; gap: 3px; }
.nav button { min-height: 40px; padding: 0 12px; border: 0; border-radius: 4px; background: transparent; color: #bdc8d0; text-align: left; }
.nav button:hover, .nav button.active { background: #273540; color: #fff; }
.nav button.active { box-shadow: inset 3px 0 #e30613; }
.operator { margin-top: auto; display: grid; gap: 3px; padding: 15px 8px 0; border-top: 1px solid #34434f; overflow: hidden; }
.operator span { overflow: hidden; text-overflow: ellipsis; font-size: 13px; white-space: nowrap; }
.operator small { color: #92a1ad; }
.link-button { justify-self: start; margin-top: 7px; padding: 0; border: 0; background: none; color: #c9d2d8; }
.main { min-width: 0; }
.topbar { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 28px; border-bottom: 1px solid #dde3e7; background: #fff; }
.topbar h1 { margin: 0; font-size: 21px; }
.topbar p { margin: 5px 0 0; color: #71808b; font-size: 13px; }
.content { padding: 24px 28px 40px; }
.notice { margin: 18px 28px 0; padding: 11px 14px; border: 1px solid #e0b4b4; border-radius: 4px; background: #fff4f4; color: #9f3030; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); border: 1px solid #dce3e7; border-radius: 6px; background: #fff; overflow: hidden; }
.metric { min-height: 100px; padding: 20px; border-right: 1px solid #e4e9ec; border-bottom: 1px solid #e4e9ec; }
.metric:nth-child(4n) { border-right: 0; }
.metric strong { display: block; font-size: 27px; font-variant-numeric: tabular-nums; }
.metric span { display: block; margin-top: 8px; color: #687680; font-size: 13px; }
.section { margin-top: 24px; }
.section:first-child { margin-top: 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.section-header h2 { margin: 0; font-size: 16px; }
.section-header p { margin: 0; color: #74818b; font-size: 13px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { min-height: 38px; padding: 0 11px; border: 1px solid #cbd4da; border-radius: 4px; background: #fff; }
.toolbar input { width: min(360px, 100%); }
.table-wrap { overflow: auto; border: 1px solid #dce3e7; border-radius: 5px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; border-bottom: 1px solid #d7dfe4; background: #f7f9fa; color: #60707c; text-align: left; font-size: 11px; text-transform: uppercase; white-space: nowrap; }
th small { display: block; margin-top: 3px; color: #87939c; font-size: 9px; font-weight: 500; text-transform: none; }
td { max-width: 360px; padding: 11px 12px; border-bottom: 1px solid #e8ecef; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfd; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f1f6f9; }
.clickable-row:focus { position: relative; z-index: 2; outline: 2px solid #2673a8; outline-offset: -2px; background: #f1f6f9; }
.station-matrix table { min-width: 1180px; table-layout: fixed; }
.station-matrix th, .station-matrix td { width: 240px; }
.station-matrix .station-id { width: 76px; }
.canonical-cell, .source-record { display: grid; gap: 4px; min-width: 0; }
.canonical-cell > span:not(.status), .source-record > span { color: #65737d; font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
.canonical-cell .status { justify-self: start; margin-top: 3px; }
.source-cell { padding: 8px 10px; }
.source-record + .source-record { margin-top: 9px; padding-top: 9px; border-top: 1px solid #e4e9ec; }
.source-record.candidate { margin: -3px; padding: 7px; border: 1px solid #e5bd69; border-radius: 4px; background: #fff9eb; }
.source-record em { justify-self: start; padding: 2px 5px; border-radius: 3px; background: #f5dfaa; color: #74530d; font-size: 9px; font-style: normal; font-weight: 700; text-transform: uppercase; }
.source-record-id { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.source-record-id .mono { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-open { flex: 0 0 auto; display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid #ccd6dc; border-radius: 4px; color: #125da6; text-decoration: none; }
.source-open:hover { background: #eaf2f7; }
.source-coordinates { color: #40515d !important; font-family: "Cascadia Mono", Consolas, monospace; font-size: 10px !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.muted { color: #75838d; }
.empty { padding: 38px; border: 1px dashed #cbd4da; border-radius: 5px; color: #73818b; text-align: center; background: #fff; }
.status { display: inline-block; padding: 2px 7px; border-radius: 3px; background: #edf1f3; color: #4f606b; font-size: 11px; white-space: nowrap; }
.status.good { background: #e6f3eb; color: #267143; }
.status.warn { background: #fff2d7; color: #835b0b; }
.status.bad { background: #fde8e8; color: #9b2c2c; }
.row-button { padding: 3px 0; border: 0; background: transparent; color: #125da6; font-weight: 600; }
.dialog-viewer { width: min(820px, calc(100vw - 32px)); height: min(760px, calc(100vh - 32px)); padding: 0; border: 1px solid #cfd8de; border-radius: 6px; }
.dialog-viewer::backdrop { background: rgb(21 30 38 / 50%); }
.dialog-viewer > header { display: flex; justify-content: space-between; align-items: start; padding: 18px 20px; border-bottom: 1px solid #dce3e7; }
.dialog-viewer h2 { margin: 0; font-size: 18px; }
.dialog-viewer p { margin: 5px 0 0; color: #75828d; font-size: 12px; }
.close-button { width: 32px; height: 32px; border: 0; background: transparent; font-size: 26px; line-height: 1; }
.messages { height: calc(100% - 76px); overflow: auto; padding: 18px; background: #f4f6f8; }
.message { width: min(76%, 580px); margin: 0 0 10px; padding: 10px 12px; border: 1px solid #dce3e7; border-radius: 5px; background: #fff; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.outgoing, .message.status { margin-left: auto; background: #e9f2f8; border-color: #cddfe9; }
.message footer { display: flex; gap: 7px; margin-top: 7px; color: #77848e; font-size: 10px; }
.record-viewer { width: min(1120px, calc(100vw - 32px)); height: min(860px, calc(100vh - 32px)); padding: 0; border: 1px solid #cfd8de; border-radius: 6px; }
.record-viewer::backdrop { background: rgb(21 30 38 / 50%); }
.record-viewer > header { display: flex; justify-content: space-between; align-items: start; padding: 18px 20px; border-bottom: 1px solid #dce3e7; }
.record-viewer h2 { margin: 0; font-size: 18px; }
.record-viewer header p { margin: 5px 0 0; color: #75828d; font-size: 12px; }
.record-content { height: calc(100% - 76px); overflow: auto; background: #fff; }
.source-links { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid #dce3e7; background: #fafcfd; }
.source-links a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; min-width: 150px; padding: 8px 10px; border: 1px solid #ced8de; border-radius: 5px; background: #fff; color: #17344c; text-decoration: none; }
.source-links a:hover { border-color: #8daabd; background: #f3f8fb; }
.source-links span { font-size: 12px; font-weight: 700; }
.source-links small { grid-column: 1; color: #6f7c86; font-family: "Cascadia Mono", Consolas, monospace; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-links b { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: #125da6; font-size: 15px; }
.db-table-section { border-bottom: 1px solid #dce3e7; }
.db-table-section:last-child { border-bottom: 0; }
.db-table-heading { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 20px; border-bottom: 1px solid #e1e6e9; background: #f4f7f8; }
.db-table-heading h3 { margin: 0; font-family: "Cascadia Mono", Consolas, monospace; font-size: 14px; }
.db-table-heading p { margin: 3px 0 0; color: #73808a; font-size: 11px; }
.db-table-heading > span { color: #54636e; font-size: 12px; white-space: nowrap; }
.raw-record { padding: 0 20px 18px; }
.raw-record + .raw-record { border-top: 1px solid #e5eaed; }
.raw-record h4 { margin: 16px 0 8px; color: #566671; font-size: 12px; }
.raw-record dl { margin: 0; }
.raw-field { display: grid; grid-template-columns: minmax(190px, 28%) minmax(0, 1fr); border-bottom: 1px solid #edf0f2; }
.raw-field:last-child { border-bottom: 0; }
.raw-field dt, .raw-field dd { min-width: 0; margin: 0; padding: 9px 10px; }
.raw-field dt { display: grid; align-content: start; gap: 3px; color: #273641; font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.raw-field dt small { color: #84909a; font-family: Inter, "Segoe UI", Arial, sans-serif; font-size: 10px; }
.raw-field dd { border-left: 1px solid #edf0f2; overflow-wrap: anywhere; font-size: 12px; }
.raw-field pre { max-height: 320px; margin: 0; overflow: auto; color: #21303a; font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; line-height: 1.5; white-space: pre-wrap; }
.raw-null { color: #9a5560; font-family: "Cascadia Mono", Consolas, monospace; }
.raw-boolean { color: #7a4c00; font-family: "Cascadia Mono", Consolas, monospace; }
.raw-scalar { white-space: pre-wrap; }
.raw-empty, .raw-loading { padding: 28px 20px; color: #74818b; }
@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .metric:nth-child(2n) { border-right: 0; }
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding-inline: 8px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, .operator span, .operator small, .operator .link-button { display: none; }
  .nav button { padding: 0 5px; font-size: 11px; text-align: center; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
}
@media (max-width: 600px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 9px 10px; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { padding: 0 8px 0 0; }
  .nav { display: flex; white-space: nowrap; }
  .nav button { min-width: auto; padding: 0 10px; }
  .operator { display: none; }
  .topbar { min-height: 76px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 86px; padding: 15px; }
  .metric strong { font-size: 23px; }
  .record-viewer { width: calc(100vw - 12px); height: calc(100vh - 12px); }
  .raw-field { grid-template-columns: 1fr; }
  .raw-field dd { padding-top: 2px; border-left: 0; }
}
