:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17201a;
  --muted: #66736c;
  --line: #dfe4dd;
  --green: #287d4a;
  --blue: #285f8f;
  --red: #b13f36;
  --amber: #9a6816;
  --shadow: 0 12px 32px rgba(24, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.hidden {
  display: none !important;
}

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

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

.login-panel h1,
.topbar h2,
.section-head h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 14px;
  background: #152018;
  color: #f4f7f0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand small {
  display: block;
  color: #b9c6bd;
}

.mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d9ead6;
  color: #152018;
  font-weight: 900;
}

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

.nav-item,
.ghost,
.small,
.primary,
.icon-button {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 700;
}

.nav-item {
  width: 100%;
  color: #dfe8e0;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #24362a;
}

.ghost {
  background: #eef2ed;
  color: var(--ink);
}

.sidebar .ghost {
  margin-top: auto;
  background: #24362a;
  color: #f4f7f0;
}

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

.small {
  min-height: 32px;
  background: #edf3f7;
  color: var(--blue);
}

.danger {
  color: #ffd6d2 !important;
}

.icon-button {
  width: 36px;
  padding: 0;
  background: #eef2ed;
  color: var(--muted);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar {
  margin-bottom: 18px;
}

.view {
  display: grid;
  gap: 18px;
}

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

.metric {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  font-size: 28px;
  font-weight: 900;
}

.metric small {
  color: var(--muted);
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 18px;
}

.table-wrap,
.split > section,
.template-grid,
.template-list,
.notice,
.secret-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.split > section {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.split table {
  min-width: 0;
  table-layout: fixed;
}

.split td {
  overflow-wrap: anywhere;
}

.actions,
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actions input {
  min-width: 260px;
}

.inline-form input {
  width: 180px;
}

.check {
  width: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.check input {
  width: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ed;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.active,
.badge.complete {
  background: #e2f3e7;
  color: var(--green);
}

.badge.deleted,
.badge.revoked {
  background: #f4e7e5;
  color: var(--red);
}

.badge.queued,
.badge.running,
.badge.deleting,
.badge.delete_queued {
  background: #f7eedc;
  color: var(--amber);
}

.template-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 12px;
}

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

.template-card h4 {
  margin: 0;
}

.template-card p {
  margin: 0;
  color: var(--muted);
}

.template-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.notice,
.secret-box {
  padding: 12px 14px;
}

.notice {
  color: var(--blue);
  background: #edf3f7;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.secret-box {
  color: #17201a;
  background: #f7f0df;
  word-break: break-all;
}

dialog {
  width: min(560px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(18, 24, 20, 0.45);
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

  .sidebar {
    min-height: auto;
  }

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

  .metrics,
  .split {
    grid-template-columns: 1fr;
  }

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

  .inline-form input,
  .actions input {
    width: 100%;
    min-width: 0;
  }
}
