/* Page layouts: the signed-in app shell (sidebar beside the page) and the signed-out layout (brand
   panel beside one column). Plus the pieces every signed-in page starts with: header, tiles, cards. */

.skip-link {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 10;
  padding: 10px 16px;
  color: var(--ink);
  background: var(--buttercup);
  border-radius: var(--radius-s);
  font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* ---- the app shell ---- */
.app-layout { display: flex; min-height: 100vh; }
/* The sidebar column stays dark the whole height of a long page, not only the first screen. */
@media (min-width: 900px) {
  .app-layout { background: linear-gradient(90deg, var(--night) 0 256px, var(--milk) 256px); }
}

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 256px;
  height: 100vh;
  overflow: hidden auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 16px;
  color: var(--milk);
  /* Two soft spots on the coat, drawn as backgrounds so they never take focus or space. */
  background:
    radial-gradient(ellipse 66px 50px at calc(100% + 30px) calc(100% - 190px), var(--night-spot) 98%, transparent 100%),
    radial-gradient(ellipse 60px 45px at 30px calc(100% + 25px), var(--night-spot) 98%, transparent 100%),
    var(--night);
}

.logo { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: var(--milk); text-decoration: none; }
.logo:hover { color: var(--milk); }
.logo:focus-visible { outline-color: var(--buttercup); }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -0.01em; }

.role-chip { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--night-chip); border-radius: 14px; }
.role-chip .role { font-size: 0.75rem; color: var(--night-muted); }
.role-chip .scope { font-weight: 700; font-size: 0.95rem; overflow-wrap: anywhere; }

.side-nav ul { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--night-text);
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-m);
}
.side-nav a:hover { color: var(--milk); background: var(--night-chip); }
.side-nav a[aria-current="page"] { color: var(--ink); background: var(--milk); }
.side-nav a:focus-visible { outline-color: var(--buttercup); }

.account { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--night-line); }
.account .email { font-size: 0.85rem; color: var(--night-text); overflow-wrap: anywhere; }
button.ghost {
  align-self: flex-start;
  min-height: 36px;
  padding: 6px 16px;
  color: var(--milk);
  background: transparent;
  border: 1.5px solid var(--milk);
  font-size: 0.875rem;
  font-weight: 500;
}
button.ghost:hover { color: var(--ink); background: var(--milk); border-color: var(--milk); }
button.ghost:focus-visible { outline-color: var(--buttercup); }

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 1180px;
  padding: 36px 44px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.app-main:focus { outline: none; }

/* Narrow screens: the sidebar becomes a band across the top, its sections a wrapping row. */
@media (max-width: 899px) {
  .app-layout { flex-direction: column; }
  .sidebar { position: static; flex: none; height: auto; overflow: visible; gap: 14px; padding: 16px; }
  .role-chip { padding: 8px 12px; }
  .side-nav ul { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .side-nav a { min-height: 40px; padding: 8px 12px; gap: 8px; }
  .account { margin-top: 0; padding-top: 12px; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .app-main { padding: 24px 16px 48px; gap: 22px; }
}

/* ---- page header and tiles ---- */
.page-header { display: flex; flex-direction: column; gap: 8px; }
.page-intro { max-width: 680px; color: var(--spot); font-size: 1.05rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 96px), 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius-l); }
.tile-number { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--spot); font-size: 0.9rem; font-weight: 500; }

/* ---- panels: a white card with a soft border, the building block of most pages ---- */
.panel {
  padding: 22px 24px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-l);
}
.panel h2 { margin-bottom: 2px; }
@media (max-width: 899px) { .panel { padding: 18px; } }

/* ---- a titled block of a page, and its heading row ---- */
.block { display: flex; flex-direction: column; gap: 12px; }
.block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.back-link { align-self: flex-start; font-size: 0.9rem; font-weight: 500; }
.tile-attention { background: var(--buttercup-pale); border-color: var(--buttercup-line); }
.tile-attention .tile-label { color: var(--ink); }

/* ---- tables in a scrolling card ---- */
/* position: relative, so the screen-reader-only heading in a table's last column is clipped with the table
   instead of widening the whole page. */
.table-wrap { position: relative; overflow-x: auto; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius-l); }
.data-table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 0.95rem; }
.data-table th { padding: 12px 14px; text-align: left; font-size: 0.8rem; font-weight: 700; color: var(--spot); background: var(--wash); white-space: nowrap; }
.data-table td { padding: 14px; vertical-align: middle; border-top: 1px solid var(--line); }
.data-table .muted { color: var(--spot); }
.data-table .number { font-variant-numeric: tabular-nums; }
.data-table .action { text-align: right; }
.data-table th:first-child, .data-table td:first-child { padding-left: 20px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 20px; }

/* ---- campaign cards ---- */
.campaign-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.campaign-card { display: flex; gap: 16px; padding: 18px; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius-xl); }
.card-glyph {
  flex: 0 0 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pasture);
  background: var(--wash);
  border-radius: var(--radius-l);
}
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card-body h2 { font-size: 1.2rem; }
.card-action { margin-top: 4px; font-weight: 700; }
.card-action.muted { color: var(--spot); font-weight: 500; font-size: 0.9rem; }

/* ---- the signed-out layout ---- */
.public-layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.brand-panel {
  position: relative;
  overflow: hidden;
  flex: 1 1 380px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 40px;
  background: var(--card);
  border-right: 1px solid var(--line);
}
.coat { position: absolute; inset: 0; width: 100%; height: 100%; }
.brand-pill {
  position: relative;
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  color: var(--ink);
  background: var(--card);
  border-radius: var(--pill);
  text-decoration: none;
  box-shadow: 0 0 0 1.5px var(--line);
}
.brand-pill:hover { color: var(--ink); }
.brand-line {
  position: relative;
  align-self: flex-start;
  max-width: 420px;
  padding: 16px 20px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.65rem);
  line-height: 1.2;
  background: var(--card);
  border-radius: var(--radius-l);
}
.public-main { flex: 1 1 380px; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.public-content { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 22px; }
.intro { display: flex; flex-direction: column; gap: 8px; }
.intro p { color: var(--spot); }
.stack { display: flex; flex-direction: column; gap: 16px; }

@media (max-width: 799px) {
  .brand-panel { flex-basis: 100%; min-height: 200px; padding: 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .public-main { padding: 32px 16px; align-items: flex-start; }
}
