/* Internal ops console. Readability over personality: the thing that matters is
   that nobody misreads which tier they are writing to. */

:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --border: #e3e2df;
  --text: #1d1c1a;
  --muted: #6b6963;
  --accent: #2f5d50;
  --danger: #9a3b2f;
  --chip: #eceae5;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181a;
    --surface: #1f2123;
    --border: #33363a;
    --text: #e8e7e4;
    --muted: #9a9893;
    --accent: #7fb3a2;
    --danger: #e08b7d;
    --chip: #2a2d30;
  }
}

* { box-sizing: border-box; }

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

code, textarea { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 12px 0 4px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

input:read-only { color: var(--muted); }
textarea { resize: vertical; line-height: 1.45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--surface);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.danger { background: var(--danger); border-color: var(--danger); }

button.link {
  padding: 2px 4px;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
}

button.link.danger { background: none; color: var(--danger); }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--chip);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- sign in --- */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 16px; }

.card {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.card button[type="submit"] { width: 100%; margin-top: 20px; }
.card .error { margin: 12px 0 0; }

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

.header-right { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.scope {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 16px;
}

.scope > div { flex: 1 1 180px; }
.scope label { margin-top: 0; }

#app-error, #app-status { padding: 0 16px; margin: 0 0 8px; }

/* --- table --- */
table {
  width: calc(100% - 32px);
  margin: 0 16px 32px;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

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

tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }

/* --- dialogs --- */
dialog {
  width: min(560px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop { background: rgb(0 0 0 / 0.4); }
dialog .row { display: flex; flex-wrap: wrap; gap: 12px; }
dialog .row > div { flex: 1 1 180px; }

menu {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 20px 0 0;
  padding: 0;
}

@media (max-width: 640px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  td { border: 0; padding: 2px 12px; }
  td.actions { text-align: left; }
}
