/* ==========================================================================
   HOME - greeting, date range, module tiles, charts, skeletons.
   ========================================================================== */

.brandmark[data-act='home'] { cursor: pointer; border-radius: var(--radius-sm); }
.brandmark[data-act='home']:hover .bm-name { color: var(--brand-quiet); }

/* --- Summary card: greeting, date, date range ----------------------------------- */
.view.is-home .view-head.home-summary {
  position: relative; overflow: hidden; isolation: isolate; align-items: flex-end;
  padding: 22px 22px 18px; margin-bottom: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.home-summary .hs-text, .home-summary .range-pick { position: relative; z-index: 1; }
.home-summary h1 { font-size: 28px; }
.hs-halftone, .hs-inks { display: none; }
/* Overprint: a faint halftone texture, and C, M, Y circles overprinting each other. */
:root[data-decor] .hs-halftone {
  display: block; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--ink) 9%, transparent) 1.2px, transparent 1.6px);
  background-size: 9px 9px;
  -webkit-mask-image: linear-gradient(105deg, transparent 35%, #000 85%); mask-image: linear-gradient(105deg, transparent 35%, #000 85%);
}
/* The circles get their own space at the right of the card, clear of the date range. */
:root[data-decor] .view.is-home .view-head.home-summary { padding-right: 132px; }
:root[data-decor] .hs-inks { display: block; position: absolute; z-index: 0; right: 22px; top: 50%; width: 92px; height: 76px; translate: 0 -50%; pointer-events: none; }
.hs-inks i { position: absolute; width: 50px; height: 50px; border-radius: 50%; mix-blend-mode: var(--blend); opacity: .62; }
.hs-inks i:nth-child(1) { left: 0; top: 0; background: var(--c); }
.hs-inks i:nth-child(2) { left: 30px; top: 0; background: var(--m); }
.hs-inks i:nth-child(3) { left: 15px; top: 26px; background: var(--y); }
@media (max-width: 699px) {
  .view.is-home .view-head.home-summary { padding: 16px; }
  :root[data-decor] .view.is-home .view-head.home-summary { padding-right: 16px; }
  :root[data-decor] .home-summary .hs-text { padding-right: 76px; }
  .home-summary h1 { font-size: 23px; }
  :root[data-decor] .hs-inks { right: 14px; top: 16px; translate: none; width: 62px; height: 52px; }
  .hs-inks i { width: 34px; height: 34px; }
  .hs-inks i:nth-child(2) { left: 20px; } .hs-inks i:nth-child(3) { left: 10px; top: 18px; }
}

/* Date range */
.range-pick { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.range-custom { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.range-custom .input { width: auto; min-height: 36px; padding: 4px 8px; }
@media (max-width: 699px) {
  .range-pick { align-items: stretch; width: 100%; }
  /* Every period stays in view: equal buttons in rows of three instead of a strip that runs off the screen. */
  .range-pick .seg { display: grid; grid-template-columns: repeat(3, 1fr); overflow: visible; }
  .range-pick .seg-opt span { padding: 7px 6px; min-height: var(--touch); display: flex; align-items: center; justify-content: center; text-align: center; white-space: normal; }
}

.home-sec { margin-bottom: 18px; }

/* --- Tiles ------------------------------------------------------------------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.home-tile { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; padding-top: 4px; }
.home-tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--mod, var(--line)); }
.ht-head {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 12px 14px; border: 0; background: none; text-align: left;
  font-family: var(--font-heading); font-weight: 600; font-size: 15.5px; color: var(--ink); border-bottom: 1px solid var(--line);
}
.ht-head svg { width: 18px; height: 18px; color: var(--mod-text, var(--brand-quiet)); }
.ht-head span { flex: 1; }
.ht-head .chev { transform: rotate(-90deg); color: var(--muted); width: 15px; height: 15px; }
.ht-head:hover { background: var(--panel2); }
.ht-stats { display: grid; grid-template-columns: repeat(2, 1fr); }
.ht-stat {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 0; background: none; text-align: left;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--ink);
}
.ht-stat:nth-child(2n) { border-right: 0; }
.ht-stat:nth-last-child(-n+2) { border-bottom: 0; }
.ht-stat:not([disabled]):hover { background: var(--panel2); }
.ht-stat[disabled] { cursor: default; }
.ht-stat .n { font-family: var(--font-figures); font-weight: 600; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ht-stat .k { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ht-stat.is-warn .n { color: var(--warn-text); }
.ht-stat.is-warn .k::after { content: ' \2022'; color: var(--warn); }

/* --- Charts ------------------------------------------------------------------ */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .chart-grid, .tile-grid { grid-template-columns: 1fr; } }
.home-chart { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-width: 0; }
.hc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.hc-head h2 { font-size: 15px; }
.hc-tag { font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.chart-canvas { position: relative; height: 240px; }
.chart-canvas.is-donut { height: 220px; }
.chart-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.chart-legend li > button, .chart-legend li > span {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink2); font-size: 12.5px;
}
.chart-legend li > button:hover { background: var(--panel2); color: var(--ink); }
.chart-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart-legend b { color: var(--ink); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.chart-empty { height: 200px; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--muted); text-align: center; font-size: 13.5px; }
.chart-empty svg { width: 28px; height: 28px; }
.chart-empty p { margin: 0; }

/* --- Loading and errors -------------------------------------------------------- */
.skel { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.skel span { display: block; height: 14px; border-radius: var(--radius-xs); background: linear-gradient(90deg, var(--panel2), var(--line), var(--panel2)); background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite; }
.skel span:nth-child(2) { width: 70%; } .skel span:nth-child(3) { width: 45%; }
.skel-chart { height: 240px; justify-content: center; }
.skel-tile span { height: 22px; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skel span { animation: none; } }
.sec-error {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px; font-size: 13.5px; color: var(--ink2);
}
.sec-error svg { width: 18px; height: 18px; color: var(--caution); flex: none; }

/* A changed-but-unsaved role picker stands out until Save. */
select.is-changed { border-color: var(--caution); box-shadow: 0 0 0 2px color-mix(in srgb, var(--caution) 30%, transparent); }

/* --- Needs attention --------------------------------------------------------- */
.att-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.att-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.att-head h2 { font-size: 16px; }
.att-count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--warn-fill); color: var(--on-warn);
  font: 700 12px/22px var(--font-mono); text-align: center;
}
.att-head .btn { margin-left: auto; }
.att-list { list-style: none; margin: 0; padding: 0; }
.att-list li + li { border-top: 1px solid var(--line); }
.att-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; width: 100%;
  padding: 11px 14px; border: 0; background: none; text-align: left; color: var(--ink);
  box-shadow: inset var(--stripe) 0 0 var(--s, var(--caution));
}
.att-item:hover { background: var(--panel2); }
.att-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--s-wash, var(--caution-soft)); color: var(--s, var(--caution)); }
.att-icon svg { width: 16px; height: 16px; }
.att-text { display: flex; flex-direction: column; min-width: 0; }
.att-title { font-weight: 600; font-size: 14.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.att-detail { font-size: 13px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-when { display: flex; flex-direction: column; align-items: flex-end; font-size: 12.5px; font-weight: 600; color: var(--s, var(--caution)); white-space: nowrap; }
.att-when small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.att-clear { display: flex; gap: 12px; align-items: center; padding: 16px 14px; color: var(--ink2); }
.att-clear svg { width: 28px; height: 28px; padding: 6px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); flex: none; }
.att-clear div { display: flex; flex-direction: column; }
.att-clear b { color: var(--ink); }
.modal .att-list { margin: 0 -4px; max-height: 65vh; overflow-y: auto; }
@media (max-width: 559px) {
  .att-item { grid-template-columns: auto 1fr; }
  .att-when { grid-column: 2; flex-direction: row; gap: 8px; align-items: baseline; justify-content: flex-start; }
}

/* --- Recent activity and record history ------------------------------------- */
.act-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.act-chips { margin-left: auto; gap: 6px; }
.act-chips .chip { min-height: 34px; padding: 3px 12px; font-size: 13px; }
@media (max-width: 559px) { .act-panel .att-head { flex-wrap: wrap; } .act-chips { margin-left: 0; } }
.act-list { list-style: none; margin: 0; padding: 0; }
.act-list li + li { border-top: 1px solid var(--line); }
.act-item { display: flex; gap: 11px; align-items: flex-start; width: 100%; padding: 10px 14px; border: 0; background: none; text-align: left; color: var(--ink); }
button.act-item:hover { background: var(--panel2); }
.act-avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-wash); color: var(--brand-quiet); font: 700 12px/1 var(--font-heading);
}
.act-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.act-line { font-size: 14px; overflow-wrap: anywhere; }
.act-meta { font-size: 12px; color: var(--muted); }
.act-more { padding: 10px 14px; border-top: 1px solid var(--line); text-align: center; }
.act-changes { list-style: none; margin: 4px 0 2px; padding: 6px 9px; border-radius: var(--radius-xs); background: var(--panel2); font-size: 12.5px; color: var(--ink2); }
.act-changes li { overflow-wrap: anywhere; }
.act-changes li + li { margin-top: 2px; }
.act-field { font-weight: 600; color: var(--ink); }
.act-arrow { color: var(--muted); padding: 0 2px; }
.history-card { margin-top: 14px; }
.history-card .act-item { padding: 9px 0; }
