* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #eef2f7;
  color: #111827;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  letter-spacing: 0;
}

a {
  color: #126b55;
  text-decoration: none;
}

a:hover {
  color: #0b4c3d;
  text-decoration: underline;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
  overflow-x: auto;
  margin: 1rem 0 0;
  border-radius: 8px;
  background: #111827;
  color: #f9fafb;
  padding: 1rem;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex: 0 0 276px;
  height: 100vh;
  flex-direction: column;
  background: #111827;
  color: #e5e7eb;
}

.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-height: 72px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  padding: 0 1.25rem;
  color: #f9fafb;
}

.brand:hover {
  color: #f9fafb;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #2f8a61;
  color: #fff;
  font-size: .8rem;
  font-weight: 800;
}

.brand-name {
  font-size: .95rem;
  font-weight: 800;
  color: #f9fafb;
}

.brand-tag {
  border: 1px solid rgba(74, 222, 128, .35);
  border-radius: 4px;
  background: rgba(47, 138, 97, .2);
  color: #bbf7d0;
  padding: .1rem .35rem;
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
}

.nav {
  display: grid;
  gap: .2rem;
  padding: 1rem .85rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  border-radius: 8px;
  color: rgba(255, 255, 255, .62);
  padding: .7rem .85rem;
  font-weight: 650;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, .08);
  color: #f9fafb;
  text-decoration: none;
}

.nav-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  color: #86efac;
  font-size: .7rem;
  font-weight: 800;
}

.sidebar-user {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding: 1rem 1.25rem;
}

.sidebar-email {
  overflow: hidden;
  margin-bottom: .75rem;
  color: rgba(255, 255, 255, .45);
  font-size: .85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, .58);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  padding: 0;
}

.logout-btn:hover {
  color: #fecaca;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 2rem;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: .25rem 0 0;
  color: #111827;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.15;
}

.section-kicker {
  margin: 0;
  color: #126b55;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.panel,
.metric-card {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 20px 60px -42px rgba(17, 24, 39, .45);
}

.panel {
  margin-bottom: 1.25rem;
  padding: 1.25rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.1rem;
}

.panel h3 {
  margin: 1.1rem 0 .55rem;
  font-size: .86rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #4b5563;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: 0 0 1.25rem;
}

.tab {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-weight: 750;
  padding: .65rem .85rem;
}

.tab:hover,
.tab.active {
  border-color: #2f8a61;
  background: #ecfdf5;
  color: #166534;
  text-decoration: none;
}

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

.metric-card {
  padding: 1.15rem;
}

.metric-card span {
  color: #6b7280;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: .5rem;
  font-size: 2rem;
  line-height: 1;
}

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

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

.span-2 {
  grid-column: 1 / -1;
}

.field-label {
  display: block;
  margin-bottom: .45rem;
  color: #374151;
  font-size: .85rem;
  font-weight: 750;
}

.field-input {
  display: block;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font: inherit;
  padding: .8rem .9rem;
}

.field-input:focus {
  border-color: #2f8a61;
  box-shadow: 0 0 0 4px rgba(47, 138, 97, .14);
  outline: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #374151;
  font-weight: 650;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: .7rem 1rem;
  text-decoration: none;
}

.btn-small {
  min-height: 34px;
  padding: .45rem .65rem;
  font-size: .82rem;
}

.btn-primary {
  border: 1px solid #2f8a61;
  background: #2f8a61;
  color: #fff;
}

.btn-primary:hover {
  background: #246d4e;
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #111827;
}

.btn-secondary:hover {
  border-color: #94a3b8;
  color: #111827;
  text-decoration: none;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.data-table th {
  background: #f8fafc;
  color: #6b7280;
  font-size: .72rem;
  letter-spacing: .14em;
  padding: .8rem;
  text-align: left;
  text-transform: uppercase;
}

.data-table td {
  border-top: 1px solid #e5e7eb;
  color: #374151;
  padding: .85rem;
  vertical-align: top;
}

.table-actions {
  display: flex;
  gap: .45rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d8dee8;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-size: .72rem;
  font-weight: 800;
  margin: .1rem .25rem .1rem 0;
  padding: .22rem .5rem;
  white-space: nowrap;
}

.chip.own {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: #166534;
}

.chip.competitor {
  border-color: #fde68a;
  background: #fffbeb;
  color: #854d0e;
}

.muted {
  color: #64748b;
  font-size: .8rem;
  margin-top: .2rem;
}

.delta {
  font-weight: 900;
}

.delta.up {
  color: #15803d;
}

.delta.down {
  color: #b91c1c;
}

.response-list {
  display: grid;
  gap: .9rem;
}

.response-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
  padding: 1rem;
}

.response-item p {
  margin: .6rem 0 0;
  color: #374151;
  line-height: 1.55;
}

.response-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.response-meta span {
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  font-size: .75rem;
  font-weight: 800;
  padding: .22rem .45rem;
}

.mt {
  margin-top: 1rem;
}

.status-badge,
.presence {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid;
  padding: .25rem .55rem;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-success,
.presence.yes {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: #166534;
}

.status-warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.status-danger,
.presence.no {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.status-muted {
  border-color: #e5e7eb;
  background: #f3f4f6;
  color: #4b5563;
}

.empty-state {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  padding: 1.5rem;
  text-align: center;
}

.empty-state.compact {
  padding: .75rem;
  text-align: left;
}

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

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

.kv-grid dt {
  color: #6b7280;
  font-size: .73rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.kv-grid dd {
  overflow-wrap: anywhere;
  margin: .2rem 0 0;
  color: #111827;
  font-weight: 650;
}

.plain-list {
  display: grid;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  color: #374151;
  padding: .75rem;
}

.result-text {
  border-left: 3px solid #2f8a61;
  margin: 0 0 1rem;
  background: #f8fafc;
  color: #374151;
  padding: .8rem 1rem;
}

.error-box {
  margin-top: 1rem;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  padding: .8rem;
}

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

.flash {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  padding: .8rem 1rem;
}

.flash-success {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: #166534;
}

.flash-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.flash-warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
}

.auth-panel {
  width: min(440px, 100%);
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px -55px rgba(17, 24, 39, .75);
  padding: 1.5rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: 1.3rem;
}

.auth-panel h1 {
  margin: 0 0 1.2rem;
  font-size: 1.8rem;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  font-weight: 650;
}

.break-all {
  word-break: break-all;
}

@media (max-width: 980px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

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

  .metrics-grid,
  .detail-grid,
  .surface-grid,
  .form-grid,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 1rem;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

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