:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --line: #ded8ca;
  --text: #201d19;
  --muted: #746c5f;
  --gold: #c49a36;
  --gold-dark: #8d681f;
  --green: #1d8f5a;
  --red: #b83232;
  --blue: #2e6d9f;
  --shadow: 0 18px 45px rgba(38, 31, 20, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

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

a {
  color: inherit;
  text-decoration: none;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark,
.brand span {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--gold);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.login-box h1,
.topbar h1,
.section-heading h2,
.modal h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-box label,
.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196, 154, 54, 0.18);
}

.button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.button {
  padding: 0 14px;
  font-weight: 800;
}

.button.primary {
  background: var(--gold);
  color: #fff;
}

.button.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.button.danger {
  background: #fff4f3;
  color: var(--red);
  border: 1px solid #efc2bd;
}

.icon-button {
  width: 42px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button:disabled,
.icon-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button svg,
.icon-button svg,
.sidebar svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.status-text {
  min-height: 20px;
  margin: 0;
  color: var(--red);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  font-size: 1rem;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.sidebar nav a.active {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar #logoutButton {
  margin-top: auto;
}

.workspace {
  min-width: 0;
  padding: 24px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.topbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold-dark);
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  font-size: 1.45rem;
}

.panel-section {
  display: grid;
  gap: 14px;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.site-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.site-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.site-title {
  min-width: 0;
}

.site-title h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.site-title a {
  color: var(--muted);
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  background: #f2eee6;
  color: var(--muted);
}

.badge.online {
  background: #eaf8f0;
  color: var(--green);
}

.badge.offline {
  background: #fff4f3;
  color: var(--red);
}

.site-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fact {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  min-width: 0;
}

.fact span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.fact strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.site-actions .button {
  min-height: 38px;
  font-size: 0.88rem;
}

.modal {
  width: min(760px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(27, 24, 19, 0.42);
}

.modal header,
.modal footer {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.form-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.logs-modal {
  width: min(920px, calc(100% - 28px));
}

.logs-modal pre {
  margin: 0;
  padding: 16px;
  min-height: 360px;
  max-height: 70vh;
  overflow: auto;
  background: #15130f;
  color: #f6eddc;
  font-size: 0.82rem;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #191713;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
  }

  .sidebar #logoutButton {
    margin-top: 0;
    margin-left: auto;
  }

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

@media (max-width: 620px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-heading,
  .site-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .button {
    flex: 1;
  }

  .metric-grid,
  .site-facts,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 14px;
  }
}
