/* Boxed panels on the page, the layout the files, organization and resources
   tabs use: a sticky directory beside a column of panels. Nothing caps its own
   height and nothing scrolls inside itself — the page does that. */
.teams-page {
  --team-accent: var(--green);
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 21%) minmax(0, 1fr);
  gap: var(--panel-gap);
  align-items: start;
}
.teams-section-label { margin: 0 0 5px; color: var(--muted); font-size: var(--text-meta); font-weight: 700; letter-spacing: var(--tracking-label); text-transform: uppercase; }

.teams-directory {
  position: sticky;
  top: 18px;
  min-width: 0;
  padding: 15px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-raised);
  box-shadow: 0 9px 28px rgba(34, 31, 25, .045);
}
.teams-directory > header { display: grid; gap: 10px; margin: 0 4px 15px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.teams-directory .panel-title { font-size: 17px; }
.teams-directory .button { min-height: 30px; justify-self: start; padding-inline: 10px; border-radius: 2px; font-size: var(--text-control); }
.teams-list { display: grid; gap: 2px; }
.team-list-item { width: 100%; min-width: 0; display: grid; grid-template-columns: 19px minmax(0, 1fr); align-items: center; gap: 6px; padding: 7px 6px; border: 0; border-left: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; text-align: left; transition: color .12s, background .12s, border-color .12s; }
.team-list-item:hover { background: rgba(23, 23, 19, .045); color: var(--ink); }
.team-list-item.is-active { border-left-color: var(--team-accent); background: rgba(47, 116, 88, .08); color: var(--ink); }
.team-list-mark { width: 17px; height: 17px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font: italic 10px/1 var(--serif); }
.team-list-item > span:last-child { min-width: 0; display: grid; }
.team-list-item strong,
.team-list-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-list-item strong { font-size: var(--text-control); font-weight: 600; }
.team-list-item small { color: var(--muted); font-size: var(--text-meta); font-variant-numeric: tabular-nums; }

/* Transparent: the panels inside it are the boxes. */
.teams-main { min-width: 0; }
.teams-back { display: none; }
.teams-main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.teams-main-head h2 { margin: 0; font: 400 clamp(29px, 4vw, 44px)/1 var(--serif); letter-spacing: -.025em; }
.teams-main-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.teams-main-actions .button { min-height: 32px; padding-inline: 11px; border-radius: 2px; font-size: var(--text-control); }
.teams-main-actions .team-danger-button { border-color: color-mix(in srgb, var(--red) 38%, var(--line)); color: var(--red); }
.teams-main-actions .team-danger-button:hover { background: rgba(181, 59, 47, .07); }
.team-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 20px; min-height: 36px; margin-bottom: 17px; padding: 7px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--text-control); }
.team-facts span { display: inline-flex; gap: 6px; }
.team-facts b { color: #aaa49a; font-size: var(--text-meta); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }

.teams-grid { display: grid; grid-template-columns: minmax(370px, 1.15fr) minmax(280px, .85fr); gap: var(--panel-gap); align-items: start; }
.team-panel { min-width: 0; border: 1px solid var(--line); border-radius: 3px; background: var(--paper-raised); box-shadow: 0 9px 28px rgba(34, 31, 25, .045); }
.team-access-panel,
.team-shares-panel,
.team-approvals-panel { grid-column: 1 / -1; }
.team-panel > header { min-height: 61px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 13px 15px 12px; border-bottom: 1px solid var(--line); }
.team-panel h3 { margin: 0; font: var(--font-panel-title); font-size: 18px; }
.team-panel > header > span { min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0 7px; border-radius: 999px; background: rgba(47, 116, 88, .09); color: var(--green); font-size: var(--text-meta); font-weight: 700; font-variant-numeric: tabular-nums; }

.team-switch-row { display: flex; align-items: center; gap: 18px; padding: 15px; cursor: pointer; }
.team-switch-row > span:first-child { min-width: 0; display: grid; gap: 3px; margin-right: auto; }
.team-switch-row strong { font-size: var(--text-body); font-weight: 600; }
.team-switch-row small { max-width: 760px; color: var(--muted); font-size: var(--text-control); line-height: 1.45; }
.team-switch-row input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.team-switch { position: relative; flex: 0 0 38px; width: 38px; height: 22px; border: 1px solid var(--line); border-radius: 999px; background: rgba(23, 23, 19, .07); transition: background .15s, border-color .15s; }
.team-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.team-switch-row input:checked + .team-switch { border-color: var(--green); background: var(--green); }
.team-switch-row input:checked + .team-switch::after { background: white; transform: translateX(16px); }
.team-switch-row input:focus-visible + .team-switch { outline: 2px solid var(--blue); outline-offset: 2px; }

.team-approval-list,
.team-share-list,
.team-member-list { margin: 0; padding: 0; list-style: none; }
.team-approval-list li,
.team-share-list li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 15px; border-top: 1px solid var(--line); }
.team-approval-list li:first-child,
.team-share-list li:first-child { border-top: 0; }
.team-approval-list li > div:first-child,
.team-share-list li > div:first-child { min-width: 0; display: grid; gap: 2px; }
.team-approval-list li > div:last-child { display: flex; gap: 8px; }
.team-approval-list strong,
.team-share-list strong { font-size: var(--text-body); font-weight: 600; }
.team-approval-list span,
.team-share-list span { color: var(--muted); font-size: var(--text-control); }

.team-user-search { display: grid; gap: 4px; padding: 12px 15px; }
.team-user-search > span { color: var(--muted); font-size: var(--text-meta); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.team-user-search input { width: 100%; padding: 6px 0; border: 0; border-bottom: 1px solid #aaa499; outline: 0; background: transparent; color: var(--ink); font-size: var(--text-body); }
.team-user-search input:focus { border-color: var(--blue); }
.team-user-results { display: grid; gap: 3px; margin: 0 15px 11px; padding: 5px; border: 1px solid #becbeb; background: var(--blue-soft); }
.team-user-results > button { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 8px; border: 0; background: transparent; color: var(--ink); cursor: pointer; text-align: left; }
.team-user-results > button:hover { background: rgba(255, 255, 255, .55); }
.team-user-results > button > span { min-width: 0; display: grid; }
.team-user-results strong,
.team-user-results small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-user-results strong { font-size: var(--text-control); font-weight: 600; }
.team-user-results small,
.team-user-results p { color: var(--muted); font-size: var(--text-meta); }
.team-user-results b { color: var(--blue); font-size: var(--text-meta); text-transform: uppercase; }
.team-user-results p { margin: 0; padding: 9px; }

.team-member-row { min-width: 0; display: grid; grid-template-columns: 31px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px 15px; border-top: 1px solid var(--line); }
.team-person-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: rgba(47, 116, 88, .1); color: var(--green); font: italic var(--text-body)/1 var(--serif); }
.team-member-identity { min-width: 0; display: grid; }
.team-member-identity strong,
.team-member-identity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-member-identity strong { font-size: var(--text-body); font-weight: 600; }
.team-member-identity span { color: var(--muted); font-size: var(--text-meta); }
.team-role { padding: 2px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: var(--text-meta); }
.team-role.is-leader { border-color: var(--green); color: var(--green); }
.team-member-actions { grid-column: 2 / -1; display: flex; justify-content: flex-end; gap: 10px; }
.team-text-action { padding: 2px 0; border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--blue); cursor: pointer; font-size: var(--text-meta); }
.team-text-action.is-danger { color: var(--red); }
.team-text-action:disabled { color: #aaa49a; cursor: default; opacity: .65; }

.team-project-list { display: grid; }
.team-project-row { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 9px; padding: 11px 15px; border-top: 1px solid var(--line); cursor: pointer; }
.team-project-row:first-child { border-top: 0; }
.team-project-row:hover { background: rgba(47, 116, 88, .035); }
.team-project-row input { margin-top: 2px; accent-color: var(--green); }
.team-project-row > span { min-width: 0; display: grid; gap: 2px; }
.team-project-row strong { overflow: hidden; font-size: var(--text-body); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.team-project-row small { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: var(--text-control); -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.team-empty-copy { margin: 0; padding: 20px 15px; color: var(--muted); font: italic var(--text-body)/1.4 var(--serif); }

/* The page is no longer a box, so the empty state has to be one. */
.teams-empty { min-height: 430px; grid-template-columns: 1fr; place-items: center; padding: 44px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper-raised); box-shadow: 0 9px 28px rgba(34, 31, 25, .045); text-align: center; }
.teams-empty > div { max-width: 420px; }
.teams-empty p:not(.teams-section-label) { margin: 8px 0 18px; color: var(--muted); }
.team-dialog { width: min(430px, calc(100% - 24px)); }
.team-dialog-card { position: relative; }
.team-dialog-close { position: absolute; top: 12px; right: 13px; }
.team-dialog-error { min-height: 18px; margin: 6px 0; color: var(--red); font-size: var(--text-meta); }

@media (max-width: 900px) {
  .teams-grid { grid-template-columns: 1fr; }
  .team-access-panel,
  .team-approvals-panel { grid-column: auto; }
}

@media (max-width: 700px) {
  /* One at a time. A sideways-scrolling strip of teams hides most of them
     off-screen and gives no sense of how many there are; the full list gets
     the width instead, and picking one swaps it for the team. */
  .teams-page { grid-template-columns: minmax(0, 1fr); }
  .teams-main-head h2 { font-size: clamp(21px, 6vw, 29px); }
  .teams-directory { position: static; padding: 13px 12px; }
  .teams-page.is-detail .teams-directory { display: none; }
  .teams-page:not(.is-detail) .teams-main { display: none; }

  .teams-list { gap: 1px; }
  .team-list-item { min-height: var(--tap); padding: 8px; border-left-width: 3px; }
  .team-list-item::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 15px; }
  .team-list-item { grid-template-columns: 19px minmax(0, 1fr) auto; }

  .teams-back {
    min-height: var(--tap-dense);
    display: inline-flex;
    align-items: center;
    margin-bottom: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--blue);
    cursor: pointer;
    font-size: var(--text-control);
  }
  .teams-back:hover { text-decoration: underline; }
}

@media (max-width: 560px) {
  .teams-main-head { align-items: flex-start; flex-direction: column; }
  .teams-main-actions { justify-content: flex-start; }
  .team-facts { display: grid; grid-template-columns: 1fr 1fr; }
  .team-switch-row { align-items: flex-start; }
  .team-approval-list li,
  .team-share-list li { align-items: flex-start; flex-direction: column; }
  .team-member-row { grid-template-columns: 31px minmax(0, 1fr); }
  .team-role { grid-column: 2; justify-self: start; }
  .team-member-actions { grid-column: 2; justify-content: flex-start; }
}
