* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--hy-theme-bg);
    color: var(--hy-theme-text);
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.center-header {
    position: sticky;
    z-index: 20;
    top: 0;
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    align-items: center;
    min-height: calc(64px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    border-bottom: 1px solid var(--hy-theme-line);
    background: color-mix(in srgb, var(--hy-theme-bg) 94%, transparent);
    backdrop-filter: blur(16px);
}

.center-header h1 {
    margin: 0;
    font-size: 22px;
    text-align: center;
}

.icon-button,
.language-button {
    display: grid;
    width: 44px;
    height: 40px;
    place-items: center;
    border: 0;
    border-radius: var(--hy-theme-radius-language);
    background: var(--hy-theme-surface);
    color: var(--hy-theme-text);
    box-shadow: var(--hy-theme-shadow);
}

.icon-button span {
    font-size: 38px;
    font-weight: 300;
    line-height: 30px;
}

.language-switcher {
    position: relative;
}

.language-button {
    font-size: 13px;
    font-weight: 800;
}

.language-menu {
    position: absolute;
    top: 46px;
    right: 0;
    overflow: hidden;
    width: 64px;
    border: 1px solid var(--hy-theme-line);
    border-radius: var(--hy-theme-radius-small);
    background: var(--hy-theme-surface);
    box-shadow: var(--hy-theme-modal-shadow);
}

[dir='rtl'] .language-menu {
    right: auto;
    left: 0;
}

.language-menu button {
    width: 100%;
    padding: 10px;
    border: 0;
    background: transparent;
    color: var(--hy-theme-text);
}

.language-menu button.is-active {
    background: var(--hy-theme-primary-soft);
    color: var(--hy-theme-primary-deep);
}

.agency-profile-card,
.contact-card,
.balance-card {
    display: flex;
    align-items: center;
    padding: 18px;
}

.agency-avatar {
    display: grid;
    flex: 0 0 76px;
    overflow: hidden;
    width: 76px;
    height: 76px;
    place-items: center;
    border: 3px solid var(--hy-theme-primary);
    border-radius: 50%;
    background: var(--hy-theme-primary-soft);
    color: var(--hy-theme-primary-deep);
    font-size: 30px;
    font-weight: 800;
}

.agency-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.agency-profile-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
    margin-inline-start: 16px;
}

.agency-profile-copy strong {
    overflow: hidden;
    font-size: 21px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agency-profile-copy span {
    color: var(--hy-theme-muted);
    font-size: 13px;
}

.contact-card {
    gap: 14px;
}

.contact-icon {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 50%;
    background: color-mix(
        in srgb,
        var(--hy-theme-success) 13%,
        var(--hy-theme-surface)
    );
    color: var(--hy-theme-success);
}

.contact-card > div {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 3px;
}

.contact-card > div span {
    overflow: hidden;
    color: var(--hy-theme-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-card > button {
    border: 0;
    background: transparent;
    color: var(--hy-theme-primary-deep);
    font-weight: 750;
}

.balance-card {
    justify-content: space-between;
    gap: 18px;
}

.balance-card > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 8px;
}

.card-label,
.section-title-row span {
    color: var(--hy-theme-muted);
    font-size: 13px;
}

.balance-value {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-wrap: anywhere;
    font-size: clamp(20px, 6vw, 30px);
}

.primary-action,
.danger-action {
    min-width: 94px;
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--hy-theme-radius-pill);
    color: #fff;
    font-weight: 750;
}

.primary-action {
    background: var(--hy-theme-button);
    box-shadow: var(--hy-theme-button-shadow);
}

.danger-action {
    background: var(--hy-theme-danger);
}

.primary-action.compact {
    display: inline-flex;
    min-width: 0;
    min-height: 38px;
    align-items: center;
    gap: 5px;
    padding: 0 14px;
    font-size: 13px;
}

.section-title-row,
.host-panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-title-row {
    margin-bottom: 12px;
}

.section-title-row h2 {
    margin: 0;
    font-size: 19px;
}

.data-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--hy-theme-line);
}

.data-tabs button {
    position: relative;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--hy-theme-muted);
    font-weight: 750;
}

.data-tabs button[aria-selected='true'] {
    color: var(--hy-theme-primary-deep);
}

.data-tabs button[aria-selected='true']::after {
    position: absolute;
    right: 18%;
    bottom: -1px;
    left: 18%;
    height: 3px;
    border-radius: var(--hy-theme-radius-pill);
    background: var(--hy-theme-primary-strong);
    content: '';
}

.guild-filter-bar {
    margin-bottom: 12px;
}

.guild-filter-bar button {
    padding: 5px 4px;
    font-size: 11px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
}

.summary-grid article {
    display: flex;
    min-height: 108px;
    align-items: center;
    justify-content: center;
    padding: 14px 8px;
    border-right: 1px solid var(--hy-theme-line);
    border-bottom: 1px solid var(--hy-theme-line);
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.summary-grid article:nth-child(3n) {
    border-inline-end: 0;
}

.summary-grid article:nth-last-child(-n + 2) {
    border-bottom: 0;
}

.summary-grid article strong {
    color: var(--hy-theme-primary-deep);
    font-size: clamp(18px, 5vw, 25px);
}

.summary-grid article span {
    color: var(--hy-theme-muted);
    font-size: 12px;
}

.host-panel-toolbar {
    margin-bottom: 10px;
    color: var(--hy-theme-muted);
    font-size: 13px;
}

.host-table-shell {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
}

.data-section,
#hostsPanel {
    min-width: 0;
    max-width: 100%;
}

.host-table {
    width: 100%;
    min-width: 1060px;
    border-collapse: collapse;
    font-size: 12px;
}

.host-table th,
.host-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--hy-theme-line);
    text-align: start;
    white-space: nowrap;
}

.host-table th {
    color: var(--hy-theme-muted);
    font-size: 11px;
    font-weight: 750;
}

.host-table tr:last-child td {
    border-bottom: 0;
}

.host-identity {
    display: flex;
    align-items: center;
    gap: 9px;
}

.host-avatar {
    display: grid;
    overflow: hidden;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 50%;
    background: var(--hy-theme-primary-soft);
    color: var(--hy-theme-primary-deep);
    font-weight: 800;
}

.host-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.host-copy {
    display: flex;
    max-width: 150px;
    flex-direction: column;
    gap: 2px;
}

.host-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
}

.host-copy span {
    color: var(--hy-theme-muted);
    font-size: 11px;
}

.remove-button {
    border: 0;
    background: transparent;
    color: var(--hy-theme-danger);
    font-weight: 750;
}

.empty-state,
.stats-status {
    padding: 24px;
    color: var(--hy-theme-muted);
    text-align: center;
}

.stats-status {
    margin-bottom: 12px;
    border: 1px solid var(--hy-theme-line);
    border-radius: var(--hy-theme-radius-control);
    background: var(--hy-theme-primary-soft);
}

.edit-dialog {
    width: min(calc(100% - 32px), 420px);
    padding: 0;
    border: 0;
    border-radius: var(--hy-theme-radius-modal);
    background: var(--hy-theme-surface);
    color: var(--hy-theme-text);
    box-shadow: var(--hy-theme-modal-shadow);
}

.edit-dialog::backdrop {
    background: rgba(31, 23, 45, 0.42);
}

.edit-dialog form {
    display: grid;
    gap: 16px;
    padding: 24px;
}

.edit-dialog h2,
.edit-dialog p {
    margin: 0;
}

.edit-dialog p {
    color: var(--hy-theme-muted);
    font-size: 13px;
    line-height: 1.55;
}

.edit-dialog label {
    display: grid;
    gap: 8px;
    color: var(--hy-theme-muted);
    font-size: 13px;
}

.edit-dialog input {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--hy-theme-line);
    border-radius: var(--hy-theme-radius-control);
    outline: none;
    background: var(--hy-theme-surface-soft);
    color: var(--hy-theme-text);
}

.edit-dialog input:focus {
    border-color: var(--hy-theme-primary-strong);
    box-shadow: 0 0 0 4px var(--hy-theme-focus-ring);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.dialog-actions > button:not(.primary-action, .danger-action) {
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--hy-theme-line);
    border-radius: var(--hy-theme-radius-pill);
    background: var(--hy-theme-surface);
    color: var(--hy-theme-text);
}

.is-loading .data-section,
.is-mutating button {
    pointer-events: none;
    opacity: 0.65;
}

@media (max-width: 520px) {
    .guild-center__content {
        padding-inline: 12px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-grid article:nth-child(3n) {
        border-inline-end: 1px solid var(--hy-theme-line);
    }

    .summary-grid article:nth-child(2n) {
        border-inline-end: 0;
    }

    .summary-grid article:nth-last-child(-n + 2) {
        border-bottom: 1px solid var(--hy-theme-line);
    }

    .summary-grid article:last-child {
        border-bottom: 0;
    }
}

@media (max-width: 380px) {
    .agency-avatar {
        flex-basis: 64px;
        width: 64px;
        height: 64px;
    }

    .balance-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .balance-card .primary-action {
        width: 100%;
    }
}
