.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: rgba(20, 22, 28, .92);
	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-mark {
	width: 44px;
	height: 44px;
	flex: none;
	display: grid;
	place-items: center;
	overflow: hidden;
	background: var(--clan-color, #555);
	border: 1px solid rgba(255,255,255,.22);
	border-radius: 10px;
	color: rgba(255,255,255,.9);
	font-weight: 800;
}

.clan-mark img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.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;
}

.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 {
	opacity: .5;
	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: transparent;
	border: 0;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	font-weight: 600;
}

.tab:hover {
	color: #e6e6e6;
}

.tab.active {
	color: #fff;
	border-bottom-color: #2f6bff;
}

.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;
}

.stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 10px;
	margin-top: 18px;
}

.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: rgba(122, 255, 158, .22);
}

.finance-group.expense .finance-heading,
.finance-group.expense .finance-row strong {
	color: #ff9292;
}

.finance-group.expense .finance-row {
	border-top-color: rgba(255, 146, 146, .22);
}

.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; }

.clan-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 18px;
}

.modal {
	width: min(440px, calc(100vw - 32px));
	padding: 20px;
	color: #e6e6e6;
	background: rgba(20, 22, 28, .98);
	border: 1px solid #2a2e38;
	border-radius: 12px;
}

.modal::backdrop {
	background: rgba(6, 7, 10, .6);
}

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

.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;
}

.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: baseline;
	gap: 8px;
	margin-bottom: 2px;
}

.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, .member, .application {
		align-items: stretch;
		flex-direction: column;
	}

	.form-grid, .stats, .finance-panel {
		grid-template-columns: 1fr;
	}

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