:root {
  --bg: #0f1115;
  --fg: #e6e6e6;
  --muted: #8a8f99;
  --accent: #6ea8ff;
  --card: #181c24;
  --border: #262b35;
  --danger: #ff7a7a;
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.brand { color: var(--fg); text-decoration: none; }

nav { display: flex; gap: 1.25rem; flex: 1; }
nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}
nav a:hover { color: var(--fg); }
nav a.active { color: var(--fg); border-bottom-color: var(--accent); }

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem;
}

a { color: var(--accent); }

.muted { color: var(--muted); }
.error { color: var(--danger); }

button {
  background: var(--accent);
  color: #0a0d12;
  border: 0;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--fg); border: 1px solid var(--border); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--border); }
button.small { padding: 0.2rem 0.5rem; font-size: 0.8rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 1rem;
}

.card-head h2 { margin: 0; }
.card h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kv {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.95rem;
  margin: 0;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

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

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

input[type="text"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="date"],
input:not([type]),
select,
textarea {
  background: #0a0d12;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  font-family: inherit;
}

textarea { resize: vertical; min-height: 4em; }

input:disabled, textarea:disabled, select:disabled { opacity: 0.6; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

form .actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
table.data th {
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
table.data tr:last-child td { border-bottom: 0; }

ul.notes { list-style: none; padding: 0; margin: 0 0 1rem; }
ul.notes li {
  border-top: 1px solid var(--border);
  padding: 0.6rem 0;
}
ul.notes li:first-child { border-top: 0; }
.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.note-body { font-size: 0.95rem; line-height: 1.45; white-space: pre-wrap; }

pre {
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
}

code { font-size: 0.85em; }

.empty {
  padding: 1.5rem 0;
  text-align: center;
}

/* Strategy detail */
.strategy section h2 { color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; margin-bottom: 0.75rem; }
.strat-row { padding: 0.5rem 0; border-top: 1px solid var(--border); }
.strat-row:first-child { border-top: 0; padding-top: 0; }
.strat-row h4 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.strat-row blockquote {
  margin: 0.4rem 0;
  padding: 0.5rem 0.9rem;
  border-left: 3px solid var(--accent);
  background: #0a0d12;
  font-style: italic;
}
.strategy ul { margin: 0; padding-left: 1.25rem; }
.strategy ul li { margin: 0.3rem 0; }

.hint {
  margin: -0.25rem 0 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(110, 168, 255, 0.07);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}
.badge-pending { background: rgba(110, 168, 255, 0.15); color: var(--accent); }
.badge-failed  { background: rgba(255, 122, 122, 0.15); color: var(--danger); }

.row-archived td:first-child a { color: var(--muted); }

.small-link {
  font-size: 0.85rem;
  text-decoration: none;
}
.small-link:hover { text-decoration: underline; }

.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

dialog.pw-dialog {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  max-width: 28rem;
  width: 90%;
}
dialog.pw-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog.pw-dialog h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
dialog.pw-dialog label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--fg);
}

/* Execution playbooks */
details.playbook {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: #0a0d12;
}
details.playbook[open] { background: var(--card); }
details.playbook summary {
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  list-style: none;
  user-select: none;
}
details.playbook summary::-webkit-details-marker { display: none; }
details.playbook summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.8rem;
  transition: transform 0.15s ease;
  display: inline-block;
}
details.playbook[open] summary::before { transform: rotate(90deg); }
details.playbook .pb-approach { font-weight: 600; flex: 1 1 60%; }
details.playbook .pb-platform {
  color: var(--accent);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
details.playbook .pb-time {
  color: var(--muted);
  font-size: 0.8rem;
}
ol.pb-steps {
  margin: 0;
  padding: 0.5rem 1rem 1rem 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
ol.pb-steps li > div {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media print {
  details.playbook { border-color: #ccc; background: white !important; break-inside: avoid; }
  details.playbook[open] { background: white; }
  details.playbook summary { display: list-item; padding: 0.4rem 0; }
  details.playbook summary::before { content: ""; }
  /* Ensure all details are open in print */
  details.playbook { display: block; }
  details.playbook > * { display: block !important; }


  body { background: white; color: black; }
  header, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { background: white; border: 1px solid #ccc; break-inside: avoid; }
  .card h2 { color: black; }
  .strategy section h2 { color: black; }
  .strat-row blockquote { background: #f5f5f5; }
}
