:root {
  color-scheme: light;
  --bg: #f4f4f0;
  --surface: #ffffff;
  --surface-soft: #f7f7f3;
  --text: #000000;
  --muted: #666666;
  --border: #000000;
  --red: #e60000;
  --blue: #0055ff;
  --orange: #ff6b00;
  --green: #00a600;
  --danger: #bf000f;
  --shadow: 4px 4px 0 #000000;
  --shadow-lg: 6px 6px 0 #000000;
  --max: 1200px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Heiti SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  border-radius: 0;
  font: inherit;
}

button {
  cursor: pointer;
}

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

.header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 72px;
  border-bottom: 2px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(var(--max), calc(100% - 48px));
  height: 100%;
  margin: 0 auto;
}

.brand,
.nav,
.button-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: max-content;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border);
  background: var(--red);
  box-shadow: 2px 2px 0 var(--border);
}

.nav {
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.nav a:hover {
  color: var(--text);
}

.shell {
  width: min(var(--max), calc(100% - 48px));
  margin: 0 auto;
  padding: 44px 0 80px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  margin-bottom: 32px;
  padding-left: 24px;
  border-left: 6px solid var(--red);
}

.eyebrow,
.panel-tag,
.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 9px;
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: 2px 2px 0 var(--border);
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 18px;
}

h1 {
  max-width: 760px;
  font-size: clamp(40px, 6vw, 76px);
  font-weight: 900;
  line-height: 1.02;
}

h2 {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 900;
}

h3 {
  font-size: 17px;
  font-weight: 900;
}

.hero p,
.muted {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.7;
}

.hero p {
  max-width: 620px;
  margin-top: 14px;
  font-size: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.stat-card,
.panel,
.record-card,
.empty {
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  min-width: 120px;
  padding: 16px;
}

.stat-number {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}

.stat-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.loading {
  min-height: 240px;
  display: grid;
  place-items: center;
}

.admin-card-grid {
  display: grid;
  gap: 24px;
}

.section-card {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-bottom: 2px solid var(--border);
}

.panel-body {
  display: grid;
  gap: 20px;
  padding: 22px;
}

.split-body {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  align-items: start;
}

.permissions-layout {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  align-items: start;
}

.record-columns {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.form,
.stack,
.record-list {
  display: grid;
  gap: 14px;
}

.form {
  align-content: start;
  padding: 18px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

input,
select,
textarea {
  width: 100%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  box-shadow: 2px 2px 0 var(--border);
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 2px 2px 0 var(--blue);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, color 150ms ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--border);
  outline: none;
}

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

.btn.primary:hover {
  background: var(--red);
  border-color: var(--red);
}

.btn.danger,
#signOutButton {
  color: var(--danger);
}

.btn.danger:hover,
#signOutButton:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}

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

.button-row {
  flex-wrap: wrap;
  gap: 12px;
}

.record-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.record-card h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

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

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pill {
  box-shadow: none;
  color: var(--text);
}

.pill.admin,
.pill.access {
  background: var(--red);
  color: var(--surface);
}

.pill.user,
.pill.viewer {
  background: var(--blue);
  color: var(--surface);
}

.pill.editor {
  background: var(--orange);
  color: var(--surface);
}

.empty,
.status-box {
  padding: 20px;
  border: 2px dashed var(--border);
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.7;
  text-align: center;
}

.status-box {
  border-style: solid;
  text-align: left;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 80;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 16px;
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.5;
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 240ms ease, transform 240ms ease;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(-8px);
}

.toast[data-tone="error"] {
  background: #fff1f1;
  color: var(--danger);
}

.toast[data-tone="success"] {
  background: #f0fff2;
  color: #006b18;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .hero,
  .split-body,
  .permissions-layout,
  .record-columns {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .header {
    height: auto;
  }

  .header-inner {
    align-items: flex-start;
    padding: 16px 0;
    flex-direction: column;
  }

  .nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .shell,
  .header-inner {
    width: min(100% - 28px, var(--max));
  }

  .shell {
    padding-top: 32px;
  }

  .hero {
    padding-left: 16px;
  }

  h1 {
    font-size: 38px;
  }

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

  .panel-header {
    flex-direction: column;
  }

  .panel-body,
  .panel-header,
  .form {
    padding: 16px;
  }

  .btn,
  .button-row {
    width: 100%;
  }
}
