/* Pulse — company access (admin). Same light look as the dashboard, on its own sheet:
   this page shares no markup with it. */

:root {
  --bg: #ffffff;
  --panel: #fafaf8;
  --fill: #f3f3f0;
  --fill-strong: #e9e9e6;
  --fg: #202124;
  --secondary: #4a4b4e;
  --tertiary: #76777b;
  --line: rgba(20, 21, 23, .10);
  --line-strong: rgba(20, 21, 23, .18);
  --accent: #ff8a1f;
  --red: #d93025;
  --red-soft: rgba(217, 48, 37, .08);
  --green: #1a7f37;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

/* ---------- top bar ---------- */

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.bar-home {
  color: var(--secondary);
  text-decoration: none;
  white-space: nowrap;
}

.bar-home:hover { color: var(--fg); }

.bar-title {
  font: 500 11px var(--mono);
  letter-spacing: .08em;
  color: var(--tertiary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.bar-title i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.bar-account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--secondary);
  min-width: 0;
}

#account-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 42vw;
}

/* ---------- buttons, fields ---------- */

button {
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--fill);
  color: var(--fg);
  font-weight: 500;
}

button { white-space: nowrap; }
button:hover { background: var(--fill-strong); }
button:disabled { opacity: .55; cursor: default; }

button.primary {
  background: var(--fg);
  border-color: var(--fg);
  color: #fff;
}

button.primary:hover { background: #000; }

button.danger {
  background: #fff;
  border-color: rgba(217, 48, 37, .35);
  color: var(--red);
}

button.danger:hover { background: var(--red-soft); }

button.quiet {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 400;
}

button.wide { width: 100%; }

input, select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

textarea { resize: vertical; min-height: 60px; }

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

label.field > span {
  font: 500 10.5px var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--tertiary);
}

.label {
  font: 500 10.5px var(--mono);
  letter-spacing: .08em;
  color: var(--tertiary);
}

.error { color: var(--red); min-height: 1.5em; margin: 8px 0 0; }

/* ---------- gate (sign in / messages) ---------- */

main { flex: 1 1 auto; min-height: 0; display: flex; }

.gate {
  width: min(420px, 100%);
  margin: 12vh auto 0;
  padding: 0 20px;
}

.gate h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 6px; }
.gate p { color: var(--secondary); margin: 0 0 18px; }
.gate form { display: flex; flex-direction: column; gap: 10px; }
.gate input { padding: 11px 12px; background: var(--fill); }
.gate button { padding: 11px 12px; }

/* ---------- layout ---------- */

.access {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.companies {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.companies-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px 10px;
}

.count { font: 500 11px var(--mono); color: var(--tertiary); }

.company-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.company-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-weight: 400;
}

.company-row:hover { background: var(--fill); }
.company-row.selected { background: var(--fill-strong); }

.company-row strong {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-row small {
  grid-column: 1 / -1;
  color: var(--tertiary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty { color: var(--tertiary); padding: 0 6px; }

.detail {
  min-height: 0;
  overflow-y: auto;
  padding: 22px 28px 60px;
}

.detail-inner { max-width: 880px; }

.detail h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -.02em;
}

.detail .sub { color: var(--tertiary); margin: 0 0 20px; }

.detail h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 30px 0 10px;
  font: 500 10.5px var(--mono);
  letter-spacing: .08em;
  color: var(--tertiary);
}

.detail h2 em { font-style: normal; color: var(--secondary); letter-spacing: 0; }

/* ---------- status pill ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font: 500 10.5px var(--mono);
  letter-spacing: .04em;
  color: var(--secondary);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tertiary);
}

.pill.active::before { background: var(--green); }
.pill.revoked, .pill.expired { color: var(--red); border-color: rgba(217, 48, 37, .3); }
.pill.revoked::before, .pill.expired::before { background: var(--red); }

/* ---------- forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.form-grid .span { grid-column: 1 / -1; }

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.actions .spacer { flex: 1 1 auto; }
.actions .note { color: var(--tertiary); }
.actions .note.error { min-height: 0; margin: 0; }

.hint { color: var(--tertiary); font-size: 12px; margin: 4px 0 0; }

.grant-form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

/* ---------- the key, shown once ---------- */

.new-key {
  margin: 12px 0 0;
  padding: 14px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(255, 138, 31, .06);
}

.new-key p { margin: 0 0 8px; }

.new-key code {
  display: block;
  padding: 9px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line-strong);
  font: 12.5px var(--mono);
  overflow-wrap: anywhere;
  user-select: all;
}

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }

table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

tr:last-child td { border-bottom: 0; }

th {
  font: 500 10.5px var(--mono);
  letter-spacing: .06em;
  color: var(--tertiary);
  background: var(--panel);
}

td.mono { font: 12px var(--mono); }
td.right, th.right { text-align: right; }
td.muted { color: var(--tertiary); }
tr.off td:not(:last-child) { color: var(--tertiary); }

.table-empty { padding: 14px 12px; color: var(--tertiary); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--fg);
  color: #fff;
  max-width: calc(100vw - 32px);
}

.toast.is-error { background: var(--red); }

/* ---------- narrow screens ---------- */

@media (max-width: 760px) {
  .bar { gap: 10px; padding: 0 12px; }
  .bar-title { display: none; }
  .access { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .companies { border-right: 0; border-bottom: 1px solid var(--line); max-height: 38vh; }
  .detail { padding: 18px 16px 60px; }
  .form-grid, .grant-form { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span { grid-column: auto; }
}
