:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --text: #172033;
    --muted: #667085;
    --border: #d9e0ea;
    --primary: #2457d6;
    --primary-dark: #183e9c;
    --danger: #b42318;
    --success: #067647;
    --shadow: 0 10px 30px rgba(20, 34, 66, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: #101828; color: white; gap: 20px; }
.topbar a { color: white; }
.brand { font-size: 1.15rem; font-weight: 800; letter-spacing: .05em; }
.topbar-meta { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: .92rem; }
.page-shell { width: min(1180px, calc(100% - 32px)); margin: 32px auto 60px; }
.page-heading { margin-bottom: 22px; }
.page-heading h1 { margin: 0 0 6px; font-size: clamp(1.7rem, 3vw, 2.35rem); }
.page-heading.split { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.muted, .help { color: var(--muted); }
.help { font-size: .9rem; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; min-height: 170px; display: flex; gap: 18px; color: var(--text); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(20,34,66,.12); text-decoration: none; }
.tile-icon { width: 54px; height: 54px; border-radius: 14px; background: #e8efff; display: grid; place-items: center; font-size: 1.65rem; flex: 0 0 auto; }
.tile h2 { margin: 2px 0 8px; font-size: 1.1rem; }
.tile p { margin: 0; color: var(--muted); }
.panel, .auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 24px; }
.auth-card { width: min(440px, 100%); margin: 8vh auto 0; }
.auth-card.wide { width: min(560px, 100%); }
.auth-card h1 { margin-top: 0; }
.auth-links { margin-top: 18px; text-align: center; }
.narrow-panel { max-width: 640px; }
.two-col { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.7fr); gap: 20px; align-items: start; }
label { display: block; margin: 14px 0 6px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #c8d1df; border-radius: 10px; padding: 11px 12px; font: inherit; background: white; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(36,87,214,.15); border-color: var(--primary); }
textarea { resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 500; margin-top: 12px; }
.checkbox input { width: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; background: white; color: var(--text); padding: 10px 15px; font: inherit; font-weight: 700; cursor: pointer; }
.btn:hover { text-decoration: none; background: #f7f9fc; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; margin-top: 20px; }
.btn-small { padding: 7px 10px; font-size: .88rem; }
.alert { border-radius: 10px; padding: 12px 14px; margin: 0 0 18px; border: 1px solid transparent; }
.alert-error { color: #7a271a; background: #fef3f2; border-color: #fecdca; }
.alert-success { color: #05603a; background: #ecfdf3; border-color: #abefc6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 2px 18px; margin-bottom: 20px; }
.form-grid .full { grid-column: 1 / -1; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: #475467; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.search-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; margin-bottom: 16px; }
.avatar { width: 44px; height: 44px; object-fit: cover; border-radius: 50%; border: 1px solid var(--border); display: inline-grid; place-items: center; }
.avatar.placeholder { background: #eef2f6; color: var(--muted); }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.badge-ok { color: var(--success); background: #ecfdf3; }
.badge-off { color: #475467; background: #f2f4f7; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select { min-width: 160px; }
.simple-list { list-style: none; padding: 0; margin: 0; }
.simple-list li { border-bottom: 1px solid var(--border); padding: 10px 0; }
.permission-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 12px 0 20px; }
.permission-item { display: flex; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin: 0; font-weight: 500; }
.permission-item input { width: auto; margin-top: 3px; }
.permission-item small { display: block; color: var(--muted); margin-top: 2px; }
@media (max-width: 800px) {
    .topbar { padding: 14px 18px; align-items: flex-start; flex-direction: column; }
    .page-heading.split { align-items: flex-start; flex-direction: column; }
    .two-col, .form-grid, .permission-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
}

.logout-form { margin: 0; display: inline; }
.link-button { border: 0; padding: 0; background: transparent; color: white; font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.small-text { font-size: .82rem; max-width: 360px; overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 8px; }
.section-heading h2 { margin: 0 0 4px; font-size: 1.15rem; }
.section-heading p { margin: 0; }
.section-divider { height: 1px; background: var(--border); margin: 28px 0; }
.split-section { align-items: center; }
.status-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge-danger { color: var(--danger); background: #fef3f2; }
.access-section { margin-top: 0; }
.access-grid { margin-top: 6px; }
.access-toggle { margin-top: 8px; font-size: 1rem; }
.access-help { margin: 5px 0 0 27px; }
.readonly-field { min-height: 44px; display: flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #f8fafc; color: #475467; }
.access-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 18px; }
.access-actions .btn:disabled { opacity: .55; cursor: not-allowed; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.access-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin: 14px 0; }
.access-summary > div { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #f8fafc; }
.access-summary span { display: block; color: var(--muted); font-size: .82rem; margin-bottom: 4px; }
.access-summary strong { overflow-wrap: anywhere; }
@media (max-width: 800px) {
    .section-heading, .split-section { flex-direction: column; align-items: flex-start; }
    .access-summary { grid-template-columns: 1fr; }
}
