/* ==========================================================================
   Diocesan Data Entry - application stylesheet
   One small file: replaces bootstrap / app.min / icon-font css.
   ========================================================================== */

:root {
	--bg: #f4f2ef;
	--surface: #ffffff;
	--surface-2: #faf9f7;
	--line: #e7e3dd;
	--line-strong: #d6d0c7;
	--ink: #1d1a17;
	--ink-2: #4a443d;
	--muted: #857c71;

	--primary: #8a1c3b;
	--primary-600: #731630;
	--primary-50: #fbf0f3;
	--primary-100: #f5dbe2;
	--ring: rgba(138, 28, 59, .18);
	--gold: #b9862b;
	--gold-50: #fbf4e6;

	--ok: #1f7a4d;   --ok-50: #e9f6ef;
	--warn: #a3640a; --warn-50: #fdf3e2;
	--danger: #b42318; --danger-50: #fdeceb;

	--side: #1f1a20;
	--side-2: #2b2430;
	--side-ink: #cfc6cf;

	--radius: 12px;
	--radius-sm: 8px;
	--shadow: 0 1px 2px rgba(29, 26, 23, .05), 0 1px 3px rgba(29, 26, 23, .04);
	--shadow-lg: 0 10px 30px -8px rgba(29, 26, 23, .18);
	--side-w: 248px;
	--top-h: 60px;
	--font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; background: var(--bg); color: var(--ink);
	font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
code, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hide, [hidden] { display: none !important; }

/* ---------- icons ---------- */
.ic { width: 18px; height: 18px; flex: none; vertical-align: -4px; }
.ic-sm { width: 15px; height: 15px; vertical-align: -3px; }
.ic-lg { width: 22px; height: 22px; }

/* ==========================================================================
   Layout: sidebar + topbar + content
   ========================================================================== */
.sidebar {
	position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40;
	background: var(--side); color: var(--side-ink);
	display: flex; flex-direction: column; transition: transform .2s ease;
}
.brand {
	height: var(--top-h); display: flex; align-items: center; gap: 10px;
	padding: 0 18px; color: #fff; font-weight: 650; font-size: 15px;
	border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand:hover { color: #fff; text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-label {
	font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
	color: #8a7f8b; padding: 14px 12px 6px;
}
.nav a {
	display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 2px 0;
	border-radius: 8px; color: var(--side-ink); font-weight: 500;
}
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-foot { padding: 14px 18px; font-size: 12px; color: #8a7f8b; border-top: 1px solid rgba(255,255,255,.06); }

.topbar {
	position: sticky; top: 0; z-index: 30; height: var(--top-h);
	margin-left: var(--side-w); display: flex; align-items: center; gap: 12px;
	padding: 0 28px; background: rgba(244, 242, 239, .86);
	backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
	border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs .ic { width: 14px; height: 14px; }
.crumbs strong { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.user-menu { position: relative; }
.user-btn {
	display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px;
	border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
	font: inherit; color: var(--ink); cursor: pointer;
}
.user-btn:hover { border-color: var(--line-strong); }
.avatar {
	width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
	background: var(--primary-50); color: var(--primary); font-weight: 700; font-size: 12px;
}
.dropdown {
	position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; padding: 6px;
	background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
	box-shadow: var(--shadow-lg); display: none;
}
.user-menu.open .dropdown { display: block; }
.dropdown a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink-2); }
.dropdown a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }

.main { margin-left: var(--side-w); min-height: calc(100vh - var(--top-h)); display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1360px; padding: 26px 28px 32px; flex: 1; }
.footer { padding: 16px 28px 22px; color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.backdrop { display: none; }

@media (max-width: 1024px) {
	.sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
	body.nav-open .sidebar { transform: none; }
	body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(20,16,20,.35); z-index: 35; }
	.topbar, .main { margin-left: 0; }
	.menu-btn { display: inline-flex; }
	.topbar { padding: 0 16px; }
	.content { padding: 20px 16px 28px; }
	.footer { padding: 14px 16px 20px; }
}

/* ==========================================================================
   Cards, stats, tables
   ========================================================================== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; }
.card-body { padding: 20px; }
.card + .card { margin-top: 18px; }

.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
@media (max-width: 900px) { .grid-3, .grid-2, .grid-7-5 { grid-template-columns: 1fr; } }

.stat { padding: 18px 20px; display: flex; align-items: center; gap: 16px; }
.stat .stat-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .stat-ic .ic { width: 22px; height: 22px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.tone-wine { background: var(--primary-50); color: var(--primary); }
.tone-gold { background: var(--gold-50); color: var(--gold); }
.tone-green { background: var(--ok-50); color: var(--ok); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
	text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
	color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfbf9; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }

.bar { height: 6px; border-radius: 3px; background: var(--primary-100); overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
	border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
	font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap;
	transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-soft { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary); }
.btn-soft:hover { background: var(--primary-100); color: var(--primary-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #962017; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(0,0,0,.04); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 8px; }
.kbd { font: 600 11px/1 var(--mono); padding: 3px 5px; border-radius: 4px; background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3); }
.btn:not(.btn-primary) .kbd { background: var(--surface-2); border-color: var(--line); color: var(--muted); }

.row-actions { display: inline-flex; gap: 4px; }
.row-actions a, .row-actions button {
	width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 7px;
	color: var(--ink-2); border: 1px solid transparent; background: none; cursor: pointer;
}
.row-actions a:hover, .row-actions button:hover { background: var(--surface-2); border-color: var(--line); text-decoration: none; }
.row-actions .del:hover { color: var(--danger); background: var(--danger-50); border-color: #f6cfcb; }

/* ==========================================================================
   Alerts / toasts
   ========================================================================== */
.alert {
	display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 18px;
	border-radius: 10px; border: 1px solid; font-weight: 500;
	animation: drop .25s ease-out;
}
.alert-ok { background: var(--ok-50); border-color: #bfe3cf; color: var(--ok); }
.alert-err { background: var(--danger-50); border-color: #f6cfcb; color: var(--danger); }
.alert .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; padding: 2px; }
.alert .close:hover { opacity: 1; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Forms
   ========================================================================== */
.fields { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 18px; }
.f { grid-column: span 4; min-width: 0; }
.f.s2 { grid-column: span 2; } .f.s3 { grid-column: span 3; } .f.s5 { grid-column: span 5; }
.f.s6 { grid-column: span 6; } .f.s8 { grid-column: span 8; } .f.s12 { grid-column: 1 / -1; }
@media (max-width: 1100px) { .f, .f.s2, .f.s3, .f.s5 { grid-column: span 6; } .f.s8 { grid-column: 1 / -1; } }
@media (max-width: 640px) { .f, .f.s2, .f.s3, .f.s5, .f.s6, .f.s8 { grid-column: 1 / -1; } .fields { gap: 14px; } }

label, .label {
	display: flex; align-items: baseline; gap: 6px; margin-bottom: 6px;
	font-size: 13px; font-weight: 600; color: var(--ink-2);
}
label .req { color: var(--primary); font-weight: 700; }
label .opt { color: var(--muted); font-weight: 400; font-size: 12px; }
.hint { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); }
.err-msg { display: none; margin-top: 5px; font-size: 12px; color: var(--danger); font-weight: 500; }

.input, input.input, select.input, textarea.input {
	width: 100%; height: 40px; padding: 0 12px;
	font: 14px/1.4 var(--font); color: var(--ink);
	background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
	transition: border-color .12s, box-shadow .12s, background .12s;
	appearance: none; -webkit-appearance: none;
}
select.input {
	padding-right: 34px; cursor: pointer; text-overflow: ellipsis;
	background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23857c71' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
}
select.input:invalid, select.input option[value=""] { color: #9a9087; }
select.input option { color: var(--ink); }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input::placeholder { color: #b3aaa0; }
.input:hover { border-color: #c4bcb1; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); background: #fff; }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
input[type="date"].input { padding-right: 8px; }
input[type="number"].input::-webkit-inner-spin-button, input[type="number"].input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"].input { -moz-appearance: textfield; }
.input.upper { text-transform: uppercase; }
.input.upper::placeholder { text-transform: none; }

.f.invalid .input { border-color: var(--danger); background: #fffafa; }
.f.invalid .input:focus { box-shadow: 0 0 0 3px rgba(180,35,24,.15); }
.f.invalid .err-msg { display: block; }
.f.invalid .hint { display: none; }

.input-group { display: flex; align-items: stretch; }
.input-group .addon {
	display: grid; place-items: center; padding: 0 12px; min-width: 40px;
	background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--muted); font-weight: 600;
}
.input-group .addon:first-child { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon:last-child { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group .input { border-radius: 0; flex: 1; min-width: 0; }
.input-group .input:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .input:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group .input:focus { position: relative; z-index: 1; }

.icon-input { position: relative; }
.icon-input .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.icon-input .input { padding-left: 38px; }

.check { display: inline-flex; margin-top: 7px !important; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; margin: 0; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.label-row label { margin-bottom: 6px; }

/* ==========================================================================
   Data entry form (sacristans/)
   ========================================================================== */
.entry { display: grid; grid-template-columns: minmax(0, 1fr) 232px; gap: 22px; align-items: start; }
@media (max-width: 1200px) { .entry { grid-template-columns: minmax(0, 1fr); } .rail { display: none; } }

.sec { scroll-margin-top: calc(var(--top-h) + 16px); }
.sec + .sec { margin-top: 18px; }
.sec-head { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.sec-num {
	width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
	background: var(--primary-50); color: var(--primary); font-weight: 700; font-size: 14px;
	transition: background .2s, color .2s;
}
.sec.done .sec-num { background: var(--primary); color: #fff; }
.sec-head h2 { font-size: 15.5px; }
.sec-head .muted { font-size: 12.5px; margin-left: auto; white-space: nowrap; }
.sec-body { padding: 20px; }
.sub-title { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sub-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.child-row { grid-column: 1 / -1; display: grid; grid-template-columns: 34px minmax(0, 2fr) minmax(0, 1fr) 40px; gap: 12px 14px; align-items: end; }
.child-row .child-del { height: 40px; width: 40px; color: var(--muted); }
.child-row .child-del:hover { color: var(--danger); background: var(--danger-50); }
.child-row .f { grid-column: auto; }
.child-row .idx { height: 40px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-weight: 700; }
@media (max-width: 640px) { .child-row { grid-template-columns: 28px minmax(0, 1fr) 40px; } .child-row .f + .f { grid-column: 2; grid-row: 2; } .child-row .child-del { grid-column: 3; grid-row: 1; } }

.salary { width: 100%; max-width: 560px; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.salary th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 9px 14px; border-bottom: 1px solid var(--line); }
.salary td { padding: 8px 14px; border-bottom: 1px solid var(--line); }
.salary td:first-child { font-weight: 600; color: var(--ink-2); width: 40%; }
.salary tr:last-child td { border-bottom: 0; background: var(--gold-50); }
.salary tr:last-child td:first-child { color: var(--ink); }
.salary .input { height: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.salary .input-group .addon { min-width: 34px; padding: 0 10px; }
.salary .addon.end { font-size: 12px; }

/* progress rail */
.rail { position: sticky; top: calc(var(--top-h) + 18px); }
.rail .card { padding: 14px; }
.rail-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 2px 6px 10px; }
.rail a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.rail a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.rail a.current { background: var(--primary-50); color: var(--primary); }
.rail .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 11px; font-weight: 700; border: 1.5px solid var(--line-strong); color: var(--muted); background: #fff; }
.rail a.done .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.rail .cnt { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rail-progress { margin: 12px 6px 4px; }
.rail-progress .bar { height: 5px; }
.rail-progress .small { display: flex; justify-content: space-between; margin-top: 6px; }
.shortcuts { margin-top: 12px; padding: 12px 14px; font-size: 12px; color: var(--muted); }
.shortcuts div { display: flex; justify-content: space-between; padding: 3px 0; }
.shortcuts kbd { font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }

/* sticky save bar */
.savebar {
	position: sticky; bottom: 0; z-index: 20; margin-top: 20px;
	display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
	padding: 12px 16px; background: rgba(255,255,255,.92);
	backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
	border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -6px 24px -10px rgba(29,26,23,.2);
}
.savebar .note { color: var(--muted); font-size: 12.5px; margin-right: auto; }
.savebar .note.dirty { color: var(--warn); }
@media (max-width: 640px) { .savebar .note { width: 100%; } .savebar .btn { flex: 1; } .kbd { display: none; } }

/* ==========================================================================
   Record view (sacristan-view/)
   ========================================================================== */
.profile-hero { display: flex; align-items: center; gap: 18px; padding: 22px; }
.profile-hero .avatar { width: 58px; height: 58px; font-size: 20px; border-radius: 16px; }
.profile-hero h1 { font-size: 22px; }
.profile-hero .meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 4px; }
.profile-hero .meta span { display: inline-flex; align-items: center; gap: 5px; }
.dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 22px; }
.dl > div { min-width: 0; }
.dl .k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.dl .v { font-weight: 550; overflow-wrap: anywhere; min-height: 21px; }
.dl .v:empty::before { content: "\2014"; color: #c9c1b6; font-weight: 400; }
.dl .wide { grid-column: 1 / -1; }
@media (max-width: 800px) { .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sign-row { display: none; }

/* ==========================================================================
   Auth / error pages
   ========================================================================== */
.auth {
	min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
	background:
		radial-gradient(900px 500px at 15% -10%, rgba(138,28,59,.12), transparent 60%),
		radial-gradient(700px 500px at 110% 110%, rgba(185,134,43,.14), transparent 60%),
		var(--bg);
}
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 34px 32px 30px; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin: 0 auto 18px; box-shadow: var(--shadow); }
.auth-card h1 { text-align: center; font-size: 21px; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 6px 0 24px; }
.auth-card .f + .f { margin-top: 16px; }
.auth-card .btn-lg { margin-top: 24px; }
.auth-card .alert { margin-bottom: 18px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); font-size: 12.5px; }
.err-code { text-align: center; font-size: 64px; font-weight: 800; letter-spacing: -.04em; color: var(--primary); line-height: 1; margin-bottom: 10px; }

/* ==========================================================================
   Dialog
   ========================================================================== */
dialog.modal { border: 0; padding: 0; border-radius: 16px; width: min(440px, calc(100% - 32px)); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog.modal::backdrop { background: rgba(20, 16, 20, .45); }
.modal-body { padding: 24px 24px 8px; }
.modal-body h3 { font-size: 17px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.modal-body h3 .ic { color: var(--danger); }
.modal-body p { color: var(--ink-2); }
.modal-pop:not(.is-danger) .modal-body h3 .ic { color: var(--primary); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px 20px; }

/* ==========================================================================
   DataTables (core only - no bootstrap integration)
   ========================================================================== */
.dt-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dt-toolbar .dataTables_filter { margin-right: auto; }
.dataTables_filter label { margin: 0; position: relative; display: block; }
.dataTables_filter input {
	width: 300px; max-width: 100%; height: 38px; padding: 0 12px 0 36px; font: 14px var(--font);
	border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23857c71' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 12px center;
}
.dataTables_filter input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.dataTables_length label { margin: 0; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dataTables_length select { height: 34px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 7px; font: inherit; background: var(--surface); color: var(--ink); }
.dt-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.dt-button {
	height: 34px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface);
	font: 600 13px var(--font); color: var(--ink-2); cursor: pointer;
}
.dt-button:hover { background: var(--surface-2); color: var(--ink); }
.dt-button-collection {
	position: absolute; z-index: 50; margin-top: 6px; padding: 6px; min-width: 220px; max-height: 360px; overflow-y: auto;
	background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.dt-button-collection .dt-button { display: flex; width: 100%; height: 32px; align-items: center; border: 0; border-radius: 6px; font-weight: 500; color: var(--muted); text-align: left; }
.dt-button-collection .dt-button.active { color: var(--ink); }
.dt-button-collection .dt-button.active::before { content: "\2713"; color: var(--primary); width: 18px; }
.dt-button-collection .dt-button:not(.active)::before { content: ""; width: 18px; }
.dt-button-background { position: fixed; inset: 0; z-index: 49; }
div.dt-button-info { position: fixed; top: 20%; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--surface); padding: 18px 26px; border-radius: 12px; box-shadow: var(--shadow-lg); text-align: center; }
div.dt-button-info h2 { font-size: 15px; margin-bottom: 4px; }

table.dataTable { width: 100% !important; border-collapse: collapse; margin: 0 !important; }
table.dataTable thead th { position: relative; cursor: pointer; padding-right: 26px; }
table.dataTable thead th.sorting::after, table.dataTable thead th.sorting_asc::after, table.dataTable thead th.sorting_desc::after { position: absolute; right: 10px; opacity: .35; font-size: 10px; }
table.dataTable thead th.sorting::after { content: "\2195"; }
table.dataTable thead th.sorting_asc::after { content: "\25B2"; opacity: .8; color: var(--primary); }
table.dataTable thead th.sorting_desc::after { content: "\25BC"; opacity: .8; color: var(--primary); }
table.dataTable thead th.sorting_disabled { cursor: default; padding-right: 14px; }
table.dataTable td.dataTables_empty { text-align: center; color: var(--muted); padding: 28px; }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }
.dataTables_info { color: var(--muted); font-size: 13px; }
.dataTables_paginate { display: flex; gap: 4px; flex-wrap: wrap; }
.dataTables_paginate .paginate_button {
	min-width: 32px; height: 32px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 7px;
	border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; font-weight: 600; font-size: 13px;
}
.dataTables_paginate .paginate_button:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.dataTables_paginate .paginate_button.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.dataTables_paginate .paginate_button.disabled { opacity: .4; cursor: default; }
.dataTables_paginate .ellipsis { padding: 0 6px; color: var(--muted); }
.dataTables_processing { display: none; }

/* ---------- Photo (sacristans form) ---------- */
.photo-layout { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 640px) { .photo-layout { grid-template-columns: 1fr; } }
.photo-panel { display: flex; flex-direction: column; align-items: flex-start; }
.photo-frame {
	position: relative; width: 100px; height: 150px; border-radius: 10px; overflow: hidden; cursor: pointer;
	border: 1.5px dashed var(--line-strong); background: var(--surface-2); transition: border-color .15s, background .15s;
}
.photo-frame:hover, .photo-frame.drag { border-color: var(--primary); background: var(--primary-50); }
.photo-frame img { display: none; width: 100px; height: 150px; object-fit: cover; }
.photo-frame.has-photo { border-style: solid; border-color: var(--line); }
.photo-frame.has-photo img { display: block; }
.photo-frame.has-photo .photo-empty { display: none; }
.photo-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.photo-actions { display: flex; gap: 6px; margin-top: 8px; }
.photo-actions .icon-btn { width: 32px; height: 32px; color: var(--muted); }
.photo-actions .icon-btn:hover { color: var(--danger); background: var(--danger-50); }
.photo-panel .hint { line-height: 1.45; }
.hero-photo { width: 100px; height: 150px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); flex: none; }

dialog.modal-crop { width: min(680px, calc(100% - 24px)); max-height: calc(100vh - 24px); overflow: auto; }
.crop-layout { display: flex; gap: 20px; align-items: flex-start; }
.crop-stage {
	position: relative; flex: none; margin: 0 auto; touch-action: none; user-select: none; cursor: crosshair;
	background: repeating-conic-gradient(#e9e6e1 0 25%, #f7f5f2 0 50%) 0 0 / 16px 16px; border-radius: 6px; overflow: hidden;
}
.crop-stage img { display: block; max-width: none; pointer-events: none; }
.crop-box {
	position: absolute; cursor: move; outline: none;
	border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(20, 16, 20, .62), 0 0 0 1px rgba(0,0,0,.35);
	background-image:
		linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.55) calc(33.33% - .5px), rgba(255,255,255,.55) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255,255,255,.55) calc(66.66% - .5px), rgba(255,255,255,.55) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
		linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.55) calc(33.33% - .5px), rgba(255,255,255,.55) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255,255,255,.55) calc(66.66% - .5px), rgba(255,255,255,.55) calc(66.66% + .5px), transparent calc(66.66% + .5px));
}
.crop-box:focus-visible { border-color: var(--gold); }
.crop-box .h { position: absolute; width: 16px; height: 16px; background: #fff; border: 2px solid var(--primary); border-radius: 4px; }
.crop-box .h.nw { left: -9px; top: -9px; cursor: nwse-resize; }
.crop-box .h.se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.crop-box .h.ne { right: -9px; top: -9px; cursor: nesw-resize; }
.crop-box .h.sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.crop-side { width: 130px; flex: none; }
.crop-side canvas { display: block; width: 100px; height: 150px; border-radius: 8px; border: 1px solid var(--line); box-shadow: var(--shadow); background: #fff; }
@media (max-width: 640px) {
	.crop-layout { flex-direction: column; align-items: center; }
	.crop-side { width: auto; display: flex; flex-direction: column; align-items: center; }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
	@page { size: A4; margin: 12mm; }
	body { background: #fff; font-size: 12px; }
	.sidebar, .topbar, .footer, .no-print, dialog, .rail, .savebar, .backdrop { display: none !important; }
	.main { margin: 0; }
	.content { padding: 0; max-width: none; }
	.card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
	.card + .card { margin-top: 10px; }
	.sec-head, .card-head { padding: 8px 12px; }
	.card-body, .sec-body { padding: 10px 12px; }
	.dl { grid-template-columns: repeat(3, 1fr); gap: 8px 16px; }
	.profile-hero { padding: 12px; }
	.sign-row { display: flex; justify-content: space-between; gap: 30px; margin-top: 36px; }
	.sign-row div { flex: 1; border-top: 1px solid #555; padding-top: 6px; text-align: center; font-size: 11px; }
	a { color: inherit; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.grid + .card, .grid + .sec { margin-top: 18px; }
