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

:root {
  --bg: #000000;
  --panel: #07050c;
  --ink: #f5f2ff;
  --muted: #a89fbc;
  --line: #2a203a;
  --brand: #cbb5ff;
  --brand-ink: #1a1230;
  --brand-soft: #2a1f43;
  --brand-soft-border: #5d4590;
  --danger: #fecaca;
  --success: #bbf7d0;
  --success-bg: #0f2015;
  --danger-bg: #2d1014;
  --radius: 14px;
  --shadow: 0 22px 45px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, #1a1130 0, transparent 30%),
    radial-gradient(circle at 92% 0%, #23163e 0, transparent 34%),
    linear-gradient(170deg, #010101 0%, #080510 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(2, 1, 5, 0.9);
  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 #35284f;
  background: rgba(12, 8, 20, 0.95);
  color: #f5f1ff;
  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: #8062be;
  background: rgba(26, 18, 43, 0.96);
  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;
}

.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
}

.checkbox-line input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #5f4794;
  border-color: #c3adff;
}

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: var(--brand-soft);
  color: #e9deff;
  border: 1px solid var(--brand-soft-border);
}

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

.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: #9f80e6;
}

.status-tab-active {
  background: var(--brand-soft);
  border-color: var(--brand-soft-border);
}

.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 #6d53a8;
  color: #eadfff;
  background: #271b3f;
}

.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: #ddd6fe;
  border-color: #6b4bb8;
  background: #231a3a;
}

.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;
}

.tos-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #05030b;
  padding: 14px;
}

.tos-block h3 {
  margin-bottom: 6px;
}

.tos-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

code {
  background: #06030d;
  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;
  }
}

/* Public TOS page style */
body.tos-screen {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #ffffff;
  background: #000000;
  line-height: 1.75;
  min-height: 100vh;
  position: relative;
}

.tos-screen a {
  color: #ffffff;
}

.tos-bg-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 25% 30%, rgba(255, 255, 255, 0.04) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.tos-logo-watermark {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  opacity: 0.28;
  z-index: 2;
}

.tos-logo-watermark img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  display: block;
  filter: brightness(0) invert(1);
}

.tos-navbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.tos-nav-container {
  max-width: 1150px;
  margin: 0 auto;
  padding: 14px 20px;
}

.tos-back-btn {
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.35);
  padding: 10px 16px;
  letter-spacing: 1px;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tos-back-btn:hover {
  text-decoration: none;
  border-color: #ffffff;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.22);
  transform: translateX(-4px);
}

.tos-container {
  max-width: 1150px;
  margin: 0 auto;
  padding: 30px 20px 50px;
  position: relative;
  z-index: 1;
}

.tos-header {
  text-align: center;
  border-bottom: 3px solid #ffffff;
  padding: 20px 0 30px;
  margin-bottom: 28px;
}

.tos-crow-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  animation: tos-float 3s ease-in-out infinite;
}

.tos-crow-icon img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  filter: brightness(0) invert(1);
}

.crow-logo-hero {
  width: 110px;
  height: 110px;
  object-fit: contain;
  display: block;
  margin: 0 auto 10px;
  animation: tos-float 3s ease-in-out infinite;
}

@keyframes tos-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.tos-main-title {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: 0.36rem;
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.34);
}

.tos-subtitle {
  margin: 10px 0 12px;
  color: #d8d8d8;
  letter-spacing: 0.24rem;
  font-size: clamp(1.2rem, 4vw, 1.9rem);
}

.tos-version {
  margin: 0;
  color: #adadad;
  letter-spacing: 0.1rem;
}

.tos-acceptance-section {
  background: rgba(0, 0, 0, 0.86);
  border: 3px solid #ffffff;
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.18);
  padding: 24px;
  margin-bottom: 28px;
}

.tos-acceptance-section h2 {
  margin: 0 0 10px;
  letter-spacing: 0.16rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.26);
}

.tos-acceptance-section p {
  margin: 0 0 16px;
  color: #d3d3d3;
}

.tos-screen .flash {
  border-radius: 0;
}

.tos-screen .flash-success {
  background: rgba(13, 51, 29, 0.62);
  border-color: rgba(134, 239, 172, 0.4);
  color: #dcfce7;
}

.tos-screen .flash-error {
  background: rgba(72, 12, 12, 0.62);
  border-color: rgba(252, 165, 165, 0.44);
  color: #fee2e2;
}

.tos-form-grid {
  display: grid;
  gap: 14px;
}

.tos-form-label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.tos-form-label input[type='text'] {
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  font: inherit;
  letter-spacing: 0.06rem;
}

.tos-form-label input[type='text']:focus {
  outline: none;
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.tos-checkbox-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.tos-checkbox-line input[type='checkbox'] {
  width: 17px;
  height: 17px;
  margin-top: 3px;
}

.tos-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tos-home-btn,
.tos-btn-accept {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  text-decoration: none;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  font-weight: 700;
  border: 2px solid #ffffff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.tos-home-btn {
  background: transparent;
  color: #ffffff;
}

.tos-btn-accept {
  background: #ffffff;
  color: #000000;
}

.tos-home-btn:hover,
.tos-btn-accept:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.24);
}

.tos-toc {
  background: rgba(0, 0, 0, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.2);
  padding: 22px;
  margin-bottom: 30px;
}

.tos-toc h3 {
  margin: 0 0 10px;
  letter-spacing: 0.16rem;
  font-size: 1.4rem;
}

.tos-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tos-toc li {
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.tos-toc li:last-child {
  border-bottom: none;
}

.tos-toc a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  text-decoration: none;
  transition: transform 0.2s ease, text-shadow 0.2s ease;
}

.tos-toc a::before {
  content: '▸';
  font-size: 1.1rem;
}

.tos-toc a span {
  color: #cfcfcf;
  min-width: 26px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.tos-toc a:hover {
  transform: translateX(8px);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.28);
}

.tos-content {
  margin-bottom: 30px;
}

.tos-section {
  margin-bottom: 24px;
  scroll-margin-top: 84px;
}

.tos-section-header {
  display: flex;
  gap: 16px;
  align-items: center;
  background: rgba(0, 0, 0, 0.92);
  border: 3px solid #ffffff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.16);
  padding: 18px;
}

.tos-section-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.tos-section-title {
  margin: 0;
  font-size: clamp(1.05rem, 3.2vw, 1.7rem);
  letter-spacing: 0.08rem;
}

.tos-section-subtitle {
  margin: 6px 0 0;
  color: #cfcfcf;
  letter-spacing: 0.04rem;
  font-size: 0.95rem;
}

.tos-section-content {
  background: rgba(0, 0, 0, 0.62);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top: none;
  padding: 18px;
}

.tos-section-content ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tos-section-content li {
  padding: 10px 0 10px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  position: relative;
}

.tos-section-content li:last-child {
  border-bottom: none;
}

.tos-section-content li::before {
  content: '◆';
  position: absolute;
  left: 0;
  color: #ffffff;
  font-size: 0.95rem;
}

.tos-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 16px;
  text-align: center;
  color: #c8c8c8;
  display: grid;
  gap: 6px;
}

.tos-footer p {
  margin: 0;
}

@media (max-width: 800px) {
  .tos-logo-watermark {
    width: 58px;
    height: 58px;
    right: 12px;
    bottom: 12px;
  }

  .tos-logo-watermark img {
    width: 42px;
    height: 42px;
  }

  .tos-nav-container,
  .tos-container {
    padding-left: 14px;
    padding-right: 14px;
  }

  .tos-header {
    margin-bottom: 20px;
    padding-bottom: 24px;
  }

  .tos-crow-icon {
    width: 82px;
    height: 82px;
  }

  .tos-crow-icon img {
    width: 56px;
    height: 56px;
  }

  .crow-logo-hero {
    width: 86px;
    height: 86px;
  }

  .tos-acceptance-section,
  .tos-toc,
  .tos-section-header,
  .tos-section-content {
    padding: 14px;
  }

  .tos-form-actions {
    flex-direction: column;
  }

  .tos-home-btn,
  .tos-btn-accept {
    width: 100%;
  }
}
