:root {
  --bg: #f6f7f9;
  --fg: #1a1d22;
  --muted: #6b7280;
  --border: #d1d5db;
  --accent: #1e40af;
  --green: #047857;
  --red: #b91c1c;
  --yellow: #b45309;
  --card: #ffffff;
}

* { box-sizing: border-box; }

body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  margin: 0;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 { font-size: 18px; margin: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}

.login-wrap {
  max-width: 420px;
  margin: 40px auto 0;
  text-align: left;
}
.login-logo {
  display: block;
  width: 240px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 24px;
}
.login-wrap h2 {
  text-align: center;
  margin-bottom: 20px;
}
.login-wrap form { margin: 0 auto; }

nav { display: flex; gap: 16px; align-items: center; }
nav a {
  color: var(--accent);
  text-decoration: none;
}
nav a:hover { text-decoration: underline; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

h2 { margin-top: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

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

th {
  background: #f3f4f6;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}
th[data-sort]:hover { background: #e5e7eb; }
th[data-sort]::after {
  content: " ⇅";
  opacity: 0.35;
  font-size: 11px;
}
th[data-sort-active="asc"]::after  { content: " ▲"; opacity: 1; color: var(--accent); }
th[data-sort-active="desc"]::after { content: " ▼"; opacity: 1; color: var(--accent); }

tr:last-child td { border-bottom: none; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.state-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.state-badge.state-running    { background: #d1fae5; color: var(--green); }
.state-badge.state-booting    { background: #fef3c7; color: var(--yellow); }
.state-badge.state-impaired   { background: #fecaca; color: var(--red); }
.state-badge.state-stopped    { background: #fee2e2; color: var(--red); }
.state-badge.state-hibernated { background: #fef3c7; color: var(--yellow); }
.state-badge.state-pending,
.state-badge.state-stopping,
.state-badge.state-shutting-down { background: #e5e7eb; color: var(--muted); }

.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}
.page-actions h2 { margin: 0; }
.actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

button {
  font: inherit;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
}

button.action-start { background: var(--green); color: white; border-color: var(--green); }
button.action-stop  { background: var(--red);   color: white; border-color: var(--red); }
button.action-hibernate { background: var(--accent); color: white; border-color: var(--accent); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.modal-box {
  position: relative;
  background: var(--card);
  border-radius: 8px;
  padding: 22px 24px;
  min-width: 360px;
  max-width: 520px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}
.modal-box h3 { margin: 0 0 8px; font-size: 16px; }
.modal-box p  { margin: 8px 0 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}
.modal-actions button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}
button.link:hover { text-decoration: underline; }

form { margin: 0; }
form.inline { display: inline-flex; align-items: center; gap: 8px; }
form:not(.inline) { display: flex; flex-direction: column; gap: 12px; max-width: 400px; }
form:not(.inline) label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
form input[type=text],
form input[type=password] {
  font: inherit;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
form small { font-weight: normal; color: var(--muted); }

.flash {
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 12px;
}
.flash-info  { background: #dbeafe; color: #1e3a8a; }
.flash-error { background: #fee2e2; color: #991b1b; }

.user { color: var(--muted); font-size: 13px; }

ul { padding-left: 20px; }
li { margin: 2px 0; }
