/* VIP Team Backend: only what kpi-styles.css does not already have. Loaded after it. */

/* The same size as the KPI report's Net Revenue board: 262px tall, measured with its four rows. Width comes from the same grid. */
.task-board { min-height: 262px; }
.task-board .card-label { min-height: 2.9em; line-height: 1.45; }

.boards-empty, .empty-panel, .list-empty {
  color: var(--text-faint); text-align: center; padding: 40px 16px; font-size: 14px;
}
.boards-empty { grid-column: 1 / -1; }

.topbar-user { display: flex; align-items: center; gap: 8px; }
.date-group { flex: 0 1 170px; min-width: 170px; }
.filters .filter-group:has(#personSelect) { min-width: 210px; }

.users-scroll { min-height: 0; max-height: calc(100vh / var(--z, 1) - 300px); }
.team-table td { vertical-align: middle; font-size: 14px; }
.team-table .mono { font-family: var(--font-mono); }
.team-table select { width: 100%; padding: 6px 8px; font-size: 13px; }
.team-table .link-btn { font-size: 11.5px; padding: 5px 8px; }
.link-btn:disabled { opacity: 0.3; cursor: default; }

.assign-scroll { min-height: 0; max-height: calc(100vh / var(--z, 1) - 240px); }
table.assign-table { min-width: 560px; }
.assign-table th:first-child { width: 46%; text-align: left; }
.assign-table th:not(:first-child) { text-align: center; }
.assign-table td { vertical-align: middle; font-size: 13.5px; }
.assign-table .day-cell { text-align: center; }
.assign-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.pass-value {
  font-family: var(--font-mono); font-size: 20px; text-align: center; color: var(--accent);
  padding: 16px; background: #0D0F14; border: 1px solid var(--border); border-radius: 8px;
  overflow-wrap: anywhere; user-select: all;
}

/* ---------- SHIFT SCHEDULE ----------
   The grid keeps the sheet's own colours. The columns freeze the way the sheet's do. */
#view-schedule .page-wrap { max-width: none; }
.schedule-actions { margin-left: auto; display: flex; gap: 8px; align-items: flex-end; }
.schedule-scroll { min-height: 0; max-height: calc(100vh / var(--z, 1) - 300px); background: #0D0F14; }
table.shift-grid { border-collapse: separate; border-spacing: 0; font-size: 13.5px; white-space: nowrap; }
.shift-grid th, .shift-grid td {
  border-right: 1px solid #000; border-bottom: 1px solid #000; text-align: center; vertical-align: middle;
  padding: 0 4px; height: 32px;
}
.shift-grid thead th { position: sticky; z-index: 3; }
.shift-grid thead tr:first-child th { top: 0; }
.shift-grid thead tr:nth-child(2) th { top: 32px; }
.shift-grid .fix { position: sticky; z-index: 2; background: var(--bg-panel-alt); color: var(--text); }
.shift-grid thead .fix { z-index: 5; background: #4A86E8; color: #fff; font-weight: 800; font-size: 14px; }
.shift-grid .team-col { left: 0; width: 150px; min-width: 150px; max-width: 150px; white-space: normal; line-height: 1.2; font-weight: 700; }
.shift-grid .title-col { left: 150px; width: 92px; min-width: 92px; max-width: 92px; }
.shift-grid .name-col { left: 242px; width: 104px; min-width: 104px; max-width: 104px; font-weight: 700; box-shadow: 2px 0 0 #000; }
.shift-grid .day-num, .shift-grid .day-name { background: #fff; color: #434343; font-weight: 800; min-width: 38px; width: 38px; }
.shift-grid .day-name { font-size: 11px; }
.shift-grid th.weekend { background: #000; color: #fff; }
.shift-grid th.today { box-shadow: inset 0 0 0 2px var(--accent); }
.shift-grid td.sc { font-family: var(--font-mono); font-weight: 600; min-width: 38px; width: 38px; background: #0D0F14; color: var(--text); position: relative; }
.shift-grid td.sc.today { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
.shift-grid td.has-note::after {
  content: ''; position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-top: 7px solid #ff8f00; border-left: 7px solid transparent;
}
.shift-grid.editable td.sc, .shift-grid.editable td[data-rowedit] { cursor: var(--cur-open, pointer); }
.shift-grid.editable td.sc:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.shift-grid .sum-head { background: #6D9EEB; color: #000; font-weight: 800; font-size: 11.5px; white-space: normal; line-height: 1.15; min-width: 72px; width: 72px; }
.shift-grid td.sum { font-family: var(--font-mono); background: var(--bg-panel-alt); color: var(--text); min-width: 72px; }

.legend-wrap { overflow-x: auto; margin-top: 10px; }
.legend-table { border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.legend-table th { color: var(--text-dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 12px; text-align: left; }
.legend-table td { padding: 5px 12px; border-top: 1px solid #20242B; color: var(--text-dim); font-family: var(--font-mono); }
.legend-table td.legend-code { text-align: center; font-weight: 700; min-width: 56px; }
.legend-table td.legend-name { color: var(--text); font-family: var(--font-display); }

.code-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.code-btn {
  height: 46px; border: 1px solid var(--border); border-radius: 7px; font-family: var(--font-mono);
  font-size: 15px; font-weight: 700; cursor: pointer; transition: transform .13s var(--ease), box-shadow .16s var(--ease);
}
.code-btn:hover { transform: translateY(-1px); box-shadow: 0 0 0 2px var(--accent); }
.code-btn:active { transform: translateY(1px) scale(0.978); }
.code-btn.current { box-shadow: 0 0 0 2px var(--neon-teal); }

/* ---------- PHONE ----------
   The 0.8 page zoom is for desktop screens. On a phone it only makes text small. */
@media (max-width: 799px) {
  body { zoom: 1; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  :root { --z: 1; }

  .page-wrap { padding: 0 12px; }
  .topbar { margin-bottom: 14px; }
  .topbar-inner { padding: 8px 12px; gap: 8px 10px; }
  .topbar-meta { display: none; }
  .topbar-user { margin-left: auto; }
  .brandmark { order: 1; }
  .topbar-user { order: 2; }
  /* A row of its own that slides sideways, so no tab is ever squeezed or wrapped. */
  .nav-tabs {
    order: 3; flex: 1 0 100%; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch; margin: 0 -12px; padding: 0 12px; max-width: 100vw;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab { flex: none; min-height: 40px; }

  .header { margin-bottom: 12px; padding-bottom: 10px; gap: 10px; flex-wrap: wrap; }
  .header .meta { white-space: normal; text-align: left; }

  /* A two-line bar pinned over a small screen would leave no room for the boards. */
  .filters { position: static; padding: 12px; gap: 10px; margin-bottom: 12px; }
  .filters .filter-group, .date-group, .filters .filter-group:has(#personSelect) { flex: 1 1 100%; width: 100%; min-width: 0; }
  .filters .reset-btn { flex: 1 1 100%; height: 44px; }
  /* Under 16px, iPhones zoom the whole page in when a field is tapped. */
  select, input[type="date"], input[type="text"], input[type="password"], textarea,
  .filters select, .filters input[type="date"], .filters input[type="text"], .auth-field input { font-size: 16px; }
  .filters select, .filters input[type="date"] { height: 44px; }

  .panel { padding: 14px 12px; }
  .big-header { font-size: 19px; }
  .big-header-row { margin-bottom: 12px; }

  /* Two boards a row, so a full day of tasks is a short scroll rather than sixteen screens. */
  .summary-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .task-board { min-height: 132px; padding: 12px; }
  .task-board .card-label { font-size: 11.5px; letter-spacing: 0.03em; overflow-wrap: anywhere; min-height: 0; }
  .task-board .card-value { font-size: 24px; }
  .task-board .card-sub { font-size: 11.5px; }

  /* Popups take the whole screen, and the bottom bar clears the phone's home bar. */
  .modal-backdrop { padding: 0; }
  .modal-backdrop.open > .modal { margin: 0; }
  .modal, .modal.drill, .modal.narrow {
    max-width: none; width: 100%; min-height: 100dvh; border: none; border-radius: 0;
    display: flex; flex-direction: column;
  }
  .modal-head { padding: 14px; }
  .modal-body { padding: 14px; flex: 1; min-height: 0; }
  .modal-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; min-height: 44px; }
  .modal-close { width: 40px; height: 40px; }

  /* Each user becomes a card: a seven-column table cannot fit a phone. */
  .users-scroll { max-height: none; overflow: visible; border: none; background: none; }
  table.team-table { min-width: 0; table-layout: auto; }
  .team-table colgroup, .team-table thead { display: none; }
  .team-table, .team-table tbody, .team-table tr, .team-table td { display: block; width: 100%; }
  .team-table tr {
    background: #0D0F14; border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; margin-bottom: 10px;
  }
  .team-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 6px 0; border: none; text-align: right; overflow-wrap: anywhere;
  }
  .team-table td::before {
    content: attr(data-label); color: var(--text-dim); font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; flex: none;
  }
  .team-table td.user-actions { display: block; padding-top: 10px; }
  .team-table td.user-actions::before { content: none; }
  .team-table td select { width: 50%; height: 40px; }
  .team-table .link-btns { gap: 6px; }
  .team-table .link-btn { flex: 1 1 45%; min-height: 40px; font-size: 13px; text-align: center; }
  table.main tr td:first-child, .team-table tr:hover td:first-child { box-shadow: none; }

  .assign-scroll { max-height: none; flex: 1; }
  table.assign-table { min-width: 520px; }
  .assign-table th:first-child, .assign-table td:first-child {
    position: sticky; left: 0; background: #0D0F14; z-index: 1;
  }
  .assign-table input[type="checkbox"] { width: 22px; height: 22px; }

  /* Only the name stays frozen: a phone has no room for three fixed columns. */
  .schedule-actions { margin-left: 0; flex: 1 1 100%; }
  .schedule-actions .btn { flex: 1; min-height: 44px; }
  .schedule-scroll { max-height: calc(100dvh - 150px); }
  .shift-grid .team-col, .shift-grid .title-col { display: none; }
  .shift-grid .name-col { left: 0; width: 84px; min-width: 84px; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
  .shift-grid td.sc, .shift-grid .day-num, .shift-grid .day-name { min-width: 42px; width: 42px; }
  .shift-grid th, .shift-grid td { height: 38px; }
  .shift-grid thead tr:nth-child(2) th { top: 38px; }
  .code-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .code-btn { height: 56px; }

  .auth-card { width: calc(100% - 24px); max-width: 420px; }
  .auth-btn { min-height: 46px; }
}

/* Hover belongs to pointers. On a touch screen it sticks after a tap. */
@media (hover: none) {
  .card.clickable:hover { transform: none; }
  .card.clickable:active { transform: scale(0.985); }
}

/* A scrollbar corner is white by default, which shows as a square on a dark page. */
.schedule-scroll::-webkit-scrollbar-corner, .table-scroll::-webkit-scrollbar-corner { background: #0D0F14; }
