.page {
	max-width: 920px;
	margin: 0 auto;
	padding: 28px 20px 60px;
}

.page h1 {
	margin: 0 0 4px;
	font-size: 24px;
}

.sub {
	margin: 0 0 24px;
	color: #9299a6;
	font-size: 13px;
}

.card {
	margin-bottom: 18px;
	padding: 18px 20px;
	background: #14161c;
	border: 1px solid #2a2e38;
	border-radius: 10px;
}

.card h2 {
	margin: 0 0 14px;
	font-size: 16px;
}

.hidden {
	display: none !important;
}

/* The hidden attribute must win over element rules like `button { display: … }`,
   otherwise JS-toggled buttons (e.g. leader-only / member-only) stay visible. */
[hidden] {
	display: none !important;
}

.notice {
	padding: 14px 16px;
	color: #bac0ca;
	background: #181b22;
	border: 1px solid #303541;
	border-radius: 8px;
}

.notice.error, .msg.error {
	color: #ff9292;
}

.msg {
	min-height: 18px;
	margin-top: 10px;
	font-size: 12px;
}

.msg.ok {
	color: #7aff9e;
}

.clan-list, .member-list, .application-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.clan-row {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 4px;
	color: inherit;
	border-top: 1px solid #252933;
	text-decoration: none;
}

.clan-row:first-child {
	border-top: 0;
}

.clan-row:hover .clan-name {
	color: #8eafff;
}

.clan-name {
	font-weight: 700;
	transition: color .15s ease;
}

.clan-tag, .muted {
	color: #858c99;
	font-size: 12px;
}

.clan-meta {
	margin-left: auto;
	color: #9aa1ad;
	font-size: 12px;
	text-align: right;
}

.clan-open {
	flex: none;
	white-space: nowrap;
}

.toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 18px;
}

.toolbar h1, .toolbar .sub {
	margin-bottom: 0;
}

button, .button {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 38px;
	padding: 8px 14px;
	color: #fff;
	background: #2f6bff;
	border: 0;
	border-radius: 7px;
	font: 600 13px/1.3 system-ui, sans-serif;
	text-decoration: none;
	cursor: pointer;
}

button.secondary, .button.secondary {
	background: #232732;
	border: 1px solid #3a3f4b;
}

button.danger {
	color: #ffabab;
	background: #3a1a1a;
	border: 1px solid #5a2c2c;
}

button:disabled {
	color: #7d8491;
	background: #20232b;
	cursor: default;
}

form {
	display: grid;
	gap: 12px;
}

.form-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

label {
	display: flex;
	flex-direction: column;
	gap: 5px;
	color: #bac0ca;
	font-size: 12px;
}

input, textarea, select {
	box-sizing: border-box;
	width: 100%;
	padding: 9px 11px;
	color: #e6e6e6;
	background: #14161c;
	border: 1px solid #3a3f4b;
	border-radius: 7px;
	font: inherit;
}

textarea {
	min-height: 92px;
	resize: vertical;
}

input[type="color"] {
	height: 40px;
	padding: 3px;
}

.tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 2px;
	margin-bottom: 18px;
	border-bottom: 1px solid #2a2e38;
}

.tab {
	min-height: 0;
	padding: 10px 16px;
	color: #9aa1ad;
	background: #14161c;
	border: 0;
	border-bottom: 2px solid #14161c;
	border-radius: 0;
	font-weight: 600;
}

.tab:hover {
	color: #e6e6e6;
}

.tab.active {
	color: #fff;
	border-bottom-color: #2f6bff;
}

.tab .notification-badge {
	vertical-align: middle;
}

.subpanel-title {
	margin: 22px 0 0;
	font-size: 14px;
}

.manage-block + .manage-block {
	margin-top: 22px;
	padding-top: 22px;
	border-top: 1px solid #252933;
}

.clan-header {
	display: flex;
	align-items: center;
	gap: 16px;
}

.clan-hero__actions {
	margin-left: auto;
}

.clan-header .clan-mark {
	width: 72px;
	height: 72px;
	border-radius: 14px;
	font-size: 18px;
}

.clan-header h1 {
	margin: 0;
}

.clan-capital-line {
	display: flex;
	align-items: center;
	gap: 7px;
	margin: 3px 0 1px;
	color: #d8dce5;
	font-size: 13px;
}

.capital-symbol {
	box-sizing: border-box;
	position: relative;
	display: inline-block;
	width: 13px;
	height: 13px;
	flex: 0 0 13px;
	border: 1.5px solid currentColor;
	border-radius: 50%;
}

.capital-symbol::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 4px;
	height: 4px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: currentColor;
}

.capital-view-button {
	box-sizing: border-box;
	display: inline-grid;
	place-items: center;
	width: 24px;
	height: 24px;
	margin-left: 1px;
	padding: 3px;
	color: #aeb7c8;
	border: 0;
	border-radius: 5px;
	text-decoration: none;
}

.capital-view-button:hover { color: #fff; background: #252a34; }
.capital-view-button:focus-visible { outline: 2px solid #68a0ff; outline-offset: 1px; }
.capital-view-button[hidden] { display: none; }
.capital-view-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 10px;
	margin-top: 18px;
}

.stats.clan-summary-stats {
	grid-template-columns: repeat(5, minmax(120px, 1fr));
	overflow-x: auto;
}

.clan-description {
	margin: 18px 0 0;
	color: #c6cbd4;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.clan-description.empty {
	color: #858c99;
	font-style: italic;
}

.form-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.tax-preview {
	margin: 4px 0 2px;
	padding: 10px 12px;
	background: #171920;
	border-radius: 8px;
}

.tax-preview:empty { display: none; }

.stat {
	padding: 12px;
	background: #171920;
	border-radius: 8px;
}

.stat strong {
	display: block;
	font-size: 18px;
}

.finance-panel {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 22px;
	margin-top: 18px;
	padding: 16px 0;
	border-top: 1px solid #252933;
	border-bottom: 1px solid #252933;
}

.finance-heading, .finance-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 4px 12px;
	align-items: baseline;
}

.finance-heading {
	margin-bottom: 4px;
	color: #e6e6e6;
	font-weight: 700;
}

.finance-heading strong {
	font-size: 18px;
	white-space: nowrap;
}

.finance-row {
	padding: 9px 0;
	border-top: 1px solid #252933;
}

.finance-row strong {
	color: #e6e6e6;
	white-space: nowrap;
}

.finance-row small {
	grid-column: 1 / -1;
	color: #9299a6;
	font-size: 12px;
}

.finance-group.income .finance-heading,
.finance-group.income .finance-row strong {
	color: #7aff9e;
}

.finance-group.income .finance-row {
	border-top-color: #214330;
}
.info-tip-wrap { position: relative; display: inline-flex; margin-left: 4px; }
.info-tip { box-sizing: border-box; width: 16px; height: 16px; min-height: 16px; flex: 0 0 16px; display: inline-grid; place-items: center; padding: 0;
	color: #cfd6e6; background: #242832; border: 1px solid #4a5160; border-radius: 50%;
	font: 700 11px/1 system-ui, sans-serif; vertical-align: middle; cursor: help; }
.info-tip:focus-visible { outline: 2px solid #68a0ff; outline-offset: 2px; }
.info-tooltip { display: none; }
.floating-tooltip { position: fixed; top: var(--tip-top, 0); left: var(--tip-left, 0); z-index: 80;
	width: 236px; max-width: calc(100vw - 44px); padding: 9px 10px; color: #eef2ff;
	background: #10131a; border: 1px solid #3a4150; border-radius: 6px; font-size: 11px;
	line-height: 1.35; visibility: hidden; pointer-events: none; transform: translateY(-3px);
	transition: transform .12s ease; }
.floating-tooltip::before { content: ""; position: absolute; top: -5px; left: 6px; width: 8px;
	height: 8px; background: #10131a; border-left: 1px solid #3a4150; border-top: 1px solid #3a4150;
	transform: rotate(45deg); }
.floating-tooltip.is-open { visibility: visible; pointer-events: auto; transform: translateY(0); }

.finance-group.expense .finance-heading,
.finance-group.expense .finance-row strong {
	color: #ff9292;
}

.finance-group.expense .finance-row {
	border-top-color: #4a2b32;
}

.member, .application {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 0;
	border-top: 1px solid #252933;
}

.member:first-child, .application:first-child {
	border-top: 0;
}

.member-actions, .application-actions {
	margin-left: auto;
	display: flex;
	gap: 8px;
}

.role {
	padding: 2px 7px;
	color: #ffd080;
	background: #372a17;
	border: 1px solid #5b4524;
	border-radius: 5px;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
}

.application-body {
	min-width: 0;
	flex: 1;
}

.application-message {
	margin: 4px 0 0;
	color: #b3b9c4;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.status {
	font-size: 12px;
	font-weight: 700;
}

.status.pending { color: #ffcf70; }
.status.accepted { color: #7aff9e; }
.status.rejected, .status.cancelled { color: #9ba1ac; }

.diplomacy-list { display: grid; gap: 10px; margin-top: 14px; }
.language-checks { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 12px 0; }
.language-checks label { display: inline-flex; align-items: center; gap: 4px; }
.currency-toggle { display: inline-flex; gap: 4px; padding: 3px; margin-bottom: 12px; border: 1px solid #363c48; border-radius: 8px; background: #171a21; }
.currency-toggle label { cursor: pointer; }
.currency-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.currency-toggle span { display: block; padding: 6px 12px; border-radius: 6px; color: #aeb5c1; }
.currency-toggle input:checked + span { color: #fff; background: #303745; }
.diplomacy-card { display: flex; align-items: center; gap: 12px; padding: 12px;
	background: #171a21; border: 1px solid #30343d; border-radius: 8px; }
.diplomacy-card__body { flex: 1; min-width: 0; }
.diplomacy-card__body strong, .diplomacy-card__body small { display: block; }
.diplomacy-card__body small { margin-top: 4px; color: #aeb5c1; }
.diplomacy-card__actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }

.clan-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 18px;
}

.modal {
	width: min(440px, calc(100vw - 32px));
	padding: 20px;
	color: #e6e6e6;
	background: #14161c;
	border: 1px solid #2a2e38;
	border-radius: 12px;
}

.create-dialog {
	width: min(540px, calc(100vw - 28px));
	max-height: calc(100vh - 28px);
	padding: 0;
	overflow: auto;
	background: #141820;
	border-color: #343b4a;
	box-shadow: none;
}

.create-dialog[open] {
	position: fixed;
	inset: 50% auto auto 50%;
	margin: 0;
	transform: translate(-50%, -50%);
	z-index: 40;
}

.modal::backdrop {
	background: #06070a;
}

.modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.create-dialog .modal-head {
	margin: 0;
	padding: 18px 20px;
	background: #171c27;
	border-bottom: 1px solid #2a2e38;
}

.modal-head h2 {
	margin: 0;
	font-size: 16px;
}

.icon-button {
	min-height: 0;
	padding: 4px 9px;
	color: #b3b9c4;
	background: #232732;
	border: 1px solid #3a3f4b;
	font-size: 14px;
	line-height: 1;
}

.create-preview {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 18px 20px 0;
	padding: 14px;
	background: #191e28;
	border: 1px solid #2f3645;
	border-radius: 8px;
}

.create-preview .clan-mark {
	width: 56px;
	height: 56px;
	border-radius: 12px;
	font-size: 16px;
}

.create-preview strong {
	display: block;
	margin-bottom: 3px;
}

.create-preview p {
	margin: 0;
	color: #9299a6;
	font-size: 12px;
}

.create-dialog form {
	padding: 18px 20px 20px;
}

.create-dialog .form-grid label.wide {
	grid-column: 1 / -1;
}

.create-dialog .form-footer {
	margin-top: 2px;
}

.chat-log {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 360px;
	margin-bottom: 14px;
	padding: 4px 2px;
	overflow-y: auto;
}

.chat-empty {
	color: #858c99;
	font-style: italic;
}

.chat-msg {
	padding: 8px 11px;
	background: #171920;
	border-radius: 8px;
}

.chat-msg .chat-head {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 2px;
}

.diplomacy-card .clan-mark { width: 38px; height: 38px; border-radius: 9px; }

.chat-msg .chat-author {
	font-weight: 700;
	font-size: 12px;
	color: #c6cbd4;
}

.chat-msg .chat-time {
	font-size: 11px;
	color: #6f7682;
}

.chat-msg .chat-body {
	margin: 0;
	color: #d6dae2;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.chat-msg.system {
	background: #16201a;
	border: 1px solid #284a32;
}

.chat-msg.system .chat-body {
	color: #9fe9b6;
}

.chat-compose {
	display: flex;
	gap: 8px;
}

.chat-compose input {
	flex: 1;
}

@media (max-width: 640px) {
	.page {
		padding: 22px 14px 48px;
	}

	.toolbar {
		align-items: stretch;
		flex-direction: column;
	}

	.member, .application { flex-wrap: wrap; }
	.member-actions, .application-actions { flex-basis: 100%; }

	.form-grid, .stats, .finance-panel {
		grid-template-columns: 1fr;
	}

	.create-dialog .form-footer {
		align-items: stretch;
		flex-direction: column;
	}

	.clan-meta, .clan-open, .member-actions, .application-actions {
		margin-left: 0;
		text-align: left;
	}
}
