:root {
  --bg: #f3efe6;
  --ink: #1a1f16;
  --muted: #5c6554;
  --card: #fffdf8;
  --line: #d5d0c4;
  --ok: #2f6b3a;
  --warn: #9a6b12;
  --bad: #8a2f2f;
  --accent: #2c4a3e;
  --accent-ink: #f7f4ec;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #e4ddd0 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #d7e0d4 0%, transparent 50%),
    var(--bg);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.5rem 1.75rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.top h1 {
  margin: 0;
  font-family: var(--font);
  font-weight: 600;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}

.user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.user-email {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-signout {
  font: inherit;
  font-size: 0.85rem;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.25rem 0.55rem;
  border-radius: 2px;
  cursor: pointer;
}

.user-signout:hover {
  border-color: var(--accent);
}

.login-google {
  margin-top: 0.25rem;
}

main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.banner {
  background: #f8e8e6;
  color: var(--bad);
  border: 1px solid #e2c4c0;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.hidden { display: none; }

.login {
  max-width: 22rem;
  margin: 0 0 1.5rem;
  padding: 1.15rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
}

.login h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font);
  font-size: 1.15rem;
}

.login-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.login form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login input {
  font: inherit;
  color: var(--ink);
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
}

.apps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
  gap: 1rem;
}

.app {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  min-height: 11rem;
}

.app h2 {
  margin: 0 0 0.15rem;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
}

.stack {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
  word-break: break-all;
}

.status {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  padding: 0.55rem 0.65rem;
  border-radius: 3px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  flex: 1;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-label {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.status-stats {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.status-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  font-weight: 400;
}

/* Color-coded status blocks */
.status--ready,
.status--running {
  background: #e8f3ea;
  border-color: #b7d4bc;
  color: var(--ok);
}

.status--warming,
.status--starting,
.status--stopping {
  background: #f8f1e0;
  border-color: #e2cfa0;
  color: var(--warn);
}

.status--stopped {
  background: #f0eee9;
  border-color: var(--line);
  color: var(--muted);
}

.status--unknown {
  background: #f8e8e6;
  border-color: #e2c4c0;
  color: var(--bad);
}

.status--ready .status-hint,
.status--running .status-hint {
  color: #3d6b45;
}

.status--warming .status-hint,
.status--starting .status-hint,
.status--stopping .status-hint {
  color: #7a5a14;
}

.dot {
  flex-shrink: 0;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--muted);
}

.dot.ready, .dot.running { background: var(--ok); }
.dot.warming, .dot.starting, .dot.stopping { background: var(--warn); }
.dot.stopped { background: #8a8a8a; }
.dot.unknown { background: var(--bad); }

.spinner {
  flex-shrink: 0;
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(154, 107, 18, 0.25);
  border-top-color: var(--warn);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.45rem 0.85rem;
  border-radius: 2px;
  text-decoration: none;
  display: inline-block;
}

button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button.danger {
  background: #f7ecec;
  border-color: #d9b5b5;
  color: var(--bad);
}

button:disabled, .btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.25rem;
  max-width: 22rem;
}

dialog::backdrop {
  background: rgba(26, 31, 22, 0.35);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0;
  margin: 1rem 0 0;
}
