/* Dashboard page styles. Builds on site.css and reuses landing.css
   components (workspace, feed, record, filter, demo-pill, mapcard). */

.dash-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 40px;
    margin: 20px 0 30px
}

.dash-head h1 {
    font-size: clamp(34px, 3.6vw, 50px);
    letter-spacing: -3px
}

.dash-aside {
    width: 300px;
    flex-shrink: 0;
    padding-bottom: 4px
}

.dash-aside p {
    font-size: 13px;
    line-height: 1.75;
    color: var(--muted);
    margin: 0 0 18px
}

.dash-aside .button {
    width: 100%
}

.app-error {
    border: 1px solid #d8b7ad;
    background: #f8efe9;
    color: #7c4a37;
    border-radius: 9px;
    padding: 13px 18px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px
}

.app-error button {
    border: 1px solid #d8b7ad;
    background: transparent;
    border-radius: 5px;
    font-size: 11px;
    padding: 6px 10px;
    color: #7c4a37
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr) 1.35fr;
    gap: 12px;
    margin-bottom: 17px
}

.stat {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fffefa;
    padding: 17px 19px
}

.stat .k {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8a9983
}

.stat .v {
    font-family: Manrope, sans-serif;
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -1px;
    margin: 8px 0 2px
}

.stat .s {
    font-size: 10px;
    color: #94a18b
}

.stat.coverage {
    background: #1e382f;
    border-color: #1e382f;
    color: #d3dfd0
}

.stat.coverage .k {
    color: #8fa896
}

.stat.coverage .bars {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 15px 0 10px;
    background: #16291f
}

.stat.coverage .bars i {
    height: 100%;
    min-width: 0
}

.stat.coverage .legend {
    font-size: 9px;
    color: #9db3a2;
    display: flex;
    gap: 10px;
    flex-wrap: wrap
}

.stat.coverage .legend b {
    color: #d3dfd0;
    font-weight: 500
}

.top-right {
    display: flex;
    gap: 6px;
    align-items: center
}

.layer-chip {
    font-size: 9px;
    border: 1px solid #d7ddcf;
    border-radius: 20px;
    padding: 5px 9px;
    color: #6a7867;
    background: transparent
}

.layer-chip.active {
    background: var(--ink);
    border-color: var(--ink);
    color: white
}

.layer-chip:disabled {
    opacity: .45;
    cursor: default
}

.scope {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #52634c;
    background: #eef2e4;
    border: 1px solid #dbe2d0;
    border-radius: 6px;
    padding: 8px 11px;
    margin-bottom: 12px
}

.scope button {
    border: 0;
    background: transparent;
    color: #7c8e72;
    font-size: 11px;
    padding: 0 2px
}

.feed .empty {
    font-size: 11px;
    color: #8a9484;
    line-height: 1.7;
    padding: 14px 0
}

/* Map */
.workspace .map {
    min-height: 560px;
    background: #e8ecdf
}

.map-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #8a9682;
    z-index: 500
}

.map-loading[hidden] {
    display: none
}

.map-key {
    z-index: 500
}

/* Leaflet skin to match the product */
.leaflet-container {
    font-family: 'DM Sans', sans-serif
}

/* Soften the standard OSM tiles toward the paper palette */
.leaflet-tile-pane {
    filter: saturate(.72) brightness(1.01)
}

.leaflet-popup-content-wrapper {
    background: #fffef9;
    color: var(--ink);
    border-radius: 9px;
    box-shadow: 0 10px 30px #30442426;
    padding: 4px
}

.leaflet-popup-content {
    margin: 12px 16px;
    font-size: 11px;
    line-height: 1.6
}

.leaflet-popup-content strong {
    font-family: Manrope, sans-serif;
    font-size: 13px;
    display: block;
    margin-bottom: 3px
}

.leaflet-popup-content .popup-kind {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #7c8e72
}

.leaflet-popup-content .popup-src {
    display: inline-block;
    margin-top: 7px;
    font-size: 10px;
    border-bottom: 1px solid #9cac9e;
    padding-bottom: 2px
}

.leaflet-popup-tip {
    background: #fffef9
}

.leaflet-container a.leaflet-popup-close-button {
    color: #8a9682
}

.leaflet-control-zoom a {
    background: #fffef9 !important;
    color: var(--ink) !important;
    border-radius: 0 !important
}

.leaflet-control-attribution {
    background: #f6f8ecde !important;
    color: #79836d !important;
    font-size: 9px !important
}

/* Bottom panels */
.dash-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 17px;
    margin: 17px 0 60px
}

.panel {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fffefa;
    padding: 26px 28px
}

.panel h3 {
    font-family: Manrope, sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.4px;
    margin: 0 0 20px
}

.bar-row {
    display: grid;
    grid-template-columns: 130px 1fr 44px;
    gap: 14px;
    align-items: center;
    padding: 6px 0
}

.bar-row .k {
    font-size: 11px;
    color: #5c6b58
}

.bar-row .track {
    height: 10px;
    background: #edf0e4;
    border-radius: 5px;
    overflow: hidden
}

.bar-row .fill {
    height: 100%;
    background: #47664e;
    border-radius: 5px
}

.bar-row.hl .fill {
    background: #a9c45e
}

.bar-row .n {
    font-size: 11px;
    color: #8a9983;
    text-align: right
}

.top-list {
    margin: 0;
    padding: 0;
    list-style: none
}

.top-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid #edf0e6;
    font-size: 12px;
    cursor: pointer
}

.top-list li:last-child {
    border: 0
}

.top-list .rank {
    font-size: 10px;
    color: #97a58d;
    width: 26px
}

.top-list .name {
    flex: 1
}

.top-list .cnt {
    font-family: Manrope, sans-serif;
    font-weight: 600;
    font-size: 13px
}

/* API key gate */
.gate {
    position: fixed;
    inset: 0;
    background: #f7f8f3f5;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    padding: 20px
}

.gate[hidden] {
    display: none
}

.gate-card {
    background: #fffef9;
    border: 1px solid var(--line);
    border-radius: 13px;
    box-shadow: 0 18px 55px #203c2710;
    padding: 40px;
    max-width: 420px;
    width: 100%
}

.gate-card h2 {
    font-family: Manrope, sans-serif;
    font-size: 26px;
    font-weight: 500;
    letter-spacing: -1.5px;
    margin: 14px 0 10px
}

.gate-card p {
    font-size: 12px;
    line-height: 1.8;
    color: var(--muted);
    margin: 0 0 18px
}

.gate-card input {
    width: 100%;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
    font-size: 12px;
    margin-bottom: 14px
}

.gate-card .button {
    width: 100%
}

.gate-error {
    color: #a04b32 !important;
    font-size: 11px !important
}

.gate-card .form-note {
    font-size: 10px !important;
    color: #9aa790 !important;
    margin: 14px 0 0 !important
}

@media (max-width:1050px) {
    .dash-head {
        display: block
    }

    .dash-aside {
        width: auto;
        margin-top: 20px;
        max-width: 420px
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr)
    }

    .dash-bottom {
        grid-template-columns: 1fr
    }

    .top-right .demo-pill {
        display: none
    }
}

/* The landing hides the feed on small screens; the dashboard keeps it. */
@media (max-width:760px) {
    .dash-head h1 {
        font-size: 38px;
        letter-spacing: -2.4px
    }

    .feed {
        display: block
    }

    .workspace .map {
        min-height: 430px
    }

    .workspace-top {
        height: auto;
        min-height: 57px;
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px
    }

    .bar-row {
        grid-template-columns: 96px 1fr 40px;
        gap: 10px
    }

    .panel {
        padding: 20px
    }
}

/* The internal panel is a wide work surface: search and records stay beside
   the map while the headline and summary strip use less vertical space. */
.shell {
    max-width: 1800px;
    padding-right: 48px;
    padding-left: 48px
}

.dash-head {
    align-items: center;
    gap: 28px;
    margin: 15px 0 16px
}

.dash-head h1 {
    margin: 5px 0 0;
    font-size: clamp(29px, 2.5vw, 37px);
    line-height: 1.12;
    letter-spacing: -1.8px
}

.dash-head h1 span {
    color: #829656
}

.dash-aside {
    width: auto;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0
}

.dash-aside p {
    max-width: 290px;
    margin: 0;
    font-size: 12px;
    line-height: 1.55
}

.dash-aside .button {
    width: auto;
    flex-shrink: 0;
    padding: 12px 16px;
    white-space: nowrap
}

.stats-row {
    grid-template-columns: repeat(4, minmax(120px, 1fr)) minmax(230px, 1.45fr);
    gap: 9px;
    margin-bottom: 12px
}

.stat {
    padding: 12px 15px;
    border-radius: 8px
}

.stat .k {
    font-size: 9px;
    letter-spacing: .8px
}

.stat .v {
    font-size: 25px;
    margin: 5px 0 0
}

.stat .s {
    font-size: 9px
}

.stat.coverage .bars {
    margin: 11px 0 8px
}

.stat.coverage .legend {
    gap: 5px 9px
}

.workspace-top {
    height: 50px;
    padding: 0 18px
}

.workspace-inner {
    grid-template-columns: minmax(345px, .84fr) minmax(0, 2.16fr);
    height: clamp(480px, 60vh, 640px);
    min-height: 0
}

.feed {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 16px;
    border-right: 1px solid #e5e8dd
}

.feed-title {
    align-items: baseline;
    margin-bottom: 11px
}

.feed-title span {
    font-variant-numeric: tabular-nums
}

.feed-search {
    display: flex;
    gap: 7px;
    margin: 0 0 11px
}

.search-field {
    min-width: 0;
    min-height: 37px;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 9px;
    border: 1px solid #dce3d8;
    border-radius: 6px;
    background: #fff
}

.search-field:focus-within {
    border-color: #829656;
    box-shadow: 0 0 0 3px #8296561c
}

.search-field svg {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    fill: none;
    stroke: #829083;
    stroke-width: 1.7;
    stroke-linecap: round
}

.search-field input {
    min-width: 0;
    flex: 1;
    padding: 8px 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: 11px
}

.search-field input::placeholder {
    color: #929d8e
}

.search-field input::-webkit-search-cancel-button {
    display: none
}

.search-field button {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: #f0f2ea;
    color: #697867;
    font-size: 15px;
    line-height: 1
}

.search-field button[hidden] {
    display: none
}

.search-submit {
    flex: 0 0 auto;
    border: 1px solid var(--ink);
    border-radius: 6px;
    padding: 0 12px;
    background: var(--ink);
    color: #fff;
    font-size: 10px;
    font-weight: 600
}

.search-submit:hover {
    background: #284b3f
}

.filter {
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px
}

.filter button {
    flex: 0 0 auto;
    border-radius: 99px;
    padding: 5px 8px;
    font-size: 9px
}

.feed #records {
    min-height: 0;
    flex: 1;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-color: #c8d0c1 transparent;
    scrollbar-width: thin
}

.feed .record {
    padding: 12px 4px
}

.feed .record.active {
    padding: 12px
}

.feed .empty {
    margin: 0;
    padding: 20px 4px;
    font-size: 11px
}

.load-more {
    flex: 0 0 auto;
    width: 100%;
    margin-top: 8px;
    padding: 9px 12px;
    border: 1px solid #dce3d8;
    border-radius: 6px;
    background: #fffefa;
    color: var(--ink);
    font-size: 10px;
    font-weight: 600
}

.load-more:hover:not(:disabled) {
    background: #f0f3e9
}

.load-more:disabled {
    color: #8a9983;
    cursor: wait
}

.load-more[hidden] {
    display: none
}

.workspace .map {
    height: 100%;
    min-height: 0
}

.map-key {
    padding: 7px 10px;
    font-size: 9px
}

.dash-bottom {
    gap: 12px;
    margin: 12px 0 35px
}

.panel {
    padding: 16px 20px;
    border-radius: 8px
}

.panel h3 {
    margin-bottom: 10px;
    font-size: 14px
}

.bar-row {
    grid-template-columns: 125px 1fr 40px;
    gap: 10px;
    padding: 4px 0
}

.top-list li {
    padding: 7px 0;
    font-size: 11px
}

.top-list .cnt {
    font-size: 12px
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0
}

@media (max-width: 1279px) {
    .shell {
        padding-right: 30px;
        padding-left: 30px
    }

    .stats-row {
        grid-template-columns: repeat(4, minmax(110px, 1fr)) minmax(190px, 1.3fr)
    }
}

@media (max-width: 1050px) {
    .dash-head {
        align-items: flex-start
    }

    .dash-aside {
        margin-top: 0;
        max-width: none
    }

    .dash-aside p {
        max-width: 230px
    }

    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }

    .stat.coverage {
        grid-column: span 2
    }

    .workspace-inner {
        grid-template-columns: minmax(300px, .95fr) minmax(0, 1.6fr);
        height: clamp(450px, 58vh, 570px)
    }
}

@media (max-width: 760px) {
    .shell {
        padding-right: 20px;
        padding-left: 20px
    }

    header {
        height: 76px
    }

    .dash-head {
        display: block;
        margin: 18px 0 16px
    }

    .dash-head h1 {
        font-size: 32px;
        letter-spacing: -1.6px
    }

    .dash-aside {
        justify-content: space-between;
        gap: 12px;
        margin-top: 12px
    }

    .dash-aside p {
        max-width: 230px;
        font-size: 11px
    }

    .dash-aside .button {
        padding: 10px 12px;
        font-size: 10px
    }

    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
        margin-bottom: 10px
    }

    .stat {
        padding: 11px 12px
    }

    .stat.coverage {
        grid-column: 1 / -1
    }

    .workspace-top {
        height: auto;
        min-height: 54px;
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px
    }

    .workspace-region {
        display: none
    }

    .top-right {
        flex-wrap: wrap
    }

    .workspace-inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        height: auto;
        min-height: 0
    }

    .feed {
        height: 370px;
        border-right: 0;
        border-bottom: 1px solid #e5e8dd;
        padding: 14px
    }

    .workspace .map {
        height: min(70vw, 420px);
        min-height: 310px
    }

    .dash-bottom {
        grid-template-columns: 1fr;
        margin-bottom: 28px
    }

    .panel {
        padding: 16px
    }
}

.app-error[hidden] {
    display: none
}

.bar-row {
    width: 100%;
    border: 0;
    border-bottom: 1px solid transparent;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer
}

.bar-row .track {
    width: 100%
}

.bar-row .fill {
    display: block
}

.bar-row:hover .k,
.bar-row.selected .k {
    color: var(--ink);
    font-weight: 600
}

.bar-row.selected .track {
    outline: 1px solid #829656;
    outline-offset: 2px
}

.city-filter {
    margin: 0 0 10px
}

.city-field {
    min-height: 35px
}

.city-field input {
    font-size: 10px
}

.city-hint {
    display: block;
    padding: 5px 2px 0;
    color: #8a6e4a;
    font-size: 9px
}

.city-hint[hidden] {
    display: none
}

.document-dialog {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    width: min(1120px, calc(100vw - 48px));
    height: min(850px, calc(100vh - 48px));
    max-width: none;
    max-height: none;
    padding: 0;
    overflow: hidden;
    border: 1px solid #dce3d8;
    border-radius: 12px;
    background: #fffefa;
    color: var(--ink);
    box-shadow: 0 24px 80px #102a1e40
}

.document-dialog[open] {
    margin: auto
}

.document-dialog:not([open]) {
    display: none
}

.document-dialog::backdrop {
    background: #10251dcc;
    backdrop-filter: blur(3px)
}

.document-header {
    height: auto;
    min-height: 78px;
    gap: 18px;
    padding: 15px 20px;
    border-bottom: 1px solid #e3e8df
}

.document-heading {
    min-width: 0;
    flex: 1
}

.document-meta {
    margin-bottom: 5px;
    color: #829083;
    font-size: 10px;
    letter-spacing: .4px
}

.document-heading h2 {
    overflow: hidden;
    margin: 0;
    font-family: Manrope, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    text-overflow: ellipsis
}

.document-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    font-size: 10px
}

.document-actions button,
.document-actions a {
    display: inline-flex;
    min-width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border: 1px solid #dce3d8;
    border-radius: 5px;
    background: #fffefa;
    color: var(--ink);
    font-size: 10px
}

.document-actions button:disabled {
    opacity: .4;
    cursor: default
}

.document-actions a {
    white-space: nowrap
}

.document-actions .document-close {
    width: 30px;
    padding: 0;
    font-size: 18px
}

.document-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 18px 0;
    border-bottom: 1px solid #e3e8df
}

.document-tabs button {
    padding: 9px 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #748173;
    font-size: 11px
}

.document-tabs button[aria-selected="true"] {
    border-bottom-color: #829656;
    color: var(--ink);
    font-weight: 600
}

.document-panel {
    min-height: 0;
    overflow: hidden
}

.document-panel[hidden],
.document-actions [hidden],
.document-panel [hidden] {
    display: none
}

.pdf-panel:not([hidden]) {
    display: flex;
    flex-direction: column;
    align-items: stretch
}

.pdf-panel iframe {
    width: 100%;
    min-height: 0;
    flex: 1;
    border: 0;
    background: #eef0eb
}

.pdf-open {
    align-self: flex-end;
    padding: 9px 15px;
    color: #657650;
    font-size: 10px
}

.document-message {
    align-self: center;
    margin: auto;
    padding: 24px;
    color: #778474;
    font-size: 12px;
    line-height: 1.7;
    text-align: center
}

.text-panel:not([hidden]) {
    overflow: auto;
    padding: 22px clamp(20px, 5vw, 64px) 42px
}

.markdown-body {
    max-width: 760px;
    margin: 0 auto;
    color: #283d32;
    font-size: 13px;
    line-height: 1.8;
    overflow-wrap: anywhere
}

.markdown-body p {
    margin: 0 0 1em
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin: 1.4em 0 .5em;
    font-family: Manrope, sans-serif;
    font-size: 1.15em;
    font-weight: 700;
    letter-spacing: -.2px
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
    margin-top: 0
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.5em;
    margin: 0 0 1em
}

.markdown-body li + li {
    margin-top: .25em
}

.markdown-body blockquote {
    margin: 1em 0;
    padding: 3px 0 3px 14px;
    border-left: 2px solid #a8bb84;
    color: #6d7b73
}

.markdown-body pre {
    padding: 14px;
    overflow: auto;
    border-radius: 6px;
    background: #f0f2ea;
    font-size: 11px;
    white-space: pre-wrap
}

.markdown-body code {
    padding: 1px 4px;
    border-radius: 3px;
    background: #f0f2ea;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .92em
}

.markdown-body pre code {
    padding: 0;
    background: transparent
}

.markdown-body a {
    color: #47664e;
    text-decoration: underline;
    text-underline-offset: 2px
}

.markdown-body hr {
    margin: 1.5em 0;
    border: 0;
    border-top: 1px solid #dce3d8
}

@media (max-width: 760px) {
    .document-dialog {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        border-radius: 8px
    }

    .document-header {
        align-items: flex-start;
        gap: 10px;
        padding: 12px
    }

    .document-heading h2 {
        font-size: 14px
    }

    .document-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 4px
    }

    .document-actions a {
        order: 2;
        width: 100%
    }

    .document-tabs {
        padding-left: 10px
    }
}
