*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: 16px/1.5 var(--font); }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--blue-ink); }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.pad { padding: 16px; }
.icon { width: 20px; height: 20px; display: block; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 8px 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 0 0 16px; overflow-x: auto; }
.card.list { padding: 0; overflow: hidden; }

/* coloured icon squares */
.chip { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; color: #fff; flex: none; }
.chip-blue { background: var(--blue); } .chip-green { background: var(--green); } .chip-orange { background: var(--orange); }
.chip-red { background: var(--red); } .chip-purple { background: var(--purple); } .chip-teal { background: var(--teal); }
.chip-rose { background: var(--rose); }
.chip-gray { background: var(--gray); }

/* buttons (also covers the class names django-two-factor-auth's templates use) */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--touch); padding: 0 18px; border: 0; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; background: #E8E8ED; color: var(--text); }
.btn-primary { background: var(--blue-ink); color: #fff; }
.btn-danger { background: var(--red-ink); color: #fff; }
.btn-link { background: transparent; color: var(--blue-ink); }
.btn-block { width: 100%; }
.btn:focus-visible, .nav-link:focus-visible, .tab:focus-visible, .row:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--blue-ink); outline-offset: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 16px; }

/* forms (Django renders each field as a div) */
form div:has(> input, > select) { margin-bottom: 12px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; min-height: var(--touch); padding: 8px 12px; font: inherit; color: var(--text); background: #fff; border: 1px solid #C7C7CC; border-radius: var(--radius-sm); }
.helptext, form div > .helptext { color: var(--text-2); font-size: 14px; }
.errorlist { list-style: none; margin: 0 0 8px; padding: 0; color: var(--red-ink); font-size: 14px; }
.messages { list-style: none; margin: 0 0 16px; padding: 0; }
.message { background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 8px; }

/* list rows (Settings) */
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; color: var(--text); text-decoration: none; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-text { display: flex; flex-direction: column; flex: 1; }
.row-go { color: var(--text-2); }
.row-go .icon { width: 16px; height: 16px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.pill-on { background: #E3F5E8; color: var(--green-ink); }
.pill-off { background: #FFF1F2; color: var(--red-ink); }

/* focus layout (login, 2FA setup) */
.focus { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.focus-card { width: 100%; max-width: 440px; }
.focus-card img { max-width: 100%; height: auto; background: #fff; }

/* shell: phone first (bottom tab bar), sidebar from 1024px */
.shell { min-height: 100vh; }
.content { padding: 16px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); max-width: 960px; margin: 0 auto; }
.sidebar { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(255, 255, 255, 0.94); border-top: 1px solid var(--line); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--touch); color: var(--text-2); text-decoration: none; font-size: 12px; }
.tab.is-active { color: var(--text); font-weight: 600; }
.tab .chip { width: 28px; height: 28px; }

@media (min-width: 1024px) {
  .sidebar { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); padding: 20px 12px; background: rgba(255, 255, 255, 0.7); border-right: 1px solid var(--line); }
  .brand { font-size: 20px; font-weight: 700; padding: 0 12px 16px; }
  .sidebar nav { flex: 1; }
  .nav-link { display: flex; align-items: center; gap: 12px; min-height: var(--touch); padding: 6px 12px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
  .nav-link.is-active { background: rgba(0, 0, 0, 0.07); font-weight: 600; }
  .sidebar-foot { display: flex; flex-direction: column; gap: 8px; padding: 0 12px; word-break: break-all; }
  .content { margin-left: var(--sidebar-w); max-width: none; padding: 32px 40px; }
  .content > * { max-width: 880px; }
  .tabbar { display: none; }
}
