* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  -webkit-font-smoothing: antialiased;
}

:root {
  --primary-color: #1a73e8;
  --primary-hover: #1557b0;
  --danger-color: #d93025;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --border-color: #dadce0;
  --background-light: #f8f9fa;
  --surface-hover: #f1f3f4;
  --danger-hover: #b7271d;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--background-light);
  color: var(--text-primary);
  font-weight: 400;
}

/* Navigation Bar Styles */
.navbar {
  background-color: white;
  box-shadow: 0 1px 2px 0 rgb(60 64 67 / 30%), 0 2px 6px 2px rgb(60 64 67 / 15%);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;

  /* Match .container so the logo lines up with the page content below it. */
  max-width: 1500px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
}

.nav-logo a {
  color: var(--primary-color);
  font-size: 1.25rem;
  font-weight: 500;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--primary-color);
}

.container {
  width: 100%;
  max-width: 1500px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.login-card {
  background: white;
  padding: 3rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 450px;
  text-align: center;
}

.profile-card {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  width: 100%;
  margin-bottom: 2rem;
}

h1 {
  color: var(--text-primary);
  font-size: 24px;
  margin-bottom: 2rem;
  font-weight: 500;
}

h2 {
  color: var(--text-primary);
  font-size: 20px;
  margin: 1.5rem 0;
  font-weight: 500;
}

.input-group {
  text-align: left;
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-weight: 500;
}

input {
  width: 100%;

  /* Keep text fields readable instead of stretching the full page width. */
  max-width: 40rem;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 400;
  outline: none;
  transition: border 0.2s;
}

/* Checkboxes/radios are not text fields: don't stretch them to 100% (which
   made the "Enabled" box render full-width with a centered tick). */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  max-width: none;

  /* Pin the tick colour to the brand instead of the viewer's OS accent. */
  accent-color: var(--primary-color);
}

input:focus {
  border: 2px solid var(--primary-color);
}

/* Selects share the text-input look instead of the tiny native default. */
select {
  width: 100%;
  max-width: 40rem;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  background: white;
  color: var(--text-primary);
  cursor: pointer;
}

select:focus {
  border: 2px solid var(--primary-color);
  outline: none;
}

/* stylelint-disable no-descending-specificity */

/* Button system. One primary accent (brand blue) with quiet secondary and
   destructive variants, so action hierarchy is legible at a glance. Bare
   <button> and .btn (for links styled as buttons) share the same box. */
button,
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primary-color);
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:hover,
.btn:hover,
a.btn:hover {
  background: var(--primary-hover);
  color: white;
}

button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Secondary: neutral actions (toggle, regenerate, edit, cancel). */
.btn-secondary {
  background: white;
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* Danger: destructive actions (delete). Restrained until hovered. */
.btn-danger {
  background: white;
  border-color: var(--danger-color);
  color: var(--danger-color);
}

.btn-danger:hover {
  background: var(--danger-color);
  color: white;
}

.btn-block {
  width: 100%;
}

/* stylelint-enable no-descending-specificity */

.links {
  margin-top: 1.5rem;
  font-size: 0.875rem;
}

.links a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.forgot-password-link a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.95em;
  transition: color 0.2s;
}

.links a:hover {
  text-decoration: underline;
}

.forgot-password-link a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.error-message {
  background-color: #fce8e6;
  color: var(--danger-color);
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--danger-color);
  border-radius: 4px;
  font-size: 0.875rem;
  text-align: center;
}

.info-message {
  background-color: #e8f0fe;
  color: var(--primary-color);
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--primary-color);
  border-radius: 4px;
  font-size: 0.875rem;
}

.profile-info {
  text-align: left;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.profile-info p {
  margin: 0.75rem 0;
  color: var(--text-secondary);
}

.profile-info strong {
  color: var(--text-primary);
  display: inline-block;
  width: 150px;
}

.events-list {
  margin-top: 1rem;
}

.event-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.event-item:last-child {
  border-bottom: none;
}

.event-time {
  color: var(--text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
}

.event-content {
  flex: 1;
}

.event-action {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.event-details {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.change-password {
  text-align: left;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.logout-btn {
  margin-top: 1.5rem;
  background: var(--danger-color);
}

.logout-btn:hover {
  background: #c5221f;
}

/* Table styles moved from users.css */
.table-container {
  overflow-x: auto;
  margin-top: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background-color: white;
  box-shadow: 0 1px 2px 0 rgb(60 64 67 / 30%);
  border-radius: 4px;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background-color: var(--background-light);
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background-color: rgb(0 0 0 / 2%);
}

.text-muted {
  color: var(--text-secondary);
  font-style: italic;
}

.margin-top-1 {
  margin-top: 1rem;
}

.margin-top-2 {
  margin-top: 2rem;
}

.admin-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.password-input {
  width: 320px;
  max-width: 100%;
}

.forgot-password-link {
  text-align: right;
  margin-bottom: 1em;
}

/* Admin UI */
.admin-nav {
  display: flex;
  gap: 1.5rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* stylelint-disable-next-line no-descending-specificity */
.admin-nav a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.admin-nav .admin-nav-right {
  margin-left: auto;
  color: var(--text-secondary);
}

.flash {
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  font-size: 0.875rem;
}

.flash-info {
  background-color: #e8f0fe;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.flash-error {
  background-color: #fce8e6;
  color: var(--danger-color);
  border: 1px solid var(--danger-color);
}

/* A bordered panel, e.g. one application on the Applications page. Capped to a
   readable column so cards don't stretch the full width on large monitors. */
.card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  max-width: 48rem;
  box-shadow: 0 1px 2px rgb(60 64 67 / 8%);
}

.card h2 {
  margin-top: 0;
}

/* --- Application card internals --- */

/* Title row: name + status/kind pills on one baseline. */
.app-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.app-head h2 {
  margin: 0 0.25rem 0 0;
  font-size: 1.15rem;
}

/* Small caption above a control group (e.g. "Route to destinations"). */
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.app-meta {
  margin-bottom: 1.25rem;
}

.app-meta p {
  margin-bottom: 0.5rem;
}

/* Ingest URL rendered as a copyable code line, not loose text. */
.ingest-url {
  display: block;
  padding: 0.5rem 0.7rem;
  background: var(--background-light);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow-x: auto;
  white-space: nowrap;
}

/* Routing checkboxes as a wrapping inline list instead of a big empty box. */
.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1rem;
}

.checkbox-grid label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-weight: 400;
  color: var(--text-primary);
}

.card form {
  margin-bottom: 1.25rem;
}

/* Lifecycle actions sit below a divider, visually separate from the primary
   Save action above them. */
.app-actions {
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
  margin-bottom: 0;
}

/* A horizontal row of action buttons/forms (each button may be its own
   <form>, so they are laid out as flex items rather than stacking). */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
}

/* Inside a table cell the actions align to the right and drop the top margin
   so they sit level with the other cells. */
.grid .row-actions {
  margin-top: 0;
  justify-content: flex-end;
}

/* Data-entry forms: keep the whole form (fields + fieldsets) to a readable
   column instead of spanning the wide table container. */
.admin-form {
  max-width: 40rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.filters input,
.filters select {
  width: auto;
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background-color: white;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 1px 2px 0 rgb(60 64 67 / 30%);
}

/* stylelint-disable no-descending-specificity */
.grid th,
.grid td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}
/* stylelint-enable no-descending-specificity */

.grid th {
  background-color: var(--background-light);
  color: var(--text-secondary);
  font-weight: 500;
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  margin: 0.1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background-color: var(--background-light);
  border: 1px solid var(--border-color);
}

.pill-success {
  background-color: #e6f4ea;
  border-color: #34a853;
  color: #137333;
}

.pill-failed,
.pill-exhausted,
.pill-revocation {
  background-color: #fce8e6;
  border-color: var(--danger-color);
  color: var(--danger-color);
}

.pill-verification {
  background-color: #e6f4ea;
  border-color: #34a853;
  color: #137333;
}

/* Sub-navigation between sibling list views under one tab (Events/Handshakes). */
.views {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* stylelint-disable-next-line no-descending-specificity */
.views a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.views a.active {
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
}

.muted {
  color: var(--text-secondary);
  font-style: italic;
}

.body {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-family: monospace;
  font-size: 0.8rem;
}

.meta dt {
  font-weight: 500;
  color: var(--text-secondary);
}

.meta dd {
  margin: 0 0 0.5rem;
}

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.login-box {
  background: white;
  padding: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-width: 400px;
  margin: 2rem auto;
}

textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

fieldset {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.75rem 1rem 1rem;
  margin-bottom: 1rem;
}

/* Give the legend padding so it sits cleanly in the border notch (the global
   reset had stripped it, leaving the text jammed against the border). */
legend {
  padding: 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* stylelint-disable-next-line no-descending-specificity */
fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-right: 1rem;
  margin-bottom: 0.35rem;
}

/* Add-form field rhythm. Placed after the base element rules above so the
   more-specific .admin-form selectors don't precede their lower-specificity
   counterparts (no-descending-specificity). Each label sits just above its
   control and every control has the same gap to the next field; checkboxes
   /radios are excluded so the inline .form-check row is untouched. */
.admin-form label {
  margin-bottom: 0.4rem;
}

.admin-form input:not([type="checkbox"], [type="radio"]),
.admin-form select,
.admin-form textarea,
.admin-form fieldset {
  margin-bottom: 1.25rem;
}

.admin-form .form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 1.25rem;
}

.admin-form .form-check label {
  margin: 0;
}

/* Numeric fields (timeout, retries, window) don't need the full text width. */
.admin-form input[type="number"] {
  max-width: 12rem;
}
