/* Ai ZaxBot — team page (Phase 2). Use only the theme tokens from index.html :root.
   Live board · routing · staffing calculator · members + the wizard/confirm dialogs and alert toasts (on <body>). */

#view-team, .tm-modal, #tm-toasts, .tm-um {
  --tm-good: color-mix(in srgb, var(--green) 62%, var(--ink));
  --tm-bad: color-mix(in srgb, var(--red) 78%, var(--ink));
  --tm-warn: color-mix(in srgb, var(--amber) 60%, var(--ink));
  --tm-info: color-mix(in srgb, var(--accent) 70%, var(--ink));
}
.tm { display: flex; flex-direction: column; gap: 24px; max-width: 1440px; margin: 0 auto; font-variant-numeric: tabular-nums; }
.tm svg { flex: none; }
#view-team :focus-visible, .tm-modal :focus-visible, #tm-toasts :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons / controls ---------- */
.tm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--card); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tm-btn:hover { border-color: var(--accent); background: var(--hover); }
.tm-btn:disabled { opacity: .5; cursor: not-allowed; }
.tm-btn svg { width: 16px; height: 16px; }
.tm-btn--primary { background: var(--accent); border-color: transparent; color: #fff; }
.tm-btn--primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); border-color: transparent; }
.tm-btn--danger { background: var(--red); border-color: transparent; color: #fff; }
.tm-btn--danger:hover { background: color-mix(in srgb, var(--red) 86%, var(--ink)); border-color: transparent; }
.tm-btn--sm { min-height: 32px; padding: 0 10px; font-size: 12px; }
.tm-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.tm-icon-btn:hover { background: var(--hover); color: var(--ink); border-color: var(--line); }
.tm-icon-btn svg { width: 18px; height: 18px; }
.tm-select { height: 38px; padding: 0 30px 0 10px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.tm-select--sm { height: 34px; font-size: 12.5px; }
.tm-fld { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 0; }
.tm-fld input, .tm-fld select { height: 40px; font-size: 14px; font-weight: 500; width: 100%; }
.tm-fld--grow { flex: 1; }
.tm-fld-h { font-size: 11.5px; font-weight: 500; color: var(--faint); }
.tm-err { margin: 6px 0 0; min-height: 16px; font-size: 12.5px; color: var(--tm-bad); }

/* ---------- header ---------- */
.tm-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.tm-head-main { flex: 1; min-width: 240px; }
.tm-eyebrow { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.tm-title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.tm-intro { margin: 6px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.tm-head-side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tm-me { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

.tm-error { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--red) 35%, var(--line)); background: color-mix(in srgb, var(--red) 7%, var(--card)); }
.tm-error[hidden] { display: none; }
.tm-error-ic { color: var(--tm-bad); display: inline-flex; } .tm-error-ic svg { width: 20px; height: 20px; }
.tm-error-t { flex: 1; font-size: 14px; font-weight: 600; color: var(--tm-bad); }

/* ---------- KPI tiles ---------- */
.tm-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.tm-kpi { --tone: var(--muted); min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 16px; text-align: left; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); font: inherit; }
button.tm-kpi { cursor: pointer; transition: border-color .15s, transform .15s; }
button.tm-kpi:hover { border-color: color-mix(in srgb, var(--tone) 55%, var(--line)); }
button.tm-kpi:active { transform: translateY(1px); }
.tm-kpi.tone-warn { --tone: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, var(--line)); }
.tm-kpi.tone-bad { --tone: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.tm-kpi.tone-good { --tone: var(--green); }
.tm-kpi-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tm-kpi-ic { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, var(--card)); }
.tm-kpi.tone-n .tm-kpi-ic { color: var(--tm-info); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.tm-kpi-ic svg { width: 16px; height: 16px; }
.tm-kpi-l { font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1.3; min-width: 0; }
.tm-kpi-v { font-family: Inter, "Noto Sans Thai", sans-serif; font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin: 6px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-kpi.tone-warn .tm-kpi-v { color: var(--tm-warn); } .tm-kpi.tone-bad .tm-kpi-v { color: var(--tm-bad); }
.tm-kpi-v small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.tm-kpi-s { font-size: 12px; line-height: 1.45; color: var(--muted); }

/* ---------- cards ---------- */
.tm-card { min-width: 0; padding: 20px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.tm-card-h { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.tm-card-h > div { flex: 1; min-width: 0; }
.tm-card-h h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.tm-card-sub { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.tm-sub-h { margin: 20px 0 0; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.tm-updated { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tm-updated.bad { color: var(--tm-bad); }
.tm-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.tm-note { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.tm-note svg, .tm-note .bi { width: 15px; height: 15px; margin: 2px 0 0; flex: none; color: var(--faint); }
.tm-note--sm { margin-top: 4px; font-size: 11.5px; }
.tm-hint { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--card2); border: 1px dashed var(--line2); font-size: 13px; color: var(--muted); }
.tm-hint svg { width: 18px; height: 18px; color: var(--tm-info); }
.tm-sk { display: block; border-radius: 10px; background: linear-gradient(90deg, var(--card2), var(--hover), var(--card2)); background-size: 200% 100%; animation: tm-sk 1.2s ease-in-out infinite; }
@keyframes tm-sk { to { background-position: -200% 0; } }

/* ---------- board table ---------- */
.tm-table-wrap { overflow-x: auto; margin: 0 -4px; }
.tm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tm-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 12px 10px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tm-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
.tm-table tbody tr:last-child td { border-bottom: none; }
.tm-table tbody tr:hover td { background: var(--hover); }
.tm-table tr.is-off .tm-person, .tm-table tr.is-off .tm-num { opacity: .7; }
.tm-person { min-width: 200px; }
.tm-person-in { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tm-person-txt { min-width: 0; }
.tm-name { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-you { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.tm-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.tm-av { position: relative; width: 36px; height: 36px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tm-av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.tm-av .pdot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--card); }
.tm-num { font-weight: 600; white-space: nowrap; }
.tm-good { color: var(--tm-good); } .tm-bad { color: var(--tm-bad); }
.tm-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line); background: var(--card2); color: var(--muted); }
.tm-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tm-pill.st-AVAILABLE { color: var(--tm-good); background: color-mix(in srgb, var(--green) 10%, var(--card)); border-color: color-mix(in srgb, var(--green) 30%, var(--line)); }
.tm-pill.st-BREAK { color: var(--tm-warn); background: color-mix(in srgb, var(--amber) 10%, var(--card)); border-color: color-mix(in srgb, var(--amber) 32%, var(--line)); }
.tm-pill.st-AWAY, .tm-pill.st-off { color: var(--muted); }
.tm-load { display: flex; flex-direction: column; gap: 6px; min-width: 96px; }
.tm-load-n { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.tm-load-n b { font-size: 14px; color: var(--ink); }
.tm-full { font-size: 11px; font-weight: 700; color: var(--tm-bad); }
.tm-bar { display: block; height: 6px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); overflow: hidden; }
.tm-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .3s; }
.tm-bar i.warn { background: var(--amber); } .tm-bar i.bad { background: var(--red); }

/* ---------- routing ---------- */
.tm-modes { display: flex; flex-direction: column; gap: 8px; }
.tm-mode { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px; text-align: left; border-radius: 12px; border: 1px solid var(--line2); background: var(--card); color: var(--ink); cursor: pointer; font: inherit; }
.tm-mode:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line2)); background: var(--hover); }
.tm-mode.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--card)); box-shadow: 0 0 0 1px var(--accent) inset; }
.tm-mode.is-static { cursor: default; }
.tm-mode-ic { width: 34px; height: 34px; border-radius: 10px; flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--tm-info); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.tm-mode-ic svg { width: 18px; height: 18px; }
.tm-mode-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tm-mode-t { font-size: 14px; font-weight: 700; }
.tm-mode-d { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.tm-mode-radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line2); flex: none; margin-top: 2px; }
.tm-mode.on .tm-mode-radio { border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--card); background: var(--accent); }
.tm-switch { display: flex; align-items: flex-start; gap: 12px; margin-top: 16px; cursor: pointer; }
.tm-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tm-switch-ui { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--line2); flex: none; transition: background .15s; margin-top: 1px; }
.tm-switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.tm-switch input:checked + .tm-switch-ui { background: var(--accent); }
.tm-switch input:checked + .tm-switch-ui::after { transform: translateX(16px); }
.tm-switch input:focus-visible + .tm-switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.tm-switch-txt { display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; color: var(--ink); }
.tm-switch-txt span { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.tm-saved { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tm-saved svg { width: 14px; height: 14px; }
.tm-saved.ok { color: var(--tm-good); } .tm-saved.bad { color: var(--tm-bad); white-space: normal; }
.tm-caps { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; }
.tm-cap { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.tm-cap .tm-av { width: 30px; height: 30px; font-size: 12px; }
.tm-cap-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-cap-in { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.tm-cap-in input { width: 72px; height: 36px; text-align: right; }
.tm-cap-in input[aria-invalid="true"] { border-color: var(--red); }
.tm-cap-st { width: 88px; font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; }
.tm-cap-st svg { width: 16px; height: 16px; }
.tm-cap-st.ok { color: var(--tm-good); } .tm-cap-st.bad { color: var(--tm-bad); }

/* ---------- staffing ---------- */
.tm-hours-wrap { padding: 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); }
.tm-hours-h { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.tm-hours { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; height: 84px; align-items: end; }
.tm-hbar { height: 100%; display: flex; align-items: flex-end; }
.tm-hbar i { display: block; width: 100%; border-radius: 3px 3px 1px 1px; background: color-mix(in srgb, var(--accent) 38%, var(--card2)); }
.tm-hbar.peak i { background: var(--accent); }
.tm-hours-ax { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10.5px; color: var(--faint); }
.tm-hours-cap { margin: 8px 0 0; font-size: 12.5px; color: var(--ink); font-weight: 600; }
.tm-calc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.tm-res { --tone: var(--accent); display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 14px 16px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--tone) 32%, var(--line)); background: color-mix(in srgb, var(--tone) 7%, var(--card)); }
.tm-res.tone-good { --tone: var(--green); } .tm-res.tone-warn { --tone: var(--amber); } .tm-res.tone-n { --tone: var(--muted); }
.tm-res-n { font-family: Inter, "Noto Sans Thai", sans-serif; font-size: 36px; font-weight: 800; line-height: 1; letter-spacing: -.02em; color: var(--ink); min-width: 44px; text-align: center; }
.tm-res-txt { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.tm-res-txt b { font-size: 14px; color: var(--ink); }
.tm-formula { margin: 10px 0 0; font-size: 12px; color: var(--muted); font-family: Inter, "Noto Sans Thai", sans-serif; }
.tm-advice { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.tm-advice-h { font-size: 13.5px; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.tm-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); flex-wrap: wrap; }
.tm-tab { min-height: 34px; padding: 0 14px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.tm-tab:hover { color: var(--ink); background: var(--hover); border: none; }
.tm-tab.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tm-tips { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tm-tips li { display: flex; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--ink); }
.tm-tips svg { width: 16px; height: 16px; margin-top: 2px; color: var(--tm-good); }
.tm-hire { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; color: var(--muted); background: color-mix(in srgb, var(--amber) 8%, var(--card)); border: 1px solid color-mix(in srgb, var(--amber) 25%, var(--line)); }
.tm-hire b { color: var(--tm-warn); }

/* ---------- members ---------- */
#team-members .team-row:first-child { border-top: none; }
.tm-invite { margin-top: 8px; padding-top: 4px; border-top: 1px solid var(--line); }
.tm-inv-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.tm-inv-form .tm-btn { height: 40px; }
.tm-perm { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
#team-invites .team-row:first-child { border-top: none; }

/* ---------- dialogs (wizard + confirm) ---------- */
body.tm-noscroll { overflow: hidden; }
.tm-modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 10, 20, .55); backdrop-filter: blur(2px); }
.tm-modal[hidden] { display: none; }
.tm-dlg { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; border-radius: 18px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 24px 64px rgba(0,0,0,.35); color: var(--ink); }
.tm-dlg-h { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 0; }
.tm-dlg-h > div { flex: 1; min-width: 0; }
.tm-dlg-h h3 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; }
.tm-steps { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--tm-info); }
.tm-dots { display: flex; gap: 6px; padding: 12px 20px 0; }
.tm-dots span { flex: 1; height: 4px; border-radius: 999px; background: var(--line2); }
.tm-dots span.on { background: var(--accent); }
.tm-dlg-b { padding: 16px 20px 4px; }
.tm-dlg-p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.tm-dlg-f { display: flex; align-items: center; gap: 8px; padding: 16px 20px 20px; }
.tm-dlg-f .tm-btn { min-height: 40px; }
#tm-confirm .tm-dlg { width: min(420px, 100%); }
#tm-confirm .tm-dlg-f { justify-content: flex-end; }
.tm-spacer { flex: 1; }
.tm-sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tm-size { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px 14px; text-align: left; border-radius: 14px; border: 1px solid var(--line2); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; }
.tm-size:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line2)); background: var(--hover); }
.tm-size.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); box-shadow: 0 0 0 1px var(--accent) inset; }
.tm-size-ic { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--tm-info); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.tm-size-ic svg { width: 20px; height: 20px; }
.tm-size-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tm-size-t { font-size: 15px; font-weight: 700; }
.tm-size-d { font-size: 12px; color: var(--muted); line-height: 1.4; }
.tm-rec { display: flex; flex-direction: column; gap: 12px; }
.tm-rec-row { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); }
.tm-rec-ic { width: 36px; height: 36px; border-radius: 10px; flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--tm-info); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.tm-rec-ic svg { width: 18px; height: 18px; }
.tm-rec-l { font-size: 12px; font-weight: 600; color: var(--muted); }
.tm-rec-v { font-size: 16px; font-weight: 700; margin-top: 2px; }
.tm-rec-why { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.tm-links { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tm-links li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); }
.tm-link-e { font-size: 13px; font-weight: 600; grid-column: 1; }
.tm-link-u { font-size: 11.5px; color: var(--muted); grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
.tm-links .tm-btn { grid-column: 2; grid-row: 1 / span 2; }
.tm-sum { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tm-sum li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.tm-sum svg { width: 18px; height: 18px; color: var(--tm-good); }
.tm-done { display: flex; gap: 14px; align-items: flex-start; padding: 8px 0; }
.tm-done > svg { width: 40px; height: 40px; color: var(--tm-good); }
.tm-done-t { font-size: 16px; font-weight: 700; margin-bottom: 4px; }

/* ---------- toasts ---------- */
#tm-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 95; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.tm-toast { --tone: var(--accent); pointer-events: auto; display: flex; align-items: stretch; border-radius: 14px; background: var(--card); border: 1px solid color-mix(in srgb, var(--tone) 40%, var(--line)); border-left: 4px solid var(--tone); box-shadow: 0 12px 32px rgba(0,0,0,.22); color: var(--ink); animation: tm-in .2s ease-out; transition: opacity .2s, transform .2s; }
.tm-toast.out { opacity: 0; transform: translateY(6px); }
.tm-toast.tone-good { --tone: var(--green); } .tm-toast.tone-warn { --tone: var(--amber); } .tm-toast.tone-bad { --tone: var(--red); }
@keyframes tm-in { from { opacity: 0; transform: translateY(8px); } }
.tm-toast-main { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 10px; padding: 12px 4px 12px 12px; border: none; background: transparent; color: inherit; text-align: left; font: inherit; border-radius: 14px 0 0 14px; }
button.tm-toast-main { cursor: pointer; } button.tm-toast-main:hover { background: var(--hover); border: none; }
.tm-toast-ic { color: var(--tone); display: inline-flex; margin-top: 1px; } .tm-toast-ic svg { width: 18px; height: 18px; }
.tm-toast-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tm-toast-t { font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.tm-toast-s { font-size: 12px; color: var(--muted); line-height: 1.4; }
.tm-toast-x { width: 40px; flex: none; display: inline-flex; align-items: flex-start; justify-content: center; padding: 12px 0 0; border: none; background: transparent; color: var(--faint); border-radius: 0 14px 14px 0; }
.tm-toast-x:hover { color: var(--ink); background: var(--hover); border: none; }
.tm-toast-x svg { width: 16px; height: 16px; }

/* ---------- my status in the user menu ---------- */
.tm-um { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.tm-um label { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); white-space: nowrap; }
.tm-um-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.tm-um-dot.st-AVAILABLE { background: var(--green); } .tm-um-dot.st-BREAK { background: var(--amber); }
.tm-um .tm-select { height: 32px; max-width: 132px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) { .tm-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1024px) { .tm-grid2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .tm { gap: 16px; }
  .tm-card { padding: 16px; }
  .tm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tm-kpi { padding: 12px; }
  .tm-kpi-v { font-size: 24px; }
  .tm-head-side { width: 100%; }
  .tm-head-side .tm-btn, .tm-me { flex: 1; }
  .tm-me .tm-select { flex: 1; }
  .tm-select, .tm-btn, .tm-fld input, .tm-fld select { min-height: 40px; }
  /* board rows become cards */
  .tm-table-wrap { overflow: visible; margin: 0; }
  .tm-table thead { display: none; }
  .tm-table, .tm-table tbody { display: block; }
  .tm-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .tm-table tbody tr:last-child { border-bottom: none; }
  .tm-table tbody tr:hover td { background: transparent; }
  .tm-table td { display: flex; flex-direction: column; gap: 4px; padding: 0; border: none; }
  .tm-table td[data-l]::before { content: attr(data-l); font-size: 11.5px; font-weight: 600; color: var(--muted); }
  .tm-table td.tm-person { grid-column: 1 / -1; min-width: 0; }
  .tm-calc { grid-template-columns: minmax(0, 1fr); }
  .tm-sizes { grid-template-columns: minmax(0, 1fr); }
  .tm-size { flex-direction: row; align-items: center; gap: 12px; }
  .tm-inv-form .tm-btn { width: 100%; }
  .tm-cap-st { width: auto; }
  .tm-modal { align-items: flex-end; padding: 0; }
  .tm-dlg { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  #tm-toasts { left: 16px; right: 16px; width: auto; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) { .tm-toast, .tm-bar i, .tm-sk { animation: none; transition: none; } }

/* ===================== Phase 3: page tabs · commission & targets · role permissions ===================== */
.tm-ptabs { display: flex; gap: 4px; padding: 4px; align-self: flex-start; max-width: 100%; overflow-x: auto; scrollbar-width: none; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); }
.tm-ptabs::-webkit-scrollbar { display: none; }
.tm-ptab { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 16px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.tm-ptab svg { width: 16px; height: 16px; }
.tm-ptab:hover { color: var(--ink); background: var(--hover); border: none; }
.tm-ptab.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tm-ptab.on svg { color: var(--accent); }
.tm-pane { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.tm-pane[hidden] { display: none; }
.tm-icon-btn:disabled { opacity: .4; cursor: not-allowed; background: transparent; }

/* ---------- commission: header tools ---------- */
.tm-com-head { flex-wrap: wrap; }
.tm-com-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tm-com-tools .tm-btn { min-height: 40px; }
.tm-month { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card); }
.tm-month .tm-icon-btn { width: 36px; height: 36px; }
.tm-month .tm-month-in { height: 36px; width: 156px; padding: 0 6px; border: none; background: transparent; box-shadow: none; color: var(--ink); font-size: 13.5px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- commission: summary ---------- */
.tm-com-sum { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 2fr); gap: 16px; }
.tm-com-goal { display: flex; align-items: center; gap: 16px; min-width: 0; padding: 16px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 6%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)); }
.tm-com-goal-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tm-com-l { font-size: 12.5px; font-weight: 600; line-height: 1.35; color: var(--muted); }
.tm-com-big { font-family: Inter, "Noto Sans Thai", sans-serif; font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; color: var(--ink); overflow-wrap: anywhere; }
.tm-com-s { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.tm-ring { position: relative; width: 88px; height: 88px; flex: none; }
.tm-ring svg { display: block; width: 100%; height: 100%; }
.tm-ring-bg { fill: none; stroke: color-mix(in srgb, var(--accent) 14%, var(--card2)); stroke-width: 8; }
.tm-ring-fg { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dasharray .4s ease; }
.tm-ring.done .tm-ring-fg { stroke: var(--green); }
.tm-ring-v { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: Inter, "Noto Sans Thai", sans-serif; font-size: 17px; font-weight: 700; color: var(--ink); }
.tm-com-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tm-com-stat { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 0; padding: 16px; border-radius: 14px; background: var(--card2); border: 1px solid var(--line); }
.tm-com-stat b { font-family: Inter, "Noto Sans Thai", sans-serif; font-size: 20px; font-weight: 700; line-height: 1.2; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- commission: shop settings (owner/admin) ---------- */
.tm-com-set { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 260px) minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 16px; padding: 16px; border-radius: 14px; border: 1px dashed var(--line2); }
.tm-com-act { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 22px; }
.tm-com-act .tm-btn { min-height: 40px; }
.tm-affix { position: relative; display: flex; align-items: center; }
.tm-affix input { width: 100%; padding-right: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.tm-affix input[aria-invalid="true"] { border-color: var(--red); }
.tm-affix > span { position: absolute; right: 12px; font-size: 13px; font-weight: 600; color: var(--muted); pointer-events: none; }
.tm-affix--pre input { padding-right: 12px; padding-left: 28px; }
.tm-affix--pre > span { right: auto; left: 12px; }
.tm-affix--sm input { height: 36px; width: 96px; font-size: 13px; }
.tm-affix--pre.tm-affix--sm input { width: 136px; }

/* ---------- commission: per-person table ---------- */
#tm-com-body > .tm-hint { margin-top: 16px; }
#tm-com-body .tm-table-wrap { margin-top: 16px; }
.tm-com-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tm-com-cell--col { flex-direction: column; align-items: stretch; gap: 6px; min-width: 136px; }
.tm-com-tag { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--muted); background: var(--card2); border: 1px solid var(--line); }
.tm-com-prog { font-size: 11.5px; color: var(--muted); }
.tm-com-none { color: var(--faint); }
.tm-com-money { color: var(--tm-good); }
.tm-bar i.acc { background: var(--accent); }
.tm-com-how { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.tm-com-how .tm-tips { margin-top: 0; }

/* ---------- role permissions matrix ---------- */
.tm-pm th[scope="row"] { min-width: 240px; padding: 14px 12px; font-weight: 400; white-space: normal; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.tm-pm tbody tr:last-child th { border-bottom: none; }
.tm-pm thead th:not(:first-child), .tm-pm td { width: 128px; text-align: center; }
.tm-pm td.is-me { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.tm-pm-t { display: block; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.tm-pm-d { display: block; max-width: 540px; margin-top: 3px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.tm-pm-yes, .tm-pm-no { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.tm-pm-yes { color: var(--tm-good); } .tm-pm-no { color: var(--muted); }
.tm-pm-yes svg, .tm-pm-no svg { width: 16px; height: 16px; }
.tm-pm-sw { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 40px; cursor: pointer; }
.tm-pm-sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tm-pm-sw input:checked + .tm-switch-ui { background: var(--accent); }
.tm-pm-sw input:checked + .tm-switch-ui::after { transform: translateX(16px); }
.tm-pm-sw input:focus-visible + .tm-switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.tm-pm-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.tm-pm-foot .tm-btn { min-height: 40px; }
#tm-perm-body > .tm-hint { margin-top: 16px; }

@media (max-width: 1024px) { .tm-com-sum { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .tm-pane { gap: 16px; }
  .tm-ptabs { align-self: stretch; }
  .tm-ptab { flex: 1 0 auto; min-height: 40px; padding: 0 12px; }
  .tm-com-tools { width: 100%; }
  .tm-month { flex: 1; min-width: 0; }
  .tm-month .tm-icon-btn { width: 40px; height: 40px; }
  .tm-month .tm-month-in { flex: 1; width: auto; min-width: 0; height: 40px; }
  .tm-com-goal { padding: 12px; gap: 12px; }
  .tm-ring { width: 72px; height: 72px; }
  .tm-ring-v { font-size: 15px; }
  .tm-com-big { font-size: 24px; }
  .tm-com-stats { gap: 8px; }
  .tm-com-stat { padding: 12px 10px; }
  .tm-com-stat b { font-size: 16px; white-space: normal; overflow-wrap: anywhere; }
  .tm-com-set { grid-template-columns: minmax(0, 1fr); }
  .tm-com-act { padding-top: 0; }
  .tm-com-act .tm-btn { width: 100%; }
  .tm-affix--sm input, .tm-affix--pre.tm-affix--sm input { width: 100%; height: 40px; }
  .tm-com-cell--col { min-width: 0; }
  /* permission rows become cards: title on top, owner / admin / agent side by side */
  .tm-pm tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tm-pm th[scope="row"] { grid-column: 1 / -1; min-width: 0; padding: 0; border: none; }
  .tm-pm td { width: auto; text-align: left; align-items: flex-start; }
  .tm-pm td.is-me { background: transparent; }
  .tm-pm-sw { justify-content: flex-start; }
  .tm-pm-foot .tm-btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .tm-ring-fg { transition: none; } }
