:root {
  --navy: #0b1f3a;
  --navy-light: #16305a;
  --gold: #b08d57;
  --gold-dark: #8a6d3f;
  --ink: #1a2233;
  --muted: #64748b;
  --border: #e2e6ee;
  --bg: #f4f6fa;
  --card: #ffffff;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
}

* { box-sizing: border-box; }
body {
  font-family: "Segoe UI", -apple-system, Roboto, Arial, sans-serif;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- Header ---------- */
.topbar {
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  padding: 0 28px;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  text-decoration: none;
  padding: 14px 0;
}
.brand-logo {
  height: 34px;
  width: auto;
  display: block;
  /* Logo art is navy-on-transparent -- a small white backing card keeps it
     legible against the navy header. */
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  box-sizing: content-box;
}
.brand-logo-placeholder {
  height: 42px;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 0.9rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 1.05rem; font-weight: 600; }
.brand-text small { color: #b9c3d9; font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase; }

/* ---------- Shell layout: sidebar + main ---------- */
.shell {
  display: flex;
  align-items: flex-start;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
  gap: 28px;
}

.sidebar {
  flex: 0 0 260px;
  position: sticky;
  top: 28px;
}
.sidebar-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.sidebar-label-spaced { margin-top: 28px; }

.action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: 8px;
  padding: 16px 16px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.action-card:hover {
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.12);
  transform: translateY(-1px);
}
.action-card-refresh { border-left-color: var(--gold-dark); }
.action-icon {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 1rem;
}
.action-card-refresh .action-icon { background: var(--gold-dark); }
.action-text { display: flex; flex-direction: column; line-height: 1.3; }
.action-text strong { font-size: 0.98rem; }
.action-text small { color: var(--muted); font-size: 0.78rem; }

.sidebar-link {
  display: block;
  padding: 8px 4px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
  border-radius: 6px;
}
.sidebar-link:hover { background: #eef1f7; }
.sidebar-link.active { color: var(--navy); font-weight: 600; }

main { flex: 1 1 auto; min-width: 0; }

/* ---------- Content ---------- */
h1 { font-size: 1.4rem; margin-top: 0; }
h2 { font-size: 1.05rem; margin-top: 28px; color: var(--navy); }
.muted { color: var(--muted); }
.mono { font-family: Consolas, Menlo, monospace; font-size: 0.88rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

table { width: 100%; border-collapse: collapse; margin-top: 4px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafbfd; }

form label { display: block; margin-bottom: 16px; font-size: 0.92rem; font-weight: 500; }
form label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
form input[type="text"], form input[type="password"], form input[type="file"] {
  width: 100%; max-width: 480px; padding: 9px 10px; margin-top: 6px; display: block;
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.92rem;
  font-family: inherit;
}
form input[type="text"]:focus, form input[type="password"]:focus, form input[type="file"]:focus {
  outline: 2px solid var(--navy); outline-offset: 1px;
}

button, .button {
  background: var(--navy); color: #fff; border: none; padding: 10px 20px;
  border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block;
  font-size: 0.92rem; font-weight: 600; margin-right: 8px;
}
button.secondary { background: var(--danger); }
button:hover, .button:hover { background: var(--navy-light); }
button.secondary:hover { background: #991b1b; }

.flash { background: var(--danger-bg); border: 1px solid #fca5a5; color: var(--danger); padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.banner { background: #fffbeb; border: 1px solid #fcd34d; padding: 16px; border-radius: 8px; margin: 16px 0; }
.banner form { margin-top: 10px; }

.log-list {
  background: var(--navy); padding: 10px; border-radius: 8px;
  max-height: 420px; overflow-y: auto;
}
.log-entry {
  background: rgba(255, 255, 255, 0.06); color: #d6dcea;
  padding: 7px 12px; border-radius: 6px; margin-bottom: 5px;
  font-size: 0.84rem; font-family: Consolas, Menlo, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.log-entry:last-child { margin-bottom: 0; }
.log-entry-warning { background: rgba(252, 165, 165, 0.16); color: #fecaca; border-left: 3px solid #f87171; padding-left: 9px; }
.log-entry-success { background: rgba(134, 239, 172, 0.14); color: #bbf7d0; border-left: 3px solid #4ade80; padding-left: 9px; }
.log-entry-empty { color: #8b95ab; font-style: italic; }

.status { padding: 3px 12px; border-radius: 12px; font-size: 0.78rem; text-transform: capitalize; font-weight: 600; }
.status-queued { background: #e5e7eb; color: #374151; }
.status-running { background: #dbeafe; color: #1e40af; }
.status-waiting_for_input { background: #fef3c7; color: #92400e; }
.status-done { background: #d1fae5; color: #065f46; }
.status-failed { background: #fee2e2; color: #991b1b; }
.status-stopped { background: #fee2e2; color: #991b1b; }

.empty-state { padding: 40px 0; text-align: center; color: var(--muted); }

.vnc-screen {
  width: 100%;
  height: 560px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.vnc-screen canvas { display: block; }

.page-header-row { display: flex; align-items: center; justify-content: space-between; }
.page-header-row form { margin: 0; }

.link-button {
  background: none; border: none; text-decoration: underline;
  cursor: pointer; font-size: 0.85rem; padding: 0; margin: 0;
  color: var(--navy); font-family: inherit;
}
.link-button:hover { color: var(--navy-light); }
.link-button-danger { color: var(--danger); }
.link-button-danger:hover { color: #991b1b; }

footer { text-align: center; color: #9aa3b2; font-size: 0.78rem; padding: 20px 24px 32px; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; flex: none; }
}

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}
.login-card {
  background: var(--card);
  border-radius: 10px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-brand strong { display: block; font-size: 0.95rem; }
.login-brand small { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.login-card form input[type="text"], .login-card form input[type="password"] {
  max-width: none;
}
.login-card button { width: 100%; margin-right: 0; }

/* ---------- Header: title left, user menu + logo right ---------- */
.topbar-inner { display: flex; align-items: center; justify-content: space-between; }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.user-menu { color: #cfd6e6; font-size: 0.85rem; display: flex; align-items: center; gap: 14px; }
.user-menu form { display: inline; }
.user-menu button.link-button {
  background: none; border: none; color: #cfd6e6; text-decoration: underline;
  cursor: pointer; font-size: 0.85rem; padding: 0; margin: 0;
}
.user-menu button.link-button:hover { color: #fff; }
