*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 1rem/1.55 Inter, system-ui, sans-serif;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { line-height: 1.15; font-weight: 620; }
h1 { margin: 0; font-size: clamp(1.85rem, 1.35rem + 2vw, 3.25rem); letter-spacing: -.05em; }
h2 { font-size: clamp(1.25rem, 1.125rem + .5vw, 1.65rem); letter-spacing: -.025em; }
a { color: var(--link); text-underline-offset: .18em; }
a:hover { color: var(--ink); }
button, input, select, textarea { font: inherit; }
li { overflow-wrap: anywhere; }

:focus-visible {
  outline: .1875rem solid var(--focus);
  outline-offset: .1875rem;
}

.skip-link {
  position: absolute;
  z-index: 2;
  inset: .75rem auto auto .75rem;
  padding: .65rem 1rem;
  background: var(--surface);
  transform: translateY(-200%);
}

.skip-link:focus { transform: translateY(0); }
.crm-shell { min-height: 100vh; }

.crm-shell--signed-in {
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr);
}

.crm-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: clamp(1rem, 2.5vw, 2rem);
  background: var(--secondary);
  border-bottom: 1px solid var(--line);
}

.crm-shell--signed-in .crm-header {
  position: sticky;
  inset-block-start: 0;
  align-self: start;
  align-content: start;
  min-height: 100vh;
  max-height: 100vh;
  overflow: auto;
  border: 0;
  border-inline-end: 1px solid var(--line);
}

.crm-brand {
  display: inline-flex;
  align-items: baseline;
  gap: .4em;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 680;
  letter-spacing: -.055em;
  text-decoration: none;
}

.crm-brand .brand-full > span {
  font-size: .66em;
  letter-spacing: .035em;
  font-weight: 560;
}

.brand-short { display: none; }

.sidebar-toggle {
  display: inline-grid;
  place-items: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border: 1px solid var(--control-line);
  border-radius: .5rem;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.sidebar-toggle:hover { background: var(--canvas); }
.crm-logout .sidebar-item { gap: .55rem; }
.sidebar-hint {
  position: fixed;
  z-index: 3;
  max-width: 14rem;
  padding: .4rem .65rem;
  border: 1px solid var(--control-line);
  border-radius: .4rem;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 .2rem .7rem var(--shadow);
  font-size: .875rem;
  pointer-events: none;
}

@media (width > 54rem) {
  .crm-shell--collapsed { grid-template-columns: 4.75rem minmax(0, 1fr); }
  .crm-shell--collapsed .crm-header { padding-inline: .75rem; justify-content: center; }
  .crm-shell--collapsed .brand-full,
  .crm-shell--collapsed .sidebar-label { display: none; }
  .crm-shell--collapsed .brand-short { display: inline; }
  .crm-shell--collapsed .crm-menu > a { justify-content: center; padding-inline: 0; }
  .crm-shell--collapsed .crm-logout .sidebar-item { width: 100%; padding-inline: 0; }
  .crm-shell--collapsed .sidebar-toggle svg { transform: scaleX(-1); }
}

@media (width > 54rem) and (prefers-reduced-motion: no-preference) {
  .crm-shell--signed-in.crm-shell--ready { transition: grid-template-columns 180ms ease; }
}

.crm-menu {
  flex-basis: 100%;
  display: grid;
  gap: .375rem;
  margin-block-start: clamp(.25rem, 2vw, 1.75rem);
}

.crm-menu > a {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-height: 2.75rem;
  padding: .55rem .75rem;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: .5rem;
  font-size: .9375rem;
  text-decoration: none;
}

.crm-menu > a:hover { background: var(--canvas); }
.crm-menu > a[aria-current] {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: inset .25rem 0 var(--focus);
  font-weight: 650;
}

.crm-logout { margin-block-start: .75rem; }
.crm-icon { width: 1.25rem; height: 1.25rem; flex: none; vertical-align: middle; }
.crm-workspace { min-width: 0; }
.crm-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
  min-height: 4rem;
  padding: .5rem clamp(1rem, 3vw, 3rem);
  border-bottom: 1px solid var(--line);
}
.crm-context { min-width: 0; overflow-wrap: anywhere; }
.crm-section { color: var(--muted); font-size: .875rem; font-weight: 650; }
.crm-topbar-actions, .crm-user { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.crm-user { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.theme-toggle { flex: none; }
.crm-main {
  min-width: 0;
  width: min(100%, 96rem);
  margin-inline: auto;
  padding: clamp(1rem, 3vw, 3rem);
  overflow-wrap: anywhere;
}

.crm-main > section { max-width: 72rem; border-top: 1px solid var(--line); padding-block: 1rem; }
.crm-main > form { max-width: 48rem; }
.inline { display: inline-block; margin: .25rem; }

@media (max-width: 54rem) {
  .crm-shell--signed-in { display: block; }
  .crm-shell--signed-in .crm-header {
    position: static;
    min-height: auto;
    max-height: none;
    overflow: visible;
    border: 0;
    border-bottom: 1px solid var(--line);
  }
  .crm-header { padding-block: .65rem; }
  .crm-topbar { min-height: 3.5rem; gap: .5rem; }
  .crm-topbar-actions, .crm-user { gap: .4rem; }
  .crm-user .crm-icon { display: none; }
}

@media (max-width: 28rem) {
  .theme-label { display: none; }
  .crm-user { font-size: .75rem; }
}
