/* ============================================================================
   Kabstour — dashboard layer
   ----------------------------------------------------------------------------
   Loaded after the refinement layer on BOTH the portal and the admin panel,
   which is the point: before this file the three dashboards were three
   different products. The employer's and the resource's were built from
   Bootstrap rows with a block of hand-written CSS at the top of each view;
   the admin's was still the template's own marketplace dashboard, reporting
   order revenue and jobs posted on a platform that sells neither.

   Everything here is namespaced .kd-. Nothing overrides an existing class, so
   this file cannot break a screen it was not applied to, and the old .kp-
   components (hero, folder, feed) go on working beside it.

   Three rules this file keeps:
     1. A figure never appears without what it is measured against. A number
        on its own invites a guess; a number with "+3 this week" under it
        does not.
     2. Anything that is a link looks like one and is one -- the whole tile,
        not a word inside it.
     3. Phone first. Every grid starts narrow and earns more columns.
   ========================================================================= */

:root {
  /* Fall back to literals so this file also works on the admin panel, which
     does not load the portal's token sheet. */
  --kd-brand:        var(--kp-primary, #F7412B);
  --kd-brand-dark:   var(--kp-primary-dark, #C7331E);
  --kd-brand-wash:   var(--kp-primary-light, #FDECE9);
  --kd-gold:         var(--kp-gold, #C2AD63);

  --kd-ink:          var(--kp-text-primary, #1D2632);
  --kd-ink-2:        var(--kp-text-secondary, #4B5563);
  --kd-mute:         var(--kp-text-tertiary, #6B7280);

  --kd-card:         #FFFFFF;
  --kd-line:         var(--kp-border, #E5E7EB);
  --kd-line-soft:    #EEF0F4;
  --kd-wash:         #F7F8FA;

  --kd-good:         #047857;
  --kd-good-bg:      #ECFDF5;
  --kd-warn:         #B45309;
  --kd-warn-bg:      #FFFBEB;
  --kd-bad:          #B42318;
  --kd-bad-bg:       #FEF3F2;
  --kd-cool:         #0369A1;
  --kd-cool-bg:      #F0F9FF;

  --kd-r:            12px;
  --kd-r-sm:         9px;
  --kd-rest:         0 1px 2px rgba(16, 24, 40, .05);
  --kd-lift:         0 8px 24px rgba(16, 24, 40, .10);
  --kd-ease:         cubic-bezier(.2, .7, .3, 1);

  --kd-gap:          16px;
}

@media (min-width: 992px) {
  :root { --kd-gap: 20px; }
}

/* The page scope. Stacks every band with one gap, so no band carries its own
   bottom margin and nothing double-spaces when a band is conditional. */
.kd {
  display: flex;
  flex-direction: column;
  gap: var(--kd-gap);
  /* The page scope sits inside layouts this file does not own -- the admin
     panel's content column among them -- and a flex or grid item defaults to
     min-width:auto, which lets a wide child push the whole column out rather
     than being clipped. Pinned defensively, not in response to an observed
     break: measured at 390px the Latest Contracts table scrolls inside its
     own box and the page does not move sideways. */
  min-width: 0;
  max-width: 100%;
}

.kd > * { min-width: 0; max-width: 100%; }

/* --- SECTION HEAD --------------------------------------------------------
   A title, an optional one-line explanation, and an optional link on the
   right. Used by every band, so a section never has to invent its own. */

.kd-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.kd-head h2,
.kd-head h3 {
  font-size: 16px !important;
  font-weight: 700 !important;
  letter-spacing: -.01em;
  color: var(--kd-ink);
  margin: 0 !important;
  line-height: 1.3 !important;
}

.kd-head p {
  font-size: 13px;
  color: var(--kd-mute);
  margin: 3px 0 0;
  line-height: 1.5;
}

.kd-head-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--kd-brand);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kd-head-link:hover { color: var(--kd-brand-dark); text-decoration: underline; }
.kd-head-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; }

/* --- PANEL ---------------------------------------------------------------
   One surface. One border. One radius. The page background does the
   separating, so a panel needs no shadow at rest. */

.kd-panel {
  background: var(--kd-card);
  border: 1px solid var(--kd-line);
  border-radius: var(--kd-r);
  padding: 18px;
}

.kd-panel > .kd-head { margin-bottom: 16px; }
.kd-panel-tight { padding: 0; }
.kd-panel-tight > .kd-head { padding: 18px 18px 0; margin-bottom: 14px; }

/* --- METRICS -------------------------------------------------------------
   The figure row. One column on a phone would spend a whole screen on four
   numbers, so it is two from the smallest width and widens from there.
   auto-fit is deliberately NOT used: it reflows unpredictably when the
   number of tiles differs between roles. */

.kd-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 768px)  { .kd-metrics { gap: var(--kd-gap); } }
@media (min-width: 992px)  { .kd-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Six tiles in a four-column grid come out four and two, with a hole beside
   them. Three columns divides six exactly; six columns divides it exactly
   again once there is room. */
@media (min-width: 992px)  { .kd-metrics-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* 1700, not 1400. Measured on the admin panel at 1440: six columns beside a
   320px menu gave each tile 165px, and "Payslips, last 30 days" wrapped to
   three lines. Three across and two rows reads better until there is real
   room for six. */
@media (min-width: 1700px) { .kd-metrics-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* Three tiles in a two-column grid leave a hole at the end of the second
   row. The odd one out spans the width instead, so the row always fills --
   which is the thing the client pointed at first. */
.kd-metrics-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kd-metrics-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }

@media (min-width: 992px) {
  .kd-metrics-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kd-metrics-3 > :last-child:nth-child(odd) { grid-column: auto; }
}

/* The plain .kd-metrics row gets no such rule on purpose. It is used with a
   spotlight tile, which already spans the full width on a phone, so an
   "odd last child" rule there would push the SECOND tile into a half-width
   row of its own -- the very hole it was meant to close. The rows that use
   it are sized to fill: spotlight (2) + 2 tiles = 4 across. */

.kd-metric {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 16px;
  background: var(--kd-card);
  border: 1px solid var(--kd-line);
  border-radius: var(--kd-r);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: border-color 140ms var(--kd-ease), box-shadow 140ms var(--kd-ease), transform 140ms var(--kd-ease);
}

/* A tile that is a link says so on hover and on keyboard focus, and the
   whole tile is the target -- not a word inside it. */
a.kd-metric:hover,
a.kd-metric:focus-visible {
  border-color: var(--kd-brand);
  box-shadow: var(--kd-lift);
  transform: translateY(-2px);
  outline: none;
  text-decoration: none;
}

.kd-metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.kd-metric-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: var(--kd-r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--kd-wash);
  color: var(--kd-ink-2);
}

.kd-metric-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.kd-metric-icon-brand { background: var(--kd-brand-wash); color: var(--kd-brand); }
.kd-metric-icon-good  { background: var(--kd-good-bg);    color: var(--kd-good); }
.kd-metric-icon-warn  { background: var(--kd-warn-bg);    color: var(--kd-warn); }
.kd-metric-icon-cool  { background: var(--kd-cool-bg);    color: var(--kd-cool); }
.kd-metric-icon-gold  { background: #F7F1DD;              color: #8A7331; }

.kd-metric-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--kd-ink);
  /* A currency figure can be long. It wraps rather than pushing the tile
     wider and putting a sideways scrollbar on the page. */
  overflow-wrap: anywhere;
}

.kd-metric-money { font-size: 21px; }

.kd-metric-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--kd-mute);
  line-height: 1.4;
}

/* --- DELTA ---------------------------------------------------------------
   What the figure is measured against. Direction is carried by the arrow and
   the wording as well as the colour, so it still reads without colour. */

.kd-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.kd-delta svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.kd-delta-up   { background: var(--kd-good-bg); color: var(--kd-good); }
.kd-delta-down { background: var(--kd-bad-bg);  color: var(--kd-bad); }
.kd-delta-flat { background: var(--kd-wash);    color: var(--kd-mute); }

.kd-metric-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--kd-line-soft);
  font-size: 11.5px;
  color: var(--kd-mute);
  line-height: 1.45;
}

/* --- SPOTLIGHT -----------------------------------------------------------
   The money tile. One per dashboard, and it carries the brand so the eye
   lands on it first. It spans both phone columns, because a currency figure
   in half a phone width wraps to three lines. */

.kd-metric-spot {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--kd-brand) 0%, var(--kd-brand-dark) 100%);
  border-color: transparent;
  color: #fff;
}

@media (min-width: 992px) { .kd-metric-spot { grid-column: span 2; } }

/* It is twice the width of a plain tile, so the figure is sized for the
   room it has rather than sitting small in a wide box. */
.kd-metric-spot .kd-metric-value { font-size: 32px; }
.kd-metric-spot .kd-metric-money { font-size: 28px; }

/* The same soft corner light the hero band carries, so the two read as one
   family rather than two gradients that happen to share a colour. */
.kd-metric-spot::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -70px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 65%);
  pointer-events: none;
}

.kd-metric-spot > * { position: relative; z-index: 1; }

.kd-metric-spot .kd-metric-value,
.kd-metric-spot .kd-metric-label { color: #fff; }
.kd-metric-spot .kd-metric-label { opacity: .88; }
.kd-metric-spot .kd-metric-icon { background: rgba(255,255,255,.18); color: #fff; }
.kd-metric-spot .kd-metric-foot { border-top-color: rgba(255,255,255,.26); color: rgba(255,255,255,.9); }
.kd-metric-spot .kd-delta { background: rgba(255,255,255,.2); color: #fff; }

a.kd-metric-spot:hover,
a.kd-metric-spot:focus-visible { border-color: transparent; }

/* --- ATTENTION -----------------------------------------------------------
   What this person has to do, in the order it matters, each one a link to
   where it is done. This is the band that makes a dashboard useful rather
   than decorative, so it sits above the figures -- and it renders only when
   there is something in it. An empty "nothing to do" card is noise. */

.kd-attention {
  border: 1px solid var(--kd-line);
  border-radius: var(--kd-r);
  background: var(--kd-card);
  overflow: hidden;
}

.kd-attention-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 18px;
  background: var(--kd-wash);
  border-bottom: 1px solid var(--kd-line);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--kd-ink);
}

.kd-attention-head svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.kd-attention-count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--kd-brand-wash);
  color: var(--kd-brand);
  border-radius: 999px;
  padding: 2px 9px;
}

.kd-task {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--kd-line-soft);
  text-decoration: none;
  color: inherit;
  transition: background 120ms var(--kd-ease);
}

.kd-task:last-child { border-bottom: 0; }
.kd-task:hover, .kd-task:focus-visible { background: var(--kd-wash); outline: none; text-decoration: none; }

.kd-task-mark {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: var(--kd-r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kd-task-mark svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kd-task-urgent .kd-task-mark { background: var(--kd-bad-bg);  color: var(--kd-bad); }
.kd-task-due    .kd-task-mark { background: var(--kd-warn-bg); color: var(--kd-warn); }
.kd-task-info   .kd-task-mark { background: var(--kd-cool-bg); color: var(--kd-cool); }

.kd-task-body { flex: 1; min-width: 0; }
.kd-task-title { display: block; font-size: 14px; font-weight: 600; color: var(--kd-ink); line-height: 1.35; }
.kd-task-sub { display: block; font-size: 12.5px; color: var(--kd-mute); line-height: 1.45; margin-top: 2px; }

.kd-task-go { flex: 0 0 auto; color: var(--kd-mute); display: inline-flex; }
.kd-task-go svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.kd-task:hover .kd-task-go { color: var(--kd-brand); }

/* --- SPLIT --------------------------------------------------------------
   Two panels side by side on a wide screen, stacked below it. Replaces the
   Bootstrap row/col each of the three dashboards used differently. */

.kd-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--kd-gap);
}

@media (min-width: 992px) {
  .kd-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kd-split-wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
}

/* Two panels side by side are stretched to the taller one's height by the
   grid, which left a pocket of empty white under the shorter one's content.
   The panel becomes a column and its closing block is pushed to the floor,
   so the pair reads as two filled panels rather than one and a half. */
.kd-split > .kd-panel { display: flex; flex-direction: column; }
.kd-facts-tail { margin-top: auto; padding-top: 18px; }

/* --- FUNNEL -------------------------------------------------------------
   The hiring pipeline, as stages with a bar each. A funnel answers the
   question four separate counters cannot: where the drop-off is. Bar widths
   come from an inline --kd-w, because only the server knows the figures. */

.kd-funnel { display: flex; flex-direction: column; gap: 14px; }

.kd-stage { min-width: 0; }

.kd-stage-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.kd-stage-name { font-size: 13px; font-weight: 600; color: var(--kd-ink-2); min-width: 0; overflow-wrap: anywhere; }
.kd-stage-figure { font-size: 14px; font-weight: 700; color: var(--kd-ink); white-space: nowrap; }
.kd-stage-figure small { font-weight: 500; color: var(--kd-mute); font-size: 11.5px; margin-left: 4px; }

.kd-stage-track {
  height: 9px;
  border-radius: 999px;
  background: var(--kd-line-soft);
  overflow: hidden;
}

.kd-stage-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  width: calc(var(--kd-w, 0) * 1%);
  background: var(--kd-brand);
  transition: width .5s var(--kd-ease);
}

/* Later stages are lighter, so the shape of the funnel is visible at a
   glance rather than read off the numbers. */
.kd-stage:nth-child(2) .kd-stage-fill { background: #F7714B; }
.kd-stage:nth-child(3) .kd-stage-fill { background: var(--kd-gold); }
.kd-stage:nth-child(4) .kd-stage-fill { background: var(--kd-good); }

/* --- SPARK --------------------------------------------------------------
   A twelve-bar trend, in CSS. No charting library: it is a dozen divs, it
   costs nothing, and it cannot fail to load. Heights are inline, from the
   server. */

.kd-spark {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 72px;
  margin-top: 4px;
}

.kd-spark-bar {
  flex: 1 1 0;
  min-width: 0;
  min-height: 3px;
  height: calc(var(--kd-h, 0) * 1%);
  background: var(--kd-brand-wash);
  border-radius: 4px 4px 2px 2px;
  transition: background 140ms var(--kd-ease);
}

.kd-spark-bar:last-child { background: var(--kd-brand); }
.kd-spark:hover .kd-spark-bar { background: #FBD5CD; }
.kd-spark:hover .kd-spark-bar:hover,
.kd-spark:hover .kd-spark-bar:last-child { background: var(--kd-brand); }

.kd-spark-axis {
  display: flex;
  gap: 5px;
  margin-top: 7px;
}

.kd-spark-axis span {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-size: 10px;
  color: var(--kd-mute);
  overflow: hidden;
  white-space: nowrap;
}

/* --- RECORD LIST --------------------------------------------------------
   Offers, payslips, contracts. Replaces three near-identical .offer-card
   blocks that lived in style tags at the top of the views. */

.kd-list { display: flex; flex-direction: column; }

.kd-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 18px;
  border-top: 1px solid var(--kd-line-soft);
  text-decoration: none;
  color: inherit;
  transition: background 120ms var(--kd-ease);
}

.kd-row:first-child { border-top: 0; }
.kd-row:hover, .kd-row:focus-visible { background: var(--kd-wash); outline: none; text-decoration: none; }

.kd-row-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--kd-brand-wash);
  color: var(--kd-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  overflow: hidden;
}

.kd-row-avatar img { width: 100%; height: 100%; object-fit: cover; }

.kd-row-body { flex: 1; min-width: 0; }
.kd-row-title { display: block; font-size: 14px; font-weight: 600; color: var(--kd-ink); line-height: 1.35; overflow-wrap: anywhere; }

.kd-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--kd-mute);
  line-height: 1.45;
}

.kd-row-meta span { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.kd-row-meta svg { width: 13px; height: 13px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.kd-row-end { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }

/* The status pill on a row. The same five states everywhere, named rather
   than numbered, so a view never picks a colour by hand again. */
.kd-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--kd-wash);
  color: var(--kd-ink-2);
}

.kd-pill-wait { background: var(--kd-warn-bg); color: var(--kd-warn); }
.kd-pill-live { background: var(--kd-good-bg); color: var(--kd-good); }
.kd-pill-cool { background: var(--kd-cool-bg); color: var(--kd-cool); }
.kd-pill-stop { background: var(--kd-bad-bg);  color: var(--kd-bad); }

/* On a phone the status and the chevron drop above the title rather than
   squeezing it to two characters a line. */
@media (max-width: 575px) {
  .kd-row { flex-wrap: wrap; }
  .kd-row-body { flex: 1 1 100%; order: 2; }
  .kd-row-avatar { order: 1; }
  .kd-row-end { order: 1; margin-left: auto; }
}

.kd-row-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--kd-line);
  background: var(--kd-wash);
  text-align: center;
}

.kd-row-foot a { font-size: 13px; font-weight: 600; color: var(--kd-brand); text-decoration: none; }
.kd-row-foot a:hover { text-decoration: underline; }

/* --- EMPTY --------------------------------------------------------------
   Says what is missing, why, and what to do about it. A grey icon and the
   words "No data" tell somebody nothing they did not already know. */

.kd-empty { padding: 34px 20px; text-align: center; }

.kd-empty-mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 13px;
  border-radius: var(--kd-r-sm);
  background: var(--kd-wash);
  color: var(--kd-mute);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kd-empty-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.kd-empty h4 { font-size: 14.5px !important; font-weight: 650 !important; color: var(--kd-ink); margin: 0 0 5px !important; }
.kd-empty p { font-size: 13px; color: var(--kd-mute); margin: 0 auto; max-width: 42ch; line-height: 1.55; }
.kd-empty .kd-btn { margin-top: 15px; }

/* --- BUTTONS ------------------------------------------------------------
   Two. One that performs the page's action, one that does not shout. */

.kd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--kd-r-sm);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms var(--kd-ease), border-color 140ms var(--kd-ease), transform 140ms var(--kd-ease);
}

.kd-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kd-btn-primary { background: var(--kd-brand); color: #fff; }
.kd-btn-primary:hover { background: var(--kd-brand-dark); color: #fff; transform: translateY(-1px); }
.kd-btn-quiet { background: var(--kd-card); border-color: var(--kd-line); color: var(--kd-ink); }
.kd-btn-quiet:hover { border-color: var(--kd-brand); color: var(--kd-brand); }

/* --- FACTS --------------------------------------------------------------
   A short label-and-value list inside a panel. The admin panel had eleven
   settings in a list styled for country names; this is the shape that list
   should have had. */

.kd-facts { list-style: none; margin: 0; padding: 0; }

.kd-facts li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--kd-line-soft);
  font-size: 13px;
}

.kd-facts li:last-child { border-bottom: 0; }
.kd-fact-key { color: var(--kd-mute); min-width: 0; overflow-wrap: anywhere; }
.kd-fact-val { font-weight: 600; color: var(--kd-ink); text-align: right; white-space: nowrap; }

/* --- ADMIN PAGE HEAD ----------------------------------------------------
   The admin dashboard had no title at all: it opened on a row of figures.
   A greeting band would be out of place there, so it gets a plain head. */

.kd-pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.kd-pagehead h1 {
  font-size: 22px !important;
  font-weight: 700 !important;
  letter-spacing: -.02em;
  color: var(--kd-ink);
  margin: 0 !important;
}

.kd-pagehead p { font-size: 13.5px; color: var(--kd-mute); margin: 4px 0 0; }

.kd-stamp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--kd-mute);
  background: var(--kd-card);
  border: 1px solid var(--kd-line);
  border-radius: 999px;
  padding: 7px 14px;
  white-space: nowrap;
}

.kd-stamp svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- CHART BOX ----------------------------------------------------------
   A canvas with no height of its own grows without limit inside a flex or
   grid child. Chart.js is told not to keep its aspect ratio, and the height
   is set here. */

.kd-chartbox { position: relative; height: 260px; min-width: 0; }
.kd-chartbox canvas { max-width: 100%; }

/* --- TABLE --------------------------------------------------------------
   One table treatment for the admin dashboard, in its own scroll box so a
   wide table never widens the page itself. */

.kd-tablebox {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Without max-width the box takes the table's content width instead of its
     parent's, and then there is nothing to scroll inside -- the page scrolls
     instead, which is the thing the box exists to prevent. */
  max-width: 100%;
  width: 100%;
}

.kd-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.kd-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--kd-mute);
  background: var(--kd-wash);
  padding: 11px 14px;
  white-space: nowrap;
}

.kd-table td { padding: 12px 14px; border-top: 1px solid var(--kd-line-soft); color: var(--kd-ink-2); white-space: nowrap; }
.kd-table tbody tr:hover td { background: var(--kd-wash); }

/* --- SWITCH --------------------------------------------------------------
   The resource's "available for hire" toggle. It used to be defined in a
   style block at the top of that one view; it lives here because it is the
   only switch in the product and there should go on being only one.

   44px of hit area, not 26: a switch is operated with a thumb. */

.toggle-switch { position: relative; display: inline-block; width: 50px; height: 28px; flex: 0 0 auto; }
.toggle-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

.toggle-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #C9CDD6;
  border-radius: 999px;
  transition: background 180ms var(--kd-ease);
  pointer-events: none;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .25);
  transition: transform 180ms var(--kd-ease);
}

.toggle-switch input:checked + .toggle-slider { background: var(--kd-good); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow: 0 0 0 3px rgba(4, 120, 87, .25); }

/* --- ACTION TILES INSIDE A PANEL ----------------------------------------
   The shared .kp-action-grid fits as many 170px tiles as the width allows,
   which is right for a bare grid and wrong inside a panel: six tiles at
   1440px came out five across with one stranded underneath, and the panel
   grew a row of empty space to hold it. Inside a dashboard panel the count
   is fixed instead -- three across, so six fill two rows exactly and four
   fill one and a bit rather than one and an orphan. */

.kd-panel .kp-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

@media (min-width: 768px) {
  .kd-panel .kp-action-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

/* --- MOTION -------------------------------------------------------------
   Bars and tiles animate. Somebody who has asked their system not to
   animate things gets none of it. */

@media (prefers-reduced-motion: reduce) {
  .kd-metric, .kd-stage-fill, .kd-spark-bar, .kd-task, .kd-row, .kd-btn { transition: none !important; }
  a.kd-metric:hover, .kd-btn-primary:hover { transform: none; }
}

/* ─── THE SPOTLIGHT TILE STOPS DOUBLING ONCE THERE IS REAL ROOM ────────────
   The row is spotlight (2 columns) + two plain tiles = 4 across, which is
   right up to about 1400px of content. Past that the spotlight just gets
   wider without getting taller: measured at a 1700px window after the
   signed-in pages were allowed to use it, the wallet tile was 670 x 175 —
   nearly four to one, a big flat block with a figure stranded in the corner.
   That is the "too short and big" the client pointed at.

   From 1500px the row is three equal columns instead, so the spotlight keeps
   its colour and its prominence without becoming a banner. Its figure comes
   down a step with it, because 32px was sized for a tile twice this wide. */
@media (min-width: 1500px) {
  .kd-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kd-metric-spot { grid-column: auto; }
  .kd-metric-spot .kd-metric-value { font-size: 30px; }
  .kd-metric-spot .kd-metric-money { font-size: 27px; }
}

/* A floor, so a tile with one short line in it is not half the height of the
   one beside it. Not a fixed height: a tile with a comparison line under it
   is legitimately taller, and cropping that would lose the comparison. */
@media (min-width: 992px)  { .kd-metric { min-height: 148px; } }

/* The floor rises with the width, so a tile does not flatten out as the row
   gets wider. Measured at 1920 without this: 500 x 167, three to one. The
   figures want to sit in a card, not in a strip. */
@media (min-width: 1500px) { .kd-metric { min-height: 168px; } }
@media (min-width: 1800px) { .kd-metric { min-height: 190px; } }
