:root {
    --navy: #0b2e5e;
    --navy-2: #123f78;
    --blue: #1877b9;
    --blue-soft: #eaf5fc;
    --green: #238757;
    --green-soft: #e8f7ef;
    --amber: #a66a00;
    --amber-soft: #fff1cc;
    --red: #c62f43;
    --red-soft: #fff1f3;
    --ink: #11243f;
    --muted: #68778c;
    --line: #d8e0e9;
    --surface: #ffffff;
    --background: #f2f5f8;
    --shadow: 0 10px 28px rgba(11, 46, 94, .08);
    color: var(--ink);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #dde5ed; }
body { margin: 0; min-height: 100vh; background: #dde5ed; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:disabled { opacity: .58; cursor: wait; }

.app-shell {
    position: relative;
    width: min(100%, 540px);
    min-height: 100vh;
    margin: 0 auto;
    background: var(--background);
    box-shadow: 0 0 50px rgba(11, 46, 94, .16);
    overflow-x: hidden;
}

.app-shell[data-route="request"] { padding-bottom: 84px; }

.auth-page {
    min-height: 100vh;
    padding: max(40px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
    display: grid;
    place-items: center;
}

.auth-card {
    width: 100%;
    padding: 24px 20px;
    display: grid;
    gap: 14px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    text-align: left;
}

.auth-card h1 { margin: 2px 0 0; font-size: 23px; text-align: center; }
.auth-card p { margin: 0; color: var(--muted); line-height: 1.5; text-align: center; }
.auth-card label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.auth-card input { text-transform: uppercase; }
.auth-help { color: var(--muted); text-align: center; }
.auth-status { justify-items: center; }
.auth-icon {
    width: 66px;
    height: 66px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(145deg, var(--navy), var(--blue));
    border-radius: 20px;
    font-size: 20px;
    font-weight: 800;
}
.auth-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--blue-soft);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: auth-spin .8s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 68px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.topbar-main { display: flex; align-items: center; min-width: 0; gap: 11px; }
.topbar-copy { display: flex; min-width: 0; flex-direction: column; }
.topbar-copy span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.topbar-copy strong { overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark, .profile-avatar, .message-avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: linear-gradient(145deg, var(--navy), var(--blue));
    font-weight: 800;
}
.brand-mark { width: 40px; height: 40px; font-size: 13px; }
.icon-button { position: relative; display: grid; width: 42px; height: 42px; padding: 0; place-items: center; border: 0; border-radius: 12px; background: transparent; cursor: pointer; }
.icon-button:active { background: var(--blue-soft); }
.notification-button b { position: absolute; top: 2px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; color: white; background: var(--red); border: 2px solid white; border-radius: 10px; font-size: 10px; line-height: 14px; }

.page { min-height: calc(100vh - 146px); padding: 18px 16px 104px; }
.preview-note { margin-bottom: 14px; padding: 8px 12px; color: #684d00; background: #fff4cf; border: 1px solid #f3d979; border-radius: 10px; font-size: 12px; text-align: center; }
.welcome p { margin: 0; color: var(--muted); font-size: 15px; }
.welcome h1 { margin: 2px 0 16px; font-size: 29px; letter-spacing: -.025em; }

.support-line, .support-card { color: inherit; font: inherit; text-decoration: none; }
.support-line { min-height: 48px; padding: 10px 12px; display: flex; align-items: center; gap: 9px; background: var(--blue-soft); border-radius: 12px; }
.support-line:is(button), .support-card:is(button) { border: 0; cursor: pointer; }
.support-line .icon { color: var(--blue); }
.support-line span { color: var(--muted); font-size: 13px; }
.support-line strong { margin-left: auto; }

.summary-card, .receipt-card, .support-card {
    width: 100%;
    margin-top: 14px;
    min-height: 74px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 13px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: var(--shadow);
    text-align: left;
    cursor: pointer;
}
.summary-card > span:nth-child(2), .receipt-card > span, .support-card > span { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.summary-card small, .receipt-card small, .support-card small { color: var(--muted); font-style: normal; }
.summary-card strong { font-size: 28px; line-height: 1; }
.summary-card b, .receipt-card b { margin-left: auto; font-size: 26px; font-weight: 400; }
.summary-icon, .request-icon, .notification-icon { display: grid; flex: 0 0 auto; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 12px; }
.summary-icon { width: 46px; height: 46px; }
.receipt-card > .icon { width: 30px; height: 30px; color: var(--blue); }

.primary-button, .secondary-button, .danger-button {
    min-height: 48px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    font-weight: 750;
    cursor: pointer;
}
.primary-button { color: white; background: var(--navy); border: 1px solid var(--navy); }
.primary-button:active { background: var(--navy-2); }
.secondary-button { color: var(--navy); background: white; border: 1px solid #aebdd0; }
.danger-button { color: var(--red); background: white; border: 1px solid #ef9dab; }
.large-button { width: 100%; margin-top: 14px; }
.large-button .icon { width: 20px; height: 20px; }
.disabled-file { cursor: default; opacity: .72; }

.section-block { margin-top: 24px; }
.section-heading { min-height: 36px; display: flex; align-items: center; gap: 8px; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading button { min-height: 36px; margin-left: auto; padding: 0 8px; color: var(--blue); background: transparent; border: 0; font-weight: 700; cursor: pointer; }
.section-heading > span { display: grid; min-width: 24px; height: 24px; place-items: center; color: var(--muted); background: #e6ebf1; border-radius: 12px; font-size: 12px; }

.request-list { margin-top: 12px; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 14px; }
.request-row { position: relative; width: 100%; min-height: 80px; padding: 12px 44px 12px 12px; display: flex; align-items: center; gap: 11px; background: white; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; }
.request-row:last-child { border-bottom: 0; }
.request-row:active { background: #f6f9fc; }
.request-icon { width: 38px; height: 38px; }
.request-row-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.request-row-copy small { color: var(--muted); font-size: 11px; }
.request-row-copy strong { margin-top: 2px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.request-row-copy em { color: var(--muted); font-size: 12px; font-style: normal; }
.chevron { position: absolute; right: 14px; color: var(--muted); font-size: 24px; }
.status { padding: 5px 9px; flex: 0 0 auto; border-radius: 9px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-new { color: #11639c; background: #dff1fd; }
.status-progress, .status-waiting { color: var(--amber); background: var(--amber-soft); }
.status-completed { color: var(--green); background: var(--green-soft); }

.search-field { min-height: 48px; padding: 0 13px; display: flex; align-items: center; gap: 9px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.search-field .icon { color: var(--muted); }
.search-field input { width: 100%; height: 46px; background: transparent; border: 0; outline: none; }
.filter-tabs { margin-top: 12px; padding: 4px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; background: #e7edf3; border-radius: 12px; }
.filter-tabs button { min-height: 40px; background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.filter-tabs button.active { color: white; background: var(--blue); font-weight: 750; }
.sticky-action { position: sticky; bottom: 90px; width: min(100%, 260px); margin: 18px auto 0; display: flex; box-shadow: 0 10px 25px rgba(11,46,94,.22); }
.empty-state { padding: 28px 16px; color: var(--muted); text-align: center; }

.form-page form { display: grid; gap: 15px; }
.form-page label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; color: var(--ink); background: white; border: 1px solid #bdc9d6; border-radius: 10px; outline: none; }
input, select { min-height: 47px; padding: 0 12px; }
textarea { padding: 12px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(24,119,185,.13); }
.file-picker { min-height: 76px; padding: 13px; display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 12px !important; color: var(--blue); background: #f7fbfe; border: 1px dashed #73add2; border-radius: 12px; cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker span { display: flex; flex-direction: column; }
.file-picker small { color: var(--muted); font-weight: 400; }
.selected-files { display: flex; flex-wrap: wrap; gap: 8px; }
.selected-files span { padding: 7px 9px; display: inline-flex; align-items: center; gap: 6px; background: white; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.selected-files .icon { width: 15px; height: 15px; }

.request-title { padding: 0 2px 16px; display: flex; align-items: flex-start; gap: 12px; }
.request-title > div { min-width: 0; flex: 1; }
.request-title h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.request-title p { margin: 5px 0 0; color: var(--muted); }
.request-facts, .description-card, .chat-section { background: white; border: 1px solid var(--line); border-radius: 14px; }
.request-facts { padding: 4px 14px; }
.request-facts p { min-height: 46px; margin: 0; padding: 8px 0; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.request-facts p:last-child { border-bottom: 0; }
.request-facts span { color: var(--muted); font-size: 12px; }
.request-facts strong { margin-left: auto; font-size: 13px; text-align: right; }
.description-card { margin-top: 12px; padding: 14px; }
.description-card h2 { margin: 0 0 7px; font-size: 14px; }
.description-card p { margin: 0; line-height: 1.5; }
.chat-section { margin-top: 12px; padding: 12px; }
.chat-list { margin-top: 6px; display: grid; gap: 13px; }
.message { display: flex; align-items: flex-start; gap: 9px; }
.message.resident { flex-direction: row-reverse; }
.message-avatar { width: 34px; height: 34px; font-size: 11px; }
.message > div { width: min(82%, 370px); }
.message header { margin: 0 4px 4px; display: flex; align-items: center; gap: 8px; }
.message header strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.message header time { margin-left: auto; color: var(--muted); font-size: 10px; }
.message p { margin: 0; padding: 10px 11px; background: #eef2f6; border-radius: 4px 13px 13px; line-height: 1.4; }
.message.resident p { background: #dff1fc; border-radius: 13px 4px 13px 13px; }
.message-file { margin-top: 5px; padding: 6px 8px; display: inline-flex; align-items: center; gap: 5px; color: var(--navy); background: white; border: 1px solid var(--line); border-radius: 8px; }
.message-file .icon { width: 14px; height: 14px; }
.chat-composer { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; width: min(100%, 540px); min-height: 72px; margin: 0 auto; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: 42px 1fr 44px; align-items: end; gap: 7px; background: rgba(255,255,255,.98); border-top: 1px solid var(--line); }
.chat-composer textarea { min-height: 44px; max-height: 110px; padding: 11px; resize: none; }
.chat-composer button, .composer-file { width: 44px; height: 44px; display: grid; place-items: center; color: white; background: var(--navy); border: 0; border-radius: 12px; cursor: pointer; }
.composer-file { color: var(--navy); background: #edf2f7; }
.composer-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.mark-all { width: 100%; min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--blue); background: var(--blue-soft); border: 0; border-radius: 10px; font-weight: 750; cursor: pointer; }
.notification-group { margin-top: 18px; }
.notification-group h2 { margin: 0 0 8px; font-size: 14px; }
.notification-group > div { overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 13px; }
.notification-row { position: relative; width: 100%; min-height: 74px; padding: 11px 46px 11px 22px; display: flex; align-items: flex-start; gap: 10px; background: white; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; }
.notification-row:last-child { border-bottom: 0; }
.notification-row.unread { background: #f5fbff; }
.unread-dot { position: absolute; top: 18px; left: 9px; width: 7px; height: 7px; background: transparent; border-radius: 50%; }
.unread .unread-dot { background: var(--blue); }
.notification-icon { width: 36px; height: 36px; }
.notification-row > span:nth-child(3) { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.notification-row strong { font-size: 13px; }
.notification-row small { margin-top: 3px; color: var(--muted); line-height: 1.3; }
.notification-row time { position: absolute; top: 12px; right: 10px; color: var(--muted); font-size: 10px; }

.profile-card { padding: 18px; display: flex; align-items: center; gap: 14px; background: white; border: 1px solid var(--line); border-radius: 15px; }
.profile-avatar { width: 64px; height: 64px; font-size: 21px; }
.profile-card h1 { margin: 0; font-size: 20px; }
.profile-card p { margin: 4px 0 0; color: var(--muted); }
.profile-details { margin-top: 12px; padding: 4px 14px; background: white; border: 1px solid var(--line); border-radius: 14px; }
.profile-details p { min-height: 46px; margin: 0; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.profile-details p:last-child { border-bottom: 0; }
.profile-details .icon, .detail-symbol { width: 24px; color: var(--blue); text-align: center; }
.support-card { box-shadow: none; }
.support-card > .icon { color: var(--blue); }
.council-card { margin-top: 12px; min-height: 72px; padding: 13px; display: flex; align-items: center; gap: 11px; background: var(--green-soft); border: 1px solid #bce4cd; border-radius: 14px; }
.council-icon { display: grid; width: 44px; height: 44px; place-items: center; color: white; background: var(--green); border-radius: 12px; font-size: 11px; font-weight: 800; }
.council-card > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.council-card small { color: var(--green); }
.profile-page > .secondary-button, .profile-page > .danger-button { width: 100%; margin-top: 12px; }

.bottom-nav { position: fixed; z-index: 25; right: 0; bottom: 0; left: 0; width: min(100%, 540px); min-height: 76px; margin: 0 auto; padding: 7px 6px max(7px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(255,255,255,.98); border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
.bottom-nav button { min-width: 0; padding: 0 2px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3px; color: #748196; background: transparent; border: 0; cursor: pointer; }
.bottom-nav button.active { color: var(--navy); }
.bottom-nav button span { position: relative; display: grid; place-items: center; }
.bottom-nav small { overflow: hidden; width: 100%; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav .nav-create span { width: 48px; height: 48px; margin-top: -25px; color: white; background: var(--blue); border: 4px solid white; border-radius: 50%; box-shadow: 0 5px 16px rgba(24,119,185,.28); }
.bottom-nav .nav-create small { margin-top: -2px; }

.toast-region { position: fixed; z-index: 100; right: 12px; bottom: 92px; left: 12px; width: min(calc(100% - 24px), 500px); margin: 0 auto; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 12px 14px; color: white; background: rgba(17,36,63,.96); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.22); text-align: center; animation: toast-in .18s ease-out; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (min-width: 700px) {
    body { padding: 24px 0; }
    .app-shell { min-height: calc(100vh - 48px); border-radius: 22px; }
    .bottom-nav, .chat-composer { bottom: 24px; border-radius: 0 0 22px 22px; }
    .topbar { border-radius: 22px 22px 0 0; }
}

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