:root {
  --brand: #0b3d62;
  --brand-2: #12557f;
  --brand-3: #1f6f9e;
  --accent: #f7a325;
  --bg: #f4f7fa;
  --card: #ffffff;
  --border: #dbe4ec;
  --text: #1c2b39;
  --muted: #6b7c8f;
  --ok: #1f9d55;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', 'Roboto', system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
a { color: var(--brand-3); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--brand) 0%, #072a44 100%);
  color: #dce8f2; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand-logo { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; font-weight: 800; color: var(--brand); }
.brand h1 { font-size: 16px; margin: 0; color: #fff; }
.brand small { color: #9fb8cd; font-size: 11px; }
.nav { margin-top: 22px; display: flex; flex-direction: column; gap: 3px; }
.nav a { color: #c9dcec; padding: 9px 12px; border-radius: 8px; text-decoration: none; font-size: 14px; display: flex; gap: 9px; align-items: center; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: rgba(247,163,37,.16); color: #fff; font-weight: 600; }
.nav .sec { color: #7f9ab1; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin: 14px 12px 4px; }

.main { padding: 26px 30px 60px; max-width: 1300px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 22px; color: var(--brand); }
.topbar .sub { color: var(--muted); font-size: 13px; }
.userbox { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-3); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1000px) { .cols-3,.cols-4 { grid-template-columns: repeat(2,1fr); } .app { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }
@media (max-width: 640px) { .cols-2,.cols-3,.cols-4 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; color: var(--brand); }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .val { font-size: 27px; font-weight: 800; color: var(--brand); }
.kpi .lbl { color: var(--muted); font-size: 12.5px; }
.kpi .ico { width: 34px; height: 34px; border-radius: 9px; background: #eaf2f9; display: grid; place-items: center; color: var(--brand-2); margin-bottom: 6px; }

/* ---------- Forms / buttons ---------- */
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #cfe2f2; border-color: var(--brand-3); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: #fff; cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn:hover { background: var(--brand-2); }
.btn.sec { background: #fff; color: var(--brand); border-color: var(--border); }
.btn.sec:hover { background: #f0f5fa; }
.btn.accent { background: var(--accent); color: #3a2500; }
.btn.danger { background: var(--err); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 140px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: #f8fbfd; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.blue { background: #e3eefb; color: var(--brand-2); }
.badge.green { background: #e2f6ea; color: var(--ok); }
.badge.orange { background: #fdf0dc; color: var(--warn); }
.badge.red { background: #fde4e4; color: var(--err); }
.badge.gray { background: #eef1f4; color: var(--muted); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.mt { margin-top: 16px; }
.pill { padding: 5px 10px; border-radius: 999px; background: #eef4f9; color: var(--brand-2); font-size: 12.5px; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8,25,40,.55); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: min(680px, 100%); max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-top: 0; }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand) 0%, #06243c 60%, #041a2c 100%); padding: 24px; }
.auth-card { background: #fff; border-radius: 16px; padding: 34px; width: min(440px, 100%); box-shadow: 0 30px 70px rgba(0,0,0,.35); }
.auth-card h1 { margin: 0 0 4px; color: var(--brand); font-size: 22px; }
.auth-card .tag { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.auth-links { margin-top: 16px; font-size: 13px; display: flex; justify-content: space-between; }

.chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 10px; }
.chart .bar { flex: 1; background: linear-gradient(180deg, var(--brand-3), var(--brand)); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.chart .bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 9px; color: var(--muted); }

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--brand); color: #fff; padding: 13px 18px; border-radius: 9px; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.err { background: var(--err); }
.spinner { width: 22px; height: 22px; border: 3px solid #dbe4ec; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }

/* ================= Betterplace-style polish ================= */

/* ---------- Topbar tools ---------- */
.tb-tools { display: flex; align-items: center; gap: 12px; }
.gsearch { position: relative; width: min(320px, 40vw); }
.gsearch input { padding-left: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' fill='none' stroke='%236b7c8f' stroke-width='2'%3E%3Ccircle cx='6.5' cy='6.5' r='5'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 10px center; }
.gsearch-pop { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 18px 40px rgba(8,25,40,.18); z-index: 60; overflow: hidden; }
.gsearch-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; color: var(--text); text-decoration: none; border-bottom: 1px solid #f0f4f8; }
.gsearch-item:last-child { border-bottom: 0; }
.gsearch-item:hover { background: #f5f9fc; text-decoration: none; }
.gsearch-item span { font-size: 11.5px; }
.gsearch-empty { padding: 12px; color: var(--muted); font-size: 13px; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 17px; display: grid; place-items: center; }
.icon-btn:hover { background: #f0f5fa; }
.icon-btn .dot { position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--err); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }

/* ---------- Modal (animated, Betterplace-like) ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8,25,40,.55); display: grid; place-items: center; z-index: 100; padding: 20px; animation: backIn .16s ease-out; }
.modal-back.closing { animation: backOut .15s ease-in forwards; }
.modal { position: relative; background: #fff; border-radius: 16px; padding: 24px 26px; width: min(680px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 30px 80px rgba(6,20,34,.4); transform: translateY(10px) scale(.985); opacity: 0; transition: transform .2s cubic-bezier(.2,.8,.25,1), opacity .2s; }
.modal-back.open .modal { transform: none; opacity: 1; }
.modal h3:first-child { margin-top: 0; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; display: grid; place-items: center; }
.modal-x:hover { background: #f3f6f9; color: var(--text); }
@keyframes backIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes backOut { from { opacity: 1 } to { opacity: 0 } }

/* ---------- Drawer (slide-in panel) ---------- */
.drawer-back { position: fixed; inset: 0; background: rgba(8,25,40,.45); z-index: 110; animation: backIn .16s ease-out; }
.drawer-back.closing { animation: backOut .18s ease-in forwards; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 96vw); background: #fff; box-shadow: -24px 0 60px rgba(6,20,34,.32); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .24s cubic-bezier(.2,.8,.25,1); }
.drawer-back.open .drawer { transform: none; }
.drawer header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer header h3 { margin: 0; color: var(--brand); font-size: 17px; }
.drawer header .modal-x { position: static; }
.drawer-body { padding: 20px 22px; overflow-y: auto; }

/* ---------- Map ---------- */
.map-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .map-layout { grid-template-columns: 1fr; } }
.map-canvas-wrap { position: relative; }
.map-canvas { height: 68vh; min-height: 420px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; background: #e8eef4; }
.map-area-btn { position: absolute; top: 12px; right: 12px; left: auto; z-index: 500; box-shadow: 0 6px 18px rgba(8,25,40,.18); }
.map-list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; height: 68vh; min-height: 420px; overflow-y: auto; }
.map-card { padding: 11px 12px; border-radius: 10px; border: 1px solid transparent; border-bottom: 1px solid #f0f4f8; cursor: pointer; }
.map-card:hover { background: #f6fafd; }
.map-card.active { background: #eef6fd; border-color: #cfe2f2; }
.map-card-price { font-size: 17px; font-weight: 800; color: var(--brand); }
.map-card-title { font-size: 13.5px; font-weight: 600; margin: 2px 0 4px; }
.map-card-link { font-size: 12px; font-weight: 600; }
.imob-pin span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--brand); box-shadow: 0 4px 10px rgba(0,0,0,.28); }
.imob-pin span { font-size: 14px; }
.imob-pin span::before { content: ''; }
.mp-pop { min-width: 190px; }
.mp-pop .mp-price { font-size: 17px; font-weight: 800; color: var(--brand); margin: 4px 0; }
.mp-pop .btn { margin-top: 8px; }
.leaflet-container { font: inherit; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin: 0; }
.chk input { width: auto; }
