/* Aviveil Base Elements and Utilities */
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
  background-color: var(--bg);
  background: var(--bg);
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  background-color: var(--bg);
  background: var(--bg);
  color: var(--tx);
  font: 14px/1.5 "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

img, video, canvas {
  max-width: 100%;
  height: auto;
}

h2 {
  font-weight: 500;
  margin: 0 0 16px;
  font-size: clamp(18px, 4vw, 22px);
}

h3 {
  font-weight: 500;
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--mu);
}

.mu {
  color: var(--mu);
  font-size: 12px;
}

.card {
  background: var(--p);
  border: 1px solid var(--ln);
  border-radius: 12px;
  padding: 16px;
}

.g2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.g3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.g4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.dg {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  align-items: start;
}

.dc {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dash-first-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 14px;
  align-items: stretch;
}

.dash-left-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.dash-metrics-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
}

.dash-metrics-stack .dash-metric-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.num {
  font-size: 28px;
  font-weight: 300;
}

.n1 { color: var(--a); }
.n2 { color: var(--b); }
.n3 { color: var(--y); }
.n4 { color: var(--g); }

button, select, input, textarea {
  font: inherit;
  color: var(--tx);
  background: var(--p2);
  border: 1px solid var(--ln);
  border-radius: 8px;
  padding: 7px 10px;
}

button {
  cursor: pointer;
  background: var(--p2);
  color: var(--tx);
  border: 1px solid var(--ln);
  border-radius: 8px;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

html[data-theme="light"] button {
  background: var(--p2);
  color: var(--tx);
  border: 1px solid var(--ln);
}

button:hover {
  border-color: var(--a);
}

button.pr {
  background: var(--a);
  color: #241d2e;
  border: none;
  font-weight: 500;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--a) 45%, transparent);
  outline-offset: 2px;
  border-color: var(--a);
}

html[data-theme="light"] button.pr {
  background: var(--a);
  color: #ffffff;
  border: none;
}

button.l {
  background: none;
  border: 0;
  color: var(--mu);
  padding: 2px 6px;
  font-size: 12px;
}

button.l:hover {
  color: var(--r);
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--ln);
}

.row:last-child {
  border: 0;
}

.pc {
  cursor: pointer;
}

.pc:hover {
  border-color: var(--a);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  flex-shrink: 0;
  white-space: nowrap;
}

.tabs button.on {
  border-color: var(--a);
  color: var(--a);
}

.hid {
  display: none !important;
}

/* Mobile & Tablet Base Touch Optimizations */
@media (max-width: 820px) {
  /* Prevent iOS Safari auto-zoom on input focus by ensuring >= 16px font-size */
  input, select, textarea {
    font-size: 16px;
  }

  button, select {
    min-height: 44px;
    touch-action: manipulation;
  }

  button.l {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }

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

  .top {
    gap: 10px;
  }
}

/* Pinch-zoom is allowed; keep iOS from auto-zooming into fields on any touch device (iPad included). */
@media (hover: none) and (pointer: coarse) {
  input, select, textarea {
    font-size: 16px;
  }
}
