@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
  --bg: #070d18;
  --panel: #101a2c;
  --ink: #e4ecf8;
  --muted: #9caece;
  --line: #24324a;
  --brand: #4ec8ff;
  --brand-ink: #04111c;
  --danger: #fecaca;
  --success: #bbf7d0;
  --success-bg: #082a1b;
  --danger-bg: #3a1016;
  --radius: 14px;
  --shadow: 0 22px 45px rgba(2, 6, 16, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, #0f294a 0, transparent 34%),
    radial-gradient(circle at 90% 3%, #1e314f 0, transparent 29%),
    linear-gradient(170deg, #060b15 0%, #071223 100%),
    var(--bg);
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.topbar {
  backdrop-filter: blur(8px);
  background: rgba(6, 11, 20, 0.72);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.topbar-nav a,
.topbar-nav .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #2a3b56;
  background: rgba(14, 24, 40, 0.9);
  color: #dbe8ff;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

.topbar-nav a:hover,
.topbar-nav .link-button:hover {
  text-decoration: none;
  border-color: #3caef0;
  background: rgba(20, 45, 72, 0.92);
  transform: translateY(-1px);
}

.topbar-nav .logout-form {
  display: flex;
}

.logout-form {
  margin: 0;
}

.page {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 16px 32px;
}

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

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head.single {
  justify-content: flex-start;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
  color: var(--ink);
  background: #0a1424;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #184a73;
  border-color: #3caef0;
}

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-primary,
.btn-secondary,
.btn-link,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 600;
  padding: 11px 16px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
}

.btn-primary:hover {
  text-decoration: none;
  filter: brightness(0.95);
}

.btn-secondary {
  background: #17314f;
  color: #bfe7ff;
}

.btn-link {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-danger {
  background: #7f1d1d;
  color: #fee2e2;
}

.btn-danger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.search-form input {
  flex: 1;
}

.status-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.status-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--ink);
}

.status-tab:hover {
  text-decoration: none;
  border-color: #3caef0;
}

.status-tab-active {
  background: #17314f;
  border-color: #2e7ab7;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 0.92rem;
}

.row-archived {
  opacity: 0.82;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--line);
}

.service-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid #295478;
  color: #c7ebff;
  background: #0f2a3f;
}

.status-active {
  color: #bbf7d0;
  border-color: #166534;
  background: #0b2f20;
}

.status-archived {
  color: #fcd34d;
  border-color: #92400e;
  background: #3f2308;
}

.status-owner {
  color: #fecdd3;
  border-color: #be123c;
  background: #4a1020;
}

.status-viewer {
  color: #cbd5e1;
  border-color: #475569;
  background: #1e293b;
}

.flash {
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.flash ul {
  margin: 0;
  padding-left: 18px;
}

.flash-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #166534;
}

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

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
}

.detail-grid h3 {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.detail-grid p {
  margin: 0;
}

.full-row {
  grid-column: 1 / -1;
}

.break {
  overflow-wrap: anywhere;
}

.prewrap {
  white-space: pre-wrap;
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stack-space > * + * {
  margin-top: 12px;
}

.stack-compact {
  gap: 8px;
}

.helper-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.85rem;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form.stack-compact {
  flex-direction: column;
  align-items: stretch;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.stats-grid span {
  font-weight: 700;
}

code {
  background: #0d1a30;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(450px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

@media (max-width: 800px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-nav {
    flex-wrap: wrap;
    gap: 10px;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-form {
    flex-wrap: wrap;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .grid-3,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-wrap: wrap;
  }
}
