:root {
    color-scheme: light;
    --bg: #f6f5f0;
    --surface: #fffefa;
    --surface-alt: #f0f2eb;
    --surface-hover: #e9efe5;
    --ink: #182a22;
    --muted: #52675a;
    --line: #dce3d8;
    --accent: #23583c;
    --accent-hover: #17432c;
    --on-accent: #fff;
    --accent-soft: #e5efe1;
    --danger: #9d302e;
    --danger-bg: #f9e5e2;
    --warning: #77551c;
    --warning-bg: #f7eccf;
    --focus: #a56925;
    --shadow: 0 10px 30px #233d2f0b;
    --shadow-raised: 0 8px 22px #233d2f19;
    --motion: 160ms ease;
    --radius: 16px;
    font-family: "DM Sans", "Tajawal", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

:root[lang="ar"] { font-family: "Tajawal", system-ui, sans-serif; }
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #142521;
    --surface: #1c302a;
    --surface-alt: #263d34;
    --surface-hover: #2d493b;
    --ink: #eef5ee;
    --muted: #b4c8bb;
    --line: #3e594b;
    --accent: #b3d7a8;
    --accent-hover: #c8e4bf;
    --on-accent: #183828;
    --accent-soft: #2e4b39;
    --danger: #ffb9b0;
    --danger-bg: #522d2c;
    --warning: #f5d899;
    --warning-bg: #4a3d25;
    --focus: #e3b86d;
    --shadow: 0 10px 28px #0d171449;
    --shadow-raised: 0 8px 22px #0d171466;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 1rem; line-height: 1.55; }
h1, h2, h3, h4, p, dl { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
svg { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.page-width { width: min(1392px, calc(100% - 64px)); margin-inline: auto; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.skip:focus { position: fixed; inset: 12px auto auto 12px; z-index: 1500; padding: 10px 16px; border-radius: 8px; background: var(--surface); }

#site-header { background: var(--surface); border-block-end: 1px solid var(--line); }
.topbar { min-height: 76px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; justify-self: start; }
.brand-icon { flex: none; width: 51px; height: 44px; border-radius: 11px; background: #142c21 url("../assets/media/qaryati-brand.73eb697aa06e.webp") center / cover no-repeat; }
.brand-name { color: var(--accent); font-weight: 900; font-size: 1.95rem; letter-spacing: -.055em; line-height: 1; }
:root[lang="ar"] .brand-name { letter-spacing: 0; padding-block-start: .14em; }
.public-nav, .header-actions, .action-row { display: flex; align-items: center; gap: 10px; }
.header-actions { justify-content: end; }
.public-nav { gap: 22px; }
.public-nav a { min-height: 76px; display: flex; align-items: center; gap: 8px; font-weight: 700; position: relative; white-space: nowrap; color: var(--muted); }
.public-nav a:is(:hover, :focus-visible, [aria-current="page"]) { color: var(--accent); }
.public-nav a[aria-current="page"]::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; border-radius: 6px 6px 0 0; background: var(--accent); }
.btn, .icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border: 1px solid transparent; color: var(--ink); background: transparent; border-radius: 10px; line-height: 1.2; font-weight: 700; text-align: center; }
.btn, .icon-btn { transition: background-color var(--motion), border-color var(--motion), color var(--motion); }
.btn { min-height: 43px; padding: 9px 15px; }
.btn.small { min-height: 34px; padding: 6px 11px; font-size: .875rem; }
.icon-btn { width: 40px; height: 40px; flex: none; border-color: var(--line); background: var(--surface); }
.icon-btn:hover, .btn.secondary:hover, .btn.text-btn:hover, .language-btn:hover { background: var(--surface-hover); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:enabled { background: var(--accent-hover); }
.btn.secondary, .language-btn { background: var(--surface); border-color: var(--line); }
.btn.text-btn { color: var(--accent); }
.btn.danger { background: var(--danger); color: var(--surface); }
.btn.danger:hover:enabled { background: color-mix(in srgb, var(--danger) 89%, var(--ink)); }
.btn.danger-outline { color: var(--danger); border-color: var(--danger); }
.btn.danger-outline:hover { background: var(--danger-bg); }
.language-btn { min-width: 52px; font-size: .875rem; }
.header-login { white-space: nowrap; }

.hero {
    isolation: isolate;
    position: relative;
    display: grid;
    align-items: center;
    margin-top: 26px;
    min-height: 314px;
    border-radius: 19px;
    overflow: hidden;
    color: #fffdf4;
    background: #142c21;
}
.hero-art { position: absolute; z-index: -2; inset-block: 0; inset-inline-end: 0; width: 62%; }
.hero-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to right, #142c21 35%, #142c2155 58%, transparent 76%); }
:root[dir="rtl"] .hero::before { background: linear-gradient(to left, #142c21 35%, #142c2155 58%, transparent 76%); }
.hero-content { width: 57%; max-width: 700px; padding: 36px 40px; }
.hero-label { display: flex; align-items: center; gap: 8px; color: #f5dba3; font-weight: 700; font-size: .95rem; margin-bottom: 12px; }
.hero h1 { font-size: clamp(2.25rem, 4.35vw, 4.5rem); font-weight: 900; max-width: 690px; letter-spacing: -.043em; margin-bottom: 13px; }
:root[lang="ar"] .hero h1 { letter-spacing: 0; }
.hero-content > p:last-child { color: #f7f4e8; font-size: clamp(1rem, 1.5vw, 1.16rem); line-height: 1.65; max-width: 46ch; }
.photo-credit { position: absolute; inset-inline-end: 14px; inset-block-end: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .75rem; background: #142920df; border-radius: 6px; padding: 4px 8px; }
.photo-credit a { text-decoration: underline; text-underline-offset: 2px; }

.explorer { display: grid; grid-template-columns: minmax(310px, 365px) minmax(0, 1fr); gap: 20px; margin-block: 22px 0; align-items: stretch; }
.directory, .map-card, .table-card, .panel, .stat, .shortcut, .workspace-nav {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.directory { min-width: 0; padding: 17px; display: flex; flex-direction: column; }
.directory-title { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.section-icon, .village-icon { display: grid; place-items: center; flex: none; color: var(--accent); background: var(--accent-soft); border-radius: 11px; }
.section-icon { width: 43px; height: 43px; }
.directory-title h2, .map-title h2 { font-size: 1.25rem; }
.directory-title p { color: var(--muted); font-size: .875rem; margin-top: 3px; }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); background: var(--surface-alt); border: 1px solid var(--line); border-radius: 11px; padding: 4px; gap: 4px; margin-bottom: 13px; }
.segmented button { display: flex; gap: 7px; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 700; min-height: 36px; padding: 4px 7px; white-space: nowrap; transition: background-color var(--motion), color var(--motion); }
.segmented button:not([aria-pressed="true"]):hover { background: var(--surface-hover); color: var(--accent); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 5px #0a26121a; }
.catalog-filters { display: grid; gap: 9px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.catalog-filters label, .form-grid label, .stack label, .filter-form label { min-width: 0; display: grid; gap: 6px; font-size: .9rem; font-weight: 700; }
input, textarea, select { min-width: 0; width: 100%; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface); min-height: 42px; transition: border-color var(--motion), background-color var(--motion); }
input:hover, textarea:hover, select:hover { border-color: var(--accent); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .9; }
select { background-color: var(--surface-alt); text-overflow: ellipsis; }
textarea { display: block; min-block-size: 102px; padding: 11px 13px; line-height: 1.65; font-weight: 400; resize: vertical; }
.search-control { display: flex !important; flex-direction: row; align-items: center; gap: 7px !important; border: 1px solid var(--line); border-radius: 9px; padding-inline-start: 11px; color: var(--accent); }
.search-control:focus-within { outline: 2px solid var(--focus); }
.search-control input { border: 0; background: transparent; outline: none; }
.select-control { position: relative; display: block; }
.select-control select { appearance: none; display: block; cursor: pointer; padding-inline-end: 40px; }
.select-control > svg { position: absolute; inset-inline-end: 13px; top: 50%; transform: translateY(-50%); color: var(--accent); pointer-events: none; }
.nearby-origin { min-width: 0; margin: 0; padding: 0; border: 0; }
.nearby-origin legend { padding: 0; margin-block-end: 5px; font-size: .9rem; font-weight: 700; }
.nearby-origin .segmented { margin: 0; }
.nearby-village-picker { display: grid; gap: 7px; }
.nearby-village-picker select:disabled { color: var(--muted); opacity: 1; cursor: default; }
.nearby-village-picker [data-retry-centers] { justify-self: start; }
.nearby-filters .coordinates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.village-list { min-height: 150px; max-height: 380px; overflow-y: auto; margin-top: 4px; flex: 1; }
.village-row { width: 100%; display: flex; text-align: start; gap: 11px; align-items: center; border: 0; border-bottom: 1px solid var(--line); padding: 9px 3px; background: var(--surface); color: var(--ink); }
.village-row:last-child { border-bottom-color: transparent; }
.village-row:hover { background: var(--surface-hover); }
.village-icon { width: 37px; height: 37px; }
.village-thumbnail { flex: none; width: 54px; height: 40px; object-fit: cover; border-radius: 7px; background: var(--surface-alt); }
.village-row strong, .village-row .muted { display: block; }
.village-name { min-width: 0; }
.village-name > span { display: block; color: var(--muted); font-size: .875rem; }
.distance { margin-inline-start: auto; color: var(--accent); font-weight: 700; font-size: .875rem; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .86rem; min-height: 42px; margin-top: 5px; }
.pager:empty { display: none; }
.pager-controls { display: flex; align-items: center; gap: 7px; }

.map-card { display: flex; min-height: 539px; flex-direction: column; min-width: 0; overflow: hidden; }
.map-toolbar { display: flex; justify-content: space-between; align-items: center; min-height: 60px; gap: 12px; padding-inline: 18px; }
.map-actions { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .875rem; text-align: end; }
.map-actions .icon-btn { width: 34px; height: 34px; color: var(--accent); }
.map-title { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.map-canvas { flex: 1; min-height: 420px; position: relative; isolation: isolate; border-top: 1px solid var(--line); background: #a5b9b5; direction: ltr; }
.map-canvas .leaflet-tile-pane { filter: brightness(1.37) saturate(.72) contrast(.91); }
.map-region span { display: inline-block; white-space: nowrap; transform: translate(-50%, -50%); color: #172d23; font-size: .83rem; font-weight: 800; text-shadow: 0 0 2px #fff9df, 0 0 5px #fff9df, 0 1px 0 #fff9df; }
.map-region.water span { color: #e2eef1; font-style: italic; text-shadow: 0 1px 4px #20465b; }
.map-north { display: grid; justify-items: center; padding: 3px 8px; border-radius: 6px; background: #193b53a8; color: white; font-size: .8rem; font-weight: 800; }
.map-north::after { content: ""; width: 14px; height: 17px; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 50% 72%, 0 100%); }
.map-unavailable { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); }
.village-marker span { display: grid; place-items: center; width: 24px; height: 24px; transform: rotate(-45deg); border-radius: 50% 50% 50% 6px; border: 2px solid #fff; background: #286442; box-shadow: 0 2px 6px #20332280; }
.village-marker span::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.search-center-marker span { width: 31px; height: 31px; background: #a4412b; box-shadow: 0 2px 8px #332018b0; }
.leaflet-tooltip.search-center-label { border-color: #823621; background: #fff8e8; color: #63311e; font-weight: 800; }
.leaflet-tooltip-top.search-center-label::before { border-top-color: #fff8e8; }
.village-cluster { display: grid; place-items: center; border-radius: 50%; border: 2px solid #fff; background: #286442; color: #fff; font-size: .95rem; font-weight: 800; box-shadow: 0 2px 6px #20332280; }
.map-village-choices { display: grid; gap: 6px; }
.map-village-choices button { border: 1px solid #dfe7db; border-radius: 6px; padding: 4px 8px; background: #f4f7ef; color: #17412a; text-align: start; }
.leaflet-container { font-family: inherit; }
.leaflet-container .leaflet-control-attribution { font-size: .7rem; }
.site-footer { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .88rem; }

dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-block-start: 3px solid var(--accent); border-radius: 19px; padding: 0; width: min(100% - 28px, 540px); max-height: min(88dvh, 900px); overflow: auto; overscroll-behavior: contain; box-shadow: 0 24px 90px #101e1b5d; }
dialog[open] { animation: dialog-enter var(--motion) both; }
@keyframes dialog-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
dialog.wide { width: min(100% - 28px, 790px); }
dialog:has(.staff-profile) { width: min(100% - 28px, 660px); }
dialog::backdrop { background: #142920a8; backdrop-filter: blur(2px); }
.dialog-heading { background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px clamp(16px, 4vw, 24px); border-block-end: 1px solid var(--line); position: sticky; inset-block-start: 0; z-index: 2; }
.dialog-heading h2 { font-size: clamp(1.12rem, 2.6vw, 1.46rem); overflow-wrap: anywhere; }
.dialog-body { padding: clamp(16px, 4vw, 24px); display: grid; gap: 16px; min-width: 0; }
.staff-profile { display: grid; gap: 15px; }
.staff-profile-identity { display: flex; align-items: center; gap: 14px; padding: clamp(12px, 3vw, 20px); border-radius: 13px; border: 1px solid var(--line); background: linear-gradient(125deg, var(--accent-soft), var(--surface-alt)); }
.staff-avatar { display: grid; place-items: center; flex: none; width: clamp(42px, 10vw, 60px); aspect-ratio: 1; border-radius: 14px; background: var(--accent); color: var(--on-accent); font-size: 1.28rem; font-weight: 800; }
.staff-profile-name { min-width: 0; }
.staff-profile-name h3 { font-size: clamp(1.15rem, 3vw, 1.68rem); font-weight: 800; overflow-wrap: anywhere; }
.staff-profile-name p { display: flex; align-items: start; gap: 6px; margin-block-start: 5px; color: var(--muted); font-size: .92rem; }
.staff-profile-name p svg { margin-block-start: .19em; color: var(--accent); }
.staff-profile-name bdi { min-width: 0; overflow-wrap: anywhere; }
.staff-profile-access, .staff-profile-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 9px; }
.staff-profile-access > div { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.staff-profile-access dt { color: var(--muted); font-size: .84rem; }
.staff-profile-access dd { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 5px 0 0; font-weight: 700; }
.staff-profile-actions:has([data-user="unlock"]) { grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr)); }
.profile-action { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 64px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; text-align: start; background: var(--surface); color: var(--ink); }
.profile-action .section-icon { width: 36px; height: 36px; border-radius: 9px; transition: background-color var(--motion), color var(--motion); }
.profile-action:is(:focus-visible, :active) .section-icon { background: var(--accent); color: var(--on-accent); }
.profile-action[data-user="unlock"] .section-icon { background: var(--warning-bg); color: var(--warning); }
.profile-action strong, .profile-action small { display: block; }
.profile-action strong { font-size: .91rem; }
.profile-action small { color: var(--muted); font-size: .77rem; }
.village-photo { margin: 0; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-alt); }
.village-photo img { display: block; width: 100%; height: clamp(156px, 33vh, 310px); object-fit: cover; object-position: 50% 57%; }
.village-photo figcaption { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 3px 12px; padding: 7px 11px; color: var(--muted); font-size: .8rem; }
.village-photo figcaption a { color: var(--accent); }
.village-other-name { color: var(--muted); font-weight: 600; }
.auth-intro { display: flex; gap: 13px; align-items: center; color: var(--muted); }
.stack, .form-grid { display: grid; gap: 13px; }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr)); align-items: start; }
.form-grid > :is(p, .span-all, .form-actions, .facts, label:has(> textarea)) { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.dialog-body .form-actions { padding-block-start: 14px; border-block-start: 1px solid var(--line); }
.form-details { border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; }
.form-details summary { color: var(--accent); cursor: pointer; font-weight: 700; }
.form-details .form-grid { margin-top: 10px; }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 8px; white-space: pre-line; }
.action-row { flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 148px), 1fr)); gap: 8px; }
.facts > div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: color-mix(in srgb, var(--surface-alt) 42%, var(--surface)); }
.facts dt { color: var(--muted); font-size: .86rem; }
.facts dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.detail-section h3 { display: flex; align-items: center; gap: 9px; font-size: 1.18rem; margin-bottom: 8px; }
.detail-section p { overflow-wrap: anywhere; }
.profile-items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 8px; }
.profile-items li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-alt); }
.profile-item-type { display: block; color: var(--accent); font-size: .8rem; margin-top: 3px; }
.profile-items p { margin-top: 4px; color: var(--muted); }
.timeline, .clean-list { margin: 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 100px 1fr; gap: 13px; padding: 12px 0; border-top: 1px solid var(--line); }
.timeline time { color: var(--accent); font-weight: 800; }
.timeline p { color: var(--muted); }
.clean-list li { padding: 9px 0; border-top: 1px solid var(--line); }
.message { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 24px 14px; text-align: center; min-height: 76px; }
.message.error { color: var(--danger); }
.spinner { width: 17px; height: 17px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { position: fixed; z-index: 1200; inset-block-end: 20px; inset-inline-end: 20px; max-width: min(480px, 100vw - 40px); padding: 11px 16px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 700; box-shadow: var(--shadow); overflow-wrap: anywhere; }

.workspace { display: grid; grid-template-columns: 246px minmax(0, 1fr); align-items: start; gap: 24px; margin-block: 26px 42px; }
.workspace-nav {
    position: sticky; inset-block-start: 18px;
    display: grid; grid-template-areas: "identity" "navigation" "logout"; padding: 12px; gap: 13px;
}
.workspace-identity {
    grid-area: identity; display: flex; align-items: center; gap: 10px; min-width: 0;
    padding: 12px; border-radius: 12px; background: var(--surface-alt); border: 1px solid var(--line);
}
.workspace-identity .section-icon { color: var(--on-accent); background: var(--accent); }
.workspace-identity > div { min-width: 0; }
.workspace-identity strong, .workspace-identity bdi { display: block; }
.workspace-identity bdi { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.workspace-nav nav { grid-area: navigation; display: grid; gap: 4px; }
.workspace-nav a {
    position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px;
    border-radius: 9px; color: var(--muted); font-weight: 700; line-height: 1.35;
}
.workspace-nav a:hover { background: var(--surface-hover); color: var(--accent); }
.workspace-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.workspace-nav a[aria-current="page"]::before {
    content: ""; position: absolute; inset-inline-start: 0; inset-block: 10px; width: 3px; border-radius: 5px; background: var(--accent);
}
.workspace-logout { grid-area: logout; justify-content: start; color: var(--muted); border-block-start-color: var(--line); border-radius: 0 0 9px 9px; }
.workspace-content { min-width: 0; }
.workspace-heading {
    margin-block-end: 18px; padding: clamp(16px, 2.5vw, 26px);
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.workspace-back { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: .86rem; font-weight: 800; }
.workspace-back:hover { text-decoration: underline; }
.workspace-title { display: flex; align-items: center; gap: 12px; margin-block-start: 11px; }
.workspace-title h1 { font-size: clamp(1.6rem, 3vw, 2.35rem); font-weight: 900; }
.workspace-title .section-icon { width: 46px; height: 46px; }
.workspace-back svg { transform: rotate(90deg); }
.workspace-hero .btn svg, .stat-top > svg, .shortcut > svg, .table-action .btn svg { transform: rotate(-90deg); }
:root[dir="rtl"] .workspace-back svg { transform: rotate(-90deg); }
:root[dir="rtl"] :is(.workspace-hero .btn, .stat-top, .shortcut, .table-action .btn) > svg:last-child { transform: rotate(90deg); }
.workspace-hero {
    --hero-direction: to right;
    position: relative; isolation: isolate; display: grid; align-items: center; overflow: hidden;
    margin-block-end: 18px; min-height: 235px; border-radius: var(--radius); color: #fffefa; box-shadow: var(--shadow);
    background: #2c5038 url("../assets/media/battir.62a112c1f14e.webp") center 47% / cover no-repeat;
}
:root[dir="rtl"] .workspace-hero { --hero-direction: to left; }
.workspace-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(var(--hero-direction), #142f25 0%, #153326e8 27%, #18362972 66%, #14292043 100%); }
.workspace-hero-content { max-width: 670px; padding: clamp(21px, 4vw, 40px); padding-block-end: 48px; }
.workspace-hero h1 { font-size: clamp(1.85rem, 3.2vw, 3.15rem); margin-block-end: 7px; font-weight: 900; }
.workspace-hero p { color: #f4f4dc; max-width: 44ch; }
.workspace-hero .btn { min-height: 38px; margin-block-start: 14px; color: #1c422c; background: #f3f4df; }
.workspace-hero .btn:hover { background: #e2e9ca; }
.stat-grid, .workspace-links { display: grid; gap: 14px; margin-block-end: 18px; }
.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid > .message { grid-column: 1 / -1; }
.workspace-links { grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr)); }
.dashboard-feeds { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 315px), 1fr)); align-items: stretch; gap: 14px; }
.panel.dashboard-feed { display: block; padding: 0; height: 100%; min-width: 0; }
.dashboard-feed-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 15px 18px; border-block-end: 1px solid var(--line); }
.dashboard-feed-heading h2 { display: flex; align-items: center; gap: 8px; font-size: 1.08rem; }
.dashboard-feed-heading h2 svg { color: var(--accent); }
.dashboard-feed-body ul { list-style: none; margin: 0; padding: 0 18px; }
.dashboard-feed-body li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-block: 12px; }
.dashboard-feed-body li + li { border-block-start: 1px solid var(--line); }
.dashboard-entry { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.dashboard-entry > span, .dashboard-feed-body time { font-size: .8rem; color: var(--muted); }
.dashboard-feed-body li > time { flex-shrink: 0; text-align: end; }
.stat { min-width: 0; padding: 16px; display: grid; gap: 6px; align-content: start; }
.stat-top { display: flex; justify-content: space-between; align-items: center; color: var(--accent); margin-block-end: 3px; }
.stat[data-symbol="bell"] .section-icon { color: var(--warning); background: var(--warning-bg); }
.stat strong { font-size: clamp(1.65rem, 3vw, 2.3rem); line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .91rem; line-height: 1.4; overflow-wrap: anywhere; }
.shortcut { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 15px; }
.shortcut > svg { align-self: center; color: var(--accent); }
.shortcut strong { display: block; line-height: 1.3; }
.shortcut p { color: var(--muted); font-size: .87rem; margin-top: 4px; }
a.stat, .shortcut, .profile-action { transition: background-color var(--motion), border-color var(--motion), box-shadow var(--motion), transform var(--motion); }
:is(a.stat, .shortcut, .profile-action):is(:focus-visible, :active) { border-color: var(--accent); background: var(--surface-hover); }
@media (hover: hover) and (pointer: fine) {
    :is(a.stat, .shortcut, .profile-action):hover { border-color: var(--accent); background: var(--surface-hover); box-shadow: var(--shadow-raised); }
    :is(a.stat, .shortcut, .profile-action):hover:not(:active) { transform: translateY(-2px); }
    .profile-action:hover .section-icon { background: var(--accent); color: var(--on-accent); }
    .profile-action[data-user="unlock"]:hover .section-icon { background: var(--warning-bg); color: var(--warning); }
}
.table-card { overflow: hidden; }
.table-tools { display: flex; align-items: end; justify-content: space-between; padding: 16px 18px; gap: 12px; flex-wrap: wrap; border-block-end: 1px solid var(--line); }
.table-tools:has(.filter-form[hidden]) { justify-content: end; }
.filter-form { display: flex; min-width: 0; align-items: end; flex-wrap: wrap; gap: 10px; }
.filter-form label { min-width: 0; }
.filter-form input { max-width: 205px; }
.filter-form .btn { min-height: 42px; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 475px; }
th, td { padding: 12px 18px; text-align: start; vertical-align: middle; border-block-end: 1px solid var(--line); }
th { background: var(--surface-alt); color: var(--muted); font-size: .88rem; font-weight: 800; white-space: nowrap; }
td { font-size: .95rem; overflow-wrap: anywhere; }
tbody tr:hover, tbody tr:focus-within { background: var(--surface-hover); }
.staff-table .table-action { width: 1%; text-align: end; white-space: nowrap; }
.table-cell-label { display: none; }
.table-card > .pager { padding: 8px 18px; }
.badge { display: inline-flex; align-items: center; color: var(--muted); background: var(--surface-alt); border-radius: 999px; padding: 4px 9px; width: fit-content; font-weight: 700; font-size: .84rem; white-space: nowrap; }
.badge.green { background: var(--accent-soft); color: var(--accent); }
.badge.red { background: var(--danger-bg); color: var(--danger); }
.badge.amber { background: var(--warning-bg); color: var(--warning); }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 225px), 1fr)); gap: 12px; }
.compare-grid:empty { display: none; }
.panel { padding: 14px; display: grid; gap: 9px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.change-list { display: grid; gap: 10px; }
pre { font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 10px; background: var(--surface-alt); border-radius: 8px; }
code { overflow-wrap: anywhere; font-size: .84em; }
.source-list { padding-inline: 15px; }

@media (max-width: 930px) {
    .page-width { width: calc(100% - 36px); }
    .topbar { gap: 15px; }
    .public-nav { gap: 7px; }
    .public-nav .btn { padding-inline: 6px; }
    .explorer { grid-template-columns: minmax(250px, 310px) minmax(0, 1fr); gap: 14px; }
    .workspace { grid-template-columns: 205px minmax(0, 1fr); gap: 15px; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
    .page-width { width: calc(100% - 24px); }
    .topbar { display: flex; flex-wrap: wrap; gap: 7px; justify-content: space-between; padding-block-start: 9px; }
    .public-nav { width: 100%; order: 3; justify-content: center; }
    .public-nav a { min-height: 42px; }
    .brand-icon { width: 42px; height: 36px; border-radius: 9px; }
    .brand-name { font-size: 1.6rem; }
    .header-actions { gap: 5px; }
    .header-actions .btn { min-height: 38px; padding-inline: 9px; }
    .header-actions .icon-btn { width: 36px; height: 36px; }
    .language-btn { min-width: 40px; }
    .hero { --hero-art-height: clamp(168px, 53vw, 310px); margin-top: 14px; min-height: 230px; border-radius: 13px; }
    .hero-art { inset: 0 0 auto; width: 100%; height: var(--hero-art-height); }
    .hero::before, :root[dir="rtl"] .hero::before { background: linear-gradient(to bottom, transparent calc(var(--hero-art-height) - 42px), #142c21 var(--hero-art-height)); }
    .hero-content { width: auto; padding: calc(var(--hero-art-height) + 3px) 19px 23px; }
    .hero h1 { font-size: 2.25rem; }
    .photo-credit { inset-block-end: 9px; inset-inline-end: 8px; }
    .explorer { grid-template-columns: minmax(0, 1fr); margin-top: 13px; }
    .map-card { min-height: 360px; }
    .map-canvas { min-height: 310px; }
    .village-list { max-height: 280px; }
    .workspace { grid-template-columns: minmax(0, 1fr); margin-block: 14px 28px; gap: 14px; }
    .workspace-nav { position: static; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "identity logout" "navigation navigation"; gap: 9px; padding: 10px; }
    .workspace-nav nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .workspace-nav nav a { padding-inline: 9px; font-size: .89rem; }
    .workspace-identity { padding: 7px; }
    .workspace-identity .section-icon { width: 33px; height: 33px; border-radius: 8px; }
    .workspace-logout { align-self: center; min-height: 40px; padding-inline: 5px; border: 0; font-size: .87rem; }
    .workspace-logout svg { width: 16px; height: 16px; }
    .workspace-heading { margin-block-end: 12px; }
    .workspace-hero { min-height: 205px; margin-block-end: 13px; }
    .workspace-hero::before { background: linear-gradient(var(--hero-direction), #142f25fa, #153326ac); }
    .stat-grid, .workspace-links, .dashboard-feeds { gap: 10px; }
    .stat { padding: 13px; }
    .stat-top .section-icon { width: 37px; height: 37px; }
    .dashboard-feed-body time { max-width: 12ch; }
    .table-tools { display: grid; padding: 12px; }
    .table-tools .action-row { justify-content: end; }
    .filter-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-form input { max-width: none; }
    .filter-form button:last-child { justify-self: start; }
    .table-card:has(.staff-table) { background: var(--surface-alt); }
    .table-card .table-tools, .table-card > .pager { background: var(--surface); }
    .staff-table, .staff-table tbody { display: block; width: 100%; min-width: 0; }
    .staff-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .staff-table tbody { padding: 10px; }
    .staff-table tbody tr {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
        padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
    }
    .staff-table tbody tr + tr { margin-block-start: 8px; }
    .staff-table td { min-width: 0; display: block; padding: 0; border: 0; }
    .staff-table td:first-child, .staff-table td.table-action { grid-column: 1 / -1; }
    .staff-table td:first-child > div { font-size: 1.05rem; }
    .staff-table td.table-action { width: auto; padding-block-start: 8px; border-block-start: 1px solid var(--line); }
    .table-cell-label { display: block; font-size: .77rem; color: var(--muted); font-weight: 700; }
    .table-card > .pager { padding-inline: 10px; }
    .staff-profile-identity { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 10px; }
    .staff-profile-name { display: contents; }
    .staff-profile-name p { grid-column: 1 / -1; margin-block-start: 0; }
    .staff-profile-access, .staff-profile-actions, .staff-profile-actions:has([data-user="unlock"]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .staff-profile-access > div:nth-child(3) { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
    .staff-profile-access > div:nth-child(3) dd { margin: 0; }
}

@media (max-width: 480px) {
    .staff-profile-actions, .staff-profile-actions:has([data-user="unlock"]) { grid-template-columns: 1fr; }
}

@media (max-width: 350px) {
    .workspace-logout { gap: 3px; }
    .workspace-logout svg { display: none; }
    .filter-form { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
    :is(a.stat, .shortcut, .profile-action):hover:not(:active) { transform: none; }
}
