/* dash.css: owner and provider-manager dashboards. All rules scoped under .db (or .db-* classes). */

.db { --db-r: 20px; --db-line: color-mix(in srgb, var(--line) 75%, transparent); }
.db .num { font-variant-numeric: tabular-nums; }
.db-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.db :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Page header */
.db .db-head { margin-bottom: 28px; gap: 20px; }
.db .db-head h1 { font-size: clamp(1.9rem, 3.6vw, 2.6rem); }
.db .db-head .eyebrow { display: flex; align-items: center; gap: 8px; }
.db .db-head .sub { font-size: 1.05rem; }
.db .db-head .sub b { color: var(--fg); font-weight: 600; }
.db-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.db-bi { width: 16px; height: 16px; flex: none; }
.db-back { margin: -8px 0 12px -8px; gap: 4px; }
.db-back svg { width: 18px; height: 18px; }
.db-meta { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 12px 0 0; }
.db-meta div { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.db-meta dt { font-size: .82rem; color: var(--muted); }
.db-meta dd { margin: 0; font-size: .95rem; overflow-wrap: anywhere; }
.db-banner { background: var(--accent-soft); border-radius: 16px; padding: 10px 12px 10px 18px; margin-bottom: 24px; }

/* KPI cards */
.db-kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 20px; }
.db-kpis-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.db-kpi { background: var(--surface); border-radius: 18px; padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; position: relative; }
.db-kpi .l { font-size: .85rem; color: var(--muted); font-weight: 500; }
.db-kpi .v { font-family: var(--display); font-size: 1.9rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.db-kpi .v .of { font-size: .95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.db-kpi .m { font-size: .8rem; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.db-kpi.is-warn .v { color: var(--warn); }
.db-kpi.is-bad .v { color: var(--bad); }
.db-v-pill { font-size: 1rem !important; padding-top: 8px; }
.db-v-pill .pill { font-size: .85rem; padding: 5px 11px; }
.db-ic { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2); color: var(--fg); margin-bottom: 12px; }
.db-ic svg { width: 17px; height: 17px; }
.db-kpi-ring { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.db-kpi-ring > div:first-child { min-width: 0; }
.db-ringbox { position: relative; width: 56px; height: 56px; flex: none; display: grid; place-items: center; }
.db-ringbox span { position: absolute; font-size: .74rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.db-ring { width: 56px; height: 56px; }
.db-ring circle { fill: none; stroke-width: 4.5; }
.db-ring .t { stroke: var(--surface-2); }
.db-ring .f { stroke: var(--accent); stroke-linecap: round; }
.db-ring.good .f { stroke: var(--good); }
.db-ring.warn .f { stroke: var(--warn); }
.db-ring.full .f { stroke: var(--bad); }
@media (prefers-reduced-motion: no-preference) {
  .db-ring .f { animation: db-ring .9s cubic-bezier(.2,.7,.2,1) both; }
  @keyframes db-ring { from { stroke-dasharray: 0 101; } }
}

/* Worker status mix (stacked bar of real counts) */
.db-kpi-mix .db-bar { display: flex; gap: 3px; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin: 14px 0 12px; }
.db-bar span { display: block; min-width: 6px; }
.db-bar .good, .db-legend .good .dot { background: var(--good); }
.db-bar .info, .db-legend .info .dot { background: var(--accent); }
.db-bar .neutral, .db-legend .neutral .dot { background: #C7C7CC; }
.db-bar .bad, .db-legend .bad .dot { background: var(--bad); }
.db-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: .84rem; color: var(--muted); }
.db-legend li { display: flex; align-items: center; gap: 7px; }
.db-legend .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.db-legend b { margin-left: auto; color: var(--fg); font-weight: 600; }
.db-legend li.hot b { color: var(--bad); }

/* Panels */
.db .db-panel { margin-top: 20px; }
.db .panel-head { align-items: flex-start; }
.db .panel-head h2 { font-size: 1.3rem; letter-spacing: -.02em; }
.db .panel-head p.muted { margin-top: 3px; max-width: 62ch; }
.db-ttl { display: flex; align-items: center; gap: 10px; }
.db-count { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.db-count.warn { background: var(--warn-soft); color: var(--warn); }
.db-tag { font-size: .8rem; font-weight: 500; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 4px 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.db-tag.warn { color: var(--warn); background: var(--warn-soft); }
.db-tag.good { color: var(--good); background: var(--good-soft); }
.db-strong { font-weight: 600; }
.db-foot { margin-top: 24px; }
.db-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.db-grid.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
.db-grid > .panel, .db-col > .panel { margin-top: 0; }
.db-grid { margin-top: 20px; }
.db-col { display: grid; gap: 20px; min-width: 0; }
@media (max-width: 900px) { .db-grid, .db-grid.even { grid-template-columns: 1fr; } }

/* Seat requests: highlighted */
.db .db-req { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent), var(--shadow); }

/* Lists (requests, unpaid invoices) */
.db-list { list-style: none; margin: 0; padding: 0; }
.db-li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--db-line); flex-wrap: wrap; }
.db-li:first-child { border-top: 0; padding-top: 4px; }
.db-li-main { flex: 1 1 160px; min-width: 0; }
.db-li-act { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* Avatars */
.db-av { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-fg); font-size: .78rem; font-weight: 600; flex: none; letter-spacing: 0; }
.db-av.xs { width: 22px; height: 22px; font-size: .62rem; margin-left: -6px; }
.db-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.db-min { min-width: 0; }
.db-ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.db-wt .seatline { min-width: 100px; }
.db-c-act .btn { white-space: nowrap; }

/* Tables */
.db-tbl { margin: 0 -8px; padding: 0 8px; }
.db-tbl table { font-size: .92rem; }
.db-tbl th { color: var(--muted); font-weight: 500; font-size: .8rem; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.db-tbl td { padding: 13px 12px; border-bottom: 1px solid var(--db-line); }
.db-tbl th.num, .db-tbl td.db-r { text-align: right; }
.db-tbl td.num { white-space: nowrap; }
.db-tbl tr.clickable td { transition: background-color .15s; }
.db-tbl tr.clickable:hover td, .db-tbl tr.clickable:focus-visible td { background: var(--surface-2); }
.db-tbl tr.clickable:focus-visible { outline: none; }
.db-tbl tr.clickable:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.db-tbl tr.clickable td:first-child { border-radius: 12px 0 0 12px; }
.db-tbl tr.clickable td:last-child { border-radius: 0 12px 12px 0; }
.db-tbl .seatline { min-width: 120px; }
.db-tbl td.db-c-main { min-width: 240px; }
.db-tbl .db-wt td.db-c-main { min-width: 220px; }
.db-tbl .meter.db-done > span { background: var(--good); }
.db-pkg { display: inline-block; font-size: .82rem; font-weight: 500; padding: 3px 10px; border-radius: 8px; background: var(--surface-2); }
.db-next { min-width: 200px; max-width: 280px; }
.db-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .82rem; letter-spacing: .01em; }
.db-wt tr.db-st-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.db-c-act { text-align: right; }
.db-c-act .btn.danger { color: var(--bad); }
.db-c-act .btn.danger:hover { background: var(--bad-soft); filter: none; }

/* Inner scroll + sticky headers */
.db-scroll { max-height: 640px; overflow: auto; overscroll-behavior: contain; }
.db-reg { max-height: 460px; }
.db-scroll thead th { position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 var(--line); border-bottom: 0; }

/* Empty states */
.db-empty { text-align: center; padding: 28px 16px; border-radius: 16px; background: var(--surface-2); }
.db-empty .db-ic { background: var(--surface); margin: 0 auto 10px; }
.db-empty.sm { padding: 20px 16px; }
.db-empty p.muted { max-width: 44ch; margin: 4px auto 0; }

/* Forms */
.db-form { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.db-form .db-span { grid-column: 1 / -1; }
.db-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--db-line); }
.db-total { font-size: .92rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.db-form-4 { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto; align-items: end; }
.db-form-btn .btn { width: 100%; justify-content: center; }
.db-help { margin-top: 12px; }
.db-note { margin-bottom: 14px; }
.db-inline { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.db-input { flex: 1; min-width: 0; padding: 11px 14px; border: 1px solid transparent; border-radius: 12px; background: var(--surface-2); font: inherit; font-size: .95rem; color: var(--fg); }
.db-input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.db-inline .btn { flex: none; }
.db-vout:not(:empty) { margin-top: 12px; }
.db-vout .note { font-size: .9rem; }
.db-fallback { width: 100%; height: 120px; margin-top: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); font: .85rem ui-monospace, Menlo, monospace; }
@media (max-width: 760px) {
  .db-form, .db-form-4 { grid-template-columns: 1fr; }
}

/* Seat stepper */
.db-seat { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.db-stepper { display: inline-flex; align-items: center; gap: 0; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.db-step { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface); color: var(--fg); font-size: 1.2rem; line-height: 1; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04); }
.db-step:hover { background: var(--accent-soft); color: var(--accent-fg); }
.db-step:active { transform: scale(.94); }
.db-stepper input { width: 76px; border: 0; background: transparent; text-align: center; font-size: 1.35rem; font-weight: 600; letter-spacing: -.02em; padding: 4px; font-variant-numeric: tabular-nums; color: var(--fg); -moz-appearance: textfield; appearance: textfield; }
.db-stepper input::-webkit-outer-spin-button, .db-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.db-stepper input:focus { outline: none; }
.db-stepper:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }
.db-use { display: flex; align-items: center; gap: 12px; margin: 20px 0 8px; }
.db-use .seatline { flex: 1; }
.db-use .meter { height: 8px; }

/* Chips */
.db-chips .chip { padding: 5px 8px 5px 12px; gap: 8px; background: var(--surface-2); }
.db-chip-tag { font-size: .72rem; color: var(--muted); background: var(--surface); padding: 2px 8px; border-radius: 999px; }

/* Competency dialog */
.db-dlg h2 { margin-top: 4px; }
.db-dlg-sub { margin-top: 4px; }
.db-check { margin-top: 16px; gap: 6px; }
.db-check label { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: background-color .15s; }
.db-check label:hover { background: var(--accent-soft); }
.db-check label:has(input:checked) { background: var(--good-soft); }
.db-check input { accent-color: var(--good); flex: none; margin-top: 3px; }
.db-dlg-by { margin-top: 16px; }
#cc-msg { margin-top: 8px; }
.db-dlg-foot { margin-top: 16px; justify-content: flex-end; }

/* Mobile: tables become stacked cards (no page-level horizontal scroll) */
@media (max-width: 720px) {
  .db .db-head { margin-bottom: 22px; }
  .db-actions, .db-actions .btn { width: 100%; justify-content: center; }
  .db-actions .btn { flex: 1; }
  .db-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .db-kpis-3 { grid-template-columns: 1fr; }
  .db-kpi { padding: 16px; }
  .db-kpi .v { font-size: 1.6rem; }
  .db-kpi-ring { gap: 8px; }
  .db-ringbox, .db-ring { width: 48px; height: 48px; }
  .db-ringbox span { font-size: .66rem; }
  .db-kpi .v .of { font-size: .82rem; margin-left: 2px; }
  .db-kpis > .db-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .db-ic { margin-bottom: 8px; }
  .db .panel { padding: 18px; border-radius: 18px; }
  .db .panel-head h2 { font-size: 1.2rem; }
  .db-tbl { margin: 0; padding: 0; }
  .db-cards.db-scroll { max-height: none; overflow: visible; }
  .db-cards table, .db-cards tbody { display: block; }
  .db-cards thead { display: none; }
  .db-cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px; margin-top: 10px; border-radius: 14px; background: var(--surface-2); }
  .db-cards tr:first-child { margin-top: 0; }
  .db-cards td { display: flex; flex-direction: column; gap: 3px; padding: 0; border: 0 !important; min-width: 0; text-align: left !important; background: none !important; border-radius: 0 !important; }
  .db-cards td[data-label]::before { content: attr(data-label); font-size: .74rem; color: var(--muted); font-weight: 500; }
  .db-cards td.db-c-main { grid-column: 1 / -1; }
  .db-cards td.db-next { grid-column: 1 / -1; max-width: none; min-width: 0; display: block; }
  .db-cards td.db-next::before { display: block; margin-bottom: 2px; }
  .db-cards td.db-c-act { grid-column: 1 / -1; align-items: stretch; }
  .db-cards td.db-c-act .btn { justify-content: center; background: var(--surface); }
  .db-cards .seatline { min-width: 0; }
  .db-cards .pill { align-self: flex-start; }
  .db-cards td > .btn { align-self: flex-start; }
  .db-cards tr.clickable:hover td { background: none; }
  .db-cards tr.clickable:active { background: var(--accent-soft); }
  .db-cards .db-wt tr.db-st-bad td:first-child, .db-wt tr.db-st-bad td:first-child { box-shadow: none; }
  .db-cards tr.db-st-bad { box-shadow: inset 3px 0 0 var(--bad); }
  .db-ell { max-width: 100%; }
  .db-av { background: var(--surface); }
  .db-inline { flex-wrap: wrap; }
  .db-inline .db-input { flex-basis: 100%; }
  .db-inline .btn { width: 100%; justify-content: center; }
  .db-li-act { width: 100%; margin-left: 0; }
  .db-req .db-li-act .btn { flex: 1; justify-content: center; }
  .db-meta { flex-direction: column; gap: 4px; }
  .db-seat .btn { flex: 1; justify-content: center; }
  .db-tbl:not(.db-cards) table { min-width: 560px; }
  .db-inv { min-width: 0 !important; }
  .db-inv td:first-child { min-width: 150px; }
}
@media (max-width: 380px) { .db-kpis { grid-template-columns: 1fr; } }
.db-wt td { padding-left: 10px; padding-right: 10px; }
.db-wt .db-next { min-width: 180px; max-width: 230px; }
.db-wt .db-c-main { min-width: 210px; }
@media (max-width: 720px) {
  .db-cards .meter, .db-cards .pill.neutral { background: var(--surface); }
  .db-cards .seatline .meter { min-width: 0; }
}
.db-reg td.name { white-space: nowrap; }
@media (max-width: 720px) {
  .db-cards td { order: 1; }
  .db-cards td.db-c-main { order: 0; }
  .db-cards td.db-next { order: 2; }
  .db-cards td.db-c-act { order: 3; }
  .db-reg table { min-width: 720px !important; }
}
.db .db-certlink { font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.db .db-certlink:hover { text-decoration-color: currentColor; }

/* ---------- Reports, bulk upload ---------- */
.db-rep { display: flex; gap: 8px; flex-wrap: wrap; }
.db-mp { margin: 8px 0 0; line-height: 1.5; }
.db-drop { display: flex; align-items: center; justify-content: center; margin-top: 14px; padding: 18px; border: 1.5px dashed var(--line); border-radius: 14px; background: var(--surface-2); cursor: pointer; font-weight: 600; color: var(--accent-fg); text-align: center; overflow-wrap: anywhere; }
.db-drop:hover, .db-drop:focus-within { border-color: var(--accent); }
.db-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.db-bu-out { margin-top: 14px; }
.db-bu-sum { margin: 0 0 10px; }
.db-bu-tbl { max-height: 280px; overflow: auto; }
.db-bu-tbl td { overflow-wrap: anywhere; }
.rp { max-width: 980px; margin: 24px auto 48px; }
.rp-acts { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rp-hint { color: var(--muted); font-size: .9rem; margin: 10px 0 16px; }
.rp-doc { background: #fff; color: #1D1D1F; border: 1px solid var(--line); border-radius: 16px; padding: clamp(18px, 4vw, 40px); box-shadow: var(--shadow); }
.rp-hd { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid #E5E5EA; }
.rp-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.rp-date { color: #6E6E73; font-size: .9rem; }
.rp-doc h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.02em; margin: 20px 0 4px; }
.rp-sub { color: #6E6E73; margin: 0 0 18px; }
.rp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.rp-kpis div { border: 1px solid #E5E5EA; border-radius: 12px; padding: 12px; }
.rp-kpis b { display: block; font-size: 1.5rem; letter-spacing: -.02em; }
.rp-kpis span { font-size: .8rem; color: #6E6E73; }
.rp-doc h2 { font-size: 1.15rem; margin: 26px 0 8px; }
.rp-note, .rp-none { color: #6E6E73; font-size: .85rem; margin: 0 0 8px; }
.rp-t { width: 100%; border-collapse: collapse; font-size: .82rem; }
.rp-t th { text-align: left; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: #6E6E73; border-bottom: 1.5px solid #1D1D1F; padding: 6px 8px 6px 0; }
.rp-t td { border-bottom: 1px solid #E5E5EA; padding: 7px 8px 7px 0; vertical-align: top; overflow-wrap: anywhere; }
.rp-t tr { break-inside: avoid; }
.rp-fine { margin-top: 24px; font-size: .78rem; color: #6E6E73; }
@media (max-width: 700px) {
  .rp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rp-doc { overflow-x: auto; }
  .rp-t { font-size: .74rem; }
  .rp-acts .btn { flex: 1; justify-content: center; }
}
@media print {
  .rp { margin: 0; max-width: none; }
  .rp-doc { border: 0; box-shadow: none; padding: 0; }
  .rp-t thead { display: table-header-group; }
}

.db-bu-out .au-err { color: var(--bad); font-weight: 500; }
.db-bu-tbl table { min-width: 520px; }
.db-remind { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-size: .88rem; line-height: 1.45; color: var(--muted); cursor: pointer; }
.db-remind b { color: var(--fg); margin-right: 4px; }
.db-remind input { width: 18px; height: 18px; margin-top: 1px; flex: none; accent-color: var(--accent); }
.db-reclink { font-size: .8rem; margin-top: 4px; }
