@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;600&display=swap');

:root {
  --ink-900: #142022;
  --ink-700: #2e4448;
  --ink-500: #4f686c;
  --ink-300: #88a2a5;
  --paper-100: #f8f4ea;
  --paper-200: #f0e8da;
  --paper-300: #e8decb;
  --accent-500: #0f8f8f;
  --accent-600: #0a7676;
  --signal-500: #d06a2d;
  --signal-600: #b95b24;
  --danger-500: #b63f2e;
  --line: #d6cbb8;
  --ok: #3b8d5f;
  --surface-shadow: 0 16px 40px rgba(26, 41, 45, 0.12);
}

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

body {
  margin: 0;
  font-family: 'Barlow', 'Segoe UI', sans-serif;
  color: var(--ink-900);
  background:
    radial-gradient(1200px 500px at 90% -100px, rgba(15, 143, 143, 0.24), transparent 70%),
    radial-gradient(900px 450px at 5% -80px, rgba(208, 106, 45, 0.18), transparent 75%),
    linear-gradient(180deg, var(--paper-100), #f7f1e4 38%, #efe4d1);
  min-height: 100vh;
}

.auth-body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(0.9rem, 2.2vw, 2rem);
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 440px at 82% -120px, rgba(15, 143, 143, 0.22), transparent 75%),
    radial-gradient(860px 380px at 12% -110px, rgba(208, 106, 45, 0.16), transparent 78%),
    linear-gradient(180deg, #f9f4ea, #efe2cd);
}

.auth-shell {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(340px, 0.94fr) minmax(340px, 1.06fr);
  gap: 1rem;
  align-items: start;
}

.auth-shell > .auth-card:only-child {
  width: min(560px, 100%);
  justify-self: center;
}

.auth-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(214, 203, 184, 0.86);
  border-radius: 20px;
  box-shadow: 0 16px 38px rgba(26, 41, 45, 0.14);
  padding: clamp(1rem, 2.1vw, 1.45rem);
  animation: riseIn 0.35s ease;
}

.auth-card h1,
.auth-card h2 {
  margin: 0 0 0.35rem;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.auth-card h1 {
  font-size: clamp(1.45rem, 2.2vw, 1.9rem);
}

.auth-card h2 {
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
}

.auth-form {
  display: grid;
  gap: 0.78rem;
}

.auth-form label {
  display: grid;
  gap: 0.34rem;
}

.auth-form label > span {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-700);
}

.auth-form input {
  height: 42px;
}

.auth-form button {
  margin-top: 0.2rem;
  width: 100%;
  height: 42px;
}

.auth-alert {
  margin: 0 0 0.75rem;
  padding: 0.62rem 0.72rem;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.auth-alert-error {
  background: #fff1ee;
  border-color: #ebc4bc;
  color: #8f3427;
}

.auth-alert-info {
  background: #edf8f7;
  border-color: #b7dcd7;
  color: #15595a;
}

.auth-inline-link {
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
}

.auth-inline-link a {
  color: var(--accent-600);
  text-decoration: none;
  font-weight: 600;
}

.auth-inline-link a:hover,
.auth-inline-link a:focus-visible {
  text-decoration: underline;
}

.auth-onboard {
  border-top: 4px solid rgba(15, 143, 143, 0.9);
}

.auth-onboard p,
.auth-onboard li {
  color: var(--ink-700);
  font-size: 0.94rem;
}

.auth-onboard ol {
  margin: 0 0 0.82rem 1.1rem;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--signal-500);
  background: linear-gradient(150deg, var(--signal-500), var(--signal-600));
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: 0.55rem 0.85rem;
  box-shadow: 0 7px 16px rgba(185, 91, 36, 0.24);
  transition: transform 130ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.button-like:hover,
.button-like:focus-visible {
  transform: translateY(-1px);
}

.auth-code {
  margin: 0;
  border-radius: 12px;
  border: 1px solid #e5d6c0;
  background: #fbf4e6;
  padding: 0.7rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #1d3235;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ambient {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(transparent 96%, rgba(20, 32, 34, 0.04) 100%),
    linear-gradient(90deg, transparent 96%, rgba(20, 32, 34, 0.04) 100%);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100vw - 2.2rem));
  margin: 1.2rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
}

.hero-copy {
  background: linear-gradient(150deg, rgba(15, 143, 143, 0.92), rgba(10, 118, 118, 0.92));
  color: #ecffff;
  border-radius: 20px;
  padding: 1.5rem 1.6rem;
  box-shadow: var(--surface-shadow);
  animation: riseIn 0.45s ease;
}

.hero-copy h1 {
  margin: 0;
  letter-spacing: 0.02em;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
  line-height: 1.05;
}

.hero-copy p {
  margin: 0.65rem 0 1rem;
  max-width: 70ch;
  color: rgba(236, 255, 255, 0.9);
  font-size: 1.02rem;
}

.notice-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.notice-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  letter-spacing: 0.015em;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.27);
}

.toolbar-card {
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(214, 203, 184, 0.86);
  padding: 1rem;
  box-shadow: var(--surface-shadow);
  display: grid;
  gap: 0.75rem;
  animation: riseIn 0.58s ease;
}

.toolbar-card label,
.field-grid label,
.stack label,
.date-filter label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.87rem;
  color: var(--ink-500);
}

.toolbar-card span,
.field-grid span,
.stack span,
.date-filter span {
  font-weight: 600;
  color: var(--ink-700);
}

input,
select,
button,
textarea {
  font-family: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.52rem 0.62rem;
  font-size: 0.95rem;
  background: #fffcf7;
  color: var(--ink-900);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-500);
  box-shadow: 0 0 0 3px rgba(15, 143, 143, 0.18);
}

.key-pair {
  display: grid;
  gap: 0.25rem;
  background: #fff8ec;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.5rem 0.65rem;
}

.key-pair strong {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-700);
}

.key-pair code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: var(--ink-900);
  overflow-wrap: anywhere;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.summary-grid article {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(214, 203, 184, 0.85);
  border-radius: 16px;
  padding: 0.8rem 0.9rem;
  box-shadow: 0 8px 22px rgba(26, 41, 45, 0.08);
}

.summary-grid h2 {
  margin: 0;
  font-size: 0.83rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.summary-grid p {
  margin: 0.22rem 0 0;
  font-size: 1.42rem;
  font-weight: 700;
  color: var(--ink-900);
}

.status-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.95rem 1.6rem;
  align-items: center;
  background: #fff7ea;
  border: 1px solid var(--paper-300);
  border-left: 5px solid var(--signal-500);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
}

.status-panel strong {
  color: var(--ink-700);
}

.status-panel span {
  color: var(--ink-900);
}

.status-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-left: auto;
  align-items: flex-end;
}

.status-controls label {
  display: grid;
  gap: 0.25rem;
  min-width: 150px;
  font-size: 0.8rem;
}

.status-controls span {
  color: var(--ink-700);
  font-weight: 600;
}

.status-meta {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  border-top: 1px dashed #dbc8ad;
  padding-top: 0.45rem;
}

.status-meta code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  background: #fff9ee;
  border: 1px solid #ebdcc8;
  border-radius: 6px;
  padding: 0.08rem 0.28rem;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.tab-btn {
  border: 1px solid var(--line);
  background: #fbf5e8;
  color: var(--ink-700);
  border-radius: 999px;
  padding: 0.55rem 0.88rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms ease;
}

.tab-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent-500);
  color: var(--accent-600);
}

.tab-btn.is-active {
  background: var(--ink-900);
  color: #fefcf5;
  border-color: var(--ink-900);
}

.tab-panel {
  display: none;
  animation: fadeIn 220ms ease;
}

.tab-panel.is-active {
  display: block;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.panel-grid-two {
  grid-template-columns: 0.95fr 1.05fr;
  margin-bottom: 1rem;
}

.card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(214, 203, 184, 0.9);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--surface-shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  margin-bottom: 0.85rem;
}

.card-head h3 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: 0.02em;
}

.chip {
  border-radius: 999px;
  background: #f2f8f8;
  color: var(--accent-600);
  border: 1px solid rgba(15, 143, 143, 0.33);
  padding: 0.28rem 0.58rem;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

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

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.58rem 0.75rem;
  font-size: 0.92rem;
  font-weight: 600;
  background: linear-gradient(150deg, var(--signal-500), var(--signal-600));
  color: #fff;
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 160ms ease, opacity 160ms ease;
  box-shadow: 0 6px 16px rgba(185, 91, 36, 0.26);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
  transform: none;
}

.ghost-btn {
  background: transparent;
  color: var(--ink-700);
  border: 1px solid var(--line);
  box-shadow: none;
}

.danger {
  background: linear-gradient(160deg, var(--danger-500), #953123);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.field-inline {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.58rem;
}

.quick-btn {
  display: grid;
  gap: 0.22rem;
  justify-items: start;
  text-align: left;
  min-height: 92px;
  background: linear-gradient(145deg, #f5fffd, #ddf6f2);
  border: 1px solid rgba(15, 143, 143, 0.34);
  color: var(--ink-900);
  box-shadow: none;
  padding: 0.6rem;
}

.quick-btn strong {
  font-size: 1rem;
  color: var(--accent-600);
}

.quick-btn small {
  color: var(--ink-500);
  font-size: 0.78rem;
}

.quick-btn em {
  color: var(--danger-500);
  font-style: normal;
  font-size: 0.75rem;
}

.quick-btn.is-muted {
  background: #f8f0e8;
  border-color: #d8c4ae;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(214, 203, 184, 0.82);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: #fffdf8;
}

thead th {
  position: sticky;
  top: 0;
  background: #f8f1e3;
  color: var(--ink-700);
  text-transform: uppercase;
  letter-spacing: 0.045em;
  font-size: 0.74rem;
  z-index: 1;
}

th,
td {
  text-align: left;
  padding: 0.48rem 0.56rem;
  border-bottom: 1px solid #eee2cf;
  font-size: 0.87rem;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: #fff9ee;
}

tbody tr:hover {
  background: #f3fbf9;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.56rem;
  margin-bottom: 0.75rem;
}

.date-filter {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.56rem;
  margin-bottom: 0.75rem;
}

.stack {
  display: grid;
  gap: 0.6rem;
}

.muted-text {
  margin: 0 0 0.8rem;
  color: var(--ink-500);
  font-size: 0.88rem;
}

.decode-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.56rem;
  margin-bottom: 0.85rem;
}

.decode-form label {
  display: grid;
  gap: 0.25rem;
}

.decode-output {
  border: 1px solid #e4d7c3;
  border-radius: 12px;
  background: #fffaf1;
  padding: 0.72rem;
}

.decode-status {
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.decode-status.valid {
  color: #2f7e55;
}

.decode-status.invalid {
  color: #aa3c2d;
}

.decode-grid {
  margin: 0;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.35rem 0.7rem;
}

.decode-grid dt {
  font-size: 0.82rem;
  color: var(--ink-500);
}

.decode-grid dd {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-900);
  overflow-wrap: anywhere;
}

.decode-grid code {
  font-family: 'IBM Plex Mono', monospace;
  background: #f5ede0;
  border: 1px solid #e6d7c2;
  border-radius: 6px;
  padding: 0.08rem 0.28rem;
  font-size: 0.83rem;
}

.sniffer-tip {
  margin: 0 0 0.8rem;
  font-size: 0.84rem;
  color: var(--ink-500);
}

.webusb-sniffer {
  display: grid;
  gap: 0.7rem;
}

.sniffer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sniffer-status {
  margin: 0;
  font-size: 0.87rem;
  color: var(--ink-700);
}

.sniffer-status.is-running {
  color: var(--ok);
  font-weight: 700;
}

.sniffer-status.is-paused {
  color: var(--signal-600);
}

.sniffer-status.is-unsupported {
  color: var(--danger-500);
  font-weight: 700;
}

.sniffer-log {
  margin: 0;
  max-height: 320px;
  min-height: 180px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid #e3d5c0;
  background: #faf5eb;
  padding: 0.68rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #203235;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sniffer-api-hint {
  margin: 0;
  font-size: 0.78rem;
}

.sniffer-api-hint code {
  font-family: 'IBM Plex Mono', monospace;
}

.sm13x-demo {
  border-top: 1px dashed #dbc8ad;
  padding-top: 0.65rem;
  display: grid;
  gap: 0.62rem;
}

.sm13x-demo h4 {
  margin: 0;
  font-size: 0.95rem;
}

.sm13x-grid {
  display: grid;
  gap: 0.56rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sm13x-grid label {
  display: grid;
  gap: 0.26rem;
}

.sm13x-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-700);
}

.sm13x-output {
  margin: 0;
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid #e3d5c0;
  background: #faf5eb;
  padding: 0.64rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #203235;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  margin: 0;
}

.error-shell {
  width: min(640px, calc(100vw - 2rem));
  background: #fff9ef;
  border: 1px solid #dec7aa;
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow: var(--surface-shadow);
}

.error-shell h1 {
  margin-top: 0;
}

.error-shell pre {
  overflow: auto;
  padding: 0.8rem;
  background: #f2ebde;
  border-radius: 10px;
  border: 1px solid #dbc8ad;
}

@media (max-width: 1200px) {
  .quick-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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

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

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

  .panel-grid,
  .panel-grid-two {
    grid-template-columns: 1fr;
  }

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

  .field-inline {
    grid-template-columns: 1fr;
  }

  .status-controls {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  .auth-body {
    padding: 0.6rem;
  }

  .auth-card {
    border-radius: 15px;
    padding: 0.9rem;
  }

  .shell {
    width: calc(100vw - 1rem);
    margin: 0.55rem auto 1rem;
  }

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

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

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

  .decode-form {
    grid-template-columns: 1fr;
  }

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

  .sniffer-controls button {
    flex: 1 1 calc(50% - 0.5rem);
  }

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

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
