:root {
  --bg: #0b0f0c;
  --fg: #c8f7c5;
  --dim: #6f9f6a;
  --accent: #52e05a;
  --accent-ink: #08130a;
  --card: #111811;
  --card-2: #151f15;
  --border: #234023;
  --error: #ff6b6b;
  --pending: #e0c25a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(82, 224, 90, 0.15);
  --radius: 8px;
  --radius-sm: 5px;
  --ease: 150ms cubic-bezier(0.2, 0, 0, 1);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f7f2; --fg: #16241a; --dim: #4a6b4a; --accent: #1f7a29; --accent-ink: #ffffff;
    --card: #ffffff; --card-2: #eef4ec; --border: #d7e4d3; --error: #c0392b; --pending: #a6790a;
    --shadow: 0 1px 2px rgba(20, 40, 20, 0.06), 0 8px 24px -14px rgba(20, 40, 20, 0.18);
  }
}
:root[data-theme="light"] {
  --bg: #f4f7f2; --fg: #16241a; --dim: #4a6b4a; --accent: #1f7a29; --accent-ink: #ffffff;
  --card: #ffffff; --card-2: #eef4ec; --border: #d7e4d3; --error: #c0392b; --pending: #a6790a;
  --shadow: 0 1px 2px rgba(20, 40, 20, 0.06), 0 8px 24px -14px rgba(20, 40, 20, 0.18);
}
:root[data-theme="dark"] {
  --bg: #0b0f0c; --fg: #c8f7c5; --dim: #6f9f6a; --accent: #52e05a; --accent-ink: #08130a;
  --card: #111811; --card-2: #151f15; --border: #234023; --error: #ff6b6b; --pending: #e0c25a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(82, 224, 90, 0.15);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Berkeley Mono", "Courier New", ui-monospace, monospace;
  margin: 0;
  line-height: 1.55;
  transition: background var(--ease), color var(--ease);
}
::selection { background: var(--accent); color: var(--accent-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0; font-weight: bold; text-decoration: none;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

header {
  position: sticky; top: 0; z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.brand { color: var(--accent); font-weight: bold; text-decoration: none; font-size: 1.1rem; letter-spacing: 0.02em; }
nav { display: flex; align-items: center; flex-wrap: wrap; }
nav a { color: var(--dim); text-decoration: none; margin-left: 1rem; padding: 0.25rem 0; border-bottom: 2px solid transparent; transition: color var(--ease), border-color var(--ease); }
nav a:hover { color: var(--accent); }
nav a.active { color: var(--fg); border-color: var(--accent); }
main { max-width: 760px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
h1 { color: var(--accent); font-size: 1.3rem; margin-top: 2.25rem; letter-spacing: 0.01em; }
h1:first-child { margin-top: 0; }
h2 { color: var(--fg); font-size: 1.05rem; border-bottom: 1px dashed var(--border); padding-bottom: 0.4rem; }
.subtitle { color: var(--dim); font-size: 0.9rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin: 0.75rem 0 1.5rem; }
table { width: 100%; border-collapse: collapse; margin: 0.75rem 0 1.5rem; }
.table-wrap table { margin: 0; border: none; }
th, td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--card-2); }
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: var(--card-2); }
tr:last-child td { border-bottom: none; }
.avail { color: var(--accent); font-size: 1.15rem; font-weight: bold; }
.bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin: 0.4rem 0 0.75rem; max-width: 320px; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width 400ms var(--ease); }
.legend .dot { margin-left: 0.9rem; }
.legend .dot:first-child { margin-left: 0; }
[data-stat] { color: var(--accent); font-weight: bold; }
.dot { display: inline-block; vertical-align: middle; width: 0.6em; height: 0.6em; border-radius: 50%; margin-right: 0.4em; box-shadow: 0 0 0 3px transparent; transition: box-shadow var(--ease); }
.dot-available { background: var(--accent); }
.dot-on-call { background: var(--pending); }
.dot-offline { background: #888; }
.dot-other { background: var(--error); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; margin: 1rem 0; box-shadow: var(--shadow);
  transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease);
}
.request-card { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
form.card { display: flex; flex-direction: column; gap: 0.5rem; }
label { color: var(--dim); font-size: 0.8rem; margin-top: 0.6rem; text-transform: uppercase; letter-spacing: 0.03em; }
input[type=text], input[type=email], input[type=password], textarea, select {
  background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  padding: 0.55rem 0.65rem; font-family: inherit; border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); outline: none;
}
.honeypot { position: absolute; left: -9999px; }
button, .copy-btn {
  background: var(--accent); color: var(--accent-ink); border: none; padding: 0.55rem 1.1rem;
  font-family: inherit; font-weight: bold; font-size: 1rem; border-radius: var(--radius-sm); cursor: pointer;
  margin: 0; display: inline-block; vertical-align: middle; line-height: 1.2;
  transition: filter var(--ease), transform var(--ease), box-shadow var(--ease);
}
/* Buttons/links used inline with running text or inside a flex row (.actions,
   .row-form-inline, table cells) must never carry extra margin -- that's what
   pushed them visibly lower than their surrounding text across the whole site. */
button:hover { filter: brightness(1.12); box-shadow: 0 2px 10px -4px color-mix(in srgb, var(--accent) 60%, transparent); }
button:active { transform: translateY(1px); }
.btn-error { background: var(--error); }
.btn-ok { background: var(--accent); }
code { background: var(--accent-ink); padding: 0.15rem 0.45rem; border-radius: var(--radius-sm); color: var(--accent); }
.ext-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 50%; color: #fff;
  font-size: 0.75rem; font-weight: bold; margin-right: 0.35rem; vertical-align: middle;
}
.badge { padding: 0.15rem 0.55rem; border-radius: 99px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-ok { background: var(--accent); color: var(--accent-ink); }
.badge-pending { background: var(--pending); color: var(--accent-ink); }
.badge-error { background: var(--error); color: var(--accent-ink); }

.flashes { list-style: none; padding: 0; margin: 0 0 1rem; position: fixed; top: 4.25rem; right: 1rem; z-index: 50; width: min(340px, calc(100vw - 2rem)); display: flex; flex-direction: column; gap: 0.5rem; }
.flashes li {
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; box-shadow: var(--shadow); font-size: 0.9rem;
  animation: toast-in 220ms var(--ease);
}
.flashes li.flash-error { border-left-color: var(--error); }
.flash-error { color: var(--error); }
.flash-ok { color: var(--fg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }
.flashes li.dismissing { animation: toast-out 200ms var(--ease) forwards; }

.creds { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px dashed var(--border); }
.subnav { color: var(--dim); }
.subnav a { color: var(--fg); text-decoration: none; }
.subnav a:hover { color: var(--accent); }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.actions button { padding: 0.2rem 0.55rem; font-size: 0.78rem; }
.copy-btn { background: transparent; color: var(--dim); border: 1px solid var(--border); padding: 0.2rem 0.55rem; font-size: 0.78rem; margin-left: 0.3rem; box-shadow: none; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); filter: none; box-shadow: none; }
.copy-btn:first-child { margin-left: 0; }

/* One consistent size for the small inline text inputs sprinkled next to
   .copy-btn actions (reason, notes, nickname, reassign-to, etc). */
.field-sm { padding: 0.2rem 0.55rem; font-size: 0.78rem; vertical-align: middle; }

/* Collapsible action forms (reassign, assign-to-user) that would otherwise
   sit permanently expanded in a packed .actions cell -- styled to match
   .copy-btn so the closed state reads as just another small button. */
.actions summary, .row-form-inline summary {
  cursor: pointer; display: inline-flex; align-items: center; list-style: none;
  background: transparent; color: var(--dim); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.2rem 0.55rem; font-size: 0.78rem;
}
.actions summary::-webkit-details-marker, .row-form-inline summary::-webkit-details-marker { display: none; }
.actions summary:hover, .row-form-inline summary:hover { color: var(--accent); border-color: var(--accent); }
.actions details[open] summary { margin-bottom: 0.35rem; }
.actions details { flex-basis: 100%; }
.actions details > form, .actions details > .row-form-inline { margin-top: 0; }
.stats { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.stats .stat { text-align: center; }
.stats .stat .n { display: block; font-size: 1.5rem; font-weight: bold; color: var(--accent); }
.stats .stat .l { color: var(--dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.row-form { display: flex; flex-direction: row; gap: 0.5rem; align-items: end; flex-wrap: wrap; }
.row-form-inline { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }

.tabs { display: flex; gap: 0.3rem; margin: 0.75rem 0 1rem; flex-wrap: wrap; }
.tabs a {
  color: var(--dim); text-decoration: none; padding: 0.3rem 0.75rem; border-radius: 99px;
  border: 1px solid var(--border); font-size: 0.85rem; transition: all var(--ease);
}
.tabs a:hover { color: var(--fg); border-color: var(--dim); }
.tabs a.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.tab-hidden { display: none; }

.conn-banner {
  background: var(--error); color: var(--accent-ink); padding: 0.5rem 0.9rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin-bottom: 0.75rem; display: none;
}
.conn-banner.show { display: block; }
.row-changed { animation: row-pulse 1.4s var(--ease); }
@keyframes row-pulse {
  0% { background: color-mix(in srgb, var(--accent) 35%, transparent); }
  100% { background: transparent; }
}
.activity-feed { list-style: none; padding: 0; margin: 0; font-size: 0.88rem; }
.activity-feed li { padding: 0.4rem 0; border-bottom: 1px dashed var(--border); }
.activity-feed li:last-child { border-bottom: none; }

.chart-bars { display: flex; align-items: flex-end; gap: 0.6rem; margin: 0.5rem 0 0.25rem; }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; }
.chart-bar .n { font-size: 0.72rem; color: var(--dim); margin-bottom: 0.25rem; }
.chart-bar .fill { width: 100%; max-width: 32px; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; transition: height 400ms var(--ease); }
.chart-bar .d { font-size: 0.72rem; color: var(--dim); margin-top: 0.3rem; text-transform: uppercase; }

.svc-cell { white-space: nowrap; }
.svc-cell form { display: inline-block; margin: 0 0 0 0.5rem; }
.svc-cell .copy-btn { margin: 0; }

.term-output {
  background: var(--accent-ink); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.9rem 1rem; font-size: 0.85rem;
  white-space: pre-wrap; overflow-x: auto; max-height: 70vh; overflow-y: auto; margin: 0;
}

/* Mobile */
@media (max-width: 640px) {
  header { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.9rem; }
  nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0; }
  nav a { margin-left: 0; margin-right: 0.85rem; font-size: 0.92rem; }
  main { padding: 1rem 0.75rem 2.5rem; }
  h1 { font-size: 1.15rem; margin-top: 1.5rem; }
  .table-wrap { border-radius: var(--radius-sm); }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  th, td { padding: 0.35rem 0.5rem; font-size: 0.9rem; }
  .card { padding: 0.85rem 1rem; }
  .row-form { flex-direction: column; align-items: stretch; }
  .stats { gap: 1rem; justify-content: space-between; }
  .stats .stat { flex: 1 1 30%; }
  input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%; font-size: 16px; /* prevents iOS auto-zoom on focus */
  }
  button { width: 100%; }
  .actions, .row-form-inline { flex-direction: column; align-items: stretch; }
  .actions button, .row-form-inline button, .copy-btn, #theme-toggle { width: auto; }
  .flashes { left: 0.75rem; right: 0.75rem; top: auto; bottom: 0.75rem; width: auto; }
}

/* Print: keep the extension/connection info, drop chrome and interactive bits */
@media print {
  header, nav, .flashes, .skip-link, form, button, .no-print, .tabs { display: none !important; }
  .tab-hidden { display: block !important; }
  main { padding: 0; }
  .card, .table-wrap { border: 1px solid #999; box-shadow: none; }
  a[href]::after { content: ""; }
  body { background: #fff; color: #000; }
  /* Masked passwords exist for shoulder-surfing safety on screen -- a printed
     page has no one looking over your shoulder, and the whole point of the
     print button is a readable paper/PDF backup, so show the real value. */
  code[data-masked-pw] { font-size: 0; }
  code[data-masked-pw]::after { content: attr(data-masked-pw); font-size: 0.85rem; }
}
