/* Reports module: attendance reports, error logs, my attendance report. Tokens only, logical properties only. */

.rep-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); min-width: 0; }
.rep-page > * { min-width: 0; }

/* Report type card: radio cards, dates, Generate */
.rep-set { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 10px; }
.rep-set > legend { padding: 0; margin-block-end: 10px; }
.rep-types { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.rep-type {
  position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 44px;
  padding: 12px 14px; border: var(--border-width) solid var(--border); border-radius: var(--radius-lg);
  background: var(--card); color: var(--card-foreground); cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}
.rep-type:hover { background: var(--accent); color: var(--accent-foreground); }
.rep-type:has(input:checked) {
  border-color: var(--primary); background: color-mix(in oklab, var(--accent) 70%, var(--card));
  outline: var(--border-width) solid var(--primary); outline-offset: calc(var(--border-width) * -2);
}
.rep-type:has(input:focus-visible) { outline: var(--focus-ring-width) solid var(--ring); outline-offset: var(--focus-ring-offset); }
.rep-type-icon {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--radius-md);
  background: var(--muted); color: var(--muted-foreground);
}
.rep-type:has(input:checked) .rep-type-icon { background: var(--primary); color: var(--primary-foreground); }
.rep-type-text { display: grid; gap: 2px; min-width: 0; }
.rep-type-name { font-weight: 600; font-size: var(--control-font-size); }
.rep-type-desc { color: var(--muted-foreground); font-size: var(--text-body-sm-size); line-height: 1.4; }
.rep-type-mark {
  display: grid; place-items: center; flex: none; width: 20px; height: 20px; margin-inline-start: auto;
  border: var(--border-width) solid var(--input); border-radius: 999px; color: transparent; background: var(--card);
}
.rep-type:has(input:checked) .rep-type-mark { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.rep-type-mark .icon { width: 12px; height: 12px; }

.rep-dates { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--gap); align-items: start; }
.rep-dates-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto; }
.rep-go .btn { width: 100%; }
.rep-gen .field-hint { margin-block-start: -8px; }
.rep-pending { color: var(--foreground); }
.rep-pending .icon { color: var(--link); }

/* Results card heading */
.rep-res-head .card-title { margin-inline-end: 0; }
.rep-head-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-inline-start: auto; }
.rep-tiles .stat-value { font-size: 24px; }

/* Tables */
.rep-table { width: 100%; } /* fills the card; nowrap cells still let it grow and scroll inside .table-wrap */
.rep-table td, .rep-table th { white-space: nowrap; }
.rep-table td.cell-email { white-space: nowrap; min-width: 0; }
.rep-date { position: relative; }
.rep-flag-late { border-inline-start: 3px solid var(--warning); }
.rep-flag-absent { border-inline-start: 3px solid var(--destructive); }
.rep-missing { display: inline-flex; align-items: center; gap: 4px; color: var(--muted-foreground); font-size: var(--text-body-sm-size); font-weight: 500; }
.rep-strong { display: block; font-weight: 600; }
.rep-group { background: var(--card); font-weight: 600; vertical-align: middle; border-inline-end: var(--border-width) solid var(--border); }
.rep-table tbody tr:hover .rep-group { background: var(--card); }
.rep-table td.rep-group:last-child { border-inline-end: 0; }
.rep-table td.rep-group + td.rep-group { border-inline-start: 0; }
.rep-users { display: inline-grid; gap: 4px; justify-items: end; }
.rep-meter { display: block; inline-size: 72px; block-size: 4px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.rep-meter > span { display: block; block-size: 100%; background: var(--chart-1); border-radius: inherit; }
.rep-tx { white-space: nowrap; }
.rep-code {
  display: block; width: fit-content; max-width: 100%; font-family: var(--brand-font-mono, ui-monospace, monospace);
  font-size: var(--text-body-xs-size, 12px); color: var(--muted-foreground); text-align: start; unicode-bidi: isolate;
}
.rep-err { white-space: normal !important; min-width: 240px; max-width: 320px; }
.rep-table.rep-fit { width: 100%; }
.rep-fit thead th { white-space: normal; }
.rep-fit .rep-err { min-width: 220px; max-width: none; }
.rep-fit th, .rep-fit td { padding-inline: 10px; }
.rep-fit td.cell-strong, .rep-fit td.rep-tx { white-space: normal; min-width: 96px; }
.rep-fit .rep-code { overflow-wrap: anywhere; }
.rep-err-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: color-mix(in oklab, var(--destructive) 85%, var(--foreground));
}
:is(.dark) .rep-err-text { color: color-mix(in oklab, var(--destructive) 60%, white); }

.rep-pager { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--gap); }
.rep-pager .pager { border: 0; padding: 0; margin-inline-start: auto; }
.rep-showing { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

/* Error logs: live pill, message, raw log */
.rep-live {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 6px 12px;
  border: var(--border-width) solid var(--border); border-radius: 999px; background: var(--muted);
  color: var(--muted-foreground); font-size: var(--text-body-sm-size);
}
.rep-live-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--success); flex: none; }
.rep-msg {
  padding: 12px 14px; border-radius: var(--radius-lg);
  border: var(--border-width) solid color-mix(in oklab, var(--destructive) 40%, transparent);
  border-inline-start-width: 4px; border-inline-start-color: var(--destructive);
  background: color-mix(in oklab, var(--destructive) 8%, var(--popover));
}
.rep-msg p { margin: 0; }
.rep-msg-title { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-block-end: 4px !important; color: color-mix(in oklab, var(--destructive) 85%, var(--foreground)); }
:is(.dark) .rep-msg-title { color: color-mix(in oklab, var(--destructive) 60%, white); }
.rep-msg-done { border-color: color-mix(in oklab, var(--success) 40%, transparent); border-inline-start-color: var(--success); background: color-mix(in oklab, var(--success) 8%, var(--popover)); }
.rep-msg-done .rep-msg-title { color: color-mix(in oklab, var(--success) 75%, var(--foreground)); }
:is(.dark) .rep-msg-done .rep-msg-title { color: color-mix(in oklab, var(--success) 60%, white); }
.rep-raw {
  margin: 0; padding: 12px; border-radius: var(--radius-lg); border: var(--border-width) solid var(--border);
  background: var(--muted); color: var(--foreground); white-space: pre-wrap; overflow-wrap: anywhere; text-align: start;
  font-family: var(--brand-font-mono, ui-monospace, monospace); font-size: var(--text-body-sm-size); line-height: 1.5;
}
.rep-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; min-height: 44px; }

/* Check in / out dialog */
.rep-punch-who { display: grid; gap: 4px; }
.rep-punch-who p { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted-foreground); font-size: var(--text-body-sm-size); }
.rep-punch-who b { color: var(--foreground); font-weight: 600; }
.rep-punch-who .icon { color: var(--link); }
.rep-ps-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.rep-ps { display: grid; justify-items: center; gap: 2px; padding: 10px 6px; border: var(--border-width) solid var(--border); border-radius: var(--radius-lg); text-align: center; }
.rep-ps b { font-size: 20px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.rep-ps span { color: var(--muted-foreground); font-size: var(--text-body-xs-size, 12px); }
.rep-ps-total b { color: var(--link); }
.rep-ps-ok b { color: color-mix(in oklab, var(--success) 75%, var(--foreground)); }
.rep-ps-failed b { color: color-mix(in oklab, var(--destructive) 85%, var(--foreground)); }
.rep-ps-pending b { color: var(--warning-foreground); }
:is(.dark) .rep-ps-ok b { color: color-mix(in oklab, var(--success) 60%, white); }
:is(.dark) .rep-ps-failed b { color: color-mix(in oklab, var(--destructive) 60%, white); }
:is(.dark) .rep-ps-pending b { color: var(--warning); }
.rep-punches { list-style: none; margin: 0; padding: 0; border-block-start: var(--border-width) solid var(--border); }
.rep-punch { display: flex; align-items: center; gap: 12px; padding-block: 10px; border-block-end: var(--border-width) solid var(--border); }
.rep-punch:last-child { border-block-end: 0; }
.rep-punch-dir { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 999px; }
.rep-dir-in { background: color-mix(in oklab, var(--success) 14%, var(--popover)); color: color-mix(in oklab, var(--success) 75%, var(--foreground)); }
.rep-dir-out { background: color-mix(in oklab, var(--destructive) 12%, var(--popover)); color: color-mix(in oklab, var(--destructive) 85%, var(--foreground)); }
:is(.dark) .rep-dir-in { color: color-mix(in oklab, var(--success) 60%, white); }
:is(.dark) .rep-dir-out { color: color-mix(in oklab, var(--destructive) 60%, white); }
.rep-punch-dir .icon { width: 18px; height: 18px; }
.rep-punch-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rep-punch-main p { margin: 0; }
.rep-punch-time { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.rep-punch-kind { color: var(--muted-foreground); font-size: var(--text-body-sm-size); }
.rep-punch-loc { display: flex; align-items: center; gap: 6px; color: var(--muted-foreground); font-size: var(--text-body-sm-size); }
.rep-punch-loc .icon { flex: none; }
.rep-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding-inline: 8px; border-radius: 999px;
  background: var(--muted); color: var(--muted-foreground); font-size: var(--text-body-xs-size, 12px); font-weight: 500;
}
.rep-chip .icon { width: 12px; height: 12px; }

/* My attendance: person strip */
.rep-person { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding: var(--card-padding); }
.rep-person p { margin: 0; }
.rep-person-meta { list-style: none; margin: 0; margin-inline-start: auto; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.rep-person-meta li { padding: 4px 10px; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); font-size: var(--text-body-sm-size); }

/* Print view */
.rep-print { display: grid; gap: var(--space-4); }
.rep-print-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--gap); padding: 12px 16px;
  border: var(--border-width) solid var(--border); border-radius: var(--radius-lg); background: var(--card);
}
.rep-print-bar p { display: flex; align-items: center; gap: 8px; flex: 1 1 280px; margin: 0; color: var(--muted-foreground); font-size: var(--text-body-sm-size); }
.rep-print-bar p > .icon { color: var(--link); flex: none; }
.rep-print-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rep-print .page-head { margin-block-end: 0; }
.rep-print-meta { margin: 0; color: var(--muted-foreground); font-size: var(--text-body-sm-size); }

/* Responsive */
@media (max-width: 1100px) {
  .rep-types { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rep-dates-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .rep-types, .rep-dates, .rep-dates-3 { grid-template-columns: minmax(0, 1fr); }
  .rep-type { align-items: center; padding-block: 8px; }
  .rep-type-desc { display: none; }
  .rep-spacer { display: none; }
  .rep-head-tools { margin-inline-start: 0; width: 100%; }
  .rep-head-tools .btn { flex: 1 1 0; }
  .rep-ps-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rep-person-meta { margin-inline-start: 0; }
  .rep-pager .pager { margin-inline-start: 0; width: 100%; }
}
@media (max-width: 720px), (pointer: coarse) {
  .rep-act { min-height: 44px; min-width: 44px; }
  .rep-type { min-height: 56px; }
}

/* Print: only the report. Scoped to pages that show the print view. */
@page rep-landscape { size: A4 landscape; margin: 10mm; }
@media print {
  html.dark:has(.rep-print) {
    --background: var(--surface-background); --foreground: var(--surface-foreground); --card: var(--surface-card);
    --card-foreground: var(--surface-foreground); --muted: var(--surface-muted); --muted-foreground: var(--surface-muted-foreground);
    --border: var(--surface-border); --secondary: var(--surface-secondary); --secondary-foreground: var(--surface-foreground);
    --popover: var(--surface-popover); --popover-foreground: var(--surface-foreground); --link: var(--brand-link);
  }
  body:has(.rep-print) { background: var(--card); }
  body:has(.rep-print) .app-header, body:has(.rep-print) .sidebar, body:has(.rep-print) .skip,
  body:has(.rep-print) .toaster, body:has(.rep-print) .scrim { display: none !important; }
  body:has(.rep-print) .app { display: block; background: none; min-height: 0; }
  body:has(.rep-print) .main { padding: 0; background: none; }
  .rep-print { page: rep-landscape; gap: 8px; }
  .rep-noprint, .rep-print .page-head .back { display: none !important; }
  .rep-print .h-page { font-size: 20px; }
  .rep-print .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .rep-print .stat-card { box-shadow: none; padding: 8px 10px; break-inside: avoid; }
  .rep-print .stat-icon { display: none; }
  .rep-print .stat-value { font-size: var(--text-body-lg-size, 18px); }
  .rep-print .table-wrap { overflow: visible; border: 0; border-radius: 0; }
  .rep-print .table { width: 100%; min-width: 0; font-size: 8pt; }
  .rep-print .table th, .rep-print .table td { padding: 3px 4px; white-space: normal; }
  .rep-print .table thead th { position: static; }
  .rep-print thead { display: table-header-group; }
  .rep-print tr { break-inside: avoid; }
  .rep-print .status { height: auto; padding: 0; background: none !important; }
  .rep-print .rep-meter { display: none; }
}
