/* VERSION: 0.8.0 */
/* Server Interface dashboard stylesheet.
   Version: 0.8.0 */
:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface: #17191c;
  --surface-strong: #1f2328;
  --surface-subtle: #121417;
  --border: #30363d;
  --border-soft: #252a30;
  --text: #e6edf3;
  --muted: #9aa4af;
  --accent: #3b82f6;
  --ok: #35c777;
  --warn: #f4b942;
  --fail: #f87171;
  --info: #60a5fa;
  --unknown: #a8b0b9;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #111315;
  color: var(--text);
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 15px;
  font-weight: 700;
}

.brand-mark {
  width: 42px;
  height: 12px;
  flex: 0 0 42px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) 0 33%, var(--ok) 33% 66%, var(--warn) 66% 100%);
}

nav {
  display: grid;
  gap: 4px;
  margin-top: 22px;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 9px;
  border-radius: 6px;
  font-size: 13px;
}

.nav-link.active,
.nav-link:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.main {
  min-width: 0;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

.topbar p,
.muted,
.admin-status {
  color: var(--muted);
  font-size: 12px;
}

.admin-status {
  min-width: 130px;
  text-align: right;
}

.admin-login-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-login-form[hidden] {
  display: none;
}

.admin-password {
  width: 168px;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 9px;
  background: var(--surface-subtle);
  color: var(--text);
}

.button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
}

.button:hover:not(:disabled) {
  border-color: #4b5563;
  background: #262b31;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.small {
  min-height: 26px;
  padding: 0 6px;
  font-size: 11px;
}

.button.danger {
  border-color: rgba(248, 113, 113, 0.48);
  color: #fecaca;
}

.button.update {
  border-color: rgba(53, 199, 119, 0.52);
  color: #bbf7d0;
}

.button.update:not(:disabled) {
  background: rgba(53, 199, 119, 0.14);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.summary-item,
.panel,
.notice,
.filters-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-item {
  min-height: 78px;
  padding: 13px;
}

.summary-value {
  display: block;
  font-size: 25px;
  font-weight: 750;
  line-height: 1;
}

.summary-label {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.notice {
  margin-bottom: 12px;
  padding: 11px 12px;
  font-size: 12px;
}

.notice.warning {
  border-color: rgba(244, 185, 66, 0.45);
  background: #211a0c;
  color: #f8d68a;
}

.filters-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.filter-toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.auto-update-panel {
  margin-bottom: 12px;
}

.auto-update-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 14px 8px;
}

.auto-update-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.auto-update-interval {
  width: 76px;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  background: var(--surface-subtle);
  color: var(--text);
}

.auto-update-details {
  min-height: 28px;
  padding: 0 14px 12px;
}

.panel {
  margin-top: 12px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  font-size: 13px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.app-name {
  font-weight: 700;
  font-size: 14px;
}

.service-summary-row > td {
  padding: 14px;
}

.service-row-grid {
  display: grid;
  grid-template-columns:
    minmax(230px, 1.35fr)
    minmax(170px, 1fr)
    minmax(170px, 0.95fr)
    minmax(165px, 0.9fr)
    minmax(95px, 0.45fr)
    minmax(230px, 1.1fr);
  gap: 12px 16px;
  align-items: start;
  min-height: 112px;
}

.service-main,
.service-health,
.service-version,
.service-deploy,
.service-links,
.service-actions {
  min-width: 0;
}

.service-description {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.service-meta {
  margin-top: 7px;
  color: #c8d1dc;
  font-size: 12px;
  word-break: break-word;
}

.service-health,
.version-summary,
.deploy-summary {
  display: grid;
  gap: 5px;
}

.field-line {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.field-value {
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  word-break: break-word;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.badge.ok {
  border-color: rgba(53, 199, 119, 0.36);
  background: rgba(53, 199, 119, 0.12);
  color: var(--ok);
}

.badge.degraded,
.badge.warning {
  border-color: rgba(244, 185, 66, 0.42);
  background: rgba(244, 185, 66, 0.13);
  color: var(--warn);
}

.badge.fail,
.badge.error {
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(248, 113, 113, 0.13);
  color: var(--fail);
}

.badge.info {
  border-color: rgba(96, 165, 250, 0.4);
  background: rgba(96, 165, 250, 0.13);
  color: var(--info);
}

.badge.unknown,
.badge.disabled,
.badge.reserved {
  border-color: rgba(168, 176, 185, 0.28);
  background: rgba(168, 176, 185, 0.1);
  color: var(--unknown);
}

.service-summary-row.status-fail td {
  background: rgba(248, 113, 113, 0.03);
}

.service-summary-row.status-degraded td {
  background: rgba(244, 185, 66, 0.035);
}

.service-detail-row td {
  padding: 0 10px 10px;
  background: #121417;
  vertical-align: top;
}

.service-advanced {
  border-top: 1px solid var(--border-soft);
  padding-top: 8px;
}

.service-advanced summary {
  width: fit-content;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.service-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px 16px;
  padding: 10px 0 4px;
}

.detail-group {
  min-width: 0;
}

.detail-group.wide {
  grid-column: span 2;
}

.detail-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-value {
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
  word-break: break-word;
}

.health-summary {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.health-summary {
  color: var(--text);
}

.monospace {
  font-family: Consolas, "Courier New", monospace;
}

.tags,
.detail-buttons,
.url-buttons,
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.service-links .url-buttons,
.service-actions .action-buttons {
  justify-content: flex-start;
}

.tag,
.availability {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 650;
}

.tag {
  background: rgba(96, 165, 250, 0.14);
  color: #bfdbfe;
}

.availability.available {
  background: rgba(53, 199, 119, 0.12);
  color: #bbf7d0;
}

.availability.unavailable {
  background: rgba(168, 176, 185, 0.1);
  color: var(--muted);
}

.command-list {
  display: grid;
  gap: 3px;
}

.action-output-panel {
  overflow: hidden;
  scroll-margin-top: 12px;
}

.action-output-panel.is-update-progress {
  position: sticky;
  top: 10px;
  z-index: 20;
  border-color: rgba(96, 165, 250, 0.52);
  background: #121821;
}

.action-output-panel.is-update-progress .panel-header {
  border-bottom-color: rgba(96, 165, 250, 0.34);
}

.action-output {
  max-height: 360px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  background: #090a0c;
  color: #dbe5ee;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.action-output-panel.is-update-progress .action-output {
  max-height: 260px;
}

.event-list {
  display: grid;
  gap: 0;
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.event-item {
  display: grid;
  grid-template-columns: 145px 90px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}

.event-item:last-child {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  table {
    min-width: 900px;
  }

  .service-row-grid {
    grid-template-columns: minmax(230px, 1.3fr) repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  nav {
    display: flex;
    margin-top: 0;
  }

  .main {
    padding: 14px;
  }

  .action-output-panel.is-update-progress {
    top: 8px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .admin-status {
    min-width: 0;
    text-align: left;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .table-wrap {
    overflow-x: visible;
  }

  table {
    min-width: 0;
  }

  thead,
  thead tr,
  thead th {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  .service-summary-row {
    display: block;
    padding: 0;
    border-top: 1px solid var(--border);
  }

  .service-summary-row:first-child {
    border-top: 0;
  }

  .service-summary-row td {
    padding: 12px;
    border-bottom: 0;
  }

  .service-row-grid {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 12px;
  }

  .field-line {
    grid-template-columns: 94px minmax(0, 1fr);
  }

  .service-detail-row td {
    padding: 0 12px 12px;
    border-bottom: 0;
  }

  .service-details {
    grid-template-columns: 1fr;
  }

  .detail-group.wide {
    grid-column: span 1;
  }
}
