* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text-strong);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.6rem;
}
h2 {
  font-size: 1.25rem;
}
h3 {
  font-size: 1.02rem;
}

p {
  margin: 0;
}

a {
  color: var(--accent-teal);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-dim);
}
.faint {
  color: var(--text-faint);
}
.small {
  font-size: 0.82rem;
}
.label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  font-weight: 600;
}
.right {
  text-align: right;
}
.center {
  text-align: center;
}
.nowrap {
  white-space: nowrap;
}
.hidden {
  display: none !important;
}

/* ---------- App shell ---------- */

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

.sidebar {
  width: 230px;
  flex: 0 0 230px;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
}
.brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-gradient);
  box-shadow: var(--hero-glow);
}
.brand .name {
  font-weight: 700;
  color: var(--text-strong);
  font-size: 0.96rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.nav-link .ico {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
}
.nav-link:hover {
  background: var(--bg-elev);
  color: var(--text);
}
.nav-link.active {
  background: var(--bg-elev);
  color: var(--text-strong);
  border-color: var(--border);
}
.nav-link.active .ico {
  filter: drop-shadow(0 0 6px var(--accent-teal));
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  z-index: 20;
}
.topbar .title h1 {
  font-size: 1.3rem;
}
.topbar .title .label {
  margin-bottom: 2px;
}

.content {
  padding: 22px;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bottom-nav {
  display: none;
}

/* ---------- Layout helpers ---------- */
.grid {
  display: grid;
  gap: 14px;
}
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.row.wrap {
  flex-wrap: wrap;
}
.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.grow {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .content {
    padding: 16px 14px calc(86px + env(safe-area-inset-bottom));
  }
  .topbar {
    padding: 14px 16px;
  }
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--bg-soft) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav .nav-link {
    flex-direction: column;
    gap: 3px;
    padding: 4px 8px;
    font-size: 0.64rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 0;
    background: none;
  }
  .bottom-nav .nav-link .ico {
    font-size: 1.25rem;
  }
  .bottom-nav .nav-link.active {
    color: var(--accent-teal);
    background: none;
  }
}
