:root {
	--red: #ef4044;
	--red-dark: #c92f33;
	--red-soft: #fdecec;
	--blue: #2365b0;
	--blue-dark: #1b4f8a;
	--blue-soft: #eaf2fb;
	--prussian: #183650;
	--ink: #22384a;
	--muted: #5f6f7e;
	--line: #dfe5ea;
	--line-dark: #c9d3dd;
	--bg: #f7f7f7;
	--white: #ffffff;
	--ok: #1e6f8f;
	--ok-soft: #e8f2f7;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--prussian);
	font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 18px;
	line-height: 1.55;
}
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
h1, h2, h3, p, dl, dd { margin-top: 0; }
h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.03em; margin-bottom: 8px; }
h2 { font-size: 20px; line-height: 1.3; letter-spacing: -0.02em; margin-bottom: 8px; }
h3 { font-size: 18px; margin-bottom: 6px; }
:focus-visible { outline: 3px solid rgba(35, 101, 176, 0.35); outline-offset: 2px; }
.muted { color: var(--muted); }
.block { display: block; }
.sr-only {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	max-width: 1240px;
	margin: 0 auto;
	padding: 14px 20px;
	background: var(--white);
	border-bottom: 1px solid var(--line);
	position: sticky;
	top: 0;
	z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--prussian); text-decoration: none; }
.brand img { width: 104px; display: block; }
.brand span { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.topbar-user { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.user-name { font-weight: 700; }
.inline-form { display: inline; margin: 0; }
.link-button {
	padding: 0; border: 0; background: none; color: var(--blue);
	font-weight: 700; cursor: pointer; text-decoration: underline; font-size: 15px;
}
.link-button:hover { color: var(--blue-dark); }

.shell {
	display: grid;
	grid-template-columns: 230px minmax(0, 1fr);
	gap: 28px;
	max-width: 1240px;
	margin: 0 auto;
	padding: 26px 20px 50px;
}
.sidebar { min-width: 0; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
	display: flex; align-items: center; gap: 8px;
	min-height: 44px; padding: 8px 11px; border-radius: 8px;
	color: var(--prussian); text-decoration: none; font-weight: 650; font-size: 16px;
}
.nav-item:hover { background: var(--blue-soft); color: var(--blue); }
.nav-item.active { background: var(--blue-soft); color: var(--blue-dark); }
.nav-count {
	margin-left: auto; min-width: 24px; padding: 2px 8px; border-radius: 999px;
	background: #eef1f4; color: var(--muted); font-size: 12px; text-align: center;
}
.nav-new {
	margin-left: auto; padding: 2px 8px; border-radius: 999px;
	background: var(--red); color: #fff; font-size: 11px; font-weight: 800;
}
.nav-heading {
	margin: 18px 0 6px; padding: 0 11px; color: var(--muted);
	font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
}
.nav-new-folder { color: var(--blue); }

.main { min-width: 0; }
.page-head {
	display: flex; align-items: flex-start; justify-content: space-between;
	gap: 18px; margin-bottom: 18px;
}
.page-sub { margin: 0; color: var(--muted); font-size: 15px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-link { display: inline-block; margin-bottom: 12px; font-weight: 700; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.search-form { display: flex; gap: 8px; flex: 1 1 320px; max-width: 520px; }
.search-form input { flex: 1; min-width: 0; height: 44px; }
.filter-links { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-link {
	display: inline-flex; align-items: center; min-height: 36px; padding: 0 11px;
	border: 1px solid var(--line-dark); border-radius: 999px; background: #fff;
	color: var(--muted); font-size: 13px; font-weight: 700; text-decoration: none;
}
.filter-link:hover { border-color: var(--blue); color: var(--blue); }
.filter-link.active { background: var(--prussian); border-color: var(--prussian); color: #fff; }

.new-banner {
	display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
	margin-bottom: 16px; padding: 11px 13px; border: 1px solid #f4c7c9;
	border-radius: 9px; background: var(--red-soft); color: #8e2b2f; font-size: 15px;
}
.new-banner a { margin-left: auto; color: #8e2b2f; font-weight: 800; }
.new-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); flex: 0 0 auto; }

.day-group { margin-bottom: 18px; }
.day-heading {
	margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 800;
	letter-spacing: 0.1em; text-transform: uppercase;
}
.lead-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.lead-row {
	display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
	min-height: 78px; padding: 14px 16px; border-bottom: 1px solid #eef1f3;
	background: #fff; color: inherit; text-decoration: none;
}
.lead-row:last-child { border-bottom: 0; }
.lead-row:hover { background: #f7fafc; }
.lead-row.unread { background: #fbfdff; }
.lead-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lead-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-name { font-weight: 650; font-size: 18px; }
.lead-row.unread .lead-name { font-weight: 800; }
.lead-summary { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.lead-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.lead-time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; }
.badge {
	display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px;
	font-size: 10px; font-weight: 850; letter-spacing: 0.05em; text-transform: uppercase;
}
.badge-quote { background: var(--blue-soft); color: var(--blue-dark); }
.badge-contact { background: #eef1f4; color: #4b5b69; }
.more-row { display: flex; justify-content: center; margin-top: 18px; }
.empty-state {
	padding: 46px 22px; border: 1px dashed var(--line-dark); border-radius: 12px;
	background: #fff; text-align: center;
}
.empty-icon { font-size: 38px; color: var(--line-dark); margin-bottom: 6px; }
.empty-state h2 { margin-bottom: 4px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 15px; }

.flash {
	display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
	margin-bottom: 16px; padding: 12px 14px; border-radius: 9px;
	border: 1px solid var(--line-dark); background: #fff; color: var(--prussian);
	font-size: 15px; font-weight: 600;
}
.flash-success { background: var(--ok-soft); border-color: #c5dfe9; color: #185b74; }
.flash-danger { background: var(--red-soft); border-color: #f4c7c9; color: #8e2b2f; }
.flash-warning { background: #fff8e8; border-color: #ecd9a8; color: #7a5a12; }
.flash-info { background: var(--blue-soft); border-color: #c8dcf1; color: var(--blue-dark); }

.card {
	margin-bottom: 18px; padding: 20px; background: #fff;
	border: 1px solid var(--line); border-radius: 12px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.folder-tools { border-left: 4px solid var(--blue); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.detail-eyebrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.detail-meta { color: var(--muted); font-size: 14px; }
.detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0; }
.detail-grid dt { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 2px; }
.detail-grid dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.detail-grid a { text-decoration: none; }
.detail-grid a:hover { text-decoration: underline; }
.route { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-bottom: 16px; }
.route-stop span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.route-stop strong { font-size: 27px; letter-spacing: -0.04em; }
.route-line { color: var(--blue); font-size: 22px; }
.message-subject { font-size: 18px; font-weight: 750; margin-bottom: 8px; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 17px; color: var(--ink); }
.detail-foot { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.status-list { display: flex; flex-direction: column; gap: 8px; }
.status-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.status {
	display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
	font-size: 12px; font-weight: 750;
}
.status-sent { background: var(--ok-soft); color: #185b74; }
.status-failed { background: var(--red-soft); color: #8e2b2f; }
.status-pending { background: #fff4d9; color: #73540b; }
.status-skipped { background: #eef1f4; color: var(--muted); }

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: 8px;
	font-size: 15px; font-weight: 750; text-decoration: none; cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line-dark); color: var(--prussian); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { background: #eef1f4; color: var(--prussian); }
.btn-small { min-height: 36px; padding: 0 11px; font-size: 13px; }
.btn-block { width: 100%; }

.form-card { max-width: 720px; padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.field input, .field select, .field textarea {
	width: 100%; min-height: 46px; padding: 9px 12px;
	border: 1px solid var(--line-dark); border-radius: 8px; background: #fff;
	color: var(--prussian); font-size: 17px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); outline: 3px solid rgba(35,101,176,.16); }
.inline-field { display: inline-flex; flex-direction: row; align-items: center; gap: 10px; margin: 0; }
.inline-field input { min-height: 36px; padding: 5px 9px; font-size: 15px; }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; font-size: 16px; }
.checkbox-row input { width: 20px; height: 20px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--blue); }
.checkbox-row.compact { margin: 0; font-size: 14px; }
.checkbox-row.compact input { width: 18px; height: 18px; }
.master-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.row-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 10px; border-bottom: 1px solid #edf0f2; text-align: left; vertical-align: top; }
.data-table thead th { background: #f7f9fa; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table input[type="tel"], .data-table input[type="email"] {
	width: 100%; min-width: 160px; min-height: 38px; padding: 6px 9px;
	border: 1px solid var(--line-dark); border-radius: 7px; font-size: 15px;
}

.help-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.help-step { display: flex; align-items: flex-start; gap: 14px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.help-step h2 { margin: 0 0 3px; }
.help-step p { margin: 0; color: var(--muted); }
.step-num { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 800; }

.footer { max-width: 1240px; margin: 0 auto; padding: 20px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }
.footer p { margin: 0; }
.footer-small { margin-top: 2px !important; font-size: 12px; color: #8894a0; }

.login-body { min-height: 100vh; background: var(--bg); }
.login-wrap { width: min(460px, calc(100% - 32px)); margin: 0 auto; padding: 48px 0; }
.login-logo { width: 132px; display: block; margin: 0 auto 22px; }
.login-wrap h1 { text-align: center; margin-bottom: 6px; }
.login-help { text-align: center; color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.login-card { padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.password-wrap { display: flex; gap: 8px; }
.password-wrap input { flex: 1; }
.show-button { min-height: 46px; padding: 0 12px; border: 1px solid var(--line-dark); border-radius: 8px; background: #fff; color: var(--blue); font-size: 14px; font-weight: 700; cursor: pointer; }
.passphrase-box {
	display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
	margin: 18px 0; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.passphrase-box code { flex: 1 1 260px; font-size: 22px; font-weight: 700; color: var(--prussian); overflow-wrap: anywhere; }

.print-body { background: #fff; }
.print-page { max-width: 800px; margin: 0 auto; padding: 40px 24px; }
.print-head { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.print-head img { width: 120px; }
.print-head h1 { margin: 0 0 2px; }
.print-head p { margin: 0; color: var(--muted); }
.print-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }

@media (max-width: 860px) {
	.shell { grid-template-columns: 1fr; gap: 18px; }
	.sidebar { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
	.nav { flex-direction: row; flex-wrap: wrap; }
	.nav-item { flex: 1 1 auto; }
	.nav-count, .nav-new { margin-left: 0; }
	.nav-heading { margin-top: 8px; padding: 0 4px; }
	.page-head { flex-direction: column; }
	.detail-head { flex-direction: column; gap: 6px; }
	.detail-actions .btn { flex: 1 1 auto; }
	.toolbar { align-items: stretch; }
	.search-form { max-width: none; }
	.master-toggles { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
	body { font-size: 17px; }
	.topbar { padding: 10px 12px; gap: 8px; }
	.brand img { width: 86px; }
	.brand span { font-size: 18px; }
	.user-name { display: none; }
	.shell { padding: 18px 12px 36px; }
	h1 { font-size: 28px; }
	.detail-grid { grid-template-columns: 1fr; }
	.route { grid-template-columns: 1fr; }
	.route-line { display: none; }
	.login-wrap { padding: 24px 0; }
	.login-card { padding: 18px; }
}

@media print {
	body { background: #fff; font-size: 14px; }
	.topbar, .sidebar, .footer, .flash, .print-actions, .back-link { display: none !important; }
	.shell { display: block; padding: 0; }
	.main { width: 100%; }
	.print-page { max-width: none; padding: 0; }
	.print-head img { width: 100px; }
}
