/* Cross-page consistency layer: one table, row-action, status-pill and minimum-text system.
   Loaded last so it can align older page-specific styles without rewriting them. */

:root {
  --tone-success-bg:#e8f6ef; --tone-success-fg:#1f7a52;
  --tone-warning-bg:#fff3e0; --tone-warning-fg:#8f5a14;
  --tone-danger-bg:#fdeeee;  --tone-danger-fg:#b23f3a;
  --tone-muted-bg:#f1f2f6;   --tone-muted-fg:#666d7d;
  --tone-info-bg:#e8f0fc;    --tone-info-fg:#2c5b9a;
  --table-head-bg:#fafbfe;
}

/* ---------- Tables: same header, cell rhythm and full-bleed container everywhere ---------- */
:root :is(.admin-table,.workflow-table) { font-size:13px; }
:root :is(.admin-table,.workflow-table) thead th { padding-top:12px;padding-bottom:12px;background:var(--table-head-bg);color:var(--muted);font-size:12px;font-weight:650;white-space:nowrap; }
:root .workflow-table td { padding:16px; }
:root :is(.admin-table,.workflow-table) tbody tr { transition:background .12s; }
:root :is(.admin-table,.workflow-table) tbody tr:hover { background:#fcfcfe; }
:root :is(.admin-table,.workflow-table) :is(small,small.block),
:root .admin-room-cell small { font-size:12px;color:var(--muted); }
/* Search/filter cards: filters on top, table edge to edge, like the room and booking lists. */
.workflow-card:has(> .workflow-filters) { padding:0;overflow:hidden; }
.workflow-card > .workflow-filters { margin:0;padding:18px 22px;border-bottom:1px solid var(--line); }
.workflow-card:has(> .workflow-filters) .workflow-table :is(th,td):first-child { padding-left:22px; }
.workflow-card:has(> .workflow-filters) .workflow-table :is(th,td):last-child { padding-right:22px; }
.workflow-card:has(> .workflow-filters) .workflow-table tbody tr:last-child td { border-bottom:0; }
.workflow-card:has(> .workflow-filters) .workflow-table td[colspan] { padding:40px 20px;text-align:center;color:var(--muted); }

/* ---------- Row actions: neutral by default, brand for the main action, red only when destructive ---------- */
:root .admin-row-actions button,
:root .admin-link[data-remove-block] { display:inline-flex;align-items:center;justify-content:center;min-height:30px;margin:2px;padding:5px 11px;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--ink);font-size:12px;font-weight:600;line-height:1.4;box-shadow:none;filter:none;cursor:pointer;transition:background .12s,border-color .12s,color .12s; }
/* The main action is set apart by weight, not brand colour, so it never competes with the red destructive action. */
:root .admin-row-actions button:is(.admin-action-edit,[data-edit],[data-booking-edit],[data-edit-equipment],[data-employee],[data-role]) { color:var(--ink);font-weight:700; }
:root .admin-row-actions button:hover:not(:disabled) { border-color:var(--brand-border);background:var(--brand-soft);color:var(--brand-text);box-shadow:none;filter:none; }
:root .admin-row-actions button:is(.admin-action-danger,[data-archive],[data-booking-cancel]),
:root .admin-link[data-remove-block] { color:var(--tone-danger-fg); }
:root .admin-row-actions button:is(.admin-action-danger,[data-archive],[data-booking-cancel]):hover:not(:disabled),
:root .admin-link[data-remove-block]:hover { border-color:#f0cfca;background:#fff4f2;color:#a3332e; }
:root .admin-row-actions button:disabled { opacity:.4;cursor:not-allowed; }
:root .admin-row-actions button:focus-visible { outline:2px solid var(--brand-text);outline-offset:2px; }

/* ---------- Status pills: one shape, one scale, tone by meaning ---------- */
:root :is(.admin-status,.workflow-pill) { display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 10px;border-radius:999px;font-size:12px;font-weight:600;line-height:1;white-space:nowrap; }
:root td > :is(.admin-status,.workflow-pill)::before { content:'';width:6px;height:6px;flex-shrink:0;border-radius:50%;background:currentColor; }
:root :is(.admin-status.published,.admin-status.phase-ongoing,.workflow-pill.active,.workflow-pill.tone-success) { background:var(--tone-success-bg);color:var(--tone-success-fg); }
/* Pending states use a fixed info blue so a red/pink brand never reads as an error. */
:root :is(.admin-status.phase-upcoming,.workflow-pill.tone-pending) { background:var(--tone-info-bg);color:var(--tone-info-fg); }
:root :is(.admin-status.paused,.workflow-pill.inactive,.workflow-pill.offline) { background:var(--tone-warning-bg);color:var(--tone-warning-fg); }
:root :is(.admin-status.draft,.admin-status.archived,.admin-status.phase-past,.workflow-pill.disabled,.workflow-pill.tone-muted) { background:var(--tone-muted-bg);color:var(--tone-muted-fg); }
:root .workflow-pill.tone-danger { background:var(--tone-danger-bg);color:var(--tone-danger-fg); }

/* ---------- Minimum reading size (12px) for helper and secondary text ---------- */
:root :is(.admin-help,.workflow-footnote,.admin-local-note,.editor-bottom-hint,.editor-properties-empty,.audit-record-label,.equipment-alias) { font-size:12px; }
:root :is(.editor-sample-actions button,.editor-plain-button,.editor-color-controls > button,.editor-color-controls small) { font-size:12px; }
:root :is(.editor-toolbar button,.editor-toolbar select,.editor-toolbar label,.editor-properties label) { font-size:12px; }
:root :is(.brand-field small,.brand-local-note) { font-size:12px; }
:root .menu-item-name small { font-size:12px; }

/* ---------- File inputs: styled drop area instead of the bare browser control ---------- */
:root .main-content .brand-field input[type=file] { width:100%;padding:10px;border:1px dashed var(--field-border,#dfe2eb);border-radius:10px;background:#fafbfe;color:var(--muted);font-size:12px;font-weight:400;cursor:pointer;transition:border-color .12s,background .12s; }
:root .main-content .brand-field input[type=file]:hover { border-color:var(--brand-border);background:var(--brand-soft); }
:root .main-content .brand-field input[type=file]::file-selector-button { margin-right:12px;padding:8px 14px;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--ink);font:inherit;font-weight:650;cursor:pointer; }
:root .main-content .brand-field input[type=file]:hover::file-selector-button { border-color:var(--brand-border);color:var(--brand-text); }

/* ---------- Narrow screens: tables become labelled cards instead of clipped columns ---------- */
@media (max-width:680px) {
  :root :is(.admin-table-scroll,.workflow-table-scroll,#employee-table,#audit-table) { overflow:visible; }
  :root :is(.admin-table,.workflow-table) { display:block;min-width:0;width:100%; }
  :root :is(.admin-table,.workflow-table) thead { display:none; }
  :root :is(.admin-table,.workflow-table) tbody { display:grid;gap:0; }
  :root :is(.admin-table,.workflow-table) tbody tr { display:grid;grid-template-columns:minmax(0,1fr);gap:8px;padding:16px;border-bottom:1px solid var(--line); }
  :root :is(.admin-table,.workflow-table) tbody tr:last-child { border-bottom:0; }
  /* Label sits in a fixed left gutter; everything in the cell (text, small lines, pills) stays in the value column. */
  :root :is(.admin-table,.workflow-table) tbody td { display:block;position:relative;width:auto;min-width:0;padding:0 0 0 88px !important;border:0;overflow-wrap:anywhere;line-height:1.6; }
  :root :is(.admin-table,.workflow-table) tbody td::before { content:attr(data-label);position:absolute;left:0;top:0;width:76px;color:var(--muted);font-size:12px;font-weight:600;line-height:1.8; }
  /* The first column is the record's title: full width, no label. */
  :root :is(.admin-table,.workflow-table) tbody td:first-child { padding-left:0 !important;margin-bottom:2px; }
  :root :is(.admin-table,.workflow-table) tbody td:first-child::before,
  :root :is(.admin-table,.workflow-table) tbody td:not([data-label])::before { display:none; }
  :root :is(.admin-table,.workflow-table) tbody td:not([data-label]) { padding-left:0 !important; }
  :root :is(.admin-table,.workflow-table) tbody td[colspan] { padding:24px 0 !important;text-align:center; }
  :root :is(.admin-table,.workflow-table) tbody td.admin-row-actions { display:flex;flex-wrap:wrap;gap:8px;padding:6px 0 0 !important;white-space:normal; }
  :root :is(.admin-table,.workflow-table) colgroup { display:none; }
  :root #view-admin-equipment .equipment-table { table-layout:auto;min-width:0; }
  :root :is(.admin-table,.workflow-table) tbody td.admin-row-actions::before { display:none; }
  :root .admin-row-actions button { flex:1 1 0;min-height:40px;margin:0; }
  :root :is(.admin-table,.workflow-table) td > :is(.admin-status,.workflow-pill) { justify-self:start; }
  .workflow-card > .workflow-filters { padding:14px;flex-wrap:wrap; }
  .workflow-card > .workflow-filters > input { flex:1 1 100%; }
  :root .admin-room-cell > img { width:56px;height:42px; }
}

/* Floor editor zoom: room for the "符合寬度" option. */
.editor-toolbar :is(#editor-zoom,.ui-select:has(#editor-zoom),.ui-select:has(#editor-zoom) .ui-select-trigger) { min-width:116px; }

/* ---------- B4 Summary/metric cards: one card style across pages ---------- */
:root :is(.admin-summary > div,.workflow-stats > div,.metric-card) { padding:18px 20px;border:1px solid var(--line);border-radius:14px;background:#fff;box-shadow:0 4px 14px #39335c06; }
:root :is(.admin-summary span,.workflow-stats span,.metric-card > span) { display:block;margin:0;color:var(--muted);font-size:12px;font-weight:600;letter-spacing:0; }
:root :is(.admin-summary strong,.workflow-stats strong,.metric-card > strong) { display:block;margin:8px 0 0;font-size:28px;font-weight:750;line-height:1.2;letter-spacing:-.6px;color:var(--ink); }
:root .metric-card > small { display:block;margin-top:4px;color:var(--muted);font-size:12px; }
:root :is(.admin-summary,.workflow-stats,.metric-grid) { gap:14px;margin-bottom:22px; }
@media (max-width:680px) {
  :root :is(.admin-summary > div,.workflow-stats > div,.metric-card) { padding:14px; }
  :root :is(.admin-summary strong,.workflow-stats strong,.metric-card > strong) { font-size:24px; }
  :root :is(.admin-summary,.workflow-stats,.metric-grid) { gap:8px; }
}

/* ---------- B5 Form footers: primary action bottom-right, separated by a rule ---------- */
.admin-form-footer { display:flex;justify-content:flex-end;gap:10px;margin-top:22px;padding-top:18px;border-top:1px solid var(--line); }
:root .admin-card .admin-form-footer .primary-button { margin-top:0; }
.admin-rules-grid { align-items:start; }
@media (max-width:680px) { .admin-form-footer .primary-button { flex:1; } }

/* ---------- B6 Native controls replaced with system patterns ---------- */
/* Weekday selector: toggle chips */
:root .admin-weekdays { display:flex;flex-wrap:wrap;gap:8px; }
:root .admin-weekdays legend { float:left;width:100%;margin:0 0 10px;padding:0;color:#56596e;font-size:12px;font-weight:650; }
:root .admin-weekdays label { position:relative;display:inline-grid;place-items:center;min-width:44px;height:38px;padding:0 12px;border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);font-size:13px;font-weight:600;cursor:pointer;transition:background .12s,border-color .12s,color .12s; }
:root .admin-weekdays label:hover { border-color:var(--brand-border); }
:root .admin-weekdays label:has(input:checked) { border-color:var(--brand-fill,var(--brand-primary));background:var(--brand-fill,var(--brand-primary));color:var(--brand-fill-on,#fff); }
:root .admin-weekdays label:has(input:focus-visible) { outline:2px solid var(--brand-text);outline-offset:2px; }
:root .admin-weekdays input { position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer; }
/* Recurring-booking group: soft panel instead of a bordered fieldset, checkbox as a switch */
:root .admin-recurring { margin:18px 0 0;padding:16px;border:0;border-radius:12px;background:#f7f8fb; }
:root .admin-recurring legend { float:left;width:100%;margin:0 0 12px;padding:0;color:var(--ink);font-size:13px;font-weight:700; }
:root .admin-recurring > label:not(.admin-check) { display:grid;gap:8px;margin:14px 0 8px;color:#56596e;font-size:12px;font-weight:650; }
:root .admin-recurring > label:not(.admin-check) input { max-width:200px; }
:root .admin-recurring .admin-check { display:flex;align-items:center;gap:10px;color:var(--ink);font-size:13px;font-weight:600;cursor:pointer; }
:root .admin-recurring .admin-check input { appearance:none;-webkit-appearance:none;position:relative;flex-shrink:0;width:38px;height:22px;margin:0;border-radius:999px;background:#d6d8e1;cursor:pointer;transition:background .18s; }
:root .admin-recurring .admin-check input::after { content:'';position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 3px #24233b40;transition:transform .18s; }
:root .admin-recurring .admin-check input:checked { background:var(--brand-fill,var(--brand-primary)); }
:root .admin-recurring .admin-check input:checked::after { transform:translateX(16px); }
:root .admin-recurring .admin-check input:focus-visible { outline:2px solid var(--brand-text);outline-offset:2px; }
/* Door-device disclosure: system chevron instead of the native triangle */
:root .p1-device-card > summary { display:flex;align-items:center;gap:10px;list-style:none;cursor:pointer; }
:root .p1-device-card > summary::-webkit-details-marker { display:none; }
:root .p1-device-card > summary::after { content:'';width:8px;height:8px;margin-left:auto;border-right:2px solid var(--muted);border-bottom:2px solid var(--muted);transform:rotate(45deg) translateY(-2px);transition:transform .15s; }
:root .p1-device-card[open] > summary::after { transform:rotate(-135deg) translateY(-2px); }

/* ---------- D4 My bookings uses the full content width like other pages ---------- */
:root .mine-list { max-width:none; }

/* ---------- D3 Table pagination ---------- */
.table-pager { display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:14px 22px;border-top:1px solid var(--line);background:#fff; }
.table-pager-summary { color:var(--muted);font-size:12px; }
.table-pager-pages { display:flex;align-items:center;gap:4px; }
.table-pager button { display:grid;place-items:center;min-width:34px;height:34px;padding:0 8px;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--ink);font-size:13px;font-weight:600;cursor:pointer; }
.table-pager button:hover:not(:disabled) { border-color:var(--brand-border);background:var(--brand-soft);color:var(--brand-text); }
.table-pager button[aria-current=page] { border-color:var(--brand-fill,var(--brand-primary));background:var(--brand-fill,var(--brand-primary));color:var(--brand-fill-on,#fff); }
.table-pager button:disabled { opacity:.35;cursor:default; }
.table-pager button:focus-visible { outline:2px solid var(--brand-text);outline-offset:2px; }
.table-pager-gap { padding:0 4px;color:var(--muted); }
@media (max-width:680px) { .table-pager { padding:14px 16px;justify-content:center; } .table-pager-summary { flex-basis:100%;text-align:center; } .table-pager button { min-width:40px;height:40px; } }
@media (max-width:680px) {
  /* Seven weekday chips share one row on narrow screens. */
  /* The floated legend takes the first line; the zero-basis chips then share the second line evenly. */
  :root .admin-weekdays { gap:6px; }
  :root .admin-weekdays label { flex:1 1 0;min-width:0;padding:0; }
}

/* ---------- Rules page: the right column holds "add a closure" and its records together ---------- */
.admin-rules-side { display:grid;gap:20px;align-content:start;min-width:0; }
.admin-rules-side > * { margin:0; }
:root .admin-block-records .admin-table { min-width:0; }
:root .admin-block-records > h3 { margin:22px 22px 12px; }

/* ---------- Page heads: description on the left, page action on the right (my bookings, analytics) ---------- */
:root .workflow-page-heading.dashboard-head { align-items:center;margin-bottom:24px; }
:root .workflow-page-heading.dashboard-head p { font-size:13px; }
:root .workflow-page-heading.p1-mobile-scan { flex-wrap:nowrap;margin-bottom:24px; }

/* ---------- Calendar: "today" sits with the period arrows, like common calendar apps ---------- */
#view-calendar .calendar-nav { display:flex;align-items:center;gap:12px;min-width:0; }
#view-calendar .calendar-today { flex-shrink:0;min-height:36px;padding:6px 14px;border-radius:10px;font-size:13px;font-weight:650; }
@media (max-width:680px) {
  #view-calendar .calendar-nav { gap:8px; }
  #view-calendar .calendar-nav .week-switcher { flex:1;min-width:0; }
  #view-calendar .calendar-today { padding:6px 12px; }
  :root .workflow-page-heading.p1-mobile-scan { flex-wrap:wrap; }
}
/* ≤700px the calendar shows its own date row with a "今天" button, so the toolbar one steps aside. */
@media (max-width:700px) { #view-calendar .calendar-nav > .calendar-today { display:none; } }
@media (max-width:680px) {
  :root .workflow-page-heading.dashboard-head { align-items:stretch; }
  :root .workflow-page-heading.dashboard-head button { width:100%;min-height:44px; }
}

/* ---------- E3 Import: the file input lives invisibly inside its button; the chosen name shows below ---------- */
:root .p1-actions label.secondary-button { position:relative;white-space:nowrap;cursor:pointer; }
:root .p1-actions label.secondary-button > input[type=file] { position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer; }
:root .p1-actions label.secondary-button:has(input:focus-visible) { outline:2px solid var(--brand-text);outline-offset:2px; }

/* ---------- E11 Booking drawer: the sticky action bar sits fully inside the screen ---------- */
:root .drawer-booking-view .modal-actions { bottom:0;padding-bottom:max(14px,env(safe-area-inset-bottom)); }

/* ---------- E6 One booking-status vocabulary and palette (details, admin list, report) ---------- */
:root :is(.status-pill.upcoming,.admin-status.pill-upcoming) { background:var(--tone-info-bg);color:var(--tone-info-fg); }
:root :is(.status-pill.waiting,.admin-status.pill-waiting,.workflow-pill.tone-warning) { background:var(--tone-warning-bg);color:var(--tone-warning-fg); }
:root :is(.status-pill.ongoing,.status-pill.checked,.admin-status.pill-ongoing,.admin-status.pill-checked) { background:var(--tone-success-bg);color:var(--tone-success-fg); }
:root :is(.status-pill.past,.admin-status.pill-past) { background:var(--tone-muted-bg);color:var(--tone-muted-fg); }

/* ---------- E4 Drawer close button matches dialog close buttons (still legible over photos) ---------- */
:root .drawer-close { width:36px;height:36px;display:grid;place-items:center;padding:0;border:1px solid var(--line);border-radius:10px;background:#ffffffeb;color:#4d5468;font-size:22px;line-height:1;box-shadow:0 4px 14px #24233b1f;backdrop-filter:blur(6px);cursor:pointer; }
:root .drawer-close:hover { background:#fff;color:var(--ink); }

/* ---------- E7 Room-detail slots: green only means "available"; the action uses the brand; taken slots are labels ---------- */
:root #detail-slots .slot-available button { border-color:var(--brand-border);background:#fff;color:var(--brand-text);font-weight:700; }
:root #detail-slots .slot-available button:hover { border-color:var(--brand-text);background:var(--brand-soft); }
:root #detail-slots .slot-row button:disabled { min-height:0;padding:4px 2px;border-color:transparent;background:transparent;color:var(--muted);font-weight:600;cursor:default; }

/* ---------- Schedule: explain a fully closed day ---------- */
.schedule-closed-note { display:flex;align-items:center;gap:6px 12px;flex-wrap:wrap;margin:0 0 14px;padding:14px 18px;border:1px solid #f1dcc0;border-radius:12px;background:#fff8ee;color:#7a4e14;font-size:13px; }
.schedule-closed-note strong { font-size:14px; }
.schedule-closed-note span { color:#8a6230; }

/* ---------- E9 Archive blocked: affected bookings as a structured list ---------- */
.admin-dialog .admin-booking-list { list-style:none;margin:16px 27px 0;padding:0;border:1px solid var(--line);border-radius:12px;overflow:hidden; }
.admin-booking-list li { display:flex;justify-content:space-between;gap:12px;padding:12px 16px;font-size:13px; }
.admin-booking-list li + li { border-top:1px solid var(--line); }
.admin-booking-list span { color:var(--muted);white-space:nowrap;font-variant-numeric:tabular-nums; }
@media (max-width:680px) { .admin-booking-list li { flex-direction:column;gap:2px; } .admin-booking-list span { white-space:normal; } }

/* ---------- E8 Role permissions: readable matrix, larger targets ---------- */
:root .permission-matrix label { font-size:13px;line-height:1.6; }
:root .permission-matrix small,:root .permission-menu small { font-size:12px; }
:root .permission-matrix input[type=checkbox] { width:18px;height:18px;accent-color:var(--brand-fill,var(--brand-text)); }
:root .permission-menu { background:#f7f8fb; }
:root .permission-menu label { font-weight:650; }
:root .permission-matrix section > div { gap:10px 22px; }
/* Long dialogs (role permissions, imports) keep their actions reachable at the bottom edge. */
:root .workflow-dialog form > .workflow-form-footer { position:sticky;bottom:-26px;z-index:2;margin:22px -26px -26px;padding:16px 26px 20px;background:#fff;border-top:1px solid var(--line); }
@media (max-width:680px) { :root .workflow-dialog form > .workflow-form-footer { bottom:-22px;margin:22px -18px -22px;padding:14px 18px 18px; } }
