/* Fixed labels never wrap: auto layout preserves their intrinsic minimum width.
   Narrow viewports scroll the table instead of shrinking Japanese headings. */
:root { --row-band-a:var(--surface); --row-band-b:var(--canvas); }
:root[data-theme=dark] { --row-band-a:var(--surface); --row-band-b:var(--surface-raised); }
.table-scroll tbody>tr:nth-child(even):not(.band-a):not(.band-b):not(.warning-row)>:is(th,td) { background:var(--row-band-b); }
.table-scroll table,.business-page .table-scroll table,.settings-page>.table-scroll table,.audit-page>.table-scroll table { table-layout:auto; }
.table-scroll thead th,.shift-table thead th,.shift-timeline thead th,.day-timeline thead th,.conflict-comparison thead th {
    white-space:nowrap; overflow-wrap:normal; word-break:normal; text-align:center;
}
.table-scroll :is(th,td),.shift-table :is(th,td),.day-timeline :is(th,td) { border-inline-end:1px dashed var(--border-subtle); }
.table-scroll tr>:last-child,.shift-table tr>:last-child,.day-timeline tr>:last-child { border-inline-end:0; }
/* Put the action/date separator inside the date column: a 44px touch button
   must not enlarge the pinned 44px action column by the border's extra pixel. */
.table-scroll .sticky-action,.shift-table .pin-action,.audit-page>.table-scroll tr>:first-child { border-inline-end:0; }
.table-scroll .sticky-date,.shift-table .pin-date,.audit-page>.table-scroll tr>:nth-child(2) { border-inline-start:1px dashed var(--border-subtle); }
.table-scroll :is(th,td).numeric,.shift-table .numeric,.table-scroll .date-cell,.table-scroll .sticky-date,.shift-table .pin-date,.shift-timeline .pin-date,.audit-page>.table-scroll tr>:nth-child(2),.day-timeline .day-time-axis { text-align:center; white-space:nowrap; font-variant-numeric:tabular-nums; }
.shift-timeline thead .pin-person,.shift-timeline thead .pin-date { text-align:center; }
.sync-page>.table-scroll :is(th,td) { text-align:center; white-space:nowrap; font-variant-numeric:tabular-nums; }
.shift-timeline .hour-tick>span:not(.last-hour) { left:0; }
.table-scroll .date-cell .issue-note { white-space:normal; text-align:left; }
.table-scroll tfoot :is(th,td),.shift-table tfoot :is(th,td),.day-timeline tfoot :is(th,td) {
    position:sticky; bottom:0; z-index:3; background:var(--surface-subtle);
    border-top:1px solid var(--border-control); box-shadow:0 -1px var(--border-subtle);
}
.business-page .table-scroll tfoot .sticky-first { z-index:5; }
.table-scroll .band-b:not(.warning-row)>.sticky-first { background:var(--row-band-b); }
.day-timeline { table-layout:auto; }
.day-timeline thead th:not(.day-time-axis) { min-width:180px; max-width:none; }
.table-scroll,.shift-table-scroll { scroll-padding-bottom:52px; }
.table-scroll thead .sticky-action,.shift-table thead .pin-action { min-width:44px; }
.settings-page { --settings-actions:88px; }
.settings-page.user-settings { --settings-actions:208px; }
.settings-page>.table-scroll tr>:first-child { width:var(--settings-actions); min-width:var(--settings-actions); max-width:var(--settings-actions); text-align:center; }
.settings-page>.table-scroll tr>:nth-child(2) { left:var(--settings-actions); }
.settings-page>.table-scroll tr>:nth-child(2) { min-width:104px; }
.audit-page>.table-scroll tr>:first-child { min-width:44px; max-width:44px; }
.audit-page>.table-scroll tr>:nth-child(2) { min-width:192px; }
/* Fact tables end with type-or-place, a name column and memo. Japanese text may wrap between
   any two characters, so auto layout squeezes short columns unless they have a minimum.
   Minimums fit the real data in the 14px cell font with 12px padding on each side:
   type ≤6 ideographs (108px), place ≤5 characters (94px), Japanese name 3+3 with a space
   (≈111px). Longer names wrap at the space. Pixels, because the header font is 13px. */
.business-page:is([data-scope=user],[data-scope=work_place],[data-scope=work_type]) .table-scroll thead th { min-width:6em; }
.business-page[data-scope=user] .table-scroll thead th:nth-child(12) { min-width:8em; }
.business-page:is([data-scope=user],[data-scope=work_place]) .table-scroll thead th:nth-last-child(3) { min-width:112px; }
.business-page[data-scope=user] .table-scroll thead th:nth-last-child(2),
.business-page[data-scope=work_type] .table-scroll thead th:nth-last-child(3) { min-width:100px; }
.business-page:is([data-scope=work_place],[data-scope=work_type]) .table-scroll thead th:nth-last-child(2) { min-width:120px; }
.business-page:is([data-scope=user],[data-scope=work_place],[data-scope=work_type]) .table-scroll thead th:last-child { min-width:18em; }
/* Reference lists keep their natural width instead of distributing empty space
   across short columns. The region still scrolls vertically and horizontally. */
.business-page>.table-compact { align-self:flex-start; width:fit-content; max-width:100%; flex:0 1 auto; min-height:84px; margin-bottom:16px; }
.business-page>.table-compact table { width:auto; min-width:0; }
.business-page>.table-compact :is(th,td) { max-width:360px; }
.settings-page>.table-compact tr>:nth-child(3) { min-width:220px; }
.settings-page.user-settings>.table-compact tr>:nth-child(4) { min-width:240px; }
.settings-page.user-settings>.table-compact tr>:nth-child(n+5) { white-space:nowrap; }
.sync-page>.table-compact tr>:first-child { min-width:248px; }
.sync-page>.table-compact tr>:nth-child(n+2) { min-width:88px; }
.sync-page>.section-heading { width:426px; max-width:100%; }
/* Avoid stretching action cells in auto-layout tables; the remainder of the
   table absorbs free space. Pinned offsets remain 44px. */
.table-scroll .sticky-action,.shift-table .pin-action { width:44px; min-width:44px; max-width:44px; white-space:nowrap; }

/* Calendar is a small non-modal reference surface, never a form or date input. */
.floating-calendar { position:fixed; width:320px; max-width:calc(100vw - 16px); max-height:calc(100dvh - 16px); overflow:auto; z-index:20; border:1px solid var(--border-control); border-radius:10px; background:var(--surface-raised); color:var(--text-primary); box-shadow:var(--shadow); }
.calendar-widget-header { display:flex; align-items:center; border-bottom:1px solid var(--border-subtle); padding:2px 4px; }
.calendar-drag { display:flex; align-items:center; gap:8px; flex:1; min-width:0; min-height:40px; padding:4px 8px; background:transparent; border:0; border-radius:6px; cursor:grab; touch-action:none; user-select:none; font-size:14px; font-weight:600; }
.calendar-drag:active { cursor:grabbing; }
.compact-calendar { padding:4px 8px; }
.compact-calendar .calendar-nav h2 { font-size:16px; margin:0; white-space:nowrap; }
.compact-calendar table { width:100%; min-width:0; border-collapse:separate; border-spacing:2px; table-layout:fixed; text-align:center; }
.compact-calendar th { height:24px; font-size:12px; font-weight:500; text-align:center; white-space:nowrap; color:var(--text-secondary); }
.compact-calendar td { height:28px; padding:0; border:0; border-radius:4px; font-size:14px; text-align:center; vertical-align:middle; font-variant-numeric:tabular-nums; }
.compact-calendar .today { outline:2px solid var(--primary); outline-offset:-2px; background:var(--selected-bg); color:var(--selected-fg); font-weight:700; }
.compact-calendar footer { display:flex; align-items:center; justify-content:space-between; padding:4px 0; }
.compact-calendar footer .button { min-height:36px; padding:4px 12px; }
.calendar-popout { display:block; width:100%; min-height:36px; padding:6px; border:0; border-top:1px solid var(--border-subtle); background:transparent; color:var(--text-secondary); font-size:12px; }
.dialog-header h2 { flex:1; }
.utility-calendar { width:336px; max-width:100%; padding:8px; margin:0 auto; }
.utility-calendar .hint { font-size:12px; }
.calendar-standalone { display:block; height:100dvh; }
.calendar-standalone .navigation,.calendar-standalone .mobile-menu,.calendar-standalone .account-name { display:none; }
.calendar-standalone .mobile-menu { display:none!important; }
.calendar-standalone .workspace { margin:0; width:100%; height:100%; }
.calendar-standalone .app-header { min-height:52px; height:52px; flex-basis:52px; padding:4px 8px; }
.calendar-standalone .app-header h1 { font-size:16px; }
.calendar-standalone .header-actions { gap:2px; }
.calendar-standalone .main { padding:0; }
.calendar-standalone .pages { overflow:auto; }
@media(pointer:coarse) {
    .calendar-drag,.calendar-popout,.compact-calendar footer .button { min-height:44px; }
    .compact-calendar td { height:32px; }
}
/* Compact reference codes and readable audit content, independent of viewport. */
.settings-page>.table-scroll tr>:nth-child(2) { width:72px; min-width:72px; max-width:72px; padding-inline:8px; }
.audit-page>.table-compact tr>:nth-child(3) { min-width:200px; overflow-wrap:normal; }
.audit-page>.table-compact tr>:nth-child(4),
.audit-page>.table-compact tr>:nth-child(5) { min-width:88px; white-space:nowrap; }
.audit-page>.table-compact tr>:nth-child(6) { min-width:280px; overflow-wrap:normal; word-break:normal; }
.audit-event-detail { min-width:0; }
.event-changes { display:flex; flex-direction:column; gap:12px; margin-top:20px; }
.change { border:1px solid var(--border-subtle); border-radius:10px; padding:10px 12px; }
.change h3 { font-size:14px; margin:0 0 6px; }
.change dl { margin:0; display:flex; flex-direction:column; gap:4px; }
.change dl>div { display:grid; grid-template-columns:56px minmax(0,1fr); gap:8px; align-items:baseline; }
.change dt { font-size:12px; color:var(--text-muted); white-space:nowrap; }
.change dd { margin:0; overflow-wrap:anywhere; }
.change.changed .change-now > dd { font-weight:600; color:var(--selected-fg); background:var(--selected-bg); border-radius:6px; padding:2px 8px; display:inline-block; }
.change-same { margin:4px 0 0; font-size:13px; color:var(--text-secondary); overflow-wrap:anywhere; }
/* Sync counters: one compact card per group (勤務実績, 社員, …), cards do not stretch on wide screens. */
.sync-counts { display:flex; flex-wrap:wrap; gap:12px; }
.sync-counts section { flex:0 0 auto; min-width:220px; padding:10px 12px; border:1px solid var(--border-subtle); border-radius:10px; background:var(--surface); }
.sync-counts h3 { font-size:13px; margin:0 0 8px; color:var(--text-secondary); font-weight:600; }
.sync-counts dl { display:grid; grid-template-columns:repeat(4,minmax(52px,auto)); gap:4px 16px; margin:0; }
.sync-counts dl > div { display:flex; flex-direction:column; gap:2px; }
.sync-counts dt { color:var(--text-muted); font-size:12px; white-space:nowrap; }
.sync-counts dd { margin:0; font-size:16px; font-weight:600; font-variant-numeric:tabular-nums; }
/* The "after" highlight is for a plain value, not for a nested counters grid. */
.change.changed .change-now > dd:has(.sync-counts) { display:block; background:none; padding:0; font-weight:400; color:inherit; }
/* Preserve control height and separate fields; only unused width is removed. */
#report-kind-hint,#audit-entity-hint,#audit-actor-name-hint,#audit-actor-name-error { display:none; }
@media (min-width:480px) and (max-width:959px) {
  .business-page:is([data-scope=user],[data-scope=work_place],[data-scope=work_type])>.query-toolbar { flex-wrap:nowrap; gap:8px; }
  .business-page:is([data-scope=user],[data-scope=work_place],[data-scope=work_type])>.query-toolbar>.entity-picker { flex:1; min-width:0; max-width:none; }
  .business-page[data-scope]>.query-toolbar .month-control { flex:none; gap:8px; }
  .business-page[data-scope]>.query-toolbar .month-control select { width:64px; min-width:0; padding-inline:6px; }
  .business-page[data-scope]>.query-toolbar .month-control .field:first-child select { width:88px; min-width:0; }
  .business-page[data-scope]>.query-toolbar>.button { flex:none; padding-inline:10px; }
  .business-page[data-scope]>.query-toolbar .picker-trigger { padding-inline:8px; gap:6px; }
  .business-page[data-scope=work_place]>.report-toolbar { flex-wrap:nowrap; gap:8px; }
  .business-page[data-scope=work_place]>.report-toolbar>.field { flex:1; min-width:0; }
  .business-page[data-scope=work_place]>.report-toolbar select { text-overflow:ellipsis; }
  .business-page[data-scope=work_place] .report-actions { flex:none; }
  .business-page[data-scope=work_place] .report-actions .hint { display:none; }
}
@media (min-width:480px) and (max-width:1279px) {
  .business-page>.audit-toolbar { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,.85fr); gap:10px 8px; }
  .business-page>.audit-toolbar>.field,.business-page>.audit-toolbar>.entity-picker { min-width:0; max-width:none; width:auto; }
  .audit-toolbar .picker-trigger { min-width:0; padding-inline:8px; gap:4px; }
  .audit-toolbar>.button { justify-self:end; grid-column:3; grid-row:2; }
  .audit-toolbar>.entity-picker { grid-column:1; }
  .audit-toolbar>.field:has(#audit-actor-name) { grid-column:2 / 4; grid-row:2; margin-right:72px; }
}
