/* Zespół, Moje konto and the one-time password page.
   Zespół's sections are grey tiles (.review-card); fields, choices and tables on them are white. */
.team-add-card { margin-bottom: var(--space-3); animation: reveal var(--duration) var(--ease-out); }
.team-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px var(--space-4); }
.team-form > .team-roles, .team-form > .team-actions, .team-wide { grid-column: 1 / -1; }
.team-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.team-field label { margin: 0; }
/* Fields that sit directly on the tile are white and borderless. */
.team-add-card .team-field input { border-color: transparent; box-shadow: var(--shadow-card); }
.team-add-card .team-field input:hover { border-color: var(--color-border); }
.team-add-card .team-field input:focus { border-color: var(--color-accent); box-shadow: var(--focus-ring); }

/* ---- A choice with a description: the role, the approval rule ---- */
.team-roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.team-roles legend { margin-bottom: 6px; padding: 0; font-size: var(--text-footnote); font-weight: 600; }
.team-role { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; margin: 0; padding: 14px var(--space-4); border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); font-weight: 400; cursor: pointer;
  transition: background-color var(--duration-fast), box-shadow var(--duration-fast); }
.team-role:hover { box-shadow: var(--shadow-card), 0 6px 16px rgba(0, 0, 0, .07); }
.team-role.is-on { background: var(--color-accent-soft); box-shadow: inset 0 0 0 1.5px var(--color-accent); }
.team-role:has(input:checked) { background: var(--color-accent-soft); box-shadow: inset 0 0 0 1.5px var(--color-accent); }
.team-role:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.team-role input { margin-top: 2px; }
.team-role > span { display: flex; flex-direction: column; gap: 2px; font-size: var(--text-body); }
.team-rules { grid-template-columns: minmax(0, 1fr); }

/* ---- An on/off setting: a white row with the switch on the right ---- */
.team .team-check { flex-direction: row-reverse; justify-content: space-between; gap: var(--space-4); align-self: end; padding: 8px var(--space-4); border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); cursor: pointer; }
.team .review-card > .team-check { align-self: stretch; }
/* The markup has a plain checkbox here; it gets the look of the shared .switch. */
.team .team-check input[type="checkbox"] { appearance: none; position: relative; width: 46px; height: 28px; min-height: 28px; flex: 0 0 46px; border-radius: var(--radius-pill); background: #b4b4b9; cursor: pointer; transition: background-color var(--duration) var(--ease-out); }
.team .team-check input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform var(--duration) var(--ease-out); }
.team .team-check input[type="checkbox"]:checked { background: var(--color-success-fill); }
.team .team-check input[type="checkbox"]:checked::after { transform: translateX(18px); }
.team .team-check input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
.team-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }

/* ---- The one-time link, shown once after an account is created ---- */
.team-created { display: flex; flex-direction: column; gap: 10px; margin-bottom: var(--space-3); padding: var(--space-5) var(--space-6); border-radius: var(--radius-xl); background: var(--color-success-soft); animation: reveal var(--duration) var(--ease-out); }
.team-created p { margin: 0; color: var(--color-text); font-size: var(--text-footnote); }
.team-created > .button-text { align-self: flex-start; margin-left: -12px; }
.team-link { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.team-link code { flex: 1 1 320px; min-width: 0; padding: 12px 14px; border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-card); font-family: var(--font-mono); font-size: var(--text-footnote); overflow-wrap: anywhere; user-select: all; }
.team-link .button-secondary { background: var(--color-surface); box-shadow: var(--shadow-card); }
.team-link .button-secondary:hover:not(:disabled) { background: var(--color-surface); box-shadow: var(--shadow-card), 0 4px 12px rgba(0, 0, 0, .08); }

/* ---- People and the role matrix: one white card per table, a line per row ---- */
.team .table-box { container-type: inline-size; overflow-x: visible; padding: 4px var(--space-2); border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); }
.team-table { width: 100%; border-collapse: collapse; }
.team-table th, .team-matrix thead th { padding: 10px; border-bottom: 1px solid var(--color-separator); color: var(--color-text-3); font-size: var(--text-footnote); font-weight: 600; text-align: left; }
.team-table td { padding: 12px 10px; border-bottom: 1px solid var(--color-separator); font-size: var(--text-footnote); vertical-align: middle; }
.team-table tbody tr:last-child td { border-bottom: 0; }
.team-table tr.is-off td { color: var(--color-text-3); }
.team-table select { min-height: 36px; min-width: 150px; max-width: 190px; padding-block: 6px; font-size: var(--text-footnote); }
.team-person strong { font-size: var(--text-body); }
.team-person strong, .team-sub { display: block; }
.team-row-actions { display: flex; flex-wrap: nowrap; gap: 2px; margin-left: -8px; }
.team-table td:last-child { width: 1%; }  /* As wide as its buttons, so they stay on one line. */
.team-row-actions .button-text { white-space: nowrap; }
.team-row-actions .button-text { min-height: 32px; padding: 0 8px; font-size: var(--text-footnote); }
/* Editing a person: a grey block under their line, with the default bordered fields. */
.team-table tr:has(+ .team-edit-row) td { border-bottom: 0; }
.team-table .team-edit-row td { padding: 0 2px 12px; }
.team-edit-row .team-form { padding: var(--space-4); border-radius: var(--radius-row); background: var(--color-tile); }
.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--space-3); margin-top: var(--space-3); align-items: start; }
.team-matrix td, .team-matrix tbody th { padding: 10px; border-bottom: 1px solid var(--color-separator); font-size: var(--text-footnote); }
.team-matrix tbody tr:last-child td, .team-matrix tbody tr:last-child th { border-bottom: 0; }
.team-matrix tbody th { color: var(--color-text); font-weight: 500; }
.team-matrix td.is-yes { color: var(--color-success); font-weight: 600; }
.team-matrix td.is-no { color: var(--color-text-3); }
.team-notice { margin: 0; padding: 12px var(--space-4); border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); color: var(--color-text); font-size: var(--text-footnote); }

/* ---- Moje konto ---- */
.account-dialog form { display: flex; flex-direction: column; }
.account-dialog form label { margin: var(--space-3) 0 6px; }
.account-dialog form .button-primary { min-height: 44px; margin-top: var(--space-4); }
.account-dialog .eyebrow { margin-bottom: 2px; font-size: var(--text-footnote); font-weight: 500; }
.account-dialog .dialog-heading > div { display: flex; flex-direction: column-reverse; }

@media (max-width: 900px) {
  .team-form, .team-roles { grid-template-columns: minmax(0, 1fr); }
}
/* When the card is too narrow for the table (a phone, or a desktop with the Agent panel open), each person
   becomes a block with labelled lines and the role matrix stacks, so nothing scrolls sideways. */
@container (max-width: 700px) {
  .team-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .team-table, .team-table tbody, .team-table tr, .team-table td { display: block; }
  .team-table tr { padding: var(--space-3) var(--space-2); border-bottom: 1px solid var(--color-separator); }
  .team-table tbody tr:last-child { border-bottom: 0; }
  .team-table td { padding: 3px 0; border: 0; }
  .team-table td[data-label] { display: grid; grid-template-columns: 116px minmax(0, 1fr); align-items: center; gap: 2px var(--space-2); }
  .team-table td[data-label]::before { content: attr(data-label); color: var(--color-text-3); font-size: var(--text-caption); font-weight: 600; }
  .team-table td[data-label] > * { grid-column: 2; justify-self: start; }
  .team-table td[data-label] > select { justify-self: stretch; max-width: 260px; width: 100%; }
  .team-row-actions { flex-wrap: wrap; margin-top: 2px; }
  .team-table td:last-child { width: auto; }
  .team-table tr:has(+ .team-edit-row) { padding-bottom: var(--space-2); border-bottom: 0; }
  .team-table .team-edit-row { padding: 0 0 var(--space-3); }
  .team-table .team-edit-row td { padding: 0; }
}
@container (max-width: 480px) {
  .team-matrix thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .team-matrix, .team-matrix tbody { display: block; }
  .team-matrix tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 6px; padding: 10px var(--space-2); border-bottom: 1px solid var(--color-separator); }
  .team-matrix tbody tr:last-child { border-bottom: 0; }
  .team-matrix tbody th { grid-column: 1 / -1; padding: 0 0 2px; border: 0; }
  .team-matrix td { display: flex; flex-direction: column; padding: 0; border: 0; font-size: var(--text-caption); }
  .team-matrix td::before { color: var(--color-text-3); font-size: var(--text-caption); font-weight: 500; }
  .team-matrix td:nth-child(2)::before { content: "Admin"; }
  .team-matrix td:nth-child(3)::before { content: "Marketing"; }
  .team-matrix td:nth-child(4)::before { content: "Akceptujący"; }
  .team-matrix td:nth-child(5)::before { content: "Podgląd"; }
}
@media (max-width: 760px) {
  .team-table select { min-height: 44px; font-size: 16px; }
  .team-row-actions .button-text { min-height: 44px; }
  .team-created { padding: var(--space-4); border-radius: var(--radius-lg); }
}

/* ---- The one-time link page (/ustaw-haslo), outside the Studio: the same card as sign-in ---- */
body.setup-page { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-6); min-height: 100vh; min-height: 100dvh; padding: var(--space-8) var(--space-4); }
.setup-card { width: 100%; max-width: 440px; padding: var(--space-10); border-radius: var(--radius-xl); background: var(--color-tile); }
.setup-logo { display: block; width: auto; height: auto; max-width: 180px; max-height: 60px; margin-bottom: var(--space-8); object-fit: contain; }
.setup-logo-text { display: block; max-width: 240px; margin-bottom: var(--space-8); overflow: hidden; color: var(--color-text); font-size: var(--text-title-3); font-weight: 700; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.setup-card h1 { font-size: 26px; }
.setup-intro { margin: var(--space-2) 0 0; color: var(--color-text-3); font-size: var(--text-headline); line-height: 1.4; }
.setup-card form { display: flex; flex-direction: column; margin-top: var(--space-6); }
.setup-card input { min-height: 52px; padding: 12px 16px; border-color: transparent; border-radius: var(--radius-md); font-size: 17px; box-shadow: var(--shadow-card); }
.setup-card input:hover { border-color: var(--color-border); }
.setup-card input:focus { border-color: var(--color-accent); box-shadow: var(--focus-ring); }
.setup-card .small-note { margin-top: 8px; color: var(--color-text-3); }
.setup-card .button-primary { min-height: 52px; margin-top: var(--space-6); font-size: 17px; }
.setup-done { margin: var(--space-6) 0 0; padding: 14px var(--space-4); border-radius: var(--radius-row); background: var(--color-success-soft); color: var(--color-success); font-weight: 600; }
@media (max-width: 760px) {
  body.setup-page { justify-content: flex-start; padding-top: 8vh; }
  .setup-card { padding: var(--space-8) var(--space-6); border-radius: var(--radius-xl); }
  .setup-card h1 { font-size: 24px; }
}

/* "Co może każda rola": closed until someone looks a permission up. */
.team-matrix-fold > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); list-style: none; }
.team-matrix-fold > summary::-webkit-details-marker { display: none; }
.team-matrix-fold > summary::after { content: ""; flex: 0 0 auto; width: 8px; height: 8px; margin-right: 4px; border-right: 2px solid var(--color-text-3); border-bottom: 2px solid var(--color-text-3); transform: rotate(45deg); transition: transform var(--duration-fast); }
.team-matrix-fold[open] > summary::after { transform: rotate(-135deg); }
.team-matrix-fold > summary h2 { margin: 0; }
.team-matrix-fold[open] > summary { margin-bottom: var(--space-3); }
