body { background: var(--portal); }
.auth { position: relative; }
.home-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.auth[hidden], .home[hidden] { display: none !important; }
.gate-card select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.65rem; font: inherit; background: var(--surface); color: inherit; }
.gate-card input:focus, .gate-card select:focus, .create-row input:focus, .email-row input:focus {
  outline: none;
  border-color: var(--wine);
}
.eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--wine); }
.gate-brand { margin-bottom: 0.85rem; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.home { width: min(1080px, 100%); margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.home-bar { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 1.4rem; }
.home-bar h1 { margin: 0; font-size: 2rem; letter-spacing: -0.03em; }
.lead { margin: 0.35rem 0 0; color: var(--ink-500); max-width: 40rem; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.9rem; }
.app-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.9rem;
  align-content: start;
  min-height: 8.5rem;
  padding: 1rem 1.05rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 10px 30px rgba(28, 31, 29, 0.04);
}
a.app-card:hover { border-color: var(--wine); }
.app-symbol {
  grid-row: 1 / span 4;
  align-self: start;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--wine);
  color: #fff;
  display: grid;
  place-items: center;
}
.app-symbol svg, .app-symbol img { width: 28px; height: 28px; display: block; }
.app-card strong { font-size: 1.12rem; letter-spacing: -0.02em; align-self: end; }
.app-text { color: var(--ink-500); font-size: 14px; line-height: 1.4; }
.app-note { color: var(--wine-dark); font-size: 13px; font-weight: 650; }
.app-status {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.app-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.app-status.is-online { color: #1b6b38; }
.app-status.is-offline { color: #9b2330; }
.app-card.is-offline { cursor: default; }
.create-row, .email-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: end; }
.create-row { margin-bottom: 0.8rem; }
.create-row input, .email-row input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  background: var(--surface);
  color: inherit;
}
.create-row input[type="text"] { min-width: 12rem; }
.email-row { margin: 0.2rem 0 0.7rem; }
.email-row label { display: grid; gap: 0.2rem; font-size: 13px; font-weight: 650; min-width: min(100%, 22rem); }
.people { display: grid; gap: 0.8rem; }
.person, .mailbox { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1rem 1.05rem 1.1rem; }
.mailbox, .always-mail { margin-bottom: 1rem; }
.always-list { display: grid; }
.always-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.05rem;
  border-top: 1px solid var(--line);
}
.always-row span { font-size: 14px; overflow-wrap: anywhere; }
.always-mail .people-empty { border: 0; background: transparent; text-align: left; padding: 0.35rem 0 0; }
.mailbox h2 { margin: 0 0 0.2rem; font-size: 1.25rem; }
.mailbox .lead { margin-bottom: 0.7rem; }
.position-editor { margin-bottom: 1rem; }
.position-editor h2 { margin: 0 0 0.2rem; font-size: 1.25rem; }
.position-editor .lead { margin-bottom: 0.75rem; }
.position-labels { display: grid; gap: 0.45rem; margin-bottom: 0.75rem; }
.label-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.label-row input, .label-row select, #position-add select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  background: var(--surface);
  color: inherit;
}
.label-row input { min-width: min(100%, 12rem); flex: 1 1 12rem; }
.label-row select, #position-add select { min-width: min(100%, 14rem); flex: 1 1 14rem; }
.position-editor .people-empty { border: 0; background: transparent; text-align: left; padding: 0.2rem 0; }
.position-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.7rem 0 0.15rem; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.18rem 0.2rem 0.18rem 0.6rem;
  border-radius: 999px;
  background: var(--wine-soft);
  color: var(--wine);
  font-size: 13px;
  font-weight: 650;
}
.tag button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  cursor: pointer;
}
.tag button:hover { background: rgba(155, 35, 48, 0.12); }
.tag-add select {
  border: 1px dashed var(--sand-300);
  border-radius: 999px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  padding: 0.32rem 0.6rem;
}
.position-choices { display: grid; gap: 0.15rem; }
.gate-card .position-choice {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.1rem;
  font-size: 15px;
  font-weight: 550;
}
.gate-card .position-choice input { width: 1.05rem; height: 1.05rem; padding: 0; margin: 0; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.person h2 { margin: 0; font-size: 1.25rem; }
.person-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.user-find { display: flex; align-items: center; gap: 0.8rem; margin: 0 0 0.85rem; }
.user-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.user-search svg { width: 18px; height: 18px; color: var(--ink-500); flex: none; }
.user-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0.15rem 0;
  background: transparent;
  font: inherit;
}
.user-search input:focus { outline: none; }
.user-search:focus-within { border-color: var(--wine); }
.user-count { margin: 0; color: var(--ink-500); font-size: 13px; font-weight: 650; white-space: nowrap; }
.people-empty {
  margin: 0;
  padding: 1.2rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--ink-500);
  text-align: center;
}
.person-id { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.person-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--wine-soft);
  color: var(--wine);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}
.right-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.65rem; }
.manage .rights-group {
  background: var(--sand-50);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.75rem 0.2rem;
}
.manage .rights-group h3 {
  margin: 0 0 0.15rem;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-500);
}
.copy-switch { border-top: 0; padding-top: 0.2rem; }
.switch-row.is-locked { cursor: default; }
.switch-row.is-locked .switch { opacity: 0.72; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  padding: 0.48rem 0.05rem;
  border-top: 1px solid var(--line);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.switch-ui {
  display: block;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--sand-300);
  position: relative;
  transition: background 0.16s ease;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(28, 31, 29, 0.28);
  transition: transform 0.16s ease;
}
.switch input:checked + .switch-ui { background: var(--wine); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--wine); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .switch-ui, .switch-ui::after { transition: none; }
}
@media (max-width: 700px) {
  .home-bar, .person header { flex-direction: column; align-items: flex-start; }
}
