:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17212b;
  background: #f5f7f8;
  --canvas: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --line: #dce3e7;
  --line-strong: #c8d3d9;
  --text: #17212b;
  --text-muted: #667784;
  --primary: #116f91;
  --primary-hover: #0c5974;
  --primary-soft: #e2f2f7;
  --success: #247143;
  --success-soft: #dcefe3;
  --warning: #8c5a00;
  --warning-soft: #fff0cf;
  --danger: #9d3030;
  --danger-soft: #f8dfdf;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input { font: inherit; }
button {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: .55rem .85rem;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  line-height: 1.25;
}
button:hover { background: var(--primary-hover); }
button:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid #8ac8dc; outline-offset: 2px; }
button:disabled { cursor: wait; opacity: .6; }
button.secondary { border-color: var(--line); background: var(--surface); color: #334450; }
button.secondary:hover { background: #edf3f5; }
button.danger { background: #b33a3a; }
button.small { padding: .42rem .66rem; font-size: .85rem; }

.shell { width: min(1240px, calc(100% - 2rem)); margin: 0 auto; }
header {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.05rem; font-weight: 750; color: var(--text); }
.tag { margin-left: .6rem; color: var(--text-muted); font-size: .8rem; }

.auth-panel {
  max-width: 440px;
  margin: 10vh auto;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(20 37 48 / 6%);
}
.auth-panel h1, .view h1 { margin: 0; font-size: 1.35rem; line-height: 1.3; }
.overview-table h2 { margin: 0; font-size: 1rem; }
.auth-panel p, .muted { color: var(--text-muted); line-height: 1.45; }

form { display: grid; gap: .9rem; }
label { display: grid; gap: .35rem; color: #3b4b55; font-size: .9rem; }
input { width: 100%; padding: .58rem .68rem; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--text); }
input:hover { border-color: #9dacb5; }

nav { display: flex; gap: .15rem; border-bottom: 1px solid var(--line); padding: 1rem 0 0; }
.nav { padding: .65rem .85rem .72rem; color: #52636d; background: transparent; border-radius: 0; }
.nav:hover { color: var(--primary); background: transparent; }
.nav.active { color: var(--primary); border-bottom: 3px solid var(--primary); }
.view { padding: 1.7rem 0 2.25rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.overview-table { margin-top: 1.5rem; }
.section-meta { margin: .3rem 0 0; color: var(--text-muted); font-size: .9rem; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.metric-grid article { padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.metric-grid span { display: block; font-size: 1.8rem; font-weight: 750; }
.metric-grid small { color: var(--text-muted); }

.form-grid { padding: 1rem; margin: 0 0 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); background: #f0f6f8; border: 1px solid #ccdee5; border-radius: 8px; }
.form-grid > div { display: flex; gap: .5rem; align-items: end; }
.form-actions { grid-column: 1 / -1; }
.node-assignment { grid-column: 1 / -1; margin: 0; padding: .65rem; border: 1px solid var(--line-strong); border-radius: 6px; }
.node-assignment legend { padding: 0 .25rem; color: #3b4b55; font-size: .9rem; }
#site-node-selector { display: flex; flex-wrap: wrap; gap: .55rem; }
.node-option, .checkbox-label { display: flex; align-items: center; gap: .4rem; font-size: .9rem; color: #3b4b55; }
.node-option input, .checkbox-label input { width: auto; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem .8rem; border-bottom: 1px solid #e6ecef; text-align: left; vertical-align: top; font-size: .9rem; }
th { color: var(--text-muted); font-weight: 650; background: var(--surface-muted); }
td code { font-size: .77rem; }

.status { display: inline-flex; align-items: center; min-height: 1.55rem; padding: .18rem .45rem; border-radius: 999px; background: #ebf0f2; color: #42545f; font-size: .76rem; font-weight: 650; line-height: 1.2; white-space: nowrap; }
.status.active, .status.succeeded { background: var(--success-soft); color: var(--success); }
.status.pending, .status.queued, .status.dispatching, .status.applying, .status.partial { background: var(--warning-soft); color: var(--warning); }
.status.revoked, .status.disabled, .status.failed { background: var(--danger-soft); color: var(--danger); }
.status.draining, .status.rolled_back { background: #e7e5f6; color: #504c89; }

#notice { min-height: 1.2rem; margin: .75rem 0 0; color: var(--danger); }
#notice.success { color: var(--success); }
.tls-task { display: grid; gap: .25rem; min-width: 11rem; }
.tls-task small { color: var(--text-muted); line-height: 1.3; overflow-wrap: anywhere; }
.actions { min-width: 12rem; }
.actions button { margin: 0 .25rem .35rem 0; white-space: nowrap; }

.site-list { display: grid; gap: .7rem; }
.site-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.15fr) minmax(490px, 2.1fr) auto;
  gap: 1.25rem;
  align-items: center;
  min-height: 108px;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(20 37 48 / 3%);
}
.site-row:hover { border-color: #b7c8d0; box-shadow: 0 3px 10px rgb(20 37 48 / 5%); }
.site-name-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.site-name-line h2 { margin: 0; font-size: 1rem; line-height: 1.3; }
.site-domain-list { display: grid; gap: .18rem; margin-top: .38rem; color: #4b5d68; font-size: .88rem; overflow-wrap: anywhere; }
.site-facts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 0; }
.site-facts > div { min-width: 0; padding: 0 .8rem; border-left: 1px solid #e2e8eb; }
.site-facts > div:first-child { padding-left: 0; border-left: 0; }
.site-facts > div:last-child { padding-right: 0; }
.site-facts dt { margin-bottom: .32rem; color: var(--text-muted); font-size: .74rem; font-weight: 650; }
.site-facts dd { display: grid; gap: .16rem; margin: 0; color: #263743; font-size: .87rem; font-weight: 600; overflow-wrap: anywhere; }
.site-facts dd small { color: var(--text-muted); font-size: .72rem; font-weight: 500; line-height: 1.25; }
.fact-muted { color: var(--text-muted); font-weight: 500; }
.site-actions { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; min-width: max-content; }
.publish-detail { grid-column: 1 / -1; margin-top: -.35rem; padding-top: .65rem; border-top: 1px solid #e8edef; color: #4a5b66; font-size: .84rem; }
.publish-detail summary { color: var(--danger); cursor: pointer; font-weight: 650; }
.publish-detail ul { display: grid; gap: .3rem; margin: .55rem 0 0; padding-left: 1.2rem; }
.action-menu { position: relative; }
.action-menu summary { display: inline-flex; align-items: center; min-height: 2rem; padding: .4rem .62rem; border: 1px solid var(--line); border-radius: 6px; color: #435560; background: var(--surface); cursor: pointer; font-size: .85rem; list-style: none; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary::after { content: ""; width: .38rem; height: .38rem; margin-left: .46rem; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.action-menu[open] summary { border-color: #9ab6c2; background: #f4f8f9; }
.action-menu-panel { position: absolute; z-index: 2; right: 0; top: calc(100% + .35rem); display: grid; min-width: 9rem; padding: .35rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 28px rgb(20 37 48 / 14%); }
button.menu-action { justify-content: flex-start; padding: .48rem .55rem; border-radius: 5px; color: #344751; background: transparent; text-align: left; white-space: nowrap; }
button.menu-action:hover { background: #edf4f6; }
.site-empty { padding: 2.5rem 1rem; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--text-muted); text-align: center; }

.secret { margin: 1rem 0; padding: .85rem; white-space: pre-wrap; word-break: break-word; border: 1px solid #decf97; border-radius: 6px; background: #fff8d9; color: #514413; }
.hidden { display: none !important; }

@media (max-width: 1000px) {
  .site-row { grid-template-columns: minmax(190px, .8fr) minmax(420px, 1.35fr); }
  .site-actions { grid-column: 1 / -1; justify-content: flex-start; padding-top: .1rem; }
}

@media (max-width: 700px) {
  .shell { width: min(100% - 1rem, 1240px); }
  .metric-grid, .form-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; }
  .site-row { grid-template-columns: 1fr; gap: 1rem; padding: 1rem; }
  .site-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 0; }
  .site-facts > div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .site-facts > div:nth-child(even) { padding-right: 0; }
  .site-actions { grid-column: auto; justify-content: flex-start; flex-wrap: wrap; }
}
