/* Shared layout and default signed-out theme. */
body {
        color-scheme: light;
        font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        --bg: #f6f8fc;
        --card: #ffffff;
        --border: #dce4f0;
        --text: #162033;
        --muted: #5f6b7a;
        --accent: #0D3B66;
        --accent-2: #2BB3B8;
        --ink: #162033;
      }

      body {
        --theme-surface: color-mix(in srgb, var(--accent-2) 5%, white);
        --theme-soft: color-mix(in srgb, var(--accent-2) 15%, white);
        --theme-border: color-mix(in srgb, var(--accent-2) 35%, white);
      }

      * { box-sizing: border-box; }
      body {
        margin: 0;
        background: var(--bg);
        color: var(--text);
      }

      .page {
        max-width: 1120px;
        margin: 0 auto;
        padding: 24px;
      }

      .toast-container {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 1000;
        display: grid;
        gap: 10px;
        width: min(360px, calc(100vw - 32px));
      }

      .toast {
        display: none;
        border-radius: 12px;
        padding: 12px 14px;
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.96);
        box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
        font-weight: 600;
      }
      .toast.show { display: block; }
      .toast.success {
        background: #ecfdf5;
        border-color: #86efac;
        color: #166534;
      }
      .toast.error {
        background: #fef2f2;
        border-color: #fca5a5;
        color: #991b1b;
      }
      .toast.info {
        background: var(--theme-soft);
        border-color: var(--theme-border);
        color: var(--accent);
      }

      .hero, .panel {
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 18px;
        box-shadow: 0 10px 30px rgba(22, 32, 51, 0.045);
      }

      .hero {
        padding: 24px;
        display: flex;
        justify-content: space-between;
        gap: 16px;
        align-items: center;
      }

      .hero-copy { min-width: 0; }
      .hero-brand {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 12px;
        flex-shrink: 0;
        max-width: 40%;
      }
      .hero-logo {
        display: block;
        width: 140px;
        max-width: 100%;
        height: auto;
        object-fit: contain;
      }
      .hero h1 { margin: 0 0 8px; font-size: 1.8rem; }
      .hero p { margin: 0; color: var(--muted); }
      .pill {
        display: inline-block;
        background: var(--accent-2);
        color: var(--accent);
        padding: 8px 12px;
        border-radius: 999px;
        font-weight: 600;
      }

      .grid {
        display: grid;
        grid-template-columns: 1.2fr 0.8fr;
        gap: 20px;
        margin-top: 20px;
      }

      .panel { padding: 20px; }
      .panel h2 { margin-top: 0; font-size: 1.1rem; }

      .toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
      .toolbar input, .toolbar select { flex: 1; min-width: 140px; }
      form { display: grid; gap: 12px; }
      label { display: grid; gap: 6px; font-size: 0.95rem; font-weight: 600; }
      input, textarea, select, button {
        font: inherit;
        padding: 10px 12px;
        border-radius: 10px;
        border: 1px solid var(--border);
      }
      .district-color-control {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 12px;
      }
      .district-color-control input[type="color"] {
        width: 120px;
        height: 56px;
        padding: 4px;
        background: var(--card);
        cursor: pointer;
      }
      .district-color-control input[type="color"]::-webkit-color-swatch-wrapper {
        padding: 0;
      }
      .district-color-control input[type="color"]::-webkit-color-swatch {
        border-radius: 6px;
        border: 1px solid var(--border);
      }
      .district-color-control input[type="color"]::-moz-color-swatch {
        border-radius: 6px;
        border: 1px solid var(--border);
      }
      .district-color-control output {
        color: var(--ink);
        font-family: ui-monospace, monospace;
      }
      button {
        cursor: pointer;
        background: var(--accent);
        color: white;
        border: none;
        font-weight: 700;
      }
      button.secondary { background: var(--accent-2); color: var(--ink); }
      .muted { color: var(--muted); font-size: 0.95rem; }
      .hidden { display: none !important; }
      .modal {
        position: fixed;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
        background: rgba(15, 23, 42, 0.3);
        z-index: 2000;
      }
      .modal-dialog {
        width: min(560px, 100%);
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
        padding: 20px;
      }
      .modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 16px;
      }
      .modal-header h3 {
        margin: 0;
      }
      .modal-close {
        background: transparent;
        color: var(--text);
        border: 1px solid var(--border);
        padding: 6px 10px;
      }
      .modal-actions {
        display: flex;
        justify-content: flex-end;
        gap: 10px;
        margin-top: 12px;
      }
      .modal-actions button {
        min-width: 120px;
      }
      .admin-panel {
        margin-top: 16px;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--theme-surface);
      }
      .admin-moderation-list {
        display: grid;
        gap: 10px;
        margin-top: 10px;
      }
      .admin-review-item {
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 12px;
        background: #ffffff;
      }
      .admin-review-item .meta-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 6px;
      }
      .meta-tag {
        display: inline-flex;
        align-items: center;
        border-radius: 999px;
        padding: 4px 8px;
        font-size: 0.78rem;
        background: var(--theme-soft);
        color: var(--accent);
      }
      .meta-tag.warning {
        background: #fff7ed;
        color: #9a5b00;
      }
      .meta-tag.success {
        background: #ecfdf5;
        color: #047857;
      }
      .meta-tag.muted {
        background: #f1f5f9;
        color: #475569;
      }
      .meta-tag.upload {
        background: var(--theme-soft);
        color: var(--accent);
      }
      .meta-tag.listing {
        background: #ede9fe;
        color: #5b21b6;
      }

      .list { display: grid; gap: 12px; }
      .listing-card {
        border: 1px solid var(--border);
        border-radius: 14px;
        padding: 14px;
        background: var(--theme-surface);
      }
      .listing-card h3 { margin: 0 0 8px; }
      .saved-listing-media {
        margin-bottom: 10px;
        border-radius: 10px;
        overflow: hidden;
        border: 1px solid var(--border);
        background: #f8fafc;
      }
      .saved-listing-media img {
        display: block;
        width: 100%;
        max-height: 180px;
        object-fit: cover;
      }
      .listing-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
      .tag {
        background: var(--theme-soft);
        color: var(--accent);
        padding: 4px 8px;
        border-radius: 999px;
        font-size: 0.85rem;
      }
      .status { font-weight: 700; }
      .status.active { color: #047857; }
      .status.claimed { color: #92400e; }
      .status.paused { color: #9a5b00; }
      .status.closed { color: #475569; }
      .status.removed { color: #991b1b; }
      .listing-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
      .listing-actions button { padding: 8px 10px; font-size: 0.9rem; }
      .claim-button-wrap {
        position: relative;
        display: inline-flex;
        align-items: center;
      }
      .request-pill {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border-radius: 999px;
        padding: 4px 8px;
        font-size: 0.8rem;
        font-weight: 700;
        background: var(--theme-soft);
        color: var(--accent);
        margin-bottom: 8px;
      }
      .request-status {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border-radius: 999px;
        padding: 4px 8px;
        font-size: 0.8rem;
        font-weight: 700;
        margin-bottom: 8px;
      }
      .request-status.pending { background: #fef3c7; color: #92400e; }
      .request-status.accepted { background: #dcfce7; color: #166534; }
      .request-status.completed { background: var(--theme-soft); color: var(--accent); }
      .request-status.declined { background: #fee2e2; color: #991b1b; }
      .section-stack { display: grid; gap: 20px; }
      .section-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        margin-bottom: 12px;
      }
      .section-header h2 {
        margin: 0;
      }
      .count-pill {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 32px;
        height: 30px;
        padding: 0 10px;
        border-radius: 999px;
        background: var(--theme-soft);
        color: var(--accent);
        font-size: 0.82rem;
        font-weight: 700;
        border: 1px solid var(--theme-border);
      }
      .mini-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--theme-surface); }
      .mini-card.action-needed {
        border-color: #f59e0b;
        box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.16);
      }
      .request-details {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
        display: grid;
        gap: 6px;
      }
      .request-details[hidden] {
        display: none;
      }
      .request-details button {
        justify-self: start;
        padding: 8px 10px;
        font-size: 0.9rem;
      }
      .request-toggle {
        background: transparent;
        color: var(--accent);
        border: 1px solid var(--border);
        padding: 6px 10px;
        margin-top: 8px;
      }
      .request-summary {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 12px;
      }
      .request-summary .chip {
        background: #f8fafc;
        border: 1px solid var(--border);
        border-radius: 999px;
        padding: 6px 10px;
        font-size: 0.85rem;
        color: var(--muted);
        cursor: pointer;
        transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
      }
      .request-summary .chip.active {
        background: var(--accent-2);
        border-color: var(--accent);
        color: var(--accent);
      }
      .request-section {
        display: grid;
        gap: 10px;
      }
      .request-section h3 {
        margin: 0;
        font-size: 0.95rem;
        color: var(--muted);
      }
      .empty-state,
      .loading-state {
        border: 1px dashed var(--border);
        border-radius: 12px;
        padding: 16px;
        background: #f8fafc;
        color: var(--muted);
        text-align: center;
        font-weight: 600;
      }
      .empty-state strong {
        display: block;
        color: var(--text);
        margin-bottom: 4px;
      }
      .message { margin-top: 10px; color: var(--muted); }
      .error { color: #b91c1c; font-weight: 600; }
      .success { color: #047857; font-weight: 600; }
      .auth-card {
        position: relative;
        display: grid;
        gap: 10px;
        margin-bottom: 16px;
        padding: 14px;
        padding-top: 62px;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: var(--theme-surface);
      }
      .auth-card > h2 {
        margin: 0;
        position: absolute;
        top: 14px;
        left: 14px;
      }
      .staff-item-request-card {
        padding-top: 14px;
      }
      .staff-item-request-card > h2 {
        position: static;
      }
      .auth-actions {
        position: absolute;
        top: 12px;
        right: 12px;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-end;
      }
      .auth-actions button.secondary {
        background: #475569;
      }
      .app-shell {
        display: grid;
        grid-template-columns: 220px minmax(0, 1fr);
        gap: 20px;
        align-items: start;
        transition: grid-template-columns 0.2s ease;
      }
      .app-shell.nav-collapsed {
        grid-template-columns: 88px minmax(0, 1fr);
      }
      .side-nav {
        position: sticky;
        top: 20px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        background: #f8fafc;
        border: 1px solid var(--border);
        border-radius: 16px;
        transition: padding 0.2s ease;
      }
      .nav-button {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        padding: 12px 14px;
        border: 1px solid transparent;
        border-radius: 10px;
        background: #ffffff;
        color: var(--ink);
        font-weight: 700;
        text-align: left;
        cursor: pointer;
      }
      #authNavButton {
        margin-top: auto;
      }
      .nav-button.active {
        background: var(--accent-2);
        border-color: var(--accent);
        color: var(--accent);
      }
      .nav-button .nav-label {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .nav-toggle {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 12px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: #ffffff;
        color: var(--ink);
        cursor: pointer;
      }
      .nav-toggle .hamburger {
        display: grid;
        gap: 4px;
        width: 22px;
      }
      .nav-toggle .hamburger span {
        display: block;
        width: 100%;
        height: 2px;
        border-radius: 999px;
        background: var(--accent);
      }
      .side-nav.collapsed {
        padding: 10px 8px;
      }
      .side-nav.collapsed .nav-button {
        justify-content: center;
        padding: 10px 6px;
        font-size: 0.75rem;
      }
      .side-nav.collapsed .nav-label {
        display: none;
      }
      .side-nav.collapsed .nav-toggle {
        font-size: 0.85rem;
      }
      .panel-section {
        display: none;
      }
      .panel-section.active {
        display: block;
      }
      .profile-card {
        display: grid;
        gap: 6px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--theme-surface);
      }
      .profile-card .profile-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
      }
      .profile-reviews {
        display: grid;
        gap: 8px;
        margin-top: 8px;
      }
      .profile-review {
        border: 1px solid var(--border);
        border-radius: 10px;
        background: #ffffff;
        padding: 8px 10px;
      }
      .profile-review strong {
        display: inline-block;
        margin-bottom: 4px;
      }
      .my-listings-section {
        display: grid;
        gap: 10px;
        margin-top: 16px;
      }
      .inline-editor {
        display: grid;
        gap: 10px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--theme-surface);
        margin-top: 8px;
      }
      .inline-editor .inline-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
      }
      .inline-editor button.secondary {
        background: #475569;
      }
      .details-panel {
        display: grid;
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--theme-surface);
        margin-top: 8px;
      }
      .details-panel .details-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
      }
      .details-panel .details-header button {
        background: transparent;
        color: var(--text);
        border: 1px solid var(--border);
        padding: 6px 10px;
        font-size: 0.85rem;
      }
      .details-gallery {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
      }
      .details-gallery img {
        width: 600px;
        height: 600px;
        max-width: 100%;
        object-fit: contain;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: #f8fafc;
      }
      .page-footer {
        margin-top: 24px;
        padding: 16px 4px;
        color: var(--ink);
        font-size: 0.875rem;
        text-align: center;
      }
      .footer-nav {
        display: flex;
        justify-content: center;
        gap: 16px;
        flex-wrap: wrap;
        margin-bottom: 8px;
      }
      .button-link {
        display: inline-block;
        padding: 10px 14px;
        border-radius: 8px;
        background: var(--accent);
        color: white;
        font-weight: 700;
        text-decoration: none;
      }
      .button-link.secondary {
        background: var(--accent-2);
        color: var(--ink);
      }
      .help-menu summary {
        padding: 12px 14px;
        border: 1px solid transparent;
        border-radius: 10px;
        background: #ffffff;
        color: var(--ink);
        font-weight: 700;
        cursor: pointer;
      }
      .help-submenu {
        display: grid;
        gap: 6px;
        padding: 8px 0 0 12px;
      }
      .help-submenu button {
        width: 100%;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: #ffffff;
        color: var(--ink);
        text-align: left;
        cursor: pointer;
      }
      .help-submenu button:hover {
        background: #f1f5f9;
      }
      .side-nav.collapsed .help-menu summary {
        padding: 10px 4px;
        font-size: 0.75rem;
      }
      .side-nav.collapsed .help-submenu {
        padding-left: 0;
      }
      .side-nav.collapsed .help-submenu button {
        padding: 8px 4px;
        font-size: 0.75rem;
        overflow-wrap: anywhere;
      }
      @media (max-width: 900px) {
        .page { padding: 16px; }
        .app-shell,
        .app-shell.nav-collapsed {
          grid-template-columns: minmax(0, 1fr);
          gap: 12px;
        }
        .side-nav {
          position: static;
          display: grid;
          grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
          align-items: start;
        }
        .side-nav.collapsed {
          padding: 12px;
        }
        .side-nav.collapsed .nav-button {
          justify-content: flex-start;
          padding: 12px 14px;
          font-size: 1rem;
        }
        .side-nav.collapsed .nav-label { display: inline; }
        .side-nav.collapsed .nav-toggle { grid-column: 1 / -1; }
        #authNavButton { margin-top: 0; }
        .nav-button,
        .help-menu summary { min-height: 44px; }
        .help-submenu { padding-left: 0; }
        .grid { grid-template-columns: 1fr; }
        .auth-card {
          padding-top: 14px;
        }
        .auth-card h2 {
          position: static;
        }
        .auth-actions {
          position: static;
          justify-content: flex-start;
        }
      }

      @media (max-width: 600px) {
        .page { padding: 12px; }
        .hero {
          align-items: flex-start;
          padding: 16px;
          gap: 12px;
        }
        .hero h1 { font-size: clamp(1.25rem, 6vw, 1.65rem); }
        .hero p { line-height: 1.45; }
        .hero-brand { max-width: 30%; gap: 8px; }
        .hero-logo { width: 88px; }
        .pill { padding: 6px 9px; font-size: 0.8rem; }
        .panel { padding: 14px; border-radius: 14px; }
        .grid { gap: 12px; margin-top: 12px; }
        .side-nav {
          grid-template-columns: repeat(2, minmax(0, 1fr));
          gap: 6px;
          padding: 8px;
        }
        .side-nav .nav-toggle { grid-column: 1 / -1; }
        .nav-button { padding: 10px 8px; gap: 6px; font-size: 0.9rem; }
        .nav-button .nav-label { min-width: 0; }
        .help-menu { min-width: 0; }
        .help-menu summary { padding: 10px 8px; }
        .help-submenu button { padding: 9px 7px; font-size: 0.85rem; }
        .toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
        .toolbar input, .toolbar select { min-width: 0; width: 100%; }
        input, textarea, select { min-width: 0; max-width: 100%; }
        .auth-card { padding: 12px; }
        .auth-actions { gap: 6px; }
        .auth-actions button { flex: 1 1 120px; }
        .modal { align-items: flex-end; padding: 8px; }
        .modal-dialog {
          width: 100%;
          max-height: calc(100dvh - 16px);
          overflow-y: auto;
          padding: 16px;
        }
        .modal-actions { flex-wrap: wrap; }
        .modal-actions button { flex: 1 1 130px; }
        .details-panel .details-header { align-items: flex-start; flex-wrap: wrap; }
        .details-gallery { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
        .request-summary { gap: 6px; }
        .request-summary .chip { padding: 7px 9px; }
        .footer-nav { gap: 8px; }
        .page-footer { padding: 12px 4px; line-height: 1.5; }
      }
