:root {
  --bg: #f3efe8;
  --bg-strong: #e8dfd2;
  --surface: rgba(255, 252, 247, 0.92);
  --surface-strong: #fffaf4;
  --surface-alt: #f7f0e6;
  --sidebar: rgba(23, 35, 43, 0.92);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --line: rgba(62, 52, 43, 0.12);
  --line-strong: rgba(62, 52, 43, 0.18);
  --ink: #162028;
  --muted: #687681;
  --accent: #c06a45;
  --accent-deep: #974927;
  --accent-soft: #f4dfd3;
  --teal: #1f6a68;
  --teal-soft: #d7ece8;
  --danger: #b24839;
  --danger-soft: #f7dfda;
  --success: #2f7c52;
  --success-soft: #ddede1;
  --shadow-lg: 0 30px 80px rgba(24, 32, 40, 0.12);
  --shadow-md: 0 16px 36px rgba(24, 32, 40, 0.08);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --font-ui: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  width: 100%;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(192, 106, 69, 0.16), transparent 28%),
    radial-gradient(circle at right 18%, rgba(31, 106, 104, 0.1), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0)),
    var(--bg);
  font-family: var(--font-ui);
}

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

code,
pre {
  font-family: Consolas, "Courier New", monospace;
}

.auth-body {
  overflow: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(23, 35, 43, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 35, 43, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.bg-glow,
.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(42px);
  pointer-events: none;
}

.bg-glow {
  width: 26rem;
  height: 26rem;
  opacity: 0.42;
}

.glow-a,
.orb-a {
  top: -8rem;
  right: -7rem;
  background: rgba(192, 106, 69, 0.34);
}

.glow-b,
.orb-b {
  bottom: -10rem;
  left: -6rem;
  width: 30rem;
  height: 30rem;
  background: rgba(31, 106, 104, 0.22);
}

.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 2rem;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
  width: 100%;
}

.auth-card,
.panel,
.stat-card,
.signal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.auth-card {
  width: min(100%, 42rem);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.35rem;
  min-height: 100vh;
  min-width: 0;
  padding: 2rem 1.4rem;
  color: #f2f5f7;
  background:
    linear-gradient(180deg, rgba(31, 44, 53, 0.98), rgba(20, 30, 37, 0.92)),
    var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  display: grid;
  gap: 0.55rem;
}

.sidebar-brand h1,
.auth-brand h1,
.page-header h2,
.panel-head h3,
.stack-form h2,
.hero-copy h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.sidebar-brand h1 {
  font-size: 1.85rem;
  color: #fff9f4;
}

.sidebar-brand p,
.auth-brand p,
.page-copy,
.muted,
.field-help,
.cell-note,
.empty-state,
.panel-copy,
.action-tile span,
.sidebar-footer,
.user-chip-label {
  color: var(--muted);
}

.sidebar-brand p,
.sidebar-footer,
.nav-link {
  color: rgba(236, 242, 246, 0.74);
}

.brand-kicker,
.eyebrow,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  color: var(--accent-deep);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-kicker {
  color: rgba(255, 216, 196, 0.78);
}

.auth-brand {
  margin-bottom: 1.6rem;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.25rem;
  min-width: 0;
  width: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 3rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
  color: #fff8f3;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.sidebar-footer {
  display: grid;
  gap: 0.85rem;
  margin-top: auto;
  padding-top: 0.8rem;
}

.user-chip {
  display: grid;
  gap: 0.18rem;
  padding: 1rem 1rem 0.95rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.user-chip strong {
  color: #fff7f2;
}

.content {
  min-width: 0;
  width: 100%;
  padding: 2rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  min-width: 0;
}

.page-title-block {
  min-width: 0;
  max-width: 54rem;
}

.page-header h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}

.page-copy {
  max-width: 46rem;
  margin: 0.8rem 0 0;
  font-size: 1.02rem;
  line-height: 1.65;
}

.stack-form,
.stack-layout {
  display: grid;
  gap: 1rem;
}

.field,
.field-grid,
.check-grid,
.panel-stack,
.detail-list,
.action-grid {
  display: grid;
  gap: 0.85rem;
}

.field {
  align-content: start;
}

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

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

.field label {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: rgba(31, 106, 104, 0.38);
  box-shadow: 0 0 0 4px rgba(31, 106, 104, 0.1);
  background: #fffdfa;
}

.field textarea {
  min-height: 5.25rem;
  resize: vertical;
}

.field-grid > .field input,
.field-grid > .field textarea,
.field-grid > .field select {
  min-height: 3.5rem;
}

.field-help {
  margin: -0.15rem 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  max-width: 100%;
  min-width: 0;
  gap: 0.45rem;
  padding: 0.8rem 1.15rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #fff9f5;
  background: linear-gradient(135deg, var(--accent), #d98862);
  box-shadow: 0 16px 28px rgba(192, 106, 69, 0.22);
}

.button-secondary {
  color: #103c3b;
  background: var(--teal-soft);
}

.button-ghost {
  color: inherit;
  background: transparent;
  border: 1px solid var(--line-strong);
}

.button-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.button-small {
  min-height: 2.3rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
}

.button-full {
  width: 100%;
}

.header-actions,
.form-actions,
.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
}

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 1rem 1.1rem;
  border: 1px solid transparent;
  border-left-width: 4px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.flash-success {
  color: #194a31;
  background: var(--success-soft);
  border-color: rgba(47, 124, 82, 0.18);
  border-left-color: var(--success);
}

.flash-error {
  color: #742517;
  background: var(--danger-soft);
  border-color: rgba(178, 72, 57, 0.18);
  border-left-color: var(--danger);
}

.panel,
.stat-card,
.signal-card {
  border-radius: var(--radius-lg);
  min-width: 0;
}

.panel {
  padding: 1.35rem;
}

.panel-inline {
  margin-bottom: 1rem;
}

.panel-warning {
  background: linear-gradient(135deg, rgba(247, 234, 222, 0.98), rgba(255, 248, 240, 0.98));
}

.panel-code {
  overflow: hidden;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hero-copy,
.hero-status-grid,
.stats-grid,
.panel-grid {
  display: grid;
  gap: 1rem;
}

.hero-copy {
  align-content: center;
  padding: 1.75rem;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(255, 252, 247, 0.94), rgba(247, 240, 231, 0.9)),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.hero-copy h3 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.hero-status-grid {
  grid-template-columns: 1fr;
}

.signal-card {
  padding: 1.2rem;
}

.signal-card-head,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.signal-card-head {
  margin-bottom: 0.7rem;
  font-weight: 700;
}

.panel-head {
  margin-bottom: 1rem;
}

.panel-head h3 {
  font-size: 1.3rem;
}

.panel-copy {
  margin: 0.3rem 0 0;
  font-size: 0.94rem;
  line-height: 1.55;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.stats-grid-compact .stat-card {
  padding: 1.1rem;
}

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

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

.panel-grid-dual {
  grid-template-columns: minmax(0, 1.45fr) minmax(20rem, 1fr);
}

.stat-card {
  padding: 1.3rem;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-value {
  display: block;
  margin-top: 0.5rem;
  font-size: 2.3rem;
  line-height: 1;
  font-family: var(--font-display);
}

.stat-value-small {
  font-size: 1.45rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.38rem 0.78rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success {
  color: #194a31;
  background: var(--success-soft);
}

.badge-danger {
  color: #722316;
  background: var(--danger-soft);
}

.badge-muted {
  color: var(--muted);
  background: rgba(58, 50, 42, 0.08);
}

.protocol-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.protocol-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.95rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  color: #11403f;
  background: rgba(31, 106, 104, 0.1);
  border: 1px solid rgba(31, 106, 104, 0.12);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(62, 52, 43, 0.08);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.52);
}

.data-table th,
.data-table td {
  padding: 0.95rem 0.85rem;
  border-bottom: 1px solid rgba(62, 52, 43, 0.08);
  text-align: left;
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: rgba(31, 106, 104, 0.04);
}

.data-table th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cell-note {
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.detail-list {
  gap: 0.9rem;
}

.detail-list div {
  display: grid;
  gap: 0.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(62, 52, 43, 0.08);
}

.detail-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.detail-list span {
  color: var(--muted);
  font-size: 0.88rem;
}

.detail-list strong {
  font-size: 0.98rem;
}

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

.action-tile {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(62, 52, 43, 0.08);
  background: rgba(255, 255, 255, 0.54);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.action-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 106, 104, 0.2);
  box-shadow: var(--shadow-md);
}

.action-tile strong {
  font-size: 1rem;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
}

.checkline input {
  width: 1.05rem;
  height: 1.05rem;
}

.code-preview {
  margin: 0;
  overflow-x: auto;
  padding: 1.15rem;
  border-radius: var(--radius-lg);
  background: #18242c;
  color: #eff4f7;
  font-size: 0.92rem;
  line-height: 1.55;
}

.permission-preview,
.permission-preview-list,
.permission-preview-item {
  display: grid;
  gap: 0.85rem;
}

.permission-preview {
  margin-top: 0.85rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(24, 36, 44, 0.04);
  border: 1px solid rgba(24, 36, 44, 0.08);
}

.permission-preview-head {
  display: grid;
  gap: 0.35rem;
}

.permission-preview-item,
.permission-preview-note {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(24, 36, 44, 0.08);
}

.permission-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.permission-preview-code {
  width: 100%;
  min-height: 4.4rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(24, 36, 44, 0.12);
  background: #18242c;
  color: #eff4f7;
  font: 500 0.92rem/1.5 Consolas, "Courier New", monospace;
  resize: vertical;
}

.permission-preview-note {
  color: var(--muted);
  line-height: 1.55;
}

.compact-code,
.code-preview-tall {
  min-height: 18rem;
}

.plain-list {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.65;
}

.mono-line {
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  color: var(--ink);
}

.empty-state {
  margin: 0;
  padding-top: 0.2rem;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    gap: 1rem;
    padding: 1.2rem 1rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .nav-list {
    flex-direction: row;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.2rem;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .nav-link {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .sidebar-footer {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    margin-top: 0;
    padding-top: 0;
  }

  .sidebar-footer .button-full {
    width: auto;
    min-width: 7rem;
  }

  .hero-panel,
  .panel-grid-dual,
  .panel-grid-triple {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  html,
  body,
  .app-shell,
  .sidebar,
  .content,
  .page-header,
  .page-title-block,
  .header-actions,
  .panel,
  .signal-card,
  .stat-card,
  .table-wrap {
    max-width: 100%;
    min-width: 0;
  }

  .content,
  .auth-shell,
  .auth-card {
    padding: 1.15rem;
  }

  .sidebar {
    padding: 1rem 0.8rem 0.9rem;
    gap: 0.8rem;
  }

  .sidebar-brand h1 {
    font-size: 1.5rem;
  }

  .sidebar-brand p,
  .page-copy,
  .panel-copy,
  .field-help {
    font-size: 0.92rem;
  }

  .page-header,
  .field-grid,
  .check-grid,
  .stats-grid,
  .panel-grid,
  .hero-panel,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    display: grid;
    gap: 1rem;
  }

  .page-header h2 {
    font-size: clamp(1.8rem, 10vw, 2.5rem);
    overflow-wrap: anywhere;
  }

  .hero-copy,
  .panel,
  .stat-card,
  .signal-card {
    padding: 1.05rem;
  }

  .stat-value {
    font-size: 1.95rem;
  }

  .stats-grid-compact .stat-value {
    font-size: 1.25rem;
  }

  .nav-list {
    gap: 0.45rem;
    padding-bottom: 0.3rem;
  }

  .nav-link {
    min-height: 2.6rem;
    padding: 0.72rem 0.92rem;
    font-size: 0.92rem;
  }

  .sidebar-footer {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .user-chip {
    display: none;
  }

  .header-actions,
  .form-actions,
  .actions-cell {
    width: 100%;
    display: grid;
  }

  .header-actions form,
  .header-actions a,
  .form-actions a,
  .form-actions button,
  .actions-cell form {
    width: 100%;
    min-width: 0;
  }

  .header-actions .button,
  .form-actions .button,
  .actions-cell .button {
    width: 100%;
  }

  .data-table th,
  .data-table td {
    padding: 0.8rem 0.7rem;
  }
}
