:root {
	--bg: #f6f7f9;
	--panel: #ffffff;
	--text: #1d2430;
	--muted: #667085;
	--line: #d9dee8;
	--blue: #1f5eff;
	--blue-dark: #1746bf;
	--green: #0f7b46;
	--red: #b42318;
	--amber: #b54708;
	--shadow: 0 18px 60px rgba(29, 36, 48, .16);
}

* {
	box-sizing: border-box;
}

html {
	font-size: 16px;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	line-height: 1.5;
}

a {
	color: var(--blue);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

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

img {
	display: block;
}

.eyebrow {
	margin: 0 0 .25rem;
	color: var(--muted);
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
}

.login-page {
	min-height: 100vh;
	display: grid;
	place-items: center;
	padding: 1.5rem;
}

.login-card {
	width: min(920px, 100%);
	display: grid;
	grid-template-columns: 1.15fr .85fr;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel);
	box-shadow: var(--shadow);
	overflow: hidden;
}

.login-copy {
	padding: clamp(2rem, 6vw, 4rem);
	background: #102033;
	color: #fff;
}

.login-copy h1,
.app-header h1 {
	margin: 0;
	font-size: clamp(1.5rem, 2.5vw, 2.0rem);
	line-height: 1.05;
	letter-spacing: 0;
}

.login-copy p:not(.eyebrow) {
	max-width: 32rem;
	margin: 1rem 0 0;
	color: #d9e2f1;
}

.login-form {
	display: grid;
	align-content: center;
	gap: .75rem;
	padding: clamp(1.5rem, 5vw, 3rem);
}

.loginput,
.field,
.newmail,
.newmailupdate,
.pwfield,
.deliverfield,
.deliverarea,
.template-text,
select {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: #fff;
	color: var(--text);
	padding: .65rem .75rem;
	outline: none;
}

.loginput:focus,
.field:focus,
.newmail:focus,
.newmailupdate:focus,
.pwfield:focus,
.deliverfield:focus,
.deliverarea:focus,
.template-text:focus,
select:focus {
	border-color: var(--blue);
	box-shadow: 0 0 0 3px rgba(31, 94, 255, .14);
}

.newmail,
.newmailupdate {
	text-align: right;
}

.newmailupdate,
input[readonly] {
	background: #eef1f5;
	color: var(--muted);
}

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.5rem;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: #fff;
	color: var(--text);
	padding: .55rem .9rem;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
	white-space: nowrap;
}

.button:hover {
	border-color: #b8c0cc;
	text-decoration: none;
}

.button.primary {
	border-color: var(--blue);
	background: var(--blue);
	color: #fff;
}

.button.primary:hover {
	background: var(--blue-dark);
}

.button.ghost {
	background: transparent;
}

.danger-button {
	color: var(--red);
}

.webmail-link {
	margin-top: .5rem;
	font-size: .92rem;
}

.login-help {
	margin: .25rem 0 0;
	color: var(--muted);
	font-size: .9rem;
}

.app-header {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem clamp(1rem, 4vw, 2rem);
	border-bottom: 1px solid var(--line);
	background: rgba(255, 255, 255, .96);
	backdrop-filter: blur(12px);
}

.app-header h1 {
	font-size: clamp(1.25rem, 3vw, 2rem);
	overflow-wrap: anywhere;
}

.header-actions,
.row-actions,
.form-actions {
	display: flex;
	align-items: center;
	gap: .5rem;
	flex-wrap: wrap;
}

.shell {
	width: min(1280px, 100%);
	margin: 0 auto;
	padding: 1.25rem clamp(1rem, 4vw, 2rem) 3rem;
}

.toolbar {
	display: flex;
	align-items: end;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
}

.filter-form {
	display: flex;
	align-items: center;
	gap: .75rem;
}

.filter-form label,
.field-group label,
.inline-create label {
	font-weight: 700;
}

.notice,
.alert {
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #fff;
	padding: .85rem 1rem;
	margin-bottom: 1rem;
}

.alert.success {
	border-color: rgba(15, 123, 70, .24);
	background: #ecfdf3;
	color: var(--green);
}

.alert.danger {
	border-color: rgba(180, 35, 24, .24);
	background: #fff1f0;
	color: var(--red);
}

.table-panel {
	overflow: auto;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel);
}

.mail-table {
	width: 100%;
	border-collapse: collapse;
	min-width: 920px;
}

.mail-table th,
.mail-table td {
	padding: .85rem .9rem;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}

.mail-table th {
	position: sticky;
	top: 0;
	background: #f0f3f8;
	color: #344054;
	font-size: .78rem;
	letter-spacing: .04em;
	text-transform: uppercase;
}

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

.mono {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.nowrap {
	white-space: nowrap;
}

.status {
	display: inline-flex;
	align-items: center;
	font-weight: 700;
}

.status.ok {
	color: var(--green);
}

.muted {
	color: #2E497E;
	background-color: #dddddd;
}

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

.icon-button {
	width: 2rem;
	height: 2rem;
	display: inline-grid;
	place-items: center;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
}

.icon-button img {
	width: 16px;
	height: 16px;
}

.row-actions form {
	display: inline-flex;
	margin: 0;
}

.empty-state {
	color: var(--muted);
	text-align: center;
	padding: 1.25rem;
}

.modal {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: rgba(13, 18, 28, .55);
}

.modal.open {
	display: flex;
}

.modal-box {
	width: min(860px, 100%);
	max-height: min(760px, calc(100vh - 2rem));
	display: flex;
	flex-direction: column;
	border-radius: 8px;
	background: var(--panel);
	box-shadow: var(--shadow);
	overflow: hidden;
}

.modal-box.large {
	width: min(960px, 100%);
}

.modal-box.help-modal {
	width: min(1180px, calc(100vw - 2rem));
}

.modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--line);
}

.modal-head h2 {
	margin: 0;
	font-size: 1.1rem;
}

.close {
	width: 2rem;
	height: 2rem;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
	font-size: 1.35rem;
	line-height: 1;
}

.tabs {
	display: flex;
	flex-direction: column;
	min-height: 520px;
}

.tab-list {
	display: flex;
	gap: .35rem;
	padding: .75rem .75rem 0;
	border-bottom: 1px solid var(--line);
	background: #f8fafc;
}

.tab {
	border: 1px solid transparent;
	border-bottom: 0;
	border-radius: 6px 6px 0 0;
	background: transparent;
	padding: .65rem .85rem;
	cursor: pointer;
	font-weight: 700;
}

.tab.active {
	border-color: var(--line);
	background: #fff;
	color: var(--blue);
}

.tab-panel {
	display: none;
	flex: 1;
}

.tab-panel.active {
	display: block;
}

iframe {
	width: 100%;
	height: 560px;
	border: 0;
	background: #fff;
}

.modal-content {
	overflow: auto;
	padding: 1.25rem;
}

.subview {
	background: #fff;
	padding: 1rem;
	font-size: .95rem;
}

.form-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1rem;
}

.field-group {
	display: grid;
	gap: .35rem;
}

.field-group.full {
	grid-column: 1 / -1;
}

.address-line {
	display: flex;
	align-items: center;
	gap: .5rem;
	max-width: 100%;
}

.address-line input {
	min-width: 0;
	flex: 1 1 12rem;
}

.address-line span {
	flex: 0 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
	color: var(--muted);
}

.deliverarea {
	min-height: 7rem;
	resize: vertical;
}

.template-text {
	min-height: 18rem;
	resize: vertical;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.hint {
	margin: .25rem 0 0;
	color: var(--muted);
	font-size: .88rem;
}

.hint.warning {
	color: var(--amber);
}

.checkline {
	display: flex;
	align-items: center;
	gap: .5rem;
	margin-top: .5rem;
}

.checkline input {
	width: auto;
}

.form-actions {
	grid-column: 1 / -1;
	justify-content: flex-end;
	padding-top: .5rem;
}

.topspace {
	margin-top: 1rem;
}

.subhead {
	margin: 1rem 0 .5rem;
}

.inline-create {
	display: grid;
	grid-template-columns: auto minmax(12rem, 1fr) auto;
	align-items: end;
	gap: .75rem;
}

.template-list {
	border: 1px solid var(--line);
	border-radius: 8px;
	overflow: hidden;
}

.template-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: .75rem;
	border-bottom: 1px solid var(--line);
}

.template-row:last-child {
	border-bottom: 0;
}

.log-output {
	margin: 0;
	padding: 1rem;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #101828;
	color: #eef4ff;
	overflow: auto;
	white-space: pre-wrap;
}

.help-page {
	display: grid;
	gap: 1.25rem;
}

.help-section {
	display: grid;
	gap: .75rem;
}

.help-section h3,
.help-card h4 {
	margin: 0;
	letter-spacing: 0;
}

.help-section p {
	margin: 0;
	color: #344054;
	text-align: left;
}

.help-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(260px, 1fr));
	gap: .75rem;
}

.help-card {
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #fff;
	padding: 1rem;
}

.settings-list {
	display: grid;
	gap: .55rem;
	margin: .75rem 0;
}

.settings-list div {
	display: grid;
	grid-template-columns: minmax(8.75rem, max-content) minmax(0, 1fr);
	column-gap: 1rem;
	row-gap: .2rem;
}

.settings-list dt {
	color: var(--muted);
	font-weight: 700;
}

.settings-list dd {
	margin: 0;
	overflow-wrap: anywhere;
}

code {
	border-radius: 4px;
	background: #eef1f5;
	padding: .1rem .3rem;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: .92em;
}

.help-table {
	width: 100%;
	border-collapse: collapse;
	border: 1px solid var(--line);
	border-radius: 8px;
	overflow: hidden;
}

.help-table th,
.help-table td {
	padding: .7rem .8rem;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}

.help-table th {
	background: #f0f3f8;
	color: #344054;
	font-size: .78rem;
	letter-spacing: .04em;
	text-transform: uppercase;
}

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

.help-list {
	margin: 0;
	padding-left: 1.2rem;
	color: #344054;
}

.help-list li + li {
	margin-top: .35rem;
}

.clear,
.dclear {
	clear: both;
}

.klein {
	font-size: .88rem;
}

.gross {
	font-size: 1rem;
}

.hide,
.hidden {
	display: none;
}

@media (max-width: 860px) {
	.login-card {
		grid-template-columns: 1fr;
	}

	.app-header,
	.toolbar {
		align-items: stretch;
		flex-direction: column;
	}

	.header-actions {
		overflow-x: auto;
		flex-wrap: nowrap;
		padding-bottom: .25rem;
	}

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

	.inline-create {
		grid-template-columns: 1fr;
	}

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

	.help-table {
		display: block;
		overflow-x: auto;
	}

	.modal {
		padding: .5rem;
	}

	.modal-box {
		max-height: calc(100vh - 1rem);
	}
}

@media (min-width: 861px) and (max-width: 1040px) {
	.help-grid {
		grid-template-columns: repeat(2, minmax(260px, 1fr));
	}
}
