/* =================================================================
   Dorm Me - main stylesheet
   Fonts: Bricolage Grotesque (headings), Figtree (body)
   ================================================================= */

:root {
    --ink: #1B2B3A;
    --ink-2: #3E4F60;
    --muted: #66768A;
    --primary: #1F5F8B;
    --primary-dark: #174A6D;
    --primary-soft: #E6F0F7;
    --accent: #F2A93B;
    --accent-dark: #D98F1F;
    --accent-soft: #FDF1DC;
    --paper: #7fb3b4;
    --white: #FFFFFF;
    --line: #E2E6EB;
    --success: #2E8B57;
    --success-soft: #E4F3EA;
    --danger: #C8453B;
    --danger-soft: #FBE9E7;
    --warning: #B7791F;
    --warning-soft: #FDF3DD;
    --grey-soft: #EEF1F4;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --shadow: 0 1px 2px rgba(27, 43, 58, .06), 0 4px 16px rgba(27, 43, 58, .06);
    --shadow-lg: 0 12px 40px rgba(27, 43, 58, .14);

    --font-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;

    --sidebar-w: 248px;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 {
    font-family: var(--font-head);
    line-height: 1.15;
    margin: 0 0 .5em;
    letter-spacing: -.01em;
    color: var(--ink);
}
h1 { font-size: clamp(1.8rem, 3.2vw, 2.4rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 2.2vw, 1.7rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
h4 { font-size: 1.02rem; font-weight: 700; }
p { margin: 0 0 1em; }
small, .small { font-size: .86rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pre-line { white-space: pre-line; }
.lead { font-size: 1.1rem; color: var(--ink-2); }
.narrow { max-width: 760px; }
.prose { max-width: 720px; }
.prose p, .prose li { color: var(--ink-2); }
.link { font-weight: 600; }
.note { background: var(--grey-soft); border-radius: var(--radius-sm); padding: .6rem .8rem; margin: .6rem 0 0; font-size: .92rem; }
.txt-open { color: var(--success); font-weight: 600; }
.txt-full { color: var(--danger); font-weight: 600; }
.txt-attention { color: var(--warning); font-weight: 700; }
.icon { flex-shrink: 0; vertical-align: -3px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.section { padding: 56px 0; }
.section--tint { background: var(--white); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.section-head h2 { margin: 0; }
.page-title { margin-bottom: 20px; }
.back-link { display: inline-block; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    font: 600 .95rem/1 var(--font-body);
    padding: .75rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--grey-soft);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { cursor: not-allowed; opacity: .75; background: var(--grey-soft); color: var(--muted); border-color: var(--line); transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: var(--ink); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: var(--white); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost.is-on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.btn-text { background: transparent; color: var(--muted); }
.btn-text:hover { color: var(--ink); background: var(--grey-soft); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #256f46; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a7372e; }
.btn-danger-ghost { background: var(--white); border-color: #efc7c2; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { padding: .5rem .75rem; font-size: .85rem; }
.btn-lg { padding: .95rem 1.4rem; font-size: 1.02rem; }
.btn-block { display: flex; width: 100%; }
.link-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    background: none; border: 0; padding: .3rem 0; cursor: pointer;
    font: 600 .95rem var(--font-body); color: var(--primary);
}
.link-btn:hover { text-decoration: underline; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--white); color: var(--ink); cursor: pointer;
}
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-actions p { margin: 0; }

/* ---------- Brand + public navbar ---------- */
.brand { display: inline-flex; align-items: center; gap: .55rem; font: 800 1.25rem var(--font-head); color: var(--ink); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand--light { color: #fff; }

.navbar { background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000; }
.navbar__inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.navbar__links { display: flex; align-items: center; gap: 6px; }
.nav-link { padding: .5rem .8rem; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 600; font-size: .95rem; }
.nav-link:hover { background: var(--grey-soft); text-decoration: none; color: var(--ink); }
.nav-link.is-active { color: var(--primary); background: var(--primary-soft); }
.navbar__links .btn { margin-left: 4px; }
.navbar__toggle { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 48px 0 56px; background: linear-gradient(180deg, var(--white) 0%, var(--paper) 100%); border-bottom: 1px solid var(--line); }
.hero__grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.02; letter-spacing: -.035em; margin-bottom: .35em; }
.hero__lead { font-size: 1.1rem; color: var(--ink-2); max-width: 36ch; }
.search-panel {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px; box-shadow: var(--shadow); margin: 26px 0 10px;
}
.search-panel__field { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px; border-radius: var(--radius-sm); }
.search-panel__field:focus-within { background: var(--paper); }
.search-panel__field span { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.search-panel__field input { border: 0; padding: 4px 0; background: transparent; font-size: 1rem; outline: none; box-shadow: none; }
.search-panel .btn { height: 100%; min-height: 48px; }
.hero__facts { display: flex; gap: 28px; margin: 26px 0 0; flex-wrap: wrap; }
.hero__facts div { border-left: 3px solid var(--accent); padding-left: 12px; }
.hero__facts dt { font-size: .82rem; color: var(--muted); }
.hero__facts dd { margin: 0; font: 800 1.6rem var(--font-head); }
.hero__map { position: relative; }
.hero__map .map-canvas { height: 460px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.hero__map-note { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); margin: 10px 4px 0; }
.hero__map-note .dot + * { margin-right: 10px; }

/* ---------- Steps / owner band ---------- */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 24px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.steps li { counter-increment: step; position: relative; padding: 22px 20px 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.steps li::before {
    content: counter(step, decimal-leading-zero);
    display: block; font: 800 2rem/1 var(--font-head); color: var(--accent); margin-bottom: 12px;
}
.steps p { color: var(--ink-2); margin: 0; }
.mini-steps { padding-left: 1.2rem; color: var(--ink-2); }
.mini-steps li { margin-bottom: .4rem; }
.owner-band {
    display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
    background: var(--ink); color: #fff; border-radius: var(--radius-lg); padding: 36px 40px;
}
.owner-band h2 { color: #fff; }
.owner-band p { color: #c9d4de; margin: 0; max-width: 52ch; }
.owner-band .btn-primary { background: var(--accent); color: var(--ink); }
.owner-band .btn-primary:hover { background: var(--accent-dark); }

/* ---------- Dorm cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }
.card-grid--3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.dorm-card {
    display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; transition: box-shadow .2s, transform .2s;
}
.dorm-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.dorm-card__media { position: relative; display: block; aspect-ratio: 16 / 10; background: var(--grey-soft); }
.dorm-card__media img { width: 100%; height: 100%; object-fit: cover; }
.dorm-card__media .avail-pill { position: absolute; top: 12px; left: 12px; }
.dorm-card__body { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 18px; flex: 1; }
.dorm-card h3 { margin: 0; font-size: 1.12rem; }
.dorm-card h3 a { color: var(--ink); }
.dorm-card__loc { display: flex; gap: 6px; color: var(--muted); font-size: .9rem; margin: 0; }
.dorm-card__loc .icon { margin-top: 3px; }
.dorm-card__distance { display: inline-flex; align-items: center; gap: 4px; font-size: .84rem; font-weight: 600; color: var(--primary); }
.dorm-card__foot { margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.price { display: flex; flex-direction: column; line-height: 1.15; }
.price small { color: var(--muted); font-size: .76rem; }
.price strong { font: 800 1.3rem var(--font-head); }

.avail-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: .3rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 700;
    background: rgba(255,255,255,.95); box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.avail-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.avail-pill.is-open { color: var(--success); }
.avail-pill.is-full { color: var(--danger); }
.avail-pill.is-static { box-shadow: none; }
.avail-pill.is-static.is-open { background: var(--success-soft); }
.avail-pill.is-static.is-full { background: var(--danger-soft); }

.chip-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip-list li { font-size: .78rem; font-weight: 600; background: var(--primary-soft); color: var(--primary-dark); padding: .25rem .6rem; border-radius: 999px; }
.chip-list--lg li { display: inline-flex; align-items: center; gap: 5px; font-size: .9rem; padding: .4rem .8rem; background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.chip-list--lg .icon { color: var(--success); }

/* ---------- Maps ---------- */
.map-canvas { width: 100%; height: 360px; border-radius: var(--radius); border: 1px solid var(--line); background: #e8edf1; z-index: 1; }
.map-canvas--tall { height: calc(100vh - 290px); min-height: 460px; }
.map-canvas--small { height: 230px; margin-bottom: 10px; }
.map-canvas--picker { height: 340px; margin: 10px 0 14px; }
.map-canvas.is-picking, .map-canvas.is-picking .leaflet-interactive { cursor: crosshair !important; }
.map-canvas.is-picking { outline: 3px solid var(--accent); }
.map-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
.map-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 290px); min-height: 460px; overflow-y: auto; padding-right: 4px; }
.map-item {
    display: flex; gap: 10px; align-items: center; text-align: left; width: 100%;
    padding: 8px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm);
    cursor: pointer; font: inherit; color: inherit;
}
.map-item:hover { border-color: var(--primary); }
.map-item img { width: 64px; height: 52px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.map-item span { display: flex; flex-direction: column; min-width: 0; }
.map-item strong { font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-item small { font-size: .8rem; color: var(--muted); }
.map-item small.txt-open { color: var(--success); }
.map-item small.txt-full { color: var(--danger); }
.map-popup { display: flex; flex-direction: column; gap: 3px; min-width: 190px; font-family: var(--font-body); }
.map-popup strong { font: 700 1rem var(--font-head); }
.map-popup span { font-size: .84rem; color: var(--ink-2); }
.map-popup .btn { margin-top: 8px; color: #fff; }
.leaflet-container { font-family: var(--font-body); }
.leaflet-popup-content-wrapper { border-radius: var(--radius-sm); }
.leaflet-popup-content a.btn { color: #fff; text-decoration: none; }

/* Custom map pin (L.divIcon) */
.dm-pin { background: none; border: 0; }
.dm-pin__shape {
    position: relative; display: block; width: 30px; height: 30px;
    border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    background: var(--accent); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.3);
}
.dm-pin__shape::after { content: ""; position: absolute; top: 50%; left: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--ink); }
.dm-pin.is-full .dm-pin__shape { background: #A9B4BF; }
.dm-pin.is-full .dm-pin__shape::after { background: #fff; }
.dm-pin.is-picker .dm-pin__shape { background: var(--primary); }
.dm-pin.is-picker .dm-pin__shape::after { background: #fff; }

.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; }
.dot-open { background: var(--accent); border: 2px solid var(--ink); }
.dot-full { background: #A9B4BF; }

/* ---------- Forms ---------- */
label { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=file], select, textarea {
    width: 100%; font: 400 .97rem var(--font-body); color: var(--ink);
    padding: .68rem .8rem; background: var(--white);
    border: 1px solid #CBD3DB; border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
input[type=file] { padding: .5rem; background: var(--paper); }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 95, 139, .15); }
input[readonly] { background: var(--paper); color: var(--ink-2); }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(200, 69, 59, .12); }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.form-group--end { justify-content: flex-end; }
.form-group--wide { grid-column: 1 / -1; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.form-row--3 { grid-template-columns: repeat(3, 1fr); }
.form-row--tight { grid-template-columns: 1fr 1fr auto; align-items: end; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.stacked-form .panel { margin-bottom: 18px; }
.form-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
.field-error { color: var(--danger); font-size: .84rem; font-weight: 600; margin: 0; }
.hint { color: var(--muted); font-size: .84rem; margin: 0; }
.select-sm { padding: .35rem .5rem; font-size: .85rem; width: auto; }
.inline-form { display: inline; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; padding: 0; }

.role-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-switch legend { grid-column: 1 / -1; }
.role-switch label { position: relative; cursor: pointer; }
.role-switch input { position: absolute; opacity: 0; }
.role-switch span {
    display: block; height: 100%; padding: .75rem .8rem; border: 1px solid #CBD3DB; border-radius: var(--radius-sm);
    font-size: .9rem; background: var(--white); transition: all .15s;
}
.role-switch input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary); }
.role-switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-bottom: 16px; }
.check { display: flex; align-items: center; gap: 8px; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; background: var(--white); }
.check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.photo-grid:empty { display: none; }
.photo-tile { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--white); cursor: pointer; }
.photo-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-tile span { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: .84rem; font-weight: 500; }
.photo-tile:has(input:checked) { border-color: var(--danger); }
.photo-tile:has(input:checked) img { opacity: .4; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 64px; }
.password-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--primary); font: 600 .8rem var(--font-body); cursor: pointer; padding: 6px; }

/* ---------- Filter bar / tabs ---------- */
.filter-bar {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 14px;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 16px 0; margin-bottom: 18px;
}
.filter-bar .form-group { margin-bottom: 14px; }
.filter-bar__actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 0 16px; border-top: 1px solid var(--line); }
.filter-bar--compact { margin-bottom: 8px; }
.filter-bar--inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 12px 14px; }
.filter-bar--inline .form-group { margin: 0; min-width: 170px; }
.filter-bar--inline .filter-bar__actions { grid-column: auto; border: 0; padding: 0; }
.form-group--range { grid-column: span 2; }
.range-inputs { display: flex; align-items: center; gap: 8px; }
.range-inputs span { color: var(--muted); font-size: .88rem; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-bottom: 16px; }
.results-head p { margin: 0; }
.results-head .btn { margin-left: auto; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: .6rem .95rem; color: var(--muted); font-weight: 600; font-size: .93rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--grey-soft); font-size: .76rem; text-align: center; margin-left: 4px; }

/* ---------- Panels, stats ---------- */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel--flush { padding: 0; overflow: hidden; }
.panel--flush > .panel__head { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--line); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel__head h2, .panel__head h3 { margin: 0; }
.panel__title { font-size: 1.08rem; margin-bottom: 14px; }
.panel__title--spaced { margin-top: 26px; }
.note-panel { background: var(--accent-soft); border-color: #f4d9a8; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-grid--4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid--5 { grid-template-columns: repeat(5, 1fr); }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.stat__label { font-size: .86rem; color: var(--muted); font-weight: 600; }
.stat__value { font: 800 2rem/1 var(--font-head); }
.stat--attention::before { background: var(--accent); }
.stat--attention { background: var(--accent-soft); border-color: #f4d9a8; }
.stat--link { transition: box-shadow .15s, transform .15s; }
.stat--link:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); }

.welcome { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.welcome h2 { margin: 0 0 4px; font-size: 1.7rem; }
.welcome p { margin: 0; }
.active-res { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.active-res h4 { margin: 6px 0 2px; font-size: 1.15rem; }
.active-res p { margin: 0; }
.active-res__code { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted); }

.empty-state { text-align: center; padding: 48px 20px; background: var(--white); border: 1px dashed #CBD3DB; border-radius: var(--radius); }
.empty-state p { color: var(--muted); max-width: 46ch; margin: 0 auto 16px; }
.empty-state--inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; text-align: left; padding: 18px; }
.empty-state--inline p { margin: 0; }

/* ---------- Alerts ---------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin: 16px auto; }
.alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid; font-size: .94rem; margin-bottom: 14px; transition: opacity .3s; }
.flash-stack .alert { margin: 0; }
.alert-success { background: var(--success-soft); border-color: #bfe0cc; color: #1f6440; }
.alert-error { background: var(--danger-soft); border-color: #f1c5c0; color: #9b2f27; }
.alert-info { background: var(--primary-soft); border-color: #c6dcec; color: var(--primary-dark); }
.alert__close { background: none; border: 0; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; opacity: .7; padding: 0 2px; }
.alert__close:hover { opacity: 1; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .22rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; background: var(--grey-soft); color: var(--ink-2); }
.badge-pending, .badge-maintenance { background: var(--warning-soft); color: var(--warning); }
.badge-approved, .badge-available, .badge-active { background: var(--success-soft); color: var(--success); }
.badge-rejected, .badge-occupied { background: var(--danger-soft); color: var(--danger); }
.badge-cancelled, .badge-inactive { background: var(--grey-soft); color: var(--muted); }
.status-select { font-weight: 600; border-radius: 999px; }
.status-available { color: var(--success); border-color: #bfe0cc; background: var(--success-soft); }
.status-occupied { color: var(--danger); border-color: #f1c5c0; background: var(--danger-soft); }
.status-maintenance { color: var(--warning); border-color: #f0dbad; background: var(--warning-soft); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--paper); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfd; }
.table tr.is-highlight td { background: var(--accent-soft); }
.table td .button-row { flex-wrap: nowrap; }
.row-note { display: block; font-size: .82rem; color: var(--muted); margin-top: 3px; }

/* ---------- Dashboard shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1100;
    display: flex; flex-direction: column; gap: 4px; padding: 20px 14px;
    background: var(--ink); color: #c9d4de; overflow-y: auto;
}
.sidebar .brand { padding: 4px 8px 2px; }
.sidebar__role { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: #8da0b3; margin: 0 8px 18px; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-link { display: flex; align-items: center; gap: 12px; padding: .7rem .8rem; border-radius: var(--radius-sm); color: #c9d4de; font-weight: 600; font-size: .95rem; }
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side-link.is-active { background: rgba(242, 169, 59, .16); color: var(--accent); }
.side-link--logout { margin-top: 12px; border-top: 1px solid rgba(255,255,255,.1); border-radius: 0; padding-top: 1rem; }
.sidebar-backdrop { display: none; }
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 900; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 28px; background: rgba(255,255,255,.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar__title { font-size: 1.2rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__user { display: flex; align-items: center; gap: 10px; }
.topbar__who { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__who strong { font-size: .9rem; }
.topbar__who small { color: var(--muted); font-size: .78rem; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--ink); font: 800 1rem var(--font-head); }
.sidebar-toggle { display: none; }
.app-content { padding: 26px 28px 48px; flex: 1; }
.app-content .flash-stack { margin-top: 0; }

/* ---------- Auth pages ---------- */
.auth { display: flex; justify-content: center; padding: 48px 20px 64px; }
.auth__card { width: 100%; max-width: 520px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 34px; box-shadow: var(--shadow); }
.auth__card h1 { font-size: 1.9rem; margin-bottom: .2em; }
.auth__card form { margin-top: 22px; }
.auth__note { margin-top: 18px; text-align: center; }

/* ---------- Dorm details ---------- */
.details-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.gallery { margin-bottom: 20px; }
.gallery__main { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); background: var(--grey-soft); }
.gallery__thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.gallery__thumb { flex: 0 0 96px; padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: none; opacity: .7; }
.gallery__thumb img { width: 100%; height: 64px; object-fit: cover; }
.gallery__thumb.is-active, .gallery__thumb:hover { border-color: var(--accent); opacity: 1; }
.details-head { margin-bottom: 20px; }
.details-head h1 { margin-bottom: 6px; }
.details-head__addr { display: flex; gap: 6px; color: var(--ink-2); margin-bottom: 10px; }
.details-head__addr .icon { margin-top: 3px; }
.sticky { position: sticky; top: 84px; }
.layout-dashboard .sticky { top: 84px; }
.price-block { display: flex; flex-direction: column; margin-bottom: 16px; line-height: 1.2; }
.price-block small { color: var(--muted); }
.price-block strong { font: 800 2.2rem var(--font-head); letter-spacing: -.02em; }
.details-side .btn-block { margin-bottom: 8px; }
.contact-list { list-style: none; padding: 16px 0 0; margin: 16px 0 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; font-size: .93rem; }
.contact-list li { display: flex; align-items: center; gap: 10px; }
.contact-list .icon { color: var(--primary); }

.detail-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; margin: 0; }
.detail-list div { min-width: 0; }
.detail-list dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.detail-list dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.detail-list__wide { grid-column: 1 / -1; }
.res-detail { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.decision-form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.decision-form .button-row { justify-content: flex-end; }

.form-drawer { padding: 0; }
.form-drawer > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 16px 20px; font: 700 1.02rem var(--font-head); color: var(--primary); }
.form-drawer > summary::-webkit-details-marker { display: none; }
.form-drawer > summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; line-height: 1; }
.form-drawer[open] > summary { border-bottom: 1px solid var(--line); }
.form-drawer[open] > summary::after { content: "\2212"; }
.form-drawer > form, .form-drawer > .alert { margin: 18px 20px; }

/* ---------- Lists (owner dorms) ---------- */
.list-stack { display: flex; flex-direction: column; gap: 14px; }
.list-row { display: flex; gap: 18px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.list-row__img { width: 150px; height: 104px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; background: var(--grey-soft); }
.list-row__body { flex: 1; min-width: 0; }
.list-row__body h3 { margin: 0 0 4px; }
.list-row__meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; color: var(--muted); margin: 6px 0 0; }
.list-row__actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.list-row__actions form { margin: 0; }

/* ---------- Charts ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.chart-grid .panel { margin-bottom: 20px; }
.stack-bar { display: flex; height: 18px; border-radius: 999px; overflow: hidden; background: var(--grey-soft); }
.seg { display: block; height: 100%; }
.seg-pending { background: var(--accent); }
.seg-approved { background: var(--success); }
.seg-rejected { background: var(--danger); }
.seg-cancelled { background: #A9B4BF; }
.legend { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .88rem; }
.legend li { display: flex; align-items: center; gap: 6px; }
.bar { display: block; height: 10px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; flex: 1; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.bar--lg { height: 16px; margin-bottom: 8px; }
.bar--inline { display: inline-block; width: 90px; vertical-align: middle; margin-right: 6px; }
.col-chart { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding-top: 10px; }
.col-chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.col-chart__bar { width: 100%; max-width: 38px; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); border-radius: 6px 6px 2px 2px; }
.col-chart__val { font-weight: 700; font-size: .85rem; }
.col-chart__label { font-size: .8rem; color: var(--muted); }
.hbar-list { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 28px; align-items: center; gap: 10px; font-size: .9rem; }
.hbar__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar strong { text-align: right; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: grid; grid-template-columns: 200px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.activity li:last-child { border-bottom: 0; }
.activity__who { font-weight: 600; }
.occupancy-list { display: flex; flex-direction: column; gap: 14px; }
.occupancy { display: grid; grid-template-columns: 1fr 1.2fr auto; align-items: center; gap: 12px; font-size: .92rem; }
.occupancy__label { display: flex; flex-direction: column; min-width: 0; }
.occupancy__label strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.occupancy__pct { font-weight: 700; font-size: .85rem; white-space: nowrap; }

/* ---------- Reports ---------- */
.report { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.report__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 18px; }
.report__head h2 { margin: 0; }
.report__head p { margin: 0; }
.report .stat-grid { margin-bottom: 18px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--white); border-top: 1px solid var(--line); padding: 36px 0 20px; margin-top: 40px; }
.site-footer__inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.site-footer__inner p { max-width: 42ch; margin-top: 10px; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: flex-start; }
.site-footer__links a { color: var(--ink-2); font-weight: 600; font-size: .93rem; }
.site-footer__note { font-size: .82rem; color: var(--muted); margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.site-main { min-height: 60vh; }

/* =================================================================
   Responsive
   ================================================================= */
@media (max-width: 1100px) {
    .stat-grid--5 { grid-template-columns: repeat(3, 1fr); }
    .chart-grid { grid-template-columns: 1fr 1fr; }
    .details-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 960px) {
    .hero__grid { grid-template-columns: 1fr; gap: 28px; }
    .hero__map .map-canvas { height: 340px; }
    .details-grid { grid-template-columns: 1fr; }
    .sticky { position: static; }
    .map-layout { grid-template-columns: 1fr; }
    .map-canvas--tall { height: 60vh; min-height: 360px; }
    .map-list { max-height: none; min-height: 0; }
    .form-layout { grid-template-columns: 1fr; }
    .stat-grid--4 { grid-template-columns: repeat(2, 1fr); }
    .steps { grid-template-columns: 1fr; }
    .activity li { grid-template-columns: 1fr; gap: 2px; }

    /* Sidebar becomes an off-canvas drawer */
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-backdrop.is-open { display: block; position: fixed; inset: 0; background: rgba(27, 43, 58, .45); z-index: 1050; }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .app-content { padding: 20px 16px 40px; }
}

@media (max-width: 760px) {
    body { font-size: 15px; }
    .section { padding: 40px 0; }
    .navbar__toggle { display: inline-flex; }
    .navbar__links {
        display: none; position: absolute; top: 68px; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 4px;
        background: var(--white); border-bottom: 1px solid var(--line); padding: 12px 20px 18px; box-shadow: var(--shadow);
    }
    .navbar__links.is-open { display: flex; }
    .navbar__links .btn { margin: 4px 0 0; }
    .search-panel { grid-template-columns: 1fr; }
    .form-row, .form-row--3, .form-row--tight { grid-template-columns: 1fr; }
    .form-group--range { grid-column: auto; }
    .chart-grid { grid-template-columns: 1fr; }
    .stat-grid, .stat-grid--4, .stat-grid--5 { grid-template-columns: repeat(2, 1fr); }
    .stat__value { font-size: 1.6rem; }
    .detail-list { grid-template-columns: 1fr; }
    .list-row { flex-direction: column; align-items: stretch; }
    .list-row__img { width: 100%; height: 170px; }
    .list-row__actions { justify-content: flex-start; }
    .owner-band { padding: 28px 22px; }
    .auth__card { padding: 24px 20px; }
    .topbar__who { display: none; }
    .results-head .btn { margin-left: 0; }
    .occupancy { grid-template-columns: 1fr; gap: 4px; }

    /* Stacked responsive tables: each cell shows its data-label */
    .table--responsive thead { display: none; }
    .table--responsive, .table--responsive tbody, .table--responsive tr, .table--responsive td { display: block; width: 100%; }
    .table--responsive tr { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 6px 0; background: var(--white); }
    .table--responsive td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 6px 12px; text-align: right; }
    .table--responsive td::before { content: attr(data-label); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; }
    .table--responsive td[data-label=""]::before, .table--responsive td:not([data-label])::before { content: none; }
    .table--responsive td .button-row { flex-wrap: wrap; justify-content: flex-end; }
    .table--responsive tbody tr:last-child td { border-bottom: 0; }
}

@media (max-width: 420px) {
    .stat-grid, .stat-grid--4, .stat-grid--5 { grid-template-columns: 1fr; }
    .hero__facts { gap: 18px; }
    .legend { grid-template-columns: 1fr; }
}

/* ---------- Print (reports) ---------- */
@media print {
    .sidebar, .sidebar-backdrop, .topbar, .navbar, .site-footer, .no-print, .flash-stack { display: none !important; }
    .app-main { margin: 0; }
    .app-content { padding: 0; }
    body { background: #fff; font-size: 12px; }
    .panel, .report, .stat { border-color: #bbb; box-shadow: none; break-inside: avoid; }
    .table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a { color: inherit; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* =================================================================
   Biñan City map: barangay markers, boundary legend, notices
   ================================================================= */
.brgy-pin { background: none; border: 0; }
.brgy-pin__dot {
    display: block; width: 16px; height: 16px; border-radius: 50%;
    background: var(--ink); border: 3px solid #fff;
    box-shadow: 0 0 0 1.5px var(--ink), 0 2px 6px rgba(0,0,0,.3);
    cursor: pointer; transition: transform .15s;
}
.brgy-pin:hover .brgy-pin__dot, .brgy-pin:focus .brgy-pin__dot { transform: scale(1.25); }
.brgy-pin__label {
    display: none; position: absolute; left: 50%; top: 20px; transform: translateX(-50%);
    white-space: nowrap; padding: 2px 7px; border-radius: 999px;
    background: rgba(27, 43, 58, .88); color: #fff;
    font: 600 11px/1.5 var(--font-body); letter-spacing: .01em; pointer-events: none;
}
.brgy-pin:hover .brgy-pin__label, .brgy-pin:focus .brgy-pin__label,
.show-brgy-labels .brgy-pin__label { display: block; }
.map-popup__kicker { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.dot-brgy { background: var(--ink); border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--ink); }
.line-boundary { display: inline-block; width: 22px; border-top: 3px dashed var(--primary); vertical-align: middle; }

.map-wrap { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.map-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .84rem; color: var(--ink-2); }
.map-legend li { display: inline-flex; align-items: center; gap: 7px; }
.map-notice { margin-bottom: 10px; }
.map-notice[hidden] { display: none; }

.service-banner {
    display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px;
    padding: 12px 16px; border-radius: var(--radius); background: var(--primary-soft);
    border: 1px solid #c6dcec; color: var(--primary-dark);
}
.service-banner p { margin: 0; font-size: .93rem; }
.service-banner .icon { margin-top: 2px; }

.hero__kicker {
    display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px;
    padding: .35rem .8rem; border-radius: 999px; background: var(--accent-soft);
    color: var(--ink); font-weight: 700; font-size: .88rem;
}
.hero__facts dd small { font: 600 .9rem var(--font-body); color: var(--muted); }

.picker-note { font-size: .88rem; font-weight: 600; margin: -6px 0 12px; min-height: 1.3em; color: var(--muted); }
.picker-note.is-ok { color: var(--success); }
.picker-note.is-bad { color: var(--danger); }

/* Bigger tap targets on touch screens */
@media (pointer: coarse) {
    .brgy-pin__dot { width: 20px; height: 20px; margin: -2px; }
    .leaflet-popup-content .btn { padding: .65rem 1rem; }
}
@media (max-width: 760px) {
    .map-canvas--tall { height: 62vh; min-height: 340px; }
    .service-banner { padding: 10px 12px; }
    .map-legend { font-size: .8rem; }
}
