/*
  COMPONENTS
  One block per piece of the site, in this order:
    1. Navigation bar        5. Bill Page
    2. Sign in page          6. Admin tab
    3. Tracking tabs, search 7. Small screens
    8. Dashboard page (Your Brief)
    4. Bill rows, star, "!"
  All spacing comes from the scale in tokens.css.
*/

/* ---- 1. Navigation bar ------------------------------------------------ */

/* Solid green bar with the white logo, per the brand guide:
   "Use white logo on colored backgrounds". */
.nav {
  background: var(--color-green);
  color: var(--color-white);
}

.nav__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  column-gap: var(--space-6);
  max-width: var(--page-width);
  min-height: 64px;
  margin-inline: auto;
  padding-inline: var(--space-5);
}

.nav__logo-link {
  display: flex;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-4);
  color: var(--color-white);
  text-decoration: none;
}

.nav__logo {
  width: auto;
  height: 28px;
}

.nav__title {
  padding-left: var(--space-3);
  border-left: 1px solid var(--color-white);
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  white-space: nowrap;
}

.tabs {
  display: flex;
  flex-wrap: wrap;  /* four tabs can be wider than a phone */
  column-gap: var(--space-5);
}

.tab {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding-inline: var(--space-1);
  border-block: 4px solid transparent; /* top one keeps the text centered */
  color: var(--color-white);
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  text-decoration: none;
}

.tab:hover {
  color: var(--color-white);
  text-decoration: underline;
  text-underline-offset: 6px;
}

.tab.is-active {
  border-bottom-color: var(--color-white);
}

.nav__user,
.nav__user form {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav__user {
  margin-left: auto;
  padding-block: var(--space-3);
}

/* Username on one line, the role under it: two separate things. */
.nav__identity {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

/* The name links to the Account page. */
.nav__username,
.nav__username:hover {
  color: var(--color-white);
  font-family: var(--font-heading);
  font-size: var(--text-small);
  font-weight: 700;
  line-height: 1.2;
}

.nav__username {
  text-decoration: none;
}

.nav__username:hover,
.nav__username[aria-current="page"] {
  text-decoration: underline;
}

.nav__role {
  font-size: 0.8125rem;
  line-height: 1.2;
}

.nav__role-select {
  min-height: 32px;
  padding-block: var(--space-1);
  border-color: var(--color-white);
  font-size: var(--text-small);
}

.nav .link-button,
.nav .link-button:hover {
  color: var(--color-white);
}

.nav :focus-visible {
  outline-color: var(--color-white);
}

/* ---- 2. Sign in page -------------------------------------------------- */

.login {
  /* Height of the riverbank scene. The page keeps this much room free at
     the bottom so the form never sits on top of the drawing. */
  --scene-height: clamp(120px, 24dvh, 220px);

  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  min-height: 100dvh;
  padding: var(--space-6) var(--space-4) calc(var(--scene-height) + var(--space-6));
  background: var(--color-green);
  color: var(--color-white);
}

.login__logo {
  width: 280px;
  height: auto;
}

.login__title {
  color: var(--color-white);
  text-align: center;
}

/* "User: [____]" with the label beside the box, as sketched. */
.login__form {
  display: grid;
  grid-template-columns: auto minmax(0, 240px);
  align-items: center;
  gap: var(--space-3);
}

.login__form label {
  font-weight: 700;
}

.login__error,
.login__submit {
  grid-column: 1 / -1;
}

.login .input {
  border-color: var(--color-white);
}

.login__submit {
  border-color: var(--color-white);
  background: var(--color-white);
  color: var(--color-green);
}

.login__error {
  background: var(--color-white);
}

/* Under the Sign in button: Forgot my password, Create an account. */
.login__links {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-small);
}

.login a,
.login a:hover {
  color: var(--color-white);
}

/* The pages before sign in other than Sign in itself (auth_base.html). */
.login__panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: 420px;
}

.login__text {
  text-align: center;
}

.login__form--wide {
  grid-template-columns: auto minmax(0, 1fr);
}

.login :focus-visible {
  outline-color: var(--color-white);
}

/* Riverbank scene (partials/_river_scene.html). Decorative only: it is
   pinned to the bottom of the sign in page, scrolls with the page, and
   never takes clicks or keyboard focus. */
.login__scene {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--scene-height);
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.river {
  width: 100%;
  height: 100%;
  max-width: none;
}

/* Flat colors only, all shades of the Harpeth green (tokens.css). */
.river__water { fill: var(--color-green-water); }
.river__far { fill: var(--color-green-far); }
.river__near,
.river__fish,
.river__bird,
.river__canoe-move,
.river__duck-move,
.river__otter-move { fill: var(--color-green-near); }

.river__stalk,
.river__leg,
.river__neck,
.river__plume,
.river__twig,
.river__paddle-shaft,
.river__otter-tail {
  fill: none;
  stroke: var(--color-green-near);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.river__stalk { stroke-width: 1.6; }
.river__leg { stroke-width: 1.8; }
.river__neck { stroke-width: 5; }
.river__plume { stroke-width: 1.4; }
.river__twig { stroke-width: 2.4; }
.river__paddle-shaft { stroke-width: 1.8; }
.river__otter-tail { stroke-width: 3.2; }

.river__ripple,
.river__splash,
.river__ring {
  fill: none;
  stroke: var(--color-green-ripple);
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* Still picture: what people see with "reduce motion" turned on.
   The fish stays under water and the birds rest in the sky. */
.river__ripple { opacity: 0.55; }
.river__splash { opacity: 0; }
.river__fish-arc { transform: translateY(20px); }
.river__bird--1 { transform: translate(24vw, calc(var(--scene-height) * 0.22)); }
.river__bird--2 { transform: translate(29vw, calc(var(--scene-height) * 0.34)) scale(0.75); }
.river__ring { opacity: 0; }
.river__canoe-move { transform: translateX(520px); }
.river__duck-move { transform: translateX(40px); }
.river__duck-fly { opacity: 0; }
.river__otter-dive { transform: translateY(24px); }  /* under water */
.river__otter-tail { opacity: 0; }
.river__beaver-move { transform: translate(364px, 152px); }

/* Motion. Every loop has a different length so the scene never visibly
   starts over. Negative delays start each loop part way through. */
@media (prefers-reduced-motion: no-preference) {
  /* Ripples drift a short way and fade in and out. */
  .river__ripple {
    opacity: 0;
    animation: river-ripple 11s linear infinite;
  }
  .river__ripple--1 { animation-duration: 13s; animation-delay: -2s; }
  .river__ripple--2 { animation-duration: 17s; animation-delay: -9s; }
  .river__ripple--3 { animation-duration: 11s; animation-delay: -5s; }
  .river__ripple--4 { animation-duration: 19s; animation-delay: -14s; }
  .river__ripple--5 { animation-duration: 14s; animation-delay: -1s; }
  .river__ripple--6 { animation-duration: 16s; animation-delay: -11s; }
  .river__ripple--7 { animation-duration: 12s; animation-delay: -7s; }
  .river__ripple--8 { animation-duration: 18s; animation-delay: -4s; }

  /* Reeds lean a few degrees from their base. */
  .river__sway { animation: river-sway 4.3s ease-in-out infinite alternate; }
  .river__sway--2 { animation-duration: 5.1s; animation-delay: -3s; }
  .river__sway--3 { animation-duration: 6.2s; animation-delay: -5s; }

  .river__branch {
    transform-origin: 420px 54px;
    animation: river-branch 9.1s ease-in-out infinite alternate;
  }

  /* The heron stands still, then tilts its head now and then. */
  .river__heron-head {
    transform-origin: 15px -101px;
    animation: river-heron 23s ease-in-out infinite;
    animation-delay: -6s;
  }

  /* The fish jumps once every 31 seconds. One part slides it sideways,
     the other lifts it in an arc, so together it leaps. */
  .river__fish-across { animation: river-fish-across 31s linear infinite; animation-delay: -18s; }
  .river__fish-arc { animation: river-fish-arc 31s linear infinite; animation-delay: -18s; }
  .river__splash {
    transform-box: fill-box;
    transform-origin: center;
    animation: river-splash-out 31s ease-out infinite;
    animation-delay: -18s;
  }
  .river__splash--in { animation-name: river-splash-in; }

  /* Birds cross the page, then wait out of sight before the next pass. */
  .river__bird--1 { animation: river-bird-1 41s linear infinite; animation-delay: -36s; }
  .river__bird--2 { animation: river-bird-2 41s linear infinite; animation-delay: -34.5s; }
  .river__wings { animation: river-flap 0.42s ease-in-out infinite alternate; }
  .river__bird--2 .river__wings { animation-duration: 0.37s; }

  /* A man paddles a canoe across every 59 seconds. */
  .river__canoe-move { animation: river-canoe 59s linear infinite; animation-delay: -12s; }
  .river__canoe-bob { animation: river-bob 3.1s ease-in-out infinite alternate; }
  .river__paddle {
    transform-origin: -7px -24px;
    animation: river-paddle 1.6s ease-in-out infinite alternate;
  }

  /* A duck surfaces, swims a little way, then flies off (every 37 seconds). */
  .river__duck-move { animation: river-duck-move 37s linear infinite; animation-delay: -2s; }
  .river__duck-sit { animation: river-duck-sit 37s linear infinite; animation-delay: -2s; }
  .river__duck-fly { animation: river-duck-fly 37s linear infinite; animation-delay: -2s; }
  .river__duck-wings { animation: river-flap 0.22s ease-in-out infinite alternate; }
  .river__ring {
    transform-box: fill-box;
    transform-origin: center;
  }
  .river__ring--duck-up { animation: river-ring-duck-up 37s ease-out infinite; animation-delay: -2s; }
  .river__ring--duck-off { animation: river-ring-duck-off 37s ease-out infinite; animation-delay: -2s; }

  /* An otter swims to the middle and dives (every 47 seconds). */
  .river__otter-move { animation: river-otter-move 47s linear infinite; animation-delay: -27s; }
  .river__otter-dive {
    transform-origin: -14px 0;
    animation: river-otter-dive 47s ease-in-out infinite;
    animation-delay: -27s;
  }
  .river__otter-tail { animation: river-otter-tail 47s linear infinite; animation-delay: -27s; }
  .river__ring--otter { animation: river-ring-otter 47s ease-out infinite; animation-delay: -27s; }

  /* A beaver comes down the right bank, stops at the water, and turns back (every 53 seconds). */
  .river__beaver-move { animation: river-beaver-move 53s linear infinite; animation-delay: -40s; }
  .river__beaver-face { animation: river-beaver-face 53s step-end infinite; animation-delay: -40s; }
  .river__beaver-step { animation: river-bob-step 0.45s ease-in-out infinite alternate; }
}

@keyframes river-ripple {
  0% { transform: translateX(-20px); opacity: 0; }
  30% { opacity: 0.7; }
  70% { opacity: 0.7; }
  100% { transform: translateX(40px); opacity: 0; }
}

/* The reeds lean further now, with a small gust in the middle of each swing. */
@keyframes river-sway {
  0% { transform: rotate(-5deg); }
  45% { transform: rotate(3deg); }
  60% { transform: rotate(1.5deg); }
  100% { transform: rotate(6.5deg); }
}

@keyframes river-branch {
  from { transform: rotate(-0.9deg); }
  to { transform: rotate(1.2deg); }
}

@keyframes river-heron {
  0%, 30% { transform: rotate(0deg); }
  33%, 41% { transform: rotate(-4deg); }
  44%, 72% { transform: rotate(0deg); }
  76%, 86% { transform: rotate(7deg); }
  90%, 100% { transform: rotate(0deg); }
}

/* The jump takes the first 4% of the loop (about 1.2 seconds). */
@keyframes river-fish-across {
  0% { transform: translateX(0); }
  4%, 100% { transform: translateX(52px); }
}

@keyframes river-fish-arc {
  0% { transform: translateY(16px) rotate(-62deg); animation-timing-function: cubic-bezier(0.2, 0.6, 0.5, 1); }
  2% { transform: translateY(-36px) rotate(0deg); animation-timing-function: cubic-bezier(0.5, 0, 0.8, 0.4); }
  4%, 100% { transform: translateY(16px) rotate(62deg); }
}

@keyframes river-splash-out {
  0% { transform: scale(0.2); opacity: 0; }
  0.6% { opacity: 0.8; }
  5%, 100% { transform: scale(1.6); opacity: 0; }
}

@keyframes river-splash-in {
  0%, 3.4% { transform: scale(0.2); opacity: 0; }
  4% { opacity: 0.8; }
  9%, 100% { transform: scale(1.8); opacity: 0; }
}

/* Each bird is on screen for the first 40% of its loop. */
@keyframes river-bird-1 {
  0% { transform: translate(-4vw, calc(var(--scene-height) * 0.36)); }
  20% { transform: translate(50vw, calc(var(--scene-height) * 0.2)); }
  40%, 100% { transform: translate(104vw, calc(var(--scene-height) * 0.1)); }
}

@keyframes river-bird-2 {
  0% { transform: translate(-4vw, calc(var(--scene-height) * 0.48)) scale(0.75); }
  20% { transform: translate(50vw, calc(var(--scene-height) * 0.36)) scale(0.75); }
  40%, 100% { transform: translate(104vw, calc(var(--scene-height) * 0.16)) scale(0.75); }
}

@keyframes river-flap {
  from { transform: scaleY(1); }
  to { transform: scaleY(-0.55); }
}

/* Canoe: crosses in the first 46% of the loop (about 27 seconds). */
@keyframes river-canoe {
  0% { transform: translateX(-780px); }
  46%, 100% { transform: translateX(1380px); }
}

@keyframes river-bob {
  from { transform: translateY(-1px); }
  to { transform: translateY(1.2px); }
}

@keyframes river-paddle {
  from { transform: rotate(-28deg); }
  to { transform: rotate(18deg); }
}

/* Duck: rises (0-3%), swims (3-18%), runs on the water and lifts off
   (18-20%), flies up and off the page (20-30%), then waits. */
@keyframes river-duck-move {
  0% { transform: translate(0, 16px); }
  3% { transform: translate(0, 0); }
  18% { transform: translate(72px, 0); }
  20% { transform: translate(86px, -8px); }
  30%, 100% { transform: translate(480px, -280px); }
}

@keyframes river-duck-sit {
  0%, 19% { opacity: 1; }
  19.5%, 100% { opacity: 0; }
}

@keyframes river-duck-fly {
  0%, 19% { opacity: 0; }
  19.5%, 30% { opacity: 1; }
  30.5%, 100% { opacity: 0; }
}

@keyframes river-ring-duck-up {
  0% { transform: scale(0.2); opacity: 0; }
  1% { opacity: 0.8; }
  9%, 100% { transform: scale(2); opacity: 0; }
}

@keyframes river-ring-duck-off {
  0%, 18% { transform: scale(0.2); opacity: 0; }
  19% { opacity: 0.8; }
  26%, 100% { transform: scale(2.2); opacity: 0; }
}

/* Otter: swims in from far right (0-30%), noses down and slips under
   (30-36%), then stays under until the loop starts again off-page. */
@keyframes river-otter-move {
  0% { transform: translateX(1000px); }
  30%, 100% { transform: translateX(0); }
}

@keyframes river-otter-dive {
  0%, 30% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-6px, 3px) rotate(-28deg); }
  36%, 100% { transform: translate(-12px, 24px) rotate(-40deg); }
}

@keyframes river-otter-tail {
  0%, 31% { opacity: 0; }
  33% { opacity: 1; }
  35.5%, 100% { opacity: 0; }
}

@keyframes river-ring-otter {
  0%, 32% { transform: scale(0.2); opacity: 0; }
  33.5% { opacity: 0.8; }
  41%, 100% { transform: scale(2.2); opacity: 0; }
}

/* Beaver: walks down the bank from off-page (0-21%), stops at the edge
   (21-26%), turns, and walks back up and off (26-44%). The points follow
   the top of the right bank. */
@keyframes river-beaver-move {
  0% { transform: translate(452px, 138px); }
  4% { transform: translate(402px, 141px); }
  8% { transform: translate(364px, 152px); }
  12% { transform: translate(320px, 166px); }
  16% { transform: translate(286px, 176px); }
  19% { transform: translate(256px, 187px); }
  21%, 26% { transform: translate(244px, 193px); }
  30% { transform: translate(286px, 176px); }
  34% { transform: translate(332px, 163px); }
  38% { transform: translate(383px, 145px); }
  44%, 100% { transform: translate(452px, 138px); }
}

@keyframes river-beaver-face {
  0% { transform: scaleX(1); }
  25.5% { transform: scaleX(-1); }
  99% { transform: scaleX(1); }
}

@keyframes river-bob-step {
  from { transform: translateY(0); }
  to { transform: translateY(-1.4px); }
}

/* Narrow or short screens: a shorter scene with just the near banks, so
   the form, its error message, and the button keep their room. */
@media (max-width: 640px), (max-height: 600px) {
  .login { --scene-height: 96px; }
  .river__extra { display: none; }
}

@media (max-height: 440px) {
  .login { --scene-height: 64px; }
}

/* ---- 3. Tracking / Untracked tabs, search ------------------------------ */

.dashboard {
  max-width: 960px;
}

/* ---- 4. Bill rows, star, "!" ------------------------------------------ */

.bill-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Search bar above the bill lists: label, field + button, hint. */
.search__bar {
  display: flex;
  gap: var(--space-2);
}

.search__input {
  flex: 1 1 auto;
  min-width: 0;
}

.search__summary {
  align-items: center;
}

/* When a list has no bills, hide it and show the "No bills" line instead. */
.bill-list__empty {
  display: none;
  padding: var(--space-4);
  border: 1px dashed var(--color-line);
  border-radius: var(--radius);
  color: var(--color-muted);
  font-family: var(--font-heading);
  font-size: var(--text-small);
}

.bill-list:not(:has(.bill-row)) {
  display: none;
}

.bill-list:not(:has(.bill-row)) + .bill-list__empty {
  display: block;
}

/* The section a bill is being dragged over. */
.bill-section.is-drop-target .bill-list,
.bill-section.is-drop-target .bill-list__empty {
  outline: 2px solid var(--color-green);
  outline-offset: var(--space-1);
}

.bill-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) 64px minmax(0, 6fr) auto;
  grid-template-areas: "name ids change marks";
  align-items: center;
  gap: var(--space-2) var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: var(--border);
  border-radius: var(--radius);
  background: var(--color-white);
}

.bill-row:hover {
  border-color: var(--color-green);
}

/* Bills with a change nobody has reviewed yet. */
.bill-row--flagged {
  border-color: var(--color-flag);
  background: var(--color-flag-bg);
}

/* Urgent bills (the calendar mark): a green tone. Listed first. */
.bill-row--urgent {
  border-color: var(--color-green);
  background: var(--color-green-tint);
}

.bill-row.is-dragging {
  opacity: 0.4;
}

.bill-row__name {
  grid-area: name;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  color: var(--color-black);
  text-decoration: none;
}

/* Stretches the link over the whole row so the row is one big click target. */
.bill-row__name::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.bill-row__name:focus-visible {
  outline: none;
}

.bill-row__name:focus-visible::after {
  outline: 2px solid var(--color-black);
  outline-offset: 2px;
}

.bill-row__nickname {
  color: var(--color-green);
  font-family: var(--font-heading);
  font-size: var(--text-lead);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.bill-row__nickname .not-set {
  font-weight: 400;
}

.bill-row__date {
  color: var(--color-muted);
  font-size: var(--text-small);
  white-space: nowrap;
}

/* Tracking tab: the words of the last action under the nickname. Smaller
   type so longer actions fit; cut off after three lines. */
.bill-row__action {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  color: var(--color-muted);
  font-size: 0.8125rem;
  line-height: 1.35;
}

/* Tracking tab: the short notes, where the AI summary was.
   A return typed in the notes starts a new line here too. Up to three
   lines show; anything longer ends in "…". */
.bill-row__summary > .bill-row__notes {
  -webkit-line-clamp: 3;
  line-clamp: 3;
  font-style: italic;
  white-space: pre-line;
}

.bill-row__ids {
  grid-area: ids;
  display: flex;
  flex-direction: column;
  font-family: var(--font-heading);
  font-size: var(--text-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* The AI summary. (The grid area is still named "change": it took the
   place of the latest change.) Cut off after four lines so rows stay even. */
.bill-row__summary {
  grid-area: change;
  min-width: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.bill-row__summary > span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}

/* Sits above the stretched link so the star stays clickable. */
.bill-row__marks {
  grid-area: marks;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bill-row__flag-slot {
  display: flex;
  justify-content: center;
  width: 24px;
}

.flag {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-flag);
  color: var(--color-black);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.star-form {
  display: flex;
}

.star-button,
.star-static {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--control-height);
  height: var(--control-height);
  color: var(--color-green);
}

.star-button {
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
}

.star-button:hover {
  color: var(--color-black);
}

.star {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.is-tracked .star {
  fill: currentColor;
}

/* ---- 5. Bill Page ----------------------------------------------------- */

.bill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
  gap: var(--space-7);
}

.bill__name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bill__ids {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  font-family: var(--font-heading);
  font-size: var(--text-lead);
  font-weight: 600;
}

.bill__title {
  font-size: var(--text-lead);
}


.tag {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding-inline: var(--space-3);
  border: 1px solid var(--color-green);
  border-radius: var(--radius);
  background: var(--color-green);
  color: var(--color-white);
  font-family: var(--font-heading);
  font-size: var(--text-small);
  font-weight: 600;
}

/* Keywords: the extra tags Admins add, outlined so the main tag stands out. */
.tag-list {
  display: contents;
}

.tag--keyword {
  background: var(--color-white);
  color: var(--color-green);
  font-weight: 400;
}

.tag--empty {
  border-color: var(--color-line);
  background: none;
  color: var(--color-muted);
  font-style: italic;
  font-weight: 400;
}

.bullets {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-left: var(--space-5);
  list-style: disc;
}

.numbered {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-left: var(--space-5);
  list-style: decimal;
}

.numbered li::marker {
  color: var(--color-green);
  font-family: var(--font-heading);
  font-weight: 700;
}

.numbered .meta {
  display: block;
}

.notes-box {
  padding: var(--space-5);
  border: 1px solid var(--color-green);
  border-radius: var(--radius);
}

/* Heading on the left, a quiet note about who can see it beside it. */
.notes-box__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

.notes-box__hint {
  color: var(--color-muted);
  font-size: 0.8125rem;
  font-style: italic;
}

.notes-box__text {
  white-space: pre-wrap;
}

.review-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-flag);
  border-radius: var(--radius);
  background: var(--color-flag-bg);
  font-family: var(--font-heading);
}

.review-banner__text {
  flex: 1 1 240px;
}

/* ---- 6. Admin tab ----------------------------------------------------- */

.admin {
  max-width: 880px;
}

.admin__form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.admin__grow {
  flex: 1 1 240px;
}

.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-heading);
  font-size: 1rem;
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  border-bottom: var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.table thead th {
  border-bottom-color: var(--color-green);
  color: var(--color-green);
  font-size: var(--text-small);
  font-weight: 700;
}

.table tbody th {
  font-weight: 600;
}

/* LegiScan pulls: the counters, status line and run log. */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.stat {
  flex: 1 1 160px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-green);
  border-radius: var(--radius);
}

.stat dt {
  color: var(--color-muted);
  font-family: var(--font-heading);
  font-size: var(--text-small);
}

.stat dd {
  margin: 0;
  color: var(--color-green);
  font-family: var(--font-heading);
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.sync-status {
  font-family: var(--font-heading);
}

.sync-status--running {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-flag);
  border-radius: var(--radius);
  background: var(--color-flag-bg);
}

.admin__note {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-flag);
  border-radius: var(--radius);
  background: var(--color-flag-bg);
  font-family: var(--font-heading);
}

.sync-message {
  display: block;
  max-width: 320px;
  color: var(--color-muted);
  font-size: var(--text-small);
  white-space: normal;
}

/* ---- 8. Dashboard page (Your Brief, Changes, New) --------------------- */

.home {
  max-width: 960px;
}

/* "Your Brief" sits in a solid green band: the first thing on the page. */
.brief {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: var(--space-5);
  padding: var(--space-6);
  border-radius: var(--radius);
  background: var(--color-green);
  color: var(--color-white);
}

.brief__title {
  color: var(--color-white);
  font-size: var(--text-title);
  line-height: 1.2;
}

.brief__text {
  max-width: 68ch;
  font-size: var(--text-lead);
}

.brief .meta,
.brief .not-set,
.brief .link-button {
  color: var(--color-white);
}

.home__section {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: start;
  gap: var(--space-5);
}

.home__heading {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.bill-row__number {
  color: var(--color-green);
  font-weight: 700;
}

/* ---- Flags on fiscal notes and amendments (Bill Page) ---- */

.flaggable {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
}

.flaggable__text {
  display: flex;
  flex-direction: column;
}

.flaggable.is-flagged .flaggable__text a {
  font-weight: 700;
}

.flag-form {
  display: flex;
}

.flag-button,
.flag-static {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--color-muted);
}

.flag-button {
  cursor: pointer;
}

.flag-button:hover,
.flag-button:focus-visible {
  border-color: var(--color-green);
  color: var(--color-green);
}

.flag-icon__fill {
  fill: transparent;
}

.is-flagged {
  color: var(--color-green);
}

.is-flagged .flag-icon__fill {
  fill: currentColor;
}

/* ---- Urgent, archive, upcoming events ---- */

.urgent-form,
.archive-form {
  display: flex;
}

.urgent-button,
.archive-button,
.urgent-static {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--color-muted);
}

.urgent-button,
.archive-button {
  cursor: pointer;
}

.urgent-button:hover,
.urgent-button:focus-visible,
.archive-button:hover,
.archive-button:focus-visible {
  border-color: var(--color-green);
  color: var(--color-green);
}

/* On the Bill Page the buttons carry a word as well as the icon. */
.urgent-button--labeled,
.archive-button--labeled {
  min-height: var(--control-height);
  height: auto;
  padding-inline: var(--space-3);
  border-color: var(--color-line);
  color: var(--color-black);
}

.calendar-icon__fill {
  fill: transparent;
}

.calendar-icon__mark {
  stroke: transparent;
}

.is-urgent {
  color: var(--color-green);
}

.is-urgent .calendar-icon__fill {
  fill: currentColor;
}

.is-urgent .calendar-icon__mark {
  stroke: var(--color-white);
}

.urgent-button--labeled.is-urgent {
  border-color: var(--color-green);
  background: var(--color-green-tint);
  color: var(--color-green);
  font-weight: 700;
}

.tag-like {
  width: auto;
  padding-inline: var(--space-2);
  font-weight: 700;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.section-head .section-title {
  flex: 1 1 auto;
}

.review-banner--archived {
  border-color: var(--color-line);
  background: var(--color-white);
}

/* Upcoming Events: dates still to come are highlighted in yellow. */
.event-date {
  display: inline-block;
  font-weight: 700;
}

.event-date--upcoming {
  padding-inline: var(--space-1);
  border-radius: var(--radius);
  background: var(--color-flag-bg);
  box-shadow: inset 0 0 0 1px var(--color-flag);
}

/* The archive pop-up. */
.dialog {
  max-width: min(440px, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-5);
  border: 1px solid var(--color-green);
  border-radius: var(--radius);
  color: var(--color-black);
}

.dialog::backdrop {
  background: rgb(17 17 17 / 0.45);
}

/* ---- 7. Small screens ------------------------------------------------- */
/* Columns stack and rows wrap. The gaps themselves do not change. */

@media (max-width: 900px) {
  .brief,
  .home__section {
    grid-template-columns: minmax(0, 1fr);
  }

  .bill {
    grid-template-columns: minmax(0, 1fr);
  }

  .bill {
    gap: var(--space-6);
  }

  .tabs {
    order: 3;
    flex-basis: 100%;
  }
}

@media (max-width: 720px) {
  .bill-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name   marks"
      "ids    marks"
      "change change";
  }

  .bill-row__ids {
    flex-direction: row;
    gap: var(--space-3);
  }
}

@media (max-width: 640px) {
  .nav__inner {
    padding-inline: var(--space-4);
  }

  .nav__title {
    display: none;
  }
}

/* ---- Click-to-edit text (partials/_inline_edit.html) ------------------ */
/* Reads as plain text until clicked, then becomes a text box with Save and
   Cancel. Without JavaScript the text box always shows. */

.inline-edit {
  min-width: 0;
}

.inline-edit__display {
  display: inline;
  border-radius: var(--radius);
  cursor: text;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.inline-edit__display--multiline {
  display: block;
  margin-inline: calc(-1 * var(--space-2));
  padding: var(--space-1) var(--space-2);
  white-space: pre-wrap;
}

.inline-edit__display:hover,
.inline-edit__display:focus-visible {
  background: var(--color-flag-bg);
  box-shadow: 0 0 0 var(--space-1) var(--color-flag-bg);
  outline: none;
}

.inline-edit__display--multiline:hover,
.inline-edit__display--multiline:focus-visible {
  box-shadow: none;
}

.inline-edit__display:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 2px;
}

/* Without JavaScript: always show the form, never the click target. */
html:not(.js) .inline-edit__display,
html:not(.js) .inline-edit__trigger,
html:not(.js) .inline-edit__cancel,
html:not(.js) .inline-edit__keys {
  display: none;
}

/* With JavaScript: show the form only while editing. */
.js .inline-edit__form {
  display: none;
}

.js .inline-edit.is-editing .inline-edit__form {
  display: flex;
}

.js .inline-edit.is-editing .inline-edit__display,
.js .inline-edit.is-editing .inline-edit__trigger {
  display: none;
}

.inline-edit__keys {
  margin-left: auto;
}

.inline-edit.is-saving .inline-edit__form {
  opacity: 0.6;
  pointer-events: none;
}

/* Nickname: the text box takes the heading's size so nothing jumps. */
.bill__name .inline-edit--heading {
  flex: 0 1 auto;
}

.bill__name .inline-edit--heading.is-editing {
  flex: 0 1 560px;
}

.inline-edit--heading .inline-edit__field {
  color: var(--color-green);
  font-family: var(--font-heading);
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1.2;
}

.inline-edit--keywords .inline-edit__field {
  max-width: 560px;
}


/* ---- Saved searches (under the search bar) ----------------------------- */

.saved-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
}

.saved-search-form__name {
  flex: 0 1 320px;
}

.saved-searches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.saved-searches__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* One saved search: its name (a link) and, for Admins, a delete "x". */
.saved-search {
  display: inline-flex;
  align-items: stretch;
  min-height: 32px;
  border: 1px solid var(--color-green);
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: var(--text-small);
}

.saved-search form {
  display: flex;
}

.saved-search__link {
  display: inline-flex;
  align-items: center;
  padding-inline: var(--space-3);
  text-decoration: none;
}

.saved-search__link:hover {
  text-decoration: underline;
}

.saved-search.is-active {
  background: var(--color-green);
}

.saved-search.is-active .saved-search__link,
.saved-search.is-active .saved-search__delete {
  color: var(--color-white);
}

.saved-search__delete {
  padding-inline: var(--space-2);
  border: 0;
  border-left: 1px solid var(--color-green);
  background: none;
  color: var(--color-green);
  font-size: var(--text-base);
  line-height: 1;
  cursor: pointer;
}

.saved-search.is-active .saved-search__delete {
  border-left-color: var(--color-white);
}

.saved-search__delete:hover {
  color: var(--color-black);
}

/* ---- Reviewers' individual notes (Bill Page) ---------------------------- */

.reviewer-notes {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.reviewer-note + .reviewer-note {
  padding-top: var(--space-4);
  border-top: var(--border);
}

.reviewer-note__name {
  color: var(--color-green);
  font-family: var(--font-heading);
  font-size: var(--text-small);
  font-weight: 700;
}

/* ---- Account page -------------------------------------------------------- */

.account__form {
  max-width: 560px;
}

.account__pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 640px) {
  .account__pair {
    grid-template-columns: 1fr;
  }
}

/* ---- Confidentiality notice at the bottom of every page ------------------ */

.disclaimer {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding: 0 var(--space-5) var(--space-6);
}

.disclaimer__text {
  padding-top: var(--space-4);
  border-top: var(--border);
  color: var(--color-muted);
  font-size: 0.8125rem;
  font-style: italic;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .disclaimer {
    padding-inline: var(--space-4);
  }
}
