/* ==========================================================================
   EB Renewal Dashboard — base stylesheet
   Design tokens, reset, and the primitives every page shares (buttons,
   fields, utilities). Page-specific rules live in their own file beside
   this one. No build step.
   ========================================================================== */

:root {
  /* --- brand -------------------------------------------------------------
     A ramp built around the NCIA red, #d3131d. The mid step is the accent;
     the darker ones carry text and hover states, the pale ones carry fills
     and focus rings that must not compete with content. */
  --brand-900: #4a0509;
  --brand-800: #7a0b12;
  --brand-700: #a80f18;
  --brand-600: #d3131d;
  --brand-400: #ec5a5f;
  --brand-200: #f7c6c8;
  --brand-100: #fae3e4;
  --brand-050: #fdf4f4;

  /* Warm orange — the illustration's secondary only. Deliberately kept out
     of the interface, so nothing in the UI competes with the brand red. */
  --sun-500: #f5883c;
  --sun-300: #fbc38a;
  --sun-100: #fdeadb;

  /* --- neutrals ----------------------------------------------------------
     Warm greys, pulled a little toward the brand hue so they sit with it
     rather than reading as a separate cool palette. */
  --ink:     #2b1618;   /* headings */
  --ink-2:   #5f4144;   /* body */
  --ink-3:   #8b6b6e;   /* secondary, captions */
  --line:    #ecdcdd;   /* borders */
  --line-2:  #f6eeef;   /* hairlines, dividers */
  --bg:      #fdfbfa;   /* page */
  --surface: #ffffff;   /* cards */

  /* --- state -------------------------------------------------------------
     One green, one amber. Errors reuse the brand red: on this page there is
     no competing "destructive" meaning, and a second red would be noise. */
  --ok-600:    #1a8f4c;
  --ok-100:    #e2f5e9;
  --warn-600:  #b4690e;
  --warn-100:  #fdf0dc;
  --error-600: #c11119;
  --error-050: #fdf3f3;

  /* --- type --- */
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  /* --- shape --- */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Shadows tinted with the brand's dark step rather than pure black, so a
     lifted surface still reads as warm. */
  --shadow-1: 0 1px 2px rgba(74, 5, 9, .05), 0 1px 3px rgba(74, 5, 9, .04);
  --shadow-2: 0 2px 6px rgba(74, 5, 9, .05), 0 12px 28px rgba(74, 5, 9, .07);

  /* --- motion ---
     One duration and one easing, used everywhere. */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur:  .22s;
}

/* ==========================================================================
   Reset
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }

img, svg { display: block; max-width: 100%; }

/* Every table column reads from the left: headers, figures, badges and action
   buttons alike. Set here so a new table gets it without asking, and so a th
   does not fall back to the browser's centred default. */
th, td { text-align: left; }

button, input, select, textarea { font: inherit; color: inherit; }

/* ==========================================================================
   Utilities
   ========================================================================== */

/* Visible to a screen reader, not to the eye. Used for the labels on the OTP
   boxes and the group that holds them. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.is-hidden { display: none !important; }

/* ==========================================================================
   Focus
   ========================================================================== */

/* :focus-visible only — a ring on every mouse click is noise, but removing
   it outright strands keyboard users. */
:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform .08s var(--ease);
}

.btn-primary {
  background: var(--brand-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(74, 5, 9, .12);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-700);
  box-shadow: 0 2px 8px rgba(211, 19, 29, .24);
}

/* A press is 1px, not a bounce. */
.btn-primary:active:not(:disabled) {
  background: var(--brand-800);
  transform: translateY(1px);
  box-shadow: none;
}

/* Shared back navigation. A tinted brand-red surface keeps the way out of a
   detail screen visible without making a secondary action feel like a submit
   button. */
.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--brand-200);
  border-radius: 8px;
  background: var(--brand-050);
  color: var(--brand-700);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

.back-button:hover {
  border-color: var(--brand-400);
  background: var(--brand-100);
  color: var(--brand-800);
  box-shadow: 0 2px 8px rgba(168, 15, 24, .12);
}

.back-button:active {
  border-color: var(--brand-400);
  background: var(--brand-100);
  color: var(--brand-800);
  box-shadow: none;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .55;
  box-shadow: none;
}

/* --- loading -------------------------------------------------------------
   The label is replaced rather than hidden, so the button keeps its width
   and the card does not reflow while a request is in flight. */

.btn.is-loading { cursor: progress; }

.btn.is-loading .btn-label { visibility: hidden; }

.btn-spinner { display: none; }

.btn.is-loading .btn-spinner {
  display: block;
  position: absolute;
  width: 17px; height: 17px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* A text button that carries no weight of its own — the resend control. */
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-600);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover { color: var(--brand-700); }

/* ==========================================================================
   Fields
   ========================================================================== */

.field { margin-bottom: 18px; }

/* A real <label>, not a placeholder. A placeholder disappears the moment
   someone starts typing, which is exactly when they might need to check what
   the field wanted. */
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.field-input { position: relative; }

.field-icon {
  position: absolute;
  top: 50%; left: 13px;
  width: 18px; height: 18px;
  margin-top: -9px;
  color: var(--ink-3);
  pointer-events: none;
  transition: color var(--dur) var(--ease);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

.input::placeholder { color: #b9a1a3; }

.input:focus {
  border-color: var(--brand-600);
  /* A ring rather than a thicker border, so the field does not shift by a
     pixel when it takes focus. */
  box-shadow: 0 0 0 3px var(--brand-100);
}

.field-input:focus-within .field-icon { color: var(--brand-600); }

.input:disabled {
  background: #faf7f7;
  color: var(--ink-3);
  cursor: not-allowed;
}

/* --- invalid --- */

.field.has-error .input {
  border-color: var(--error-600);
  background: var(--error-050);
}

.field.has-error .input:focus { box-shadow: 0 0 0 3px var(--brand-100); }

.field.has-error .field-icon { color: var(--error-600); }

/* Collapsed to nothing until it has something to say, so the card does not
   reserve a gap for an error that may never come. */
.field-error {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--error-600);
}

.field-error:empty { display: none; }

/* ==========================================================================
   Reduced motion
   ==========================================================================
   Everything animated here is decorative — a drifting cloud, a shake, a
   spinner. Honour the preference globally rather than per-rule, and keep the
   spinner turning slowly so a loading state is still legible as one. */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .btn.is-loading .btn-spinner {
    animation: spin 1.4s linear infinite !important;
    animation-duration: 1.4s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ==========================================================================
   Page banners
   One shape for every notice in the app — see app/Views/partials/banner.php.
   Always the first thing in the page body, above the first card, so a
   message about the page is never mistaken for a message about one panel.
   ========================================================================== */

.banner-stack { display: flex; flex-direction: column; gap: 8px; }

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--banner-line, #dbe6f5);
  border-radius: 9px;
  background: var(--banner-bg, #f2f7ff);
  color: var(--banner-fg, #285bb5);
  font-size: 11px;
}
.banner-success { --banner-line: #b7e3c8; --banner-bg: #f0fbf4; --banner-fg: #147a42; }
.banner-info    { --banner-line: #dbe6f5; --banner-bg: #f2f7ff; --banner-fg: #285bb5; }
.banner-warn    { --banner-line: #f0d69d; --banner-bg: #fff8e9; --banner-fg: #81530e; }

.banner-icon { display: inline-flex; flex: none; }
.banner-text { flex: 1; min-width: 0; line-height: 1.45; }
.banner-text strong { font-weight: 750; }

.banner-action {
  flex: none;
  padding: 6px 11px;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: inherit;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.banner-action:hover { background: rgba(255, 255, 255, .65); }

.banner-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: .6;
}
.banner-close:hover { background: rgba(255, 255, 255, .7); opacity: 1; }

@media (max-width: 600px) {
  .banner { flex-wrap: wrap; }
  .banner-text { flex: 1 1 100%; order: 3; }
  .banner-action { order: 4; }
}

/* ==========================================================================
   Toasts
   Transient notices — see app/Views/partials/toast.php. Fixed to the top
   right, above everything, and out of the page flow: unlike a banner, a
   toast must not push the content down as it arrives and pull it back up
   as it leaves.
   ========================================================================== */

.toast-stack {
  position: fixed;

  /* Below the topbar rather than over it: at the top of the viewport a toast
     covers the bell and the profile menu, which are the controls someone is
     most likely to reach for while one is on screen. Falls back to a plain
     offset on the signed-out pages, which have no topbar. */
  top: calc(var(--topbar-h, 0px) + 16px);
  right: 18px;
  z-index: 1200;          /* over the sidebar (1000) and every sticky header */
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(370px, calc(100vw - 36px));

  /* The stack spans the gutter even when a toast is narrower than it, so
     clicks in the empty space fall through to the page. Restored on the
     toasts themselves. */
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;       /* clips the countdown to the rounded corners */
  padding: 12px 13px;
  border: 1px solid var(--toast-line);
  border-left: 3px solid var(--toast-accent);
  border-radius: 10px;
  background: var(--toast-bg);
  color: var(--toast-fg);
  box-shadow: var(--shadow-2);
  font-size: 11px;
  pointer-events: auto;
}

/* Tinted rather than saturated: a toast sits over content, and a solid block
   of colour in the corner reads as an error even when it says "saved". The
   left rule carries the tone at full strength instead. */
.toast-success { --toast-line: #b7e3c8; --toast-bg: #f4fcf7; --toast-fg: #106b3a; --toast-accent: var(--ok-600); }
.toast-info    { --toast-line: #dbe6f5; --toast-bg: #f6faff; --toast-fg: #285bb5; --toast-accent: #3f76d4; }
.toast-warn    { --toast-line: #f0d69d; --toast-bg: #fffaf0; --toast-fg: #81530e; --toast-accent: var(--warn-600); }
.toast-error   { --toast-line: #f4c9cb; --toast-bg: #fdf6f6; --toast-fg: #9c0f16; --toast-accent: var(--error-600); }

.toast-icon { display: inline-flex; flex: none; color: var(--toast-accent); }
.toast-text { flex: 1; min-width: 0; line-height: 1.45; }
.toast-text strong { font-weight: 750; }

/* Underlined, not a button: a toast is leaving, and a call-to-action styled
   like a primary button promises a permanence it does not have. */
.toast-text a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.toast-text a:hover { text-decoration-thickness: 2px; }

.toast-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: .55;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.toast-close:hover { background: rgba(255, 255, 255, .8); opacity: 1; }

/* The countdown. Driven by an animation whose duration JS sets per toast, so
   the bar and the timer that removes the toast are the same length by
   construction rather than by two numbers kept in step by hand. */
.toast-life {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  transform-origin: left;
  background: var(--toast-accent);
  opacity: .5;
}
.toast.is-counting .toast-life { animation: toast-life linear forwards; }

@keyframes toast-life { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Hovering or focusing anywhere in the stack holds every toast in it: reading
   one should not cost you the one below it. */
.toast-stack:hover .toast-life,
.toast-stack:focus-within .toast-life { animation-play-state: paused; }

/* In from the right, out the same way. Entry is applied by JS on the next
   frame so a toast present at first paint animates in too. */
.toast.is-entering { animation: toast-in .26s var(--ease) both; }
.toast.is-leaving  { animation: toast-out .2s var(--ease) both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* Collapses its own height as it goes, so the toasts below slide up into the
   gap instead of jumping. */
@keyframes toast-out {
  from { opacity: 1; max-height: 200px; transform: none; }
  to   { opacity: 0; max-height: 0; margin-bottom: -10px;
         padding-top: 0; padding-bottom: 0;
         transform: translateX(14px); }
}

@media (max-width: 600px) {
  /* Full width across the top: at this size the right gutter is not wide
     enough for a toast to sit beside content rather than over it. */
  .toast-stack { top: calc(var(--topbar-h, 0px) + 10px); right: 12px; left: 12px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  /* The countdown still runs — it is the timer's read-out, not decoration —
     but it appears at its length rather than sweeping to it. */
  .toast.is-entering,
  .toast.is-leaving { animation: none; }
  .toast.is-leaving { opacity: 0; }
}

/* ==========================================================================
   Locked file names
   A file the viewer can see listed but not download: the account is in their
   Manager's shared book, not on their own line. Rendered by
   file_locked_label() in place of the link, and carrying the link's own class
   (doc-link, document-link, update-old is-file) so it sits where the link
   would. Muted, not clickable, with a lock in front -- the name is still
   information, only the bytes are withheld.
   ========================================================================== */
.file-locked,
.file-locked.doc-link,
.file-locked.document-link,
.file-locked.is-file {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-3);
  cursor: not-allowed;
  text-decoration-line: none;
}
.file-locked > .icon { flex: none; opacity: .85; }
.file-locked:hover,
.file-locked.doc-link:hover,
.file-locked.document-link:hover { color: var(--ink-3); text-decoration: none; }
/* The superseded value keeps its strike-through even when locked. */
.file-locked.update-old > span:not(.sr-only) { text-decoration: line-through; }

/* ---------- Segmented filter ----------
   Current / Upcoming / History / All, Active / Inactive / All. One selected
   option in a quiet track, so it reads as a view switch rather than as a set
   of buttons. Markup: app/Views/partials/segmented-filter.php. */
.segmented-filter {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--brand-050);
}
.segmented-filter-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  color: #5b6472;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.segmented-filter-option:hover { color: var(--brand-700); }
.segmented-filter-option.is-active {
  background: var(--surface);
  color: var(--brand-700);
  box-shadow: 0 1px 3px rgba(74, 5, 9, .12);
}
.segmented-filter-option:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 1px; }
.segmented-filter-count {
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--line-2);
  color: inherit;
  font-size: 11px;
  text-align: center;
}
.segmented-filter-option.is-active .segmented-filter-count { background: var(--brand-100); }
