/* Beck Enterprises Builds — hand-written design system (replaces Bootstrap + jQuery). */

:root {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff5ff;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6ea;
  --topbar: #1b1f24;
  --topbar-text: #e8eaed;
  --text: #1f2429;
  --muted: #6b7280;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

/* Cross-fade between same-origin page navigations (progressive enhancement;
   ignored by browsers without MPA view-transition support). */
@view-transition {
  navigation: auto;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

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

/* ---- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-accent {
  background-color: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background-color: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}

.btn-ghost {
  background-color: transparent;
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--topbar-text);
}

.btn-ghost:hover {
  background-color: rgba(255, 255, 255, 0.12);
  color: #fff;
  text-decoration: none;
}

/* ---- Top bar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background-color: var(--topbar);
  color: var(--topbar-text);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
}

.topbar__logo {
  width: 28px;
  height: 28px;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: rgba(232, 234, 237, 0.75);
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-right: 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.25);
}

.topbar__link {
  color: rgba(232, 234, 237, 0.75);
}

.topbar__link:hover {
  color: #fff;
  text-decoration: none;
}

a.topbar__brand:hover {
  color: #fff;
  text-decoration: none;
}

/* On narrow screens, stack the bar: brand on the first row, user + logout on the
   second row spanning the full width, so nothing wraps mid-word or squeezes. */
@media (max-width: 560px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 0.65rem;
    padding: 0.65rem 1rem;
  }

  .topbar__brand {
    flex-basis: 100%;
    font-size: 1.05rem;
  }

  .topbar__user {
    flex-basis: 100%;
    justify-content: space-between;
  }
}

/* ---- App layout ----------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* ---- Sidebar -------------------------------------------------------------- */

.sidebar {
  align-self: start;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
}

.nav-list__header {
  padding: 0.5rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-list a {
  display: block;
  padding: 0.5rem 1rem;
  border-left: 3px solid transparent;
  color: var(--text);
}

.nav-list a:hover {
  background-color: var(--accent-soft);
  text-decoration: none;
}

.nav-list a.active {
  background-color: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ---- Build list ----------------------------------------------------------- */

.content {
  min-height: 2rem;
}

.build-list {
  margin: 0;
}

.build-list-items {
  list-style: none;
  margin: 0;
  padding: 0;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.build-list-items li + li {
  border-top: 1px solid var(--border);
}

.build-list-items a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text);
}

.build-list-items a:hover {
  background-color: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

/* ---- Login ---------------------------------------------------------------- */

.login {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 1rem;
}

.login__logo {
  width: 240px;
  max-width: 70%;
  margin-bottom: 2rem;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 1.75rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card__heading {
  margin: 0 0 1.25rem;
  font-size: 1.4rem;
  font-weight: 600;
}

.login-card input {
  display: block;
  width: 100%;
  margin-bottom: 0.9rem;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card .btn-accent {
  width: 100%;
  margin-top: 0.25rem;
}

.form-error {
  margin: 1rem 0 0;
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
  color: #b42318;
  background-color: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: var(--radius);
}

.form-success {
  margin: 1rem 0 0;
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
  color: #067647;
  background-color: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: var(--radius);
}

/* ---- Pages & forms (account + admin) -------------------------------------- */

.page {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

.page--narrow {
  max-width: 420px;
}

.card {
  margin-bottom: 1.5rem;
  padding: 1.75rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card__heading {
  margin: 0 0 1.25rem;
  font-size: 1.4rem;
  font-weight: 600;
}

.field {
  margin-bottom: 0.9rem;
}

.field label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.card input:not([type="checkbox"]),
.card select {
  display: block;
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card input:focus,
.card select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- Tables (admin lists) -------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
}

/* Scroll container for tables that grow unbounded (user/token lists, the
   permissions picker). The sticky header keeps columns readable mid-scroll. */
.table-scroll {
  overflow-y: auto;
  max-height: 60vh;
  border-bottom: 1px solid var(--border);
}

.table-scroll--short {
  max-height: 260px;
}

.table-scroll .table thead th {
  position: sticky;
  top: 0;
  /* Paint above the row-action buttons (their position:relative .dropdown
     wrapper would otherwise win by DOM order); the open .dropdown__panel
     (z-index 10) still overlays the header deliberately. */
  z-index: 2;
  background-color: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}

.table th {
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
}

.table td {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.table form {
  display: inline;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.4rem;
}

/* <details>-based dropdown: the panel overlays the rows below instead of
   inline-expanding its own table row. */
.dropdown {
  position: relative;
}

.dropdown > summary {
  list-style: none;
  user-select: none;
}

.dropdown > summary::-webkit-details-marker {
  display: none;
}

.dropdown__panel {
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  z-index: 10;
  width: 260px;
  padding: 0.75rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
}

.dropdown__panel form + form {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

/* Full-width actions, like the login card's submit button. */
.dropdown__panel .btn {
  width: 100%;
  margin-top: 0.25rem;
}

.btn-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-outline {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background-color: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.btn-danger {
  background-color: var(--surface);
  border-color: #fecdca;
  color: #b42318;
}

.btn-danger:hover {
  background-color: #fef3f2;
  border-color: #b42318;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  background-color: #ecfdf3;
  color: #067647;
}

.badge--off {
  background-color: #fef3f2;
  color: #b42318;
}

.badge--muted {
  background-color: var(--bg);
  color: var(--muted);
}

/* One-time token secret: shown exactly once after creation. */
.secret {
  display: block;
  margin-top: 0.5rem;
  padding: 0.6rem 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
  word-break: break-all;
  background-color: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  user-select: all;
}
