:root {
	--bg: #f5f6f8;
	--panel: #fff;
	--text: #20252d;
	--muted: #707782;
	--line: #d8dce2;
	--line-dark: #c4c9d1;
	--primary: #2762df;
	--primary-hover: #1f51bd;
	--danger: #b42318;
	--success: #16764a;
	--warning: #9a5b00;
	--radius: 8px;
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	-webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
	font: inherit;
}

.wrap {
	width: min(1180px, calc(100% - 32px));
	margin: 26px auto 48px;
}

.header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 16px;
}

.header h1 {
	margin: 0;
	font-size: 24px;
	font-weight: 650;
}

.header p {
	margin: 4px 0 0;
	color: var(--muted);
	font-size: 13px;
}

.badge {
	padding: 6px 10px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: #fff;
	color: var(--muted);
	font-size: 12px;
	white-space: nowrap;
}

.badge.dirty {
	border-color: #e7d2a7;
	background: #fff9eb;
	color: var(--warning);
}

.panel {
	margin-bottom: 14px;
	padding: 18px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--panel);
}

.selectors {
	display: grid;
	grid-template-columns: minmax(240px, 1fr) minmax(220px, 320px);
	gap: 14px;
}

.account-select-row,
.account-add-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.account-select-row select,
.account-add-row input {
	min-width: 0;
	flex: 1 1 auto;
}

.account-delete,
.account-add {
	flex: 0 0 auto;
	margin-top: 0;
}

.account-manager {
	padding-top: 14px;
	padding-bottom: 14px;
}

.account-note {
	margin: 7px 0 0;
	color: var(--muted);
	font-size: 12px;
	line-height: 1.5;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 7px;
}

label {
	font-size: 13px;
	font-weight: 650;
}

select {
	width: 100%;
	min-height: 46px;
	padding: 0 12px;
	border: 1px solid var(--line-dark);
	border-radius: 6px;
	background: #fff;
	color: var(--text);
	outline: none;
}

input {
	width: 100%;
	min-height: 42px;
	padding: 0 12px;
	border: 1px solid var(--line-dark);
	border-radius: 6px;
	background: #fff;
	color: var(--text);
	outline: none;
}

input:focus,
select:focus,
textarea:focus {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(39, 98, 223, 0.11);
}

.title {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
	margin-bottom: 13px;
}

.title h2 {
	margin: 0;
	font-size: 16px;
	font-weight: 650;
}

.title p {
	margin: 5px 0 0;
	color: var(--muted);
	font-size: 12px;
	line-height: 1.5;
}

.grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}

.editor-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 7px;
}

.hint,
.status,
.count {
	color: var(--muted);
	font-size: 12px;
}

.status.valid {
	color: var(--success);
}

.status.invalid {
	color: var(--danger);
}

.status.checking {
	color: var(--warning);
}

textarea {
	width: 100%;
	padding: 11px 12px;
	border: 1px solid var(--line-dark);
	border-radius: 6px;
	background: #fff;
	color: var(--text);
	line-height: 1.55;
	resize: vertical;
	outline: none;
}

#plain,
#regex {
	min-height: 150px;
}

.code {
	font-family: var(--mono);
	font-size: 13px;
	tab-size: 4;
}

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin-top: 10px;
	padding: 0 15px;
	border: 1px solid transparent;
	border-radius: 6px;
	cursor: pointer;
	font-weight: 600;
}

.button:disabled {
	cursor: not-allowed;
	opacity: .45;
}

.primary,
.save-button {
	background: var(--primary);
	color: #fff;
}

.primary:not(:disabled):hover,
.save-button:not(:disabled):hover {
	background: var(--primary-hover);
}

.secondary {
	border-color: var(--line-dark);
	background: #fff;
	color: var(--text);
}

.danger {
	border-color: #efc8c3;
	background: #fff5f4;
	color: var(--danger);
}

.existing {
	min-height: 500px;
	height: 52vh;
	max-height: 760px;
	white-space: pre;
	overflow: auto;
}

.count {
	padding: 4px 8px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: #fafbfc;
	white-space: nowrap;
}





.validation {
	margin-top: 10px;
}

.save {
	position: sticky;
	bottom: 8px;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 14px 16px;
	border: 1px solid var(--line-dark);
	border-radius: var(--radius);
	background: rgba(255, 255, 255, .96);
	backdrop-filter: blur(8px);
}

.save-name {
	font-size: 13px;
	font-weight: 650;
}

.save-message {
	margin-top: 3px;
	color: var(--muted);
	font-size: 12px;
}

.save-button {
	min-width: 220px;
	margin: 0;
}

.toast {
	position: fixed;
	right: 18px;
	bottom: 18px;
	z-index: 30;
	max-width: min(420px, calc(100% - 36px));
	padding: 12px 14px;
	border-radius: 7px;
	background: #20242c;
	color: #fff;
	font-size: 13px;
	opacity: 0;
	pointer-events: none;
	transform: translateY(8px);
	transition: .15s ease;
}

.toast.show {
	opacity: 1;
	transform: translateY(0);
}

.toast.error {
	background: #8f1d14;
}

@media (max-width: 760px) {
	.wrap {
		width: calc(100% - 20px);
		margin-top: 14px;
	}

	.header h1 {
		font-size: 21px;
	}

	.panel {
		padding: 14px;
	}

	.selectors,
	.grid {
		grid-template-columns: 1fr;
	}

	.account-add-row {
		align-items: stretch;
	}

	.account-add {
		min-width: 72px;
	}

	#plain,
	#regex {
		min-height: 135px;
	}

	.existing {
		min-height: 50vh;
		height: 54vh;
		max-height: none;
		font-size: 12px;
	}

	.save {
		flex-direction: column;
		align-items: stretch;
	}

	.save-button {
		width: 100%;
		min-width: 0;
	}

	.toast {
		right: 10px;
		bottom: 10px;
		max-width: calc(100% - 20px);
	}
}

.existing-tools {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	flex-wrap: wrap;
}

.button.compact {
	min-height: 34px;
	height: 34px;
	margin-top: 0;
	padding: 0 11px;
	font-size: 12px;
}

@media (max-width: 760px) {
	.existing-title {
		align-items: flex-start;
	}

	.existing-tools {
		flex: 0 0 auto;
	}

	.button.compact {
		min-height: 40px;
		height: 40px;
	}
}



.duplicate-info {
	margin-top: 8px;
	padding: 9px 10px;
	border: 1px solid var(--line);
	border-radius: 6px;
	font-size: 12px;
	line-height: 1.5;
}

.duplicate-info.clear {
	background: #f7faf8;
	border-color: #cfe3d8;
	color: var(--success);
}

.duplicate-info.warning {
	background: #fff9eb;
	border-color: #ead3a5;
	color: #7a4a00;
}

.duplicate-title {
	font-weight: 650;
}

.duplicate-list {
	margin-top: 5px;
}

.duplicate-row {
	display: grid;
	grid-template-columns: 52px minmax(0, 1fr);
	gap: 8px;
	align-items: start;
	margin-top: 3px;
}

.duplicate-line {
	color: var(--muted);
}

.duplicate-row code {
	overflow-wrap: anywhere;
	font-family: var(--mono);
	color: inherit;
}


.regex-guide {
	margin: 24px 0 16px;
	border: 1px solid var(--line-dark);
	background: #fafbfc;
}

.regex-guide-title {
	padding: 10px 12px;
	border-bottom: 1px solid var(--line);
	font-size: 13px;
	font-weight: 650;
}

.regex-guide-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.regex-guide-table {
	width: 100%;
	min-width: 720px;
	border-collapse: collapse;
	font-size: 12px;
	line-height: 1.5;
}

.regex-guide-table th,
.regex-guide-table td {
	padding: 8px 10px;
	border-right: 1px solid var(--line);
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}

.regex-guide-table th:last-child,
.regex-guide-table td:last-child {
	border-right: 0;
}

.regex-guide-table tbody tr:last-child td {
	border-bottom: 0;
}

.regex-guide-table th {
	background: #f3f5f7;
	font-weight: 650;
	white-space: nowrap;
}

.regex-guide-table td:first-child {
	width: 110px;
	white-space: nowrap;
}

.regex-guide-table code {
	font-family: var(--mono);
	font-size: 12px;
}


.convert-buttons {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.convert-buttons[hidden] {
	display: none;
}

.convert-buttons .button {
	margin-top: 10px;
}

@media (max-width: 760px) {
	.convert-buttons {
		display: grid;
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 8px;
	}

	.convert-buttons[hidden] {
		display: none;
	}

	.convert-buttons .button {
		width: 100%;
		padding: 0 8px;
	}

	#sbjConvertButtons {
		grid-template-columns: 1fr;
	}
}


.convert-choice {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	min-width: 0;
}

.convert-choice .button {
	width: 100%;
}

.convert-example {
	margin-top: 4px;
	color: var(--muted);
	font-size: 11px;
	line-height: 1.35;
	text-align: center;
	white-space: nowrap;
}

@media (max-width: 760px) {
	.convert-example {
		font-size: 10px;
		white-space: normal;
	}
}


/* Login */
.login-page {
	min-height: 100vh;
	display: grid;
	place-items: center;
	padding: 20px;
}

.login-shell {
	width: min(420px, 100%);
}

.login-card {
	padding: 26px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--panel);
	box-shadow: 0 12px 34px rgba(32, 37, 45, .08);
}

.login-card h1 {
	margin: 0;
	font-size: 24px;
}

.login-card > p {
	margin: 5px 0 22px;
	color: var(--muted);
	font-size: 13px;
}

.login-card .field + .field {
	margin-top: 14px;
}

.login-card input {
	min-height: 46px;
}

.login-remember {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 14px;
	color: var(--text);
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
}

.login-remember input {
	width: 16px;
	height: 16px;
	min-height: 0;
	margin: 0;
	flex: 0 0 auto;
}

.login-button {
	width: 100%;
	margin-top: 20px;
}

.login-error {
	margin-bottom: 16px;
	padding: 10px 12px;
	border: 1px solid #efc8c3;
	border-radius: 6px;
	background: #fff5f4;
	color: var(--danger);
	font-size: 12px;
	line-height: 1.5;
}

.header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.logout-form {
	margin: 0;
}

.logout-button {
	margin: 0;
}

/* Statistics */
.stats-panel {
	margin-top: 24px;
}

.stats-title {
	align-items: center;
}

.stats-message {
	color: var(--muted);
	font-size: 12px;
}

.stats-cards {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 8px;
	margin-bottom: 18px;
}

.stats-card {
	padding: 11px 10px;
	border: 1px solid var(--line);
	border-radius: 7px;
	background: #fafbfc;
	text-align: center;
}

.stats-card span {
	display: block;
	color: var(--muted);
	font-size: 11px;
}

.stats-card strong {
	display: block;
	margin-top: 3px;
	font-size: 20px;
	font-weight: 700;
}

.stats-grid {
	display: grid;
	grid-template-columns: minmax(260px, .7fr) minmax(0, 1.3fr);
	gap: 14px;
}

.stats-block {
	min-width: 0;
}

.stats-block h3 {
	margin: 0 0 8px;
	font-size: 13px;
}

.stats-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--line);
	border-radius: 7px;
}

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

.stats-table th,
.stats-table td {
	padding: 8px 9px;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
	white-space: nowrap;
}

.stats-table th {
	background: #f3f5f7;
	font-weight: 650;
}

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

.stats-table td:nth-child(2):last-child,
.stats-table th:nth-child(2):last-child {
	text-align: right;
}

.recent-table td:nth-child(3) {
	max-width: 260px;
	overflow: hidden;
	text-overflow: ellipsis;
}

.stats-empty {
	color: var(--muted);
	text-align: center !important;
}

.stats-coverage {
	margin-top: 10px;
	color: var(--muted);
	font-size: 11px;
	line-height: 1.5;
}

@media (max-width: 900px) {
	.stats-cards {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.stats-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 520px) {
	.header-actions {
		flex-direction: column;
		align-items: flex-end;
	}

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

	.login-card {
		padding: 20px;
	}
}

.stats-recent-footer {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-top: 10px;
}

.stats-recent-count {
	color: var(--muted);
	font-size: 11px;
}

.stats-recent-footer .button {
	margin: 0;
}

@media (max-width: 760px) {
	.stats-recent-footer {
		flex-wrap: wrap;
	}
}
