/* Only active on the authenticated team server; the existing local dashboard stays unchanged. */

body.team-mode .team-auth[hidden],
body.team-mode [data-team-hidden] {
  display: none!important
}

.team-auth {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #f4f4f4;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 28px;
  font: 14px/1.6 system-ui,sans-serif;
  color: #40394f
}

.team-auth-card {
  width: min(100%,480px);
  background: white;
  border: 1px solid var(--surface-border);
  border-radius: 22px;
  padding: 32px;
  box-shadow: 0 18px 70px #40394f12
}

.team-auth-logo {
  font-size: 30px;
  letter-spacing: .15em;
  font-weight: 900;
  background: #f9bd16;
  margin: -32px -32px 26px;
  padding: 24px 32px;
  border-radius: 22px 22px 0 0
}

.team-auth h1 {
  font-size: 24px;
  font-weight: 850;
  line-height: 1.3;
  margin-bottom: 10px
}

.team-auth p {
  margin: 10px 0;
  color: #716a7c
}

.team-form {
  display: grid;
  gap: var(--form-stack-gap)
}

.team-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 13px
}

.team-form input:not([type=checkbox]),
.team-form select,
.team-form textarea {
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: white;
  color: #40394f;
  padding: 11px 12px;
  font: inherit;
  box-sizing: border-box
}

.team-form input:focus,
.team-form select:focus,
.team-form textarea:focus {
  outline: 2px solid #f9bd16;
  outline-offset: 2px
}

.team-form small {
  font-weight: 400;
  color: #756d80;
  line-height: 1.6
}

.team-form button,
.team-auth button {
  font: inherit;
  cursor: pointer
}

.team-primary {
  background: #f9bd16;
  border: 1px solid #eab00a;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 800;
  color: #332d3e
}

.team-secondary {
  background: #f7f5f9;
  border: 1px solid var(--control-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  color: #4b4263
}

.team-link {
  border: 0;
  background: none;
  color: #4b4263;
  text-decoration: underline;
  padding: 5px;
  font-size: 13px
}

.team-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 18px
}

.team-message {
  border: 1px solid var(--surface-border);
  background: #f8f6fa;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere
}

.team-message[data-state=error] {
  background: #fff2f2;
  color: #a32727;
  border-color: #f1c0c0
}

.team-message[data-state=success] {
  background: #edf8f5;
  color: #087c72;
  border-color: #c5e5dc
}

.team-message:empty {
  display: none
}

.team-panel {
  background: white;
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 22px;
  display: grid;
  gap: 18px
}

.team-panel h2 {
  font-size: 18px;
  font-weight: 850
}

.team-panel h3 {
  font-weight: 800
}

.team-hint {
  font-size: 13px;
  line-height: 1.7;
  color: #756d80
}

.team-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2,minmax(0,1fr))
}

.team-wide {
  grid-column: 1/-1
}

.team-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center
}

.team-permissions {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2,minmax(0,1fr));
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 12px
}

.team-permissions label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-weight: 500;
  font-size: 12px
}

.team-permissions input {
  margin-top: 3px
}

.team-table-wrap {
  overflow-x: auto
}

.team-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px
}

.team-table th,
.team-table td {
  padding: 13px 10px;
  border-bottom: 1px solid #eae5ef;
  vertical-align: middle
}

.team-table th {
  font-size: 12px;
  color: #756d80
}

.team-table small {
  display: block;
  color: #756d80
}

.team-status {
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 20px;
  background: #e9f7f2;
  color: #087c72
}

.team-status.disabled {
  background: #fff0ef;
  color: #ac3333
}

.team-status.invited {
  background: #fff7db;
  color: #8b6300
}

.team-account-button {
  margin-top: 8px;
  width: 100%;
  background: #ffda71;
  border: 1px solid #e2aa1b;
  border-radius: 9px;
  padding: 8px;
  font-weight: 700;
  font-size: 12px
}

.team-save-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  background: #edf8f5;
  border: 1px solid #c5e5dc;
  color: #087c72;
  border-radius: 12px;
  padding: 12px 15px;
  font-size: 13px
}

.team-save-state[data-state=error] {
  background: #fff1ef;
  border-color: #edc6c1;
  color: #a32c2c
}

.team-save-state[data-state=pending] {
  background: #fff9e8;
  border-color: #f0d57c;
  color: #82600b
}

.team-save-state p {
  margin: 0
}

.team-vault-dialog {
  border: 0;
  border-radius: 18px;
  padding: 26px;
  max-width: 560px;
  width: calc(100% - 40px);
  box-shadow: 0 20px 100px #0004;
  color: #40394f
}

.team-vault-dialog::backdrop {
  background: #15101c99
}

.team-vault-dialog h2 {
  font-weight: 850;
  font-size: 20px;
  margin-bottom: 14px
}

.team-vault-button {
  margin-top: 10px
}

.team-auth button:disabled,
.team-panel button:disabled,
.team-vault-dialog button:disabled {
  opacity: .5;
  cursor: not-allowed
}

.team-session-note {
  font-size: 11px!important;
  margin-top: 22px!important
}

@media(max-width:640px) {
  .team-auth {
    padding: 16px
  }

  .team-auth-card {
    padding: 24px
  }

  .team-auth-logo {
    margin: -24px -24px 22px;
    padding: 20px 24px
  }

  .team-grid,
  .team-permissions {
    grid-template-columns: 1fr
  }

  .team-panel {
    padding: 16px
  }

  .team-save-state {
    align-items: flex-start
  }

  .team-table th,
  .team-table td {
    padding: 10px 7px
  }
}

/* Portal table controls, guarded exports and the administrator activity log. */

body.team-mode [hidden] {
  display: none!important
}

.team-panel {
  min-width: 0
}

.team-table-wrap {
  max-width: 100%
}

.team-portal-access {
  min-width: 215px
}

.team-access-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px
}

.team-access-actions .team-vault-button {
  grid-column: 1/-1;
  margin-top: 0
}

.team-access-actions button {
  font-size: 11px;
  justify-content: center
}

.team-access-meta {
  font-size: 11px;
  line-height: 1.6;
  color: #756d80;
  margin: 8px 0 0;
  max-width: 300px;
  overflow-wrap: anywhere
}

.team-table-attachments {
  display: grid;
  gap: 7px;
  margin-top: 10px
}

.team-inline-attachment-heading {
  font-size: 11px;
  color: #4b4263
}

.team-inline-attachment {
  display: grid;
  gap: 5px;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center
}

.team-inline-attachment .team-open-attachment {
  display: block;
  text-align: left;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 11px;
  min-width: 0
}

.team-inline-attachment .team-download-attachment {
  font-size: 10px;
  padding: 7px
}

.team-attachment-preview {
  max-width: 900px;
  max-height: 88vh;
  max-height: 88svh;
  overflow-y: auto;
  overscroll-behavior: contain
}

.team-attachment-preview-content {
  min-height: 80px;
  margin: 18px 0;
  overflow: auto;
  max-height: 65vh;
  max-height: 65svh
}

.team-attachment-preview-content pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 13px/1.7 ui-monospace,Consolas,monospace;
  background: #f7f5f9;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 16px
}

.team-attachment-preview-content img {
  display: block;
  max-width: 100%;
  max-height: 65vh;
  max-height: 65svh;
  object-fit: contain;
  margin: auto
}

.team-vault-expanded {
  max-width: 700px;
  max-height: 88vh;
  max-height: 88svh;
  overflow-y: auto;
  overscroll-behavior: contain
}

.team-dialog-header {
  position: sticky;
  top: -26px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background: white;
  margin: -26px -26px 18px;
  padding: 22px 26px 16px;
  border-bottom: 1px solid #e4dfea
}

.team-dialog-header h2 {
  margin: 0 0 4px
}

.team-dialog-header p {
  margin: 0;
  overflow-wrap: anywhere
}

.team-dialog-x {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid #ddd5e4;
  border-radius: 10px;
  background: #f7f5f9;
  color: #40394f;
  font-size: 25px;
  line-height: 1;
  cursor: pointer
}

.team-dialog-x:focus-visible {
  outline: 3px solid #f9bd16;
  outline-offset: 2px
}

.team-vault-content {
  display: grid;
  gap: 18px;
  margin: 18px 0
}

.team-input-copy {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0
}

.team-input-copy input {
  min-width: 0;
  flex: 1
}

.team-input-copy button {
  flex: 0 0 auto
}

.team-dialog-footer {
  border-top: 1px solid #e4dfea;
  padding-top: 16px
}

.team-vault-meta {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f5f9;
  overflow-wrap: anywhere
}

.team-attachment-section {
  display: grid;
  gap: 12px;
  border-top: 1px solid #e4dfea;
  padding-top: 18px
}

.team-attachment-section h3 {
  font-weight: 800
}

.team-attachment-list {
  display: grid;
  gap: 8px
}

.team-attachment-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  min-width: 0
}

.team-attachment-row>div:first-child {
  min-width: 0
}

.team-attachment-row strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere
}

.team-attachment-row small {
  display: block;
  font-size: 11px;
  color: #756d80;
  margin-top: 4px
}

.team-attachment-row button {
  font-size: 12px
}

.team-attachment-upload {
  padding: 12px;
  background: #f7f5f9;
  border-radius: 10px
}

.team-plaintext-warning {
  padding: 16px;
  background: #fff8df;
  border: 1px solid #efd16c;
  border-radius: 12px;
  display: grid;
  gap: 14px;
  font-size: 13px;
  line-height: 1.7;
  color: #674b13
}

.team-form .team-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 600
}

.team-check input {
  flex: 0 0 auto;
  margin-top: 5px
}

.team-log-filters {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4,minmax(0,1fr))
}

.team-log-filters label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700
}

.team-log-filters input,
.team-log-filters select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: white;
  padding: 10px;
  color: #40394f;
  font: inherit
}

.team-log-filters>.team-actions {
  grid-column: 1/-1
}

.team-log-table {
  min-width: 800px
}

.team-log-table td {
  vertical-align: top;
  overflow-wrap: anywhere;
  max-width: 310px
}

.team-log-table td:first-child {
  white-space: nowrap
}

@media(max-width:950px) {
  .team-log-filters {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }
}

@media(max-width:640px) {
  .team-log-filters {
    grid-template-columns: 1fr
  }

  .team-vault-expanded {
    padding: 20px;
    max-height: 92svh;
    width: calc(100% - 20px)
  }

  .team-dialog-header {
    top: -20px;
    margin: -20px -20px 16px;
    padding: 16px 20px
  }

  .team-attachment-row {
    align-items: flex-start;
    flex-direction: column
  }

  .team-input-copy {
    gap: 5px
  }

  .team-input-copy button {
    padding: 10px 8px;
    font-size: 12px
  }
}

/* Client-only administrator preview. Server identity and role never change. */

.team-account-trigger {
  cursor: pointer;
  position: relative;
  padding-right: 25px!important
}

.team-account-trigger::after {
  content: '⌄';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  font-weight: 800
}

.team-account-trigger:hover {
  background: #ffda71
}

.team-account-trigger:focus-visible {
  outline: 3px solid #4b4263;
  outline-offset: 2px
}

.team-account-dialog {
  max-width: 650px;
  max-height: 88vh;
  max-height: 88svh;
  overflow: auto
}

.team-account-dialog .team-dialog-footer {
  margin-top: 20px
}

.team-account-dialog #teamAccountContent {
  margin: 12px 0
}

.team-preview-permissions {
  font-size: 12px;
  padding: 14px;
  background: #f7f5f9;
  border: 1px solid var(--surface-border);
  border-radius: 10px
}

.team-preview-permissions ul {
  list-style: disc;
  margin: 8px 0 0 18px;
  columns: 2;
  column-gap: 22px
}

.team-preview-permissions li {
  break-inside: avoid;
  line-height: 1.8
}

.team-preview-banner {
  position: sticky;
  top: 84px;
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  margin-bottom: 18px;
  background: #f0ecfa;
  border: 2px solid #8673a7;
  border-radius: 14px;
  color: #40394f;
  box-shadow: 0 6px 18px #40394f18
}

.team-preview-banner strong {
  font-size: 14px
}

.team-preview-banner p {
  font-size: 13px;
  margin: 4px 0
}

.team-preview-banner small {
  display: block;
  max-width: 720px;
  font-size: 11px;
  line-height: 1.6
}

.team-preview-banner button {
  flex-shrink: 0;
  background: white
}

.team-preview-mode [data-preview-disabled] {
  opacity: .5;
  cursor: not-allowed
}

@media(max-width:640px) {
  .team-preview-banner {
    top: 78px;
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
    gap: 10px
  }

  .team-preview-banner button {
    width: 100%
  }

  .team-preview-permissions ul {
    columns: 1
  }

  .team-account-dialog {
    padding: 20px;
    width: calc(100% - 20px)
  }

  .team-account-dialog .team-dialog-header {
    top: -20px;
    margin: -20px -20px 16px;
    padding: 16px 20px
  }
}
