:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #182c41;
  background: #f2f7fc;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --navy: #0b1f3a;
  --navy-light: #173a60;
  --blue: #086fc5;
  --docker-blue: #2496ed;
  --blue-pale: #eaf5ff;
  --ink: #182c41;
  --muted: #667c92;
  --line: #d3e2ef;
  --surface: #fff;
  --danger: #a94854;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; }
button, input { font: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.45rem, 3vw, 1.8rem); letter-spacing: -.025em; }
h2 { margin-bottom: 12px; font-size: 1.2rem; letter-spacing: -.015em; }
h3 { margin-bottom: 8px; font-size: 1.05rem; }
[hidden] { display: none !important; }

.site-shell { position: relative; z-index: 2; }
.topbar {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 2.5vw, 42px);
  border-bottom: 4px solid var(--docker-blue);
  color: white;
  background: var(--navy);
}
.brand { display: flex; align-items: center; gap: 12px; color: white; text-decoration: none; }
.brand-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #8bc7f4;
  color: white;
  background: var(--docker-blue);
  font-size: 18px;
  font-weight: 800;
}
.brand .eyebrow { margin-bottom: 2px; color: #afcde5; }
.brand strong { display: block; font-size: 18px; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.connection { display: flex; align-items: center; gap: 8px; margin-right: 5px; font-size: .84rem; }
.connection i, .state i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #efbd59;
}
.connection.online i, .state.running i { background: #52a9e8; }
.connection.offline i, .state.stopped i { background: #d47d86; }

.site-nav {
  display: flex;
  gap: 30px;
  padding: 0 clamp(18px, 2.5vw, 42px);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: white;
}
.site-nav a {
  position: relative;
  display: inline-flex;
  min-height: 54px;
  flex: 0 0 auto;
  align-items: center;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: .94rem;
  font-weight: 650;
  text-decoration: none;
}
.site-nav a:hover, .site-nav a.active { color: var(--navy); }
.site-nav a.active { border-bottom-color: var(--docker-blue); }

main {
  width: 100%;
  min-height: calc(100vh - 136px);
  margin: 0;
  padding: 28px clamp(16px, 2.5vw, 42px) 48px;
}
.page-view { min-height: 360px; }
.page-heading { margin: 4px 0 22px; }
.page-heading .eyebrow { margin-bottom: 7px; color: var(--blue); font-size: .72rem; font-weight: 750; letter-spacing: .14em; }
.page-heading p:last-child { margin-bottom: 0; color: var(--muted); }
.card {
  margin-bottom: 22px;
  padding: clamp(20px, 3vw, 28px);
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgb(11 31 58 / 5%);
}
.card > :last-child { margin-bottom: 0; }
.muted { color: var(--muted); font-size: .92rem; }

button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--blue);
  border-radius: 2px;
  padding: 9px 16px;
  color: white;
  background: var(--blue);
  font-size: .94rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
button:hover { border-color: #07599e; background: #07599e; }
button:active { transform: translateY(1px); }
button.secondary { border-color: #9eb4c9; color: var(--navy); background: white; }
button.secondary:hover { border-color: var(--blue); background: var(--blue-pale); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid #8bc7f4;
  outline-offset: 2px;
}

body.login-mode { color: var(--ink); background: linear-gradient(145deg, #07182e, #0b2f52 58%, #145b92); }
body.login-mode main {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
body.loading-mode { color: white; background: linear-gradient(145deg, #07182e, #0b2f52 58%, #145b92); }
body.loading-mode main {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.transition-loader { display: grid; justify-items: center; gap: 18px; color: #e8f4ff; text-align: center; }
.transition-loader p { margin: 0; font-size: .96rem; }
.loader-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgb(255 255 255 / 28%);
  border-top-color: var(--docker-blue);
  border-radius: 50%;
  animation: dockdeck-spin .8s linear infinite;
}
@keyframes dockdeck-spin { to { transform: rotate(360deg); } }
.login-page { width: min(440px, 100%); }
.login-card {
  padding: clamp(26px, 5vw, 42px);
  border: 1px solid #c9dced;
  border-top: 4px solid var(--docker-blue);
  border-radius: 2px;
  background: white;
  box-shadow: 0 18px 60px rgb(0 11 25 / 30%);
}
.login-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin-bottom: 20px;
  color: white;
  background: var(--docker-blue);
  font-size: 20px;
  font-weight: 800;
}
.login-card .eyebrow { margin-bottom: 6px; color: var(--blue); font-size: .72rem; font-weight: 750; letter-spacing: .14em; }
.login-card h2 { margin-bottom: 7px; color: var(--navy); font-size: 1.45rem; }
.login-description { margin-bottom: 22px; color: var(--muted); font-size: .92rem; }
#login-form { display: grid; gap: 16px; }
#login-form label { display: block; margin: 0; color: var(--ink); font-size: .9rem; font-weight: 650; }
input {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 7px;
  padding: 10px 12px;
  border: 1px solid #aebfd0;
  border-radius: 2px;
  color: var(--ink);
  background: white;
}
input:focus { border-color: var(--docker-blue); outline: 2px solid #8bc7f4; outline-offset: 1px; }
.login-submit-row { display: grid; gap: 8px; margin-top: 4px; }
.login-submit-row button { width: 100%; }
.login-submit-row p { min-height: 1.4em; margin: 0; }
.error-text { color: var(--danger); font-size: .9rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.caddy-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.stat-card {
  display: flex;
  min-height: 112px;
  align-items: center;
  gap: 15px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: 2px;
  background: white;
  box-shadow: 0 4px 14px rgb(11 31 58 / 5%);
}
.stat-card:nth-child(2) { border-top-color: #2496ed; }
.stat-card:nth-child(3) { border-top-color: #6889aa; }
.stat-icon { display: grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; color: var(--blue); background: var(--blue-pale); }
.stat-icon.running-icon { color: #0876c9; background: #e6f4ff; }
.stat-icon.stopped-icon { color: #58718a; background: #edf2f7; }
.stat-label { display: block; color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .1em; }
.stat-card strong { display: inline-block; margin: 2px 6px 0 0; color: var(--navy); font-size: 1.45rem; }
.stat-card small { color: var(--muted); }
.section-heading.monitoring-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}
.section-heading.caddy-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}
.monitoring-toolbar label, .caddy-controls label { display: grid; min-width: 0; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 650; }
.monitoring-toolbar > label { width: min(320px, 100%); }
.monitoring-toolbar select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid #aebfd0;
  border-radius: 2px;
  color: var(--ink);
  background: white;
  font: inherit;
}
.caddy-selection { display: grid; min-width: 0; grid-template-columns: minmax(220px, 1fr) minmax(155px, .8fr); align-items: end; gap: 10px; }
.caddy-selection label { display: grid; width: 100%; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 650; }
.caddy-selection select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid #aebfd0;
  border-radius: 2px;
  color: var(--ink);
  background: white;
  font: inherit;
}
.caddy-selection-info { display: grid; align-content: end; gap: 5px; min-width: 0; }
.caddy-selection small { color: var(--muted); font-size: .78rem; }
.monitoring-caddy-link { color: var(--blue); font-size: .82rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.monitoring-caddy-link:hover { text-decoration: underline; }
.monitoring-updated { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; color: var(--muted); font-size: .82rem; white-space: nowrap; }
.monitoring-updated button, .caddy-controls button { min-width: 112px; flex: 0 0 auto; white-space: nowrap; }
.monitor-alerts, .monitor-error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #b8d7ed;
  color: #15527c;
  background: #eff8ff;
  font-size: .88rem;
}
.monitor-table-wrap { overflow-x: auto; margin: 0 0 24px; }
.monitor-table { width: 100%; min-width: 1180px; border-collapse: collapse; font-size: .86rem; }
.monitor-table th, .monitor-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.monitor-table thead th { color: var(--muted); background: #f3f7fa; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.monitor-table tbody th { min-width: 180px; font-weight: 650; }
.monitor-table tbody th strong, .monitor-table tbody th code { display: block; }
.monitor-table tbody th code { margin-top: 4px; color: var(--muted); font-size: .74rem; font-weight: 400; }
.monitor-table td { white-space: nowrap; }
.monitor-row-actions { min-width: 290px; }
.monitor-row-actions .action-button { min-height: 34px; margin-right: 6px; padding: 6px 9px; font-size: .76rem; white-space: nowrap; }
.monitor-row-error { color: var(--danger); white-space: normal !important; }
.monitor-details { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 20px; }
.monitor-chart-toolbar { align-items: end; margin-bottom: 16px; }
.monitor-chart-toolbar h2 { margin: 0; }
.monitor-chart-toolbar label { display: grid; width: min(320px, 100%); gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 650; }
.monitor-chart-toolbar select { min-height: 42px; padding: 8px 11px; border: 1px solid #aebfd0; border-radius: 2px; color: var(--ink); background: white; font: inherit; }
.monitor-alerts.has-alerts, .monitor-error {
  border-color: #e6c6a6;
  color: #774a1d;
  background: #fff8ed;
}
.monitor-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.monitor-chart { min-width: 0; margin: 0; padding: 18px; }
.monitor-chart svg { display: block; width: 100%; height: 190px; overflow: visible; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chart-heading h2 { margin: 0; }
.chart-heading > strong { color: var(--navy); font-size: .95rem; }
.chart-heading > span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .78rem; }
.chart-grid { fill: none; stroke: #e6eef5; stroke-width: 1; }
.chart-line { fill: none; stroke-width: 3; stroke-linecap: square; stroke-linejoin: round; }
.cpu-line { stroke: var(--docker-blue); }
.memory-line { stroke: #37658e; }
.rx-line { stroke: var(--docker-blue); }
.tx-line { stroke: #e29b43; }
.legend-rx, .legend-tx { width: 8px; height: 8px; display: inline-block; background: var(--docker-blue); }
.legend-tx { margin-left: 8px; background: #e29b43; }
.chart-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; }
.network-chart { grid-column: 1 / -1; }
.caddy-toolbar h2 { margin-bottom: 3px; }
.caddy-controls { display: grid; grid-template-columns: minmax(280px, 360px) auto; align-items: end; gap: 10px; }
.caddy-controls label { width: 100%; }
.caddy-controls input { min-height: 42px; margin: 0; }
.request-table-wrap { width: 100%; overflow-x: auto; }
.request-table { width: 100%; min-width: 920px; border-collapse: collapse; text-align: left; }
.request-table th {
  padding: 11px 9px;
  border-bottom: 2px solid var(--docker-blue);
  color: var(--navy);
  background: #f1f8fe;
  font-size: .76rem;
  letter-spacing: .03em;
}
.request-table .request-group-row th {
  padding: 10px 9px;
  border-top: 1px solid #b8d7ed;
  border-bottom: 1px solid #b8d7ed;
  color: var(--navy);
  background: #eaf5ff;
  font-size: .82rem;
  text-align: left;
}
.request-table td { max-width: 420px; padding: 10px 9px; border-bottom: 1px solid var(--line); font-size: .82rem; }
.request-table td:nth-child(1), .request-table td:nth-child(2), .request-table td:nth-child(3), .request-table td:nth-child(6), .request-table td:nth-child(7) { white-space: nowrap; }
.request-table td:nth-child(5) { overflow: hidden; font-family: "Cascadia Code", Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.request-status { font-weight: 750; }
.request-status.success { color: #26714e; }
.request-status.client-error { color: #a76b18; }
.request-status.server-error { color: var(--danger); }
.caddy-empty { padding: 28px 16px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; }
.filter { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; cursor: pointer; }
.filter input { width: 17px; min-height: 17px; margin: 0; accent-color: var(--blue); }
.container-table { overflow-x: auto; }
.container-table-head {
  display: grid;
  min-width: 1500px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 2px solid var(--docker-blue);
  color: var(--navy);
  background: #f1f8fe;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .03em;
}
.container-table-head [role="columnheader"] { min-width: 0; }
.container-table-head .sort-button {
  width: 100%;
  min-height: 32px;
  justify-content: space-between;
  border: 0;
  border-radius: 0;
  padding: 4px;
  color: var(--navy);
  background: transparent;
  font-size: .78rem;
  text-align: left;
}
.container-table-head .sort-button:hover { border: 0; color: var(--blue); background: #e4f2fd; }
.container-table-head .sort-button span { margin-left: 8px; color: var(--blue); font-size: .95rem; }
.sort-heading { display: block; padding: 4px; }
.container-list { display: flex; min-width: 1500px; flex-direction: column; }
.container-card {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: center;
  gap: 14px;
  padding: 15px 4px;
  border-top: 1px solid var(--line);
}
.container-name { display: flex; min-width: 0; align-items: center; gap: 12px; }
.container-icon { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border: 1px solid var(--line); color: var(--blue); background: #f4f9fd; }
.container-name-text { min-width: 0; }
.container-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.container-name code, .image-name { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.container-url { min-width: 0; overflow: hidden; color: var(--muted); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.container-url a { color: var(--blue); text-decoration: underline; text-decoration-color: #9dc9ed; text-underline-offset: 2px; }
.container-url a:hover { color: #07599e; text-decoration-color: currentColor; }
.state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; white-space: nowrap; }
.state.running { color: var(--blue); }
.state.stopped { color: #58718a; }
.ports { overflow: hidden; color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; justify-content: flex-end; gap: 7px; white-space: nowrap; }
.action-button { min-height: 34px; padding: 6px 10px; font-size: .82rem; }
.action-button.start { border-color: var(--blue); color: var(--blue); background: white; }
.action-button.start:hover { color: white; background: var(--blue); }
.action-button.stop { border-color: #9eb4c9; color: var(--navy); background: white; }
.action-button.stop:hover { color: white; background: var(--navy-light); }
.empty-state { padding: 40px 20px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; }
.empty-state > span { color: var(--docker-blue); font-size: 1.5rem; }
.empty-state h3 { margin: 9px 0 3px; color: var(--navy); }
.empty-state p { margin: 0; }

dialog {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  flex-direction: column;
  margin: 0;
  padding: 22px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: white;
  box-shadow: 0 20px 70px rgb(11 31 58 / 24%);
}
dialog:not([open]) { display: none; }
dialog[open] { display: flex; }
dialog::backdrop { background: rgb(7 24 46 / 55%); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-heading .eyebrow { margin-bottom: 3px; color: var(--blue); }
.logs-actions { display: flex; align-items: center; gap: 8px; }
pre {
  width: 100%;
  min-height: 0;
  flex: 1;
  overflow: auto;
  margin: 17px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #f4f9fd;
  font: .82rem/1.6 "Cascadia Code", Consolas, monospace;
  white-space: pre;
}
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  z-index: 5;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
  background: white;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 8px 30px rgb(11 31 58 / 16%);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { border-color: #cf9da2; color: #78343d; background: #fff3f4; }

@media (max-width: 1100px) {
  .section-heading.monitoring-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitoring-updated { grid-column: 1 / -1; justify-self: end; }
}

@media (max-width: 700px) {
  .topbar { min-height: 72px; padding: 12px 16px; }
  .top-actions { gap: 6px; }
  .top-actions button { min-height: 38px; padding: 7px 9px; font-size: .82rem; }
  .connection { margin-right: 0; font-size: .75rem; }
  .site-nav { gap: 22px; padding: 0 16px; }
  main { padding: 22px 16px 40px; }
  dialog { padding: 14px; }
  .dialog-heading { align-items: flex-start; }
  .logs-actions { flex-wrap: wrap; justify-content: flex-end; }
  pre { margin-top: 12px; padding: 10px; font-size: .76rem; }
  .stats { gap: 8px; }
  .stat-card { min-height: 95px; gap: 9px; padding: 12px 9px; }
  .stat-icon { width: 32px; height: 32px; flex-basis: 32px; }
  .stat-card strong { font-size: 1.2rem; }
  .stat-card small { display: block; font-size: .75rem; }
  .stat-label { font-size: .62rem; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading.monitoring-toolbar, .section-heading.caddy-toolbar { display: flex; align-items: stretch; flex-direction: column; }
  .monitoring-toolbar > label, .caddy-selection, .monitoring-updated, .caddy-controls, .caddy-controls label { width: 100%; }
  .caddy-selection { grid-template-columns: 1fr; }
  .caddy-selection-info { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .monitoring-updated { justify-content: space-between; }
  .caddy-controls { grid-template-columns: minmax(0, 1fr) auto; }
  .caddy-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitor-charts { grid-template-columns: 1fr; }
  .monitor-chart-toolbar { align-items: stretch; }
  .monitor-chart-toolbar label { width: 100%; }
  .network-chart { grid-column: auto; }
}

@media (max-width: 390px) {
  .brand { gap: 8px; }
  .brand-icon { width: 32px; height: 32px; }
  .top-actions { gap: 4px; }
  .connection { font-size: .68rem; }
  .top-actions button { padding: 6px; font-size: .75rem; }
  .stats { grid-template-columns: 1fr; }
  .stat-card { min-height: 76px; padding: 10px 12px; }
  .stat-card small { display: inline; }
  .action-button { font-size: .72rem; }
  .caddy-selection-info { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-spinner { animation-duration: 1.8s; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
