.clan-page {
  background: var(--bg-deep);
  min-height: 100vh;
  --subnav-h: 48px;
}

.subnav {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  z-index: 190;
  display: flex;
  align-items: stretch;
  height: var(--subnav-h);
  max-width: 100%;
  overflow: hidden;
  background: #10161e;
  border-bottom: 1px solid rgba(255, 140, 0, 0.22);
  padding-left: max(0.85rem, env(safe-area-inset-left));
  padding-right: max(0.85rem, env(safe-area-inset-right));
  gap: 0.35rem;
}

.subnav-scroll {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.subnav-scroll a {
  display: flex;
  align-items: center;
  flex: none;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}

.subnav-scroll a:hover,
.subnav-scroll a.active {
  color: var(--accent);
  background: rgba(255, 140, 0, 0.1);
  text-decoration: none;
}

.subnav-scroll a.active {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.subnav-note {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 0.75rem;
  font-size: 0.84rem;
  white-space: nowrap;
}

.subnav:has(> .subnav-action) > .subnav-scroll {
  flex: 0 0 auto;
}

.subnav-action {
  flex: 0 0 auto;
  align-self: center;
  white-space: nowrap;
}

.subnav-action.active {
  box-shadow: 0 0 0 2px rgba(255, 140, 0, 0.45);
}

.clan-page.has-subnav .clan-main {
  padding-top: calc(var(--header-h) + var(--subnav-h) + 2rem);
}

.clan-nav {
  flex: 1;
}

.nav-drop {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-drop-toggle {
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.35rem 0.2rem;
}

.nav-sub {
  display: none;
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 30;
  width: min(280px, 80vw);
  max-height: min(70vh, 420px);
  overflow: auto;
  padding: 0.45rem;
  background: #141a22;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.nav-drop:hover .nav-sub,
.nav-drop:focus-within .nav-sub,
.nav-drop.open .nav-sub {
  display: block;
}

.nav-sub a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.nav-sub a:hover,
.nav-sub a.active {
  background: rgba(255, 140, 0, 0.1);
  color: var(--accent);
}

.nav-sub-action {
  margin-top: 0.4rem;
  text-align: center;
}

.clan-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.clan-user[hidden],
.clan-user > [hidden] {
  display: none !important;
}

.clan-user b {
  color: var(--text);
  font-weight: 600;
}

.clan-main {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 2rem) 1.25rem 3rem;
}

.clan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.5rem;
  margin-bottom: 1.1rem;
}

.clan-card h1,
.clan-card h2 {
  margin: 0 0 0.7rem;
}

.clan-card h1 {
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.clan-card h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.clan-lead {
  color: var(--text-muted);
  margin: 0 0 1.1rem;
  font-size: 0.95rem;
}

.clan-muted {
  color: var(--text-muted);
}

.clan-msg {
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
}

.clan-msg.ok { color: #6fcf97; }
.clan-msg.err { color: #eb5757; }

.clan-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
}

.clan-row .form-field {
  flex: 1;
  min-width: 180px;
  margin-bottom: 0;
}

.clan-btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}

.tg-bind {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.75rem;
  min-height: 34px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: rgba(20, 26, 34, 0.8);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  cursor: pointer;
}

.tg-bind:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tg-bind-widget {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  z-index: 1;
}

.tg-bind-widget iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.clan-btn-danger {
  border-color: #7a3030;
  color: #eb5757;
  background: transparent;
}

.clan-btn-danger:hover {
  border-color: #eb5757;
  color: #ff8a8a;
}

.clan-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  background: rgba(255, 140, 0, 0.12);
  color: var(--accent-bright);
}

.clan-badge.member {
  background: rgba(141, 151, 165, 0.12);
  color: var(--text-muted);
}

.clan-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.clan-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.clan-list li:last-child {
  border-bottom: 0;
}

.clan-list .meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.clan-list li > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.clan-list .clan-actions,
.clan-member-actions {
  flex-wrap: nowrap;
  flex: none;
}

.clan-member-actions .btn {
  white-space: nowrap;
}

.clan-card h2.clan-ban-title {
  margin-top: 1.25rem;
}

.clan-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
}

.clan-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.9rem;
}

.clan-table th,
.clan-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.clan-table th {
  background: rgba(0, 0, 0, 0.28);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.clan-table td {
  color: var(--text-muted);
  white-space: normal;
  overflow-wrap: break-word;
}

.clan-table th:nth-child(1),
.clan-table td:nth-child(1) {
  width: 22%;
  overflow-wrap: anywhere;
}

.clan-table th:nth-child(2),
.clan-table td:nth-child(2) {
  width: 12%;
}

.clan-table th:nth-child(3),
.clan-table td:nth-child(3) {
  width: 18%;
}

.clan-table th:nth-child(4),
.clan-table td:nth-child(4) {
  width: 48%;
}

.clan-table tbody tr:last-child td {
  border-bottom: none;
}

.clan-table td strong,
.clan-table td strong a {
  color: var(--text);
  font-weight: 600;
}

.clan-table-act {
  text-align: left;
  white-space: normal;
  vertical-align: middle;
}

.clan-table-btns {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 0.4rem;
  max-width: 100%;
  vertical-align: middle;
}

.clan-table-btns .btn,
.clan-table-btns .clan-table-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  white-space: nowrap;
  box-sizing: border-box;
}

.clan-table-btns .btn {
  flex: 0 0 auto;
  height: 2rem;
}

.clan-table-note {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.clan-page .btn:disabled {
  transform: none;
  cursor: default;
  opacity: 0.72;
}

.clan-page-actions {
  margin: 0 0 1rem;
}

.clan-page-actions .btn {
  min-width: 10.5rem;
}

.clan-leave {
  border-color: #a33b3b;
  background: #7a3030;
  color: #fff;
}

.clan-leave:hover {
  background: #943c3c;
  border-color: #eb5757;
  color: #fff;
}

.clan-action-note {
  margin: 0.55rem 0 0;
  color: #eb5757;
  font-size: 0.9rem;
}

.clan-apply-fields {
  margin-bottom: 0.75rem;
  max-width: 28rem;
}

.clan-apply-fields .form-field {
  margin-bottom: 0.55rem;
}

.clan-table-empty td {
  white-space: normal;
  color: var(--text-muted);
}

.clan-status-war {
  color: var(--accent-bright);
  font-weight: 600;
}

.clan-status-peace {
  color: var(--text-muted);
}

.clan-status-out {
  color: var(--text-muted);
  font-weight: 600;
}

.clan-copy {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
}

.clan-copy input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.clan-copy .btn {
  flex: none;
  white-space: nowrap;
}

.clan-id-line {
  align-items: center;
}

.clan-id {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.clan-checks {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.75rem 0 1rem;
}

.clan-checks label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.92rem;
}

.clan-radio {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.5rem 0 0.75rem;
}

.clan-invite {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.clan-invite:last-child {
  border-bottom: 0;
}

.clan-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.clan-btn-ok {
  background: #1f7a3a;
  border-color: #1f7a3a;
  color: #fff;
}

.clan-btn-ok:hover {
  background: #279247;
  border-color: #279247;
  color: #fff;
}

.clan-field {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}

.clan-field input[type="text"] {
  flex: 1;
  min-width: 180px;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

@media (max-width: 720px) {
  .clan-page {
    overflow-x: clip;
  }

  .clan-page .site-header {
    position: relative;
    height: auto;
  }

  .clan-page .header-inner {
    height: auto;
    padding: 0.45rem 0.7rem;
    gap: 0.35rem 0.5rem;
    flex-wrap: wrap;
  }

  .clan-page .brand img {
    width: 32px;
    height: 32px;
  }

  .clan-page .nav {
    display: flex !important;
    position: static;
    flex-direction: row;
    order: 3;
    flex: 1 0 100%;
    min-width: 0;
    overflow-x: auto;
    background: transparent;
    border: 0;
    padding: 0;
  }

  .clan-nav a {
    flex: none;
    padding: 0.3rem 0.45rem;
    font-size: 0.72rem;
  }

  .clan-user {
    margin-left: auto;
    max-width: 100%;
    min-width: 0;
    font-size: 0.78rem;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .subnav {
    position: static;
    top: auto;
    height: auto;
    min-height: var(--subnav-h);
  }

  .subnav-scroll a {
    min-height: var(--subnav-h);
  }

  .clan-page.has-subnav .clan-main,
  .clan-main {
    padding: 1rem 0.85rem 2.5rem;
  }

  .clan-card {
    padding: 1rem 0.9rem 1.1rem;
  }

  .clan-copy {
    flex-wrap: wrap;
  }

  .clan-copy .btn {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
  }

  .clan-id-line .btn {
    white-space: normal;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .clan-main,
  .clan-table-wrap,
  .clan-card {
    max-width: 100%;
    min-width: 0;
  }

  .clan-table-wrap {
    overflow-x: clip;
  }

  .clan-table th,
  .clan-table td {
    padding: 0.5rem 0.35rem;
  }

  .clan-table th {
    white-space: normal;
  }

  .clan-table th:nth-child(1),
  .clan-table td:nth-child(1) {
    width: 26%;
  }

  .clan-table th:nth-child(2),
  .clan-table td:nth-child(2) {
    width: 12%;
  }

  .clan-table th:nth-child(3),
  .clan-table td:nth-child(3) {
    width: 18%;
  }

  .clan-table th:nth-child(4),
  .clan-table td:nth-child(4) {
    width: 44%;
  }

  .clan-table-btns {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    gap: 0.3rem;
  }

  .clan-table-btns .btn {
    flex: 0 1 auto;
    height: auto;
    min-height: 2rem;
    max-width: 100%;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    padding: 0.35rem 0.4rem;
  }

  .clan-page-actions .btn {
    min-width: 0;
    max-width: 100%;
  }
}
