/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* ===== Design tokens ===== */
:root {
  --color-primary: #1f6f4c;
  --color-primary-dark: #175939;
  --color-primary-light: #e7f4ee;
  --color-accent: #f2994a;
  --color-accent-dark: #d97f2f;
  --color-danger: #d64545;
  --color-danger-light: #fbeaea;
  --color-warning: #c98a12;
  --color-warning-light: #fbf1de;
  --color-info: #2f80c9;
  --color-info-light: #eaf3fb;
  --color-success: #1f6f4c;

  --gray-50: #f8faf9;
  --gray-100: #f0f2f1;
  --gray-200: #e3e7e5;
  --gray-300: #cdd3d0;
  --gray-400: #a7afac;
  --gray-500: #7c8985;
  --gray-600: #5a6663;
  --gray-700: #414c49;
  --gray-800: #2c3532;
  --gray-900: #1a201e;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(26, 32, 30, 0.06), 0 1px 1px rgba(26, 32, 30, 0.08);
  --shadow-md: 0 8px 24px rgba(26, 32, 30, 0.12);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.22);

  /* Spring-like curve (Apple's default critically-damped feel) used for anything
     the user directly triggers, so motion reads as physical rather than timed. */
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);

  --sidebar-width: 232px;
  --sidebar-collapsed-width: 56px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-optical-sizing: auto;
  /* Body copy loosens toward 1.5 leading and sits near-zero tracking — the
     inverse of the headings above, which tighten as they grow. */
  line-height: 1.5;
  letter-spacing: -0.003em;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  color: var(--gray-900);
  margin-top: 0;
  font-optical-sizing: auto;
}

/* Tracking/leading are size-specific, not one fixed value: tighten as text gets
   larger, loosen toward body copy, per Apple's optical-sizing typography rules. */
h1 { letter-spacing: -0.02em; line-height: 1.15; }
h2 { letter-spacing: -0.016em; line-height: 1.2; }
h3 { letter-spacing: -0.012em; line-height: 1.25; }
h4, h5, h6 { letter-spacing: -0.006em; line-height: 1.3; }

a {
  color: var(--color-primary);
  transition: color 120ms ease;
}

table {
  font-size: 14px;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
  transition: transform 100ms ease-out, background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

/* Feedback lives on the press and is instant — never wait for release. */
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--gray-800);
  border-color: var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-danger {
  background: #fff;
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border-color: transparent;
  padding: 6px 10px;
  min-height: 32px;
}

.btn-ghost:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.btn-sm {
  padding: 4px 10px;
  min-height: 28px;
  font-size: 13px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ===== Page structure ===== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 24px;
  margin: 0;
}

.page-subtitle {
  color: var(--gray-600);
  margin-top: -12px;
  margin-bottom: 20px;
}

.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.table-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
}

.table-card th, .table-card td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.table-card th {
  background: var(--gray-50);
  color: var(--gray-700);
  font-weight: 600;
}

.table-card tbody tr {
  transition: background-color 120ms ease;
}

.table-card tbody tr:hover {
  background: var(--gray-50);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.filter-bar a {
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--gray-700);
  background: var(--gray-100);
  transition: transform 100ms ease-out, background-color 150ms ease, color 150ms ease;
}

.filter-bar a:active {
  transform: scale(0.96);
}

.filter-bar a.active {
  background: var(--color-primary);
  color: #fff;
}

.buyer-name-link {
  color: var(--gray-900);
  font-weight: 600;
  text-decoration: none;
  transition: color 120ms ease;
}

.buyer-name-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.inline-edit-select, .inline-edit-date {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: inherit;
}

.inline-edit-select:hover, .inline-edit-date:hover {
  text-decoration: underline;
}

/* ===== Flash messages ===== */
.flash-notice, .flash-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 14px;
}

.flash-notice {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.flash-alert {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.flash-notice:empty, .flash-alert:empty {
  display: none;
}

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.form-grid .field-wide {
  grid-column: 1 / -1;
}

.field, div.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
}

.field label, div.field label,
.field p label {
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-700);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field input[type="number"],
.field select,
.field textarea,
div.field input[type="text"],
div.field input[type="email"],
div.field input[type="password"],
div.field input[type="date"],
div.field input[type="number"],
div.field select,
div.field textarea {
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--gray-800);
  width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

/* Focus reads as a soft ring settling in, not a hard box snapping on. The
   keyboard-only outline is restored under :focus-visible for accessibility. */
.field input:focus, .field select:focus, .field textarea:focus,
div.field input:focus, div.field select:focus, div.field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-light);
}

.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
div.field input:focus-visible, div.field select:focus-visible, div.field textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.field-readonly {
  padding: 9px 0;
  color: var(--gray-600);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 8px 0;
}

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 14px;
  color: var(--gray-800);
}

.field-hint {
  font-size: 12px;
  color: var(--gray-500);
}

.task-notes {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

.field-errors {
  background: var(--color-danger-light);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  color: var(--color-danger);
}

.field-errors h2 {
  font-size: 15px;
  margin-bottom: 6px;
}

.actions {
  margin-top: 8px;
}

input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 100ms ease-out, background-color 150ms ease;
}

input[type="submit"]:hover {
  background: var(--color-primary-dark);
}

input[type="submit"]:active {
  transform: scale(0.97);
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Show-page detail lists ===== */
.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  margin: 0;
}

.detail-list dt {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.detail-list dd {
  margin: 2px 0 0;
  font-size: 15px;
  color: var(--gray-900);
}

@media (max-width: 720px) {
  .detail-list {
    grid-template-columns: 1fr;
  }
}

/* ===== Badges / pills ===== */
.badge, .pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill-danger { background: var(--color-danger-light); color: var(--color-danger); }
.pill-warning { background: var(--color-warning-light); color: var(--color-warning); }
.pill-info { background: var(--color-info-light); color: var(--color-info); }
.pill-success { background: var(--color-primary-light); color: var(--color-primary-dark); }
.pill-neutral { background: var(--gray-100); color: var(--gray-700); }

/* ===== New Buyer FAB ===== */
.new-buyer-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  background-size: 200% 200%;
  background-position: 0% 50%;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(31, 111, 76, 0.35), 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s ease, background-position 0.4s ease;
}

.new-buyer-fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 22px rgba(31, 111, 76, 0.45), 0 3px 6px rgba(0, 0, 0, 0.2);
  background-position: 100% 50%;
  color: #fff;
}

.new-buyer-fab:active {
  transform: translateY(0) scale(0.98);
}

.new-buyer-fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 16px;
  line-height: 1;
}

/* ===== App shell / sidebar ===== */
.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  transition: width 0.2s var(--ease-spring), transform 0.3s var(--ease-spring);
  overflow: hidden;
}

.app-shell.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-title,
.sidebar-collapsed .sidebar-link-label,
.sidebar-collapsed .sidebar-footer {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--gray-200);
}

.sidebar-toggle, .sidebar-close, .mobile-topbar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  flex-shrink: 0;
  color: var(--gray-700);
}

.sidebar-close {
  display: none;
  margin-left: auto;
  font-size: 22px;
}

.sidebar-title {
  font-weight: 700;
  white-space: nowrap;
  font-size: 16px;
}

.sidebar-title a, .mobile-topbar-title a {
  color: var(--gray-900);
  text-decoration: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  text-decoration: none;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  transition: transform 100ms ease-out, background-color 150ms ease, color 150ms ease;
}

.sidebar-link:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.sidebar-link:active {
  transform: scale(0.98);
}

.sidebar-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.sidebar-link-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-badge {
  margin-left: auto;
  min-width: 16px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.sidebar-collapsed .sidebar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  margin-left: 0;
  padding: 1px 4px;
}

.sidebar-footer {
  border-top: 1px solid var(--gray-200);
  padding: 14px 16px;
  font-size: 13px;
}

.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--gray-600);
}

.sidebar-signout {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  font-size: 13px;
  white-space: nowrap;
  font-weight: 600;
}

.app-main {
  flex: 1;
  min-width: 0;
}

.app-content {
  padding: 24px;
  max-width: 1200px;
}

/* ===== Mobile layout ===== */
@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 800;
    width: 100%;
    padding: 12px 16px;
    /* Translucent chrome: content scrolls underneath, so it reads as a floating
       material layer rather than an opaque bar consuming a fixed strip. */
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 8px 16px -12px rgba(26, 32, 30, 0.25);
  }

  .mobile-topbar-toggle {
    font-size: 22px;
  }

  .mobile-topbar-title {
    flex: 1;
    font-weight: 700;
    font-size: 16px;
  }

  .mobile-topbar-bell {
    position: relative;
    text-decoration: none;
    font-size: 18px;
    padding: 4px;
  }

  .mobile-topbar-bell .sidebar-badge {
    position: absolute;
    top: -4px;
    right: -8px;
  }

  .app-shell {
    flex-direction: column;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar-close {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    width: min(80vw, 300px);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    /* As a floating overlay (not a static column) this sidebar now sits above
       page content, so it earns real translucency — a heavier material since
       it's a large structural surface, not a small chip. */
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: min(80vw, 300px);
  }

  .app-shell.sidebar-collapsed .sidebar-title,
  .app-shell.sidebar-collapsed .sidebar-link-label,
  .app-shell.sidebar-collapsed .sidebar-footer {
    display: initial;
  }

  .app-shell.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.sidebar-mobile-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(26, 32, 30, 0.45);
    z-index: 900;
  }

  .app-content {
    padding: 16px 16px 88px;
  }

  .new-buyer-fab {
    right: 16px;
    bottom: 16px;
    padding: 12px 18px;
    font-size: 14px;
  }
}

/* ===== Auth pages ===== */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--color-primary-light), var(--gray-50));
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}

.auth-brand {
  font-weight: 700;
  font-size: 20px;
  color: var(--color-primary-dark);
  margin-bottom: 16px;
  text-align: center;
}

.auth-card h2 {
  font-size: 20px;
  margin-bottom: 18px;
}

.auth-card .field {
  margin-bottom: 14px;
}

.auth-card a {
  font-size: 13px;
}

/* ===== Main Menu / dashboard ===== */
.dashboard-welcome {
  margin-bottom: 24px;
}

.dashboard-welcome h1 {
  font-size: 26px;
  margin-bottom: 4px;
}

.dashboard-welcome p {
  color: var(--gray-600);
  margin: 0;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-tile {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-tile .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-primary-dark);
}

.stat-tile .stat-label {
  font-size: 13px;
  color: var(--gray-600);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.menu-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  background: #fff;
  text-decoration: none;
  color: var(--gray-800);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: transform 100ms ease-out, border-color 150ms ease, box-shadow 150ms ease;
}

.menu-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Press cancels the hover lift and settles — the physical response of pushing
   the raised card back down. */
.menu-card:active {
  transform: translateY(0) scale(0.98);
}

.menu-card-icon {
  font-size: 22px;
}

.menu-card-label {
  font-weight: 600;
  font-size: 14px;
}

.menu-card .sidebar-badge {
  position: absolute;
  top: 12px;
  right: 12px;
}

.dashboard-section {
  margin-bottom: 28px;
}

.dashboard-section h2 {
  font-size: 17px;
  margin-bottom: 12px;
}

.dashboard-empty {
  color: var(--gray-500);
  font-size: 14px;
  padding: 12px 0;
}

/* ===== Notifications ===== */
.notification-item {
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: #fff;
}

.notification-item.unread {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.notification-title {
  font-weight: 700;
  color: var(--gray-900);
}

.notification-new-flag {
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}

.notification-body {
  margin: 6px 0;
  color: var(--gray-700);
}

.notification-meta {
  color: var(--gray-500);
  font-size: 12px;
}

.notification-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

/* ===== Pipeline board ===== */
.pipeline-board {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.pipeline-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 260px;
  flex-shrink: 0;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 10px;
}

.pipeline-column-header {
  font-weight: 700;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px 4px;
  color: var(--gray-700);
}

.pipeline-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.pipeline-card-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.pipeline-card-summary {
  transition: transform 100ms ease-out, background-color 150ms ease;
}

.pipeline-card-summary:hover {
  background: var(--gray-50);
}

.pipeline-card-summary:active {
  transform: scale(0.98);
}

.pipeline-card-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-modal {
  border: none;
  border-radius: var(--radius-md);
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-lg);
  /* Materialize, don't just fade: scale and opacity move together so the panel
     reads as a physical surface arriving, not a plain visibility toggle. */
  opacity: 1;
  transform: scale(1);
  transition: opacity 220ms var(--ease-spring), transform 220ms var(--ease-spring), overlay 220ms allow-discrete, display 220ms allow-discrete;
}

@starting-style {
  .pipeline-modal[open] {
    opacity: 0;
    transform: scale(0.96);
  }
}

.pipeline-modal:not([open]) {
  opacity: 0;
  transform: scale(0.96);
}

.pipeline-modal::backdrop {
  background: rgba(15, 23, 42, 0);
  backdrop-filter: blur(0);
  transition: background 220ms ease, backdrop-filter 220ms ease, overlay 220ms allow-discrete, display 220ms allow-discrete;
}

.pipeline-modal[open]::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
}

@starting-style {
  .pipeline-modal[open]::backdrop {
    background: rgba(15, 23, 42, 0);
    backdrop-filter: blur(0);
  }
}

.pipeline-modal-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.pipeline-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--gray-200);
}

.pipeline-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.pipeline-modal-meta {
  margin: 4px 0 0;
  color: var(--gray-600);
  font-size: 13px;
}

.pipeline-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 16px;
  overflow-y: auto;
}

.pipeline-badge {
  display: inline-block;
  flex-shrink: 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gray-500);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.pipeline-badge-forfeited {
  background: var(--color-danger);
}

.pipeline-badge-overdue {
  background: var(--color-danger);
}

.pipeline-badge-soft {
  background: var(--color-warning);
}

.pipeline-badge-active {
  background: var(--gray-500);
}

.pipeline-badge-flagged {
  background: var(--color-info);
}

a.pipeline-badge {
  text-decoration: none;
  transition: transform 100ms ease-out;
}

a.pipeline-badge:active {
  transform: scale(0.96);
}

.pipeline-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pipeline-checklist li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.pipeline-doc-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.pipeline-doc-status-received {
  background: var(--color-primary);
}

.pipeline-doc-status-pending {
  background: var(--gray-400);
}

.pipeline-upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.pipeline-upload-form input[type="file"] {
  max-width: 140px;
  font-size: 12px;
}

.pipeline-comment-form textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
}

.pipeline-comments {
  border-top: 1px dashed var(--gray-300);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pipeline-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.pipeline-panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.pipeline-panel-subtitle {
  margin: 0;
  color: var(--gray-600);
  font-size: 13px;
}

.pipeline-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
}

.pipeline-flag-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--color-info-light);
  border: 1px solid var(--color-info);
}

.pipeline-flag-banner p {
  margin: 0;
  font-size: 13px;
  color: var(--gray-800);
}

.pipeline-flag-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
  color: var(--gray-700);
}

.pipeline-comment-flagged {
  border-left: 3px solid var(--color-info);
  padding-left: 6px;
}

/* ===== Appointments calendar ===== */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.calendar-weekday {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  text-align: center;
  padding-bottom: 4px;
}

.calendar-day {
  min-height: 90px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  transition: transform 100ms ease-out, border-color 150ms ease;
}

.calendar-day:not(:disabled):active {
  transform: scale(0.97);
}

.calendar-day:disabled {
  cursor: default;
  color: var(--gray-400);
  background: var(--gray-50);
}

.calendar-day-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.calendar-day-today .calendar-day-number {
  color: var(--color-primary-dark);
}

.calendar-appointment-chip {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Enter transitions =====
   Server-rendered feedback should materialize rather than blink into place: a
   short rise + fade reads as the message physically arriving. The global
   reduced-motion rule below collapses the duration to a plain appear. */
@keyframes surface-rise-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-notice, .flash-alert, .field-errors {
  animation: surface-rise-in 260ms var(--ease-spring);
}

/* Scroll edges, not hard clip lines: nav content fades under the header and
   footer instead of being sliced off at a crisp boundary. */
.sidebar-nav {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
}

/* ===== Accessibility: motion, transparency, contrast =====
   Reduced motion doesn't mean no feedback — it means a gentler, non-vestibular
   equivalent, so we shorten motion rather than strip it entirely. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .btn:active, input[type="submit"]:active, .sidebar-link:active,
  .menu-card:active, .menu-card:hover, .filter-bar a:active,
  .pipeline-card-summary:active, a.pipeline-badge:active,
  .calendar-day:not(:disabled):active, .new-buyer-fab:active,
  .new-buyer-fab:hover {
    transform: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .mobile-topbar {
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .pipeline-modal[open]::backdrop {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: none;
  }
}

@media (prefers-reduced-transparency: reduce) and (max-width: 900px) {
  .sidebar {
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  .card, .table-card, .stat-tile, .menu-card, .notification-item,
  .pipeline-card, .calendar-day, .auth-card {
    border-width: 1.5px;
    border-color: var(--gray-600);
  }
}
