/*
 * Bid Manager design system, part 2: components. Cards, chips, tables (stacked cards on a narrow screen), stepper,
 * timeline, callouts, alerts and toasts, empty and loading states, the drop zone, a segmented control, collapsible
 * panels, a dialog, stat tiles and icons. Icons are masks over files of this service (icons/*.svg), so they take the
 * colour of the text around them in both themes.
 */

/* ---- icons ---- */
.icon { display: inline-block; width: 1.15em; height: 1.15em; flex: none; background: currentColor; vertical-align: -0.2em; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.icon-upload { -webkit-mask-image: url(icons/upload.svg); mask-image: url(icons/upload.svg); }
.icon-download { -webkit-mask-image: url(icons/download.svg); mask-image: url(icons/download.svg); }
.icon-file { -webkit-mask-image: url(icons/file.svg); mask-image: url(icons/file.svg); }
.icon-check { -webkit-mask-image: url(icons/check.svg); mask-image: url(icons/check.svg); }
.icon-alert { -webkit-mask-image: url(icons/alert.svg); mask-image: url(icons/alert.svg); }
.icon-info { -webkit-mask-image: url(icons/info.svg); mask-image: url(icons/info.svg); }
.icon-chevron { -webkit-mask-image: url(icons/chevron.svg); mask-image: url(icons/chevron.svg); }
.icon-x { -webkit-mask-image: url(icons/x.svg); mask-image: url(icons/x.svg); }
.icon-lock { -webkit-mask-image: url(icons/lock.svg); mask-image: url(icons/lock.svg); }
.icon-list { -webkit-mask-image: url(icons/list.svg); mask-image: url(icons/list.svg); }

/* ---- page title block ---- */
.page-head { margin-bottom: var(--s5); }
.page-head .eyebrow { margin-bottom: var(--s1); }
.eyebrow { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.lede { font-size: var(--fs-lg); color: var(--text-2); max-width: 42rem; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s5); }
.card.flat { box-shadow: none; }
.card.tight { padding: var(--s4); }
.card.accent { border-top: 3px solid var(--accent); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: var(--s3); margin-bottom: var(--s4); }
.card-head h2, .card-head h3 { margin: 0; }
.card-sub { color: var(--text-2); font-size: var(--fs-sm); margin: var(--s1) 0 0; }
.card-foot { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }

/* ---- status chips ---- */
.chip { display: inline-flex; align-items: center; gap: 0.35em; font-size: var(--fs-xs); font-weight: 600; line-height: 1.2; padding: 0.22rem 0.6rem; border-radius: 999px; border: 1px solid var(--neutral-line); background: var(--neutral-bg); color: var(--neutral-fg); white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line); }
.chip-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }
.chip-bad { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-line); }
.chip-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }
.chip-type { font-family: var(--mono); letter-spacing: 0.02em; text-transform: uppercase; }
.chip-count { min-width: 1.6rem; justify-content: center; }

/* ---- tables: stacked cards on a narrow screen ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); background: var(--surface-2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table tr.is-removed td { color: var(--text-2); text-decoration: line-through; background: var(--surface-2); }
.table tr.is-removed td.actions { text-decoration: none; }
@media (max-width: 720px) {
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table tbody tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: var(--s3); padding: var(--s2) 0; box-shadow: var(--shadow); }
  .table tbody tr:hover td { background: transparent; }
  .table td { display: flex; justify-content: space-between; gap: var(--s4); border: 0; padding: var(--s1) var(--s4); text-align: right; }
  .table td::before { content: attr(data-label); flex: none; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); text-align: left; padding-top: 0.15em; }
  .table td:not([data-label])::before { content: none; }
  .table td.actions { justify-content: flex-end; padding-top: var(--s2); }
  .table td:empty { display: none; }
}

/* ---- stepper (the customer's path through the upload) ---- */
.stepper { list-style: none; display: flex; gap: var(--s2); padding: 0; margin: 0 0 var(--s5); counter-reset: step; }
.step { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: var(--s2); counter-increment: step; color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; padding-top: var(--s3); border-top: 4px solid var(--line); }
.step::before { content: counter(step); flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.65rem; height: 1.65rem; border-radius: 50%; border: 2px solid var(--line-strong); font-size: var(--fs-xs); background: var(--surface); }
.step.is-done { border-top-color: var(--accent); color: var(--text); }
.step.is-done::before { content: "\2713"; background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.step.is-current { border-top-color: var(--accent); color: var(--text); }
.step.is-current::before { border-color: var(--accent); color: var(--accent); }
@media (max-width: 560px) { .step { flex-direction: column; align-items: flex-start; gap: var(--s1); font-size: var(--fs-xs); } }

/* ---- timeline (a package's progress) ---- */
.timeline { list-style: none; padding: 0; margin: 0; display: flex; gap: var(--s2); }
.tl { flex: 1 1 0; min-width: 0; position: relative; padding-top: 1.6rem; font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; }
.tl::before { content: ""; position: absolute; top: 0.3rem; left: 0; right: 0; height: 4px; background: var(--line); border-radius: 2px; }
.tl::after { content: ""; position: absolute; top: 0; left: 0; width: 0.9rem; height: 0.9rem; border-radius: 50%; background: var(--surface); border: 3px solid var(--line-strong); }
.tl.is-done { color: var(--text); }
.tl.is-done::before { background: var(--accent); }
.tl.is-done::after { background: var(--accent); border-color: var(--accent); }
.tl.is-current { color: var(--text); }
.tl.is-current::after { border-color: var(--accent); box-shadow: 0 0 0 4px var(--info-bg); }
.tl.is-held::after { border-color: var(--warn-fg); background: var(--warn-bg); box-shadow: 0 0 0 4px var(--warn-bg); }
@media (max-width: 640px) {
  .timeline { flex-direction: column; gap: 0; }
  .tl { padding: 0 0 var(--s4) 1.9rem; }
  .tl::before { top: 0.9rem; bottom: 0; left: 0.4rem; right: auto; width: 4px; height: auto; }
  .tl:last-child::before { display: none; }
}

/* ---- callouts, inline alerts and toasts ---- */
.callout { display: flex; gap: var(--s3); padding: var(--s4); border-radius: var(--radius); border: 1px solid var(--info-line); background: var(--info-bg); color: var(--info-fg); }
.callout .icon { margin-top: 0.15em; }
.callout-body { min-width: 0; flex: 1; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; margin: 0 0 var(--s1); }
.callout ul { margin: var(--s2) 0 0; }
.callout-warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); }
.callout-bad { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad-fg); }
.callout-ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-fg); }
.alert { padding: var(--s3) var(--s4); border-radius: var(--radius-sm); border: 1px solid var(--info-line); background: var(--info-bg); color: var(--info-fg); font-size: var(--fs-sm); margin: var(--s3) 0 0; }
.alert:empty { display: none; }
.alert-bad { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad-fg); }
.alert-ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-fg); }
.alert-warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); }
.toasts { position: fixed; z-index: 60; right: var(--s4); bottom: var(--s4); display: flex; flex-direction: column; gap: var(--s2); max-width: min(24rem, calc(100vw - 2rem)); }
.toast { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--radius); background: var(--navy-900); color: #fff; box-shadow: var(--shadow-lg); font-size: var(--fs-sm); }
.toast.toast-bad { background: var(--bad-fg); color: var(--bad-bg); }
.toast.toast-ok { background: var(--ok-fg); color: var(--ok-bg); }
@media (prefers-color-scheme: dark) { .toast { background: var(--navy-700); } }

/* ---- empty, loading and error states ---- */
.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--text-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.empty .icon { width: 2rem; height: 2rem; color: var(--line-strong); margin-bottom: var(--s2); }
.empty p { margin: 0; }
.loading { display: flex; align-items: center; gap: var(--s3); justify-content: center; padding: var(--s7) var(--s4); color: var(--text-2); }
.spinner { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.skeleton { height: 1rem; border-radius: 4px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- sign-in and other single cards ---- */
.auth-wrap { max-width: 26rem; margin: var(--s6) auto 0; }
.auth-wrap .card { padding: var(--s6) var(--s5); }
.auth-wrap h1 { font-size: var(--fs-xl); margin-bottom: var(--s2); }

/* ---- the drop zone and file cards ---- */
.dropzone { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); padding: var(--s6) var(--s4); border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); transition: border-color 0.12s, background-color 0.12s; }
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); }
.dropzone.is-over { border-color: var(--accent); background: var(--info-bg); }
.dropzone .icon { width: 2.4rem; height: 2.4rem; color: var(--accent); }
.dropzone p { margin: 0; max-width: 30rem; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input:focus-visible + .btn { outline: 3px solid var(--focus); outline-offset: 2px; }
.files { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.file-card { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s1) var(--s3); align-items: start; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.file-card.is-refused { border-color: var(--bad-line); background: var(--bad-bg); }
.file-card .file-icon { width: 2.4rem; height: 2.4rem; border-radius: var(--radius-sm); background: var(--info-bg); color: var(--info-fg); display: flex; align-items: center; justify-content: center; }
.file-name { font-weight: 600; display: block; }
.file-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s1); font-size: var(--fs-xs); color: var(--text-2); }
.file-note { grid-column: 2 / 4; font-size: var(--fs-sm); color: var(--text-2); margin: 0; }
.file-members { grid-column: 2 / 4; margin: var(--s2) 0 0; padding: var(--s2) var(--s3); background: var(--surface-2); border-radius: var(--radius-sm); font-size: var(--fs-xs); }
.file-members ul { list-style: none; padding: 0; margin: var(--s1) 0 0; display: grid; gap: var(--s1); }
.totals { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); font-size: var(--fs-sm); color: var(--text-2); }
.totals strong { color: var(--text); }

/* ---- a segmented control (radios) ---- */
.segmented { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s1); background: var(--surface-3); border-radius: var(--radius); }
.segmented label { flex: 1 1 12rem; margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented .seg { display: block; height: 100%; padding: var(--s3) var(--s4); border-radius: var(--radius-sm); border: 1px solid transparent; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.segmented input:checked + .seg { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow); }
.segmented input:focus-visible + .seg { outline: 3px solid var(--focus); outline-offset: 1px; }
.segmented input:disabled + .seg { opacity: 0.55; cursor: not-allowed; }

/* ---- collapsible panels ---- */
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel + .panel { margin-top: var(--s3); }
.panel > summary { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); cursor: pointer; font-weight: 600; list-style: none; border-radius: var(--radius); }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary:hover { background: var(--surface-2); }
.panel > summary .panel-title { flex: 1; min-width: 0; }
.panel > summary .icon-chevron { color: var(--text-2); transition: transform 0.15s; }
.panel[open] > summary .icon-chevron { transform: rotate(180deg); }
.panel[open] > summary { border-bottom: 1px solid var(--line); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.panel-body { padding: var(--s4); }
.entries { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.entry { padding-bottom: var(--s3); border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; padding-bottom: 0; }
.entry p { margin: var(--s1) 0 0; color: var(--text-2); font-size: var(--fs-sm); }

/* ---- stat tiles ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--s3); }
.stat { padding: var(--s3) var(--s4); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.stat-value { display: block; font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { display: block; font-size: var(--fs-xs); color: var(--text-2); }

/* ---- a dialog (a modal card over a backdrop) ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: var(--s4); background: rgba(8, 14, 25, 0.62); }
.modal { width: 100%; max-width: 32rem; max-height: 90vh; overflow: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--s5); }
.modal h2 { font-size: var(--fs-lg); margin-bottom: var(--s2); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); margin-top: var(--s4); }

/* ---- the terms text (scrollable) ---- */
.terms { white-space: pre-wrap; max-height: 16rem; overflow: auto; padding: var(--s4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); font-size: var(--fs-sm); }
.terms:focus-visible { outline: 3px solid var(--focus); }

/* ---- long legal text: clauses, headings and a contents list ---- */
.terms { position: relative; max-height: min(60vh, 30rem); white-space: normal; line-height: 1.6; }
.terms .clause { margin: 0 0 var(--s3); }
.terms .clause-num { font-weight: 700; margin-right: 0.35em; font-variant-numeric: tabular-nums; }
.terms .clause-head { margin: var(--s5) 0 var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); font-size: var(--fs-base); letter-spacing: 0.02em; }
.terms .clause-head:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.terms .clause-note { padding: var(--s3); border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); }
.terms-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.terms-meta h3 { flex: 1 1 14rem; margin: 0; font-size: var(--fs-base); }
.contents { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--s1); }
.contents .btn { justify-content: flex-start; text-align: left; white-space: normal; font-weight: 500; }

/* a long table scrolls inside its card (wide screens) with its header kept in view */
@media (min-width: 721px) {
  .table-wrap.scroll { max-height: 32rem; overflow: auto; }
  .table-wrap.scroll th { position: sticky; top: 0; z-index: 1; }
}
.stack > .timeline { margin-top: var(--s5); }
