/* ============================================================
   Design tokens — blueprint/cadastral survey palette.
   The status colors (green/amber/brick) are the one signature
   element: they're the same encoding on the map, the sidebar
   chips, and the badges, so meaning travels with color everywhere.
   ============================================================ */
:root {
    --ink:        #161a22;
    --ink-soft:   #2b3242;
    --paper:      #f5f4ef;
    --surface:    #ffffff;
    --line:       #dedcd3;
    --line-soft:  #eceae2;
    --accent:     #1f4e8c;   /* blueprint blue — primary actions */
    --accent-ink: #ffffff;
    --available:  #3f8f5f;
    --reserved:   #c98a34;
    --sold:       #b54a3f;
    --text-muted: #6b7280;

    --font-display: 'Space Grotesk', 'Inter', sans-serif;
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:    'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
}
.mono { font-family: var(--font-mono); }

/* ---- Topbar ---- */
.topbar {
    background: var(--ink);
    background-image:
        linear-gradient(var(--ink-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--ink-soft) 1px, transparent 1px);
    background-size: 22px 22px;
    background-position: center;
    color: #fff;
    padding: 14px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand-mark { color: var(--reserved); font-size: 20px; line-height: 1; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.btn-ghost {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font-body);
}
.btn-ghost:hover { background: rgba(255,255,255,.1); }

.btn-logout {
    color: #fff;
    text-decoration: none;
    background: var(--sold);
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
}

.legend { font-size: 13px; display: flex; gap: 16px; align-items: center; color: #e7e5dd; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-inline-end: 4px; vertical-align: middle; }
.dot.available { background: var(--available); }
.dot.reserved  { background: var(--reserved); }
.dot.sold      { background: var(--sold); }

/* ---- Layout ---- */
.layout { display: flex; height: calc(100vh - 54px); }
#map { flex: 1; }
.fullmap { height: calc(100vh - 54px); width: 100%; }

.sidebar {
    width: 300px;
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
    overflow-y: auto;
    padding: 16px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sidebar h2 { font-family: var(--font-display); font-size: 15px; margin: 0; color: var(--ink); }
.count-chip {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 12px;
    font-family: var(--font-mono);
}
.hint { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; margin: 8px 0 16px; }

.plots-list { display: flex; flex-direction: column; gap: 6px; }
.plot-item {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    transition: border-color .12s;
}
.plot-item:hover { border-color: var(--accent); }
.plot-item-num { font-weight: 600; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 11px; color: #fff; }
.badge.available { background: var(--available); }
.badge.reserved  { background: var(--reserved); }
.badge.sold      { background: var(--sold); }

/* ---- Modals ---- */
.modal { position: fixed; inset: 0; background: rgba(22,26,34,.55); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.modal.hidden { display: none; }
.modal-box {
    background: var(--surface);
    padding: 26px;
    border-radius: 10px;
    width: 360px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(22,26,34,.25);
}
.modal-wide { width: 560px; }
.modal-box h3 { font-family: var(--font-display); margin: 0 0 4px; font-size: 17px; }
.modal-box label { display: block; font-size: 12px; color: var(--text-muted); margin: 12px 0 5px; }
.modal-box input, .modal-box select, .modal-box textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--paper);
}
.modal-box input:focus, .modal-box select:focus, .modal-box textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    background: var(--surface);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.modal-actions button { flex: 1; padding: 10px; border: 0; border-radius: 6px; cursor: pointer; font-size: 13.5px; font-family: var(--font-body); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #183f70; }
.btn-danger { background: var(--sold); color: #fff; }
.btn-secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line) !important; }

/* ---- Bookings table ---- */
.bookings-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bookings-table th, .bookings-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); text-align: right; }
.bookings-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; }

/* ---- Public map popup ---- */
.plot-popup { font-size: 13px; line-height: 1.7; min-width: 160px; }
.btn-book {
    margin-top: 8px;
    width: 100%;
    padding: 8px 12px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 13px;
}
.btn-book:hover { background: #183f70; }
.sold-note { margin-top: 6px; color: var(--sold); font-size: 12px; }
#bookingMsg { margin-top: 10px; font-size: 13px; color: var(--accent); }
#bookingMsg.ok { color: var(--available); }

/* ---- Auth page ---- */
.auth-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--ink);
    background-image: linear-gradient(var(--ink-soft) 1px, transparent 1px), linear-gradient(90deg, var(--ink-soft) 1px, transparent 1px);
    background-size: 24px 24px; }
.auth-box { background: var(--surface); padding: 36px 32px; border-radius: 10px; width: 320px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-mark { font-size: 26px; color: var(--reserved); margin-bottom: 6px; }
.auth-box h1 { font-family: var(--font-display); font-size: 19px; margin: 0 0 4px; }
.auth-sub { font-size: 12.5px; color: var(--text-muted); margin: 0 0 18px; }
.auth-err { background: #fbeceA; color: var(--sold); padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.auth-box label { display: block; font-size: 12px; color: var(--text-muted); margin: 12px 0 5px; }
.auth-box input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; background: var(--paper); }
.auth-box button {
    width: 100%; margin-top: 20px; padding: 11px; background: var(--accent); color: #fff;
    border: 0; border-radius: 6px; cursor: pointer; font-size: 14px; font-family: var(--font-body);
}
.auth-box button:hover { background: #183f70; }

/* ---- Responsive ---- */
@media (max-width: 720px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: 200px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
    #map { height: calc(100vh - 254px); }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
