/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18px; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f5f5f2; color: #1a1a1a; line-height: 1.6; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ────────────────────────────────────────────────────────────────── */
.site-header { background: #fff; border-bottom: 2px solid #e2e8f0; position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 1280px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 24px; }
.logo { height: 52px; }
.header-center { flex: 1; display: flex; justify-content: center; }
.nbu-rate { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 8px; padding: 6px 16px; font-size: 1rem; font-weight: 600; color: #0369a1; }
.rate-label { color: #64748b; font-weight: 400; margin-right: 6px; }
.header-nav { display: flex; gap: 8px; align-items: center; }
.nav-link { padding: 6px 14px; border-radius: 6px; font-size: 0.95rem; font-weight: 500; color: #374151; transition: background .15s; }
.nav-link:hover { background: #f1f5f9; text-decoration: none; }
.nav-manager { background: #1e40af; color: #fff !important; }
.nav-manager:hover { background: #1d4ed8 !important; }
.nav-logout { border: 1px solid #e5e7eb; }

/* ─── Main ──────────────────────────────────────────────────────────────────── */
.site-main { max-width: 1280px; margin: 0 auto; padding: 32px 24px; }

/* ─── Breadcrumb ────────────────────────────────────────────────────────────── */
.breadcrumb { margin-bottom: 16px; font-size: 0.9rem; color: #6b7280; }
.breadcrumb a { color: #2563eb; }

/* ─── Hero ──────────────────────────────────────────────────────────────────── */
.page-hero { text-align: center; margin-bottom: 40px; }
.page-title { font-size: 2.2rem; font-weight: 700; color: #111827; }
.page-subtitle { font-size: 1.1rem; color: #6b7280; margin-top: 8px; }

/* ─── Building navigation ───────────────────────────────────────────────────── */
.building-nav { display: flex; gap: 48px; justify-content: center; margin-bottom: 40px; flex-wrap: wrap; }
.entrance-block { background: #fff; border-radius: 16px; padding: 28px 32px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.entrance-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 16px; color: #1e40af; text-align: center; }
.floor-grid { display: flex; flex-direction: column; gap: 8px; }
.floor-btn { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 10px; font-weight: 600; color: #1e3a5f; transition: all .15s; cursor: pointer; }
.floor-btn:hover { background: #1e40af; color: #fff; border-color: #1e40af; text-decoration: none; }
.floor-num { font-size: 1.5rem; min-width: 32px; text-align: center; }
.floor-label { font-size: 0.9rem; color: inherit; }

/* ─── Status Legend ─────────────────────────────────────────────────────────── */
.legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px; }
.legend-item { padding: 6px 18px; border-radius: 20px; font-size: 0.9rem; font-weight: 600; }
.legend-item.free    { background: #dcfce7; color: #166534; border: 1.5px solid #86efac; }
.legend-item.booked  { background: #fef9c3; color: #854d0e; border: 1.5px solid #fde047; }
.legend-item.sold    { background: #fee2e2; color: #991b1b; border: 1.5px solid #fca5a5; }
.legend-item.unavailable { background: #f1f5f9; color: #475569; border: 1.5px solid #cbd5e1; }

/* ─── Floor plan grid ───────────────────────────────────────────────────────── */
.floor-plan { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.apt-cell { background: #fff; border: 2px solid #e2e8f0; border-radius: 12px; padding: 16px; text-align: center; transition: all .15s; }
.apt-cell:not(.apt-locked) { cursor: pointer; }
.apt-cell:not(.apt-locked):hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.apt-free    { border-color: #86efac; background: #f0fdf4; }
.apt-booked  { border-color: #fde047; background: #fefce8; }
.apt-sold    { border-color: #fca5a5; background: #fff1f2; }
.apt-unavailable { border-color: #cbd5e1; background: #f8fafc; opacity: .7; }
.apt-number  { font-size: 1.2rem; font-weight: 700; color: #111827; }
.apt-rooms   { font-size: 0.8rem; color: #6b7280; }
.apt-area    { font-size: 1rem; font-weight: 600; color: #374151; margin: 4px 0; }
.apt-status-label { font-size: 0.78rem; font-weight: 600; margin-top: 4px; }
.apt-free .apt-status-label    { color: #16a34a; }
.apt-booked .apt-status-label  { color: #d97706; }
.apt-sold .apt-status-label    { color: #dc2626; }
.apt-unavailable .apt-status-label { color: #64748b; }
.apt-timer   { font-size: 0.75rem; color: #d97706; margin-top: 4px; font-weight: 600; }

/* ─── Property card ─────────────────────────────────────────────────────────── */
.property-card { display: flex; gap: 40px; background: #fff; border-radius: 16px; padding: 36px; box-shadow: 0 2px 16px rgba(0,0,0,.08); margin-bottom: 32px; }
.property-card-left { flex: 1; min-width: 280px; }
.property-plan-img { width: 100%; height: auto; border-radius: 12px; display: block; }
.property-card-right { flex: 1.5; }
.property-plan-placeholder { background: #f8fafc; border: 2px dashed #cbd5e1; border-radius: 12px; min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #94a3b8; }
.plan-icon { font-size: 4rem; margin-bottom: 12px; }
.prop-status-badge { display: inline-block; padding: 8px 20px; border-radius: 20px; font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.status-free        { background: #dcfce7; color: #166534; }
.status-booked      { background: #fef9c3; color: #854d0e; }
.status-sold        { background: #fee2e2; color: #991b1b; }
.status-unavailable { background: #f1f5f9; color: #475569; }
.prop-title { font-size: 2rem; font-weight: 800; color: #111827; margin-bottom: 4px; }
.prop-type  { font-size: 1rem; color: #6b7280; margin-bottom: 20px; }
.prop-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.prop-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; font-size: 1rem; }
.prop-table td:first-child { color: #6b7280; width: 40%; }
.uah-equiv { font-size: 0.85rem; color: #6b7280; margin-left: 8px; }
.price-total { color: #1e40af; font-size: 1.2rem; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn { display: inline-block; padding: 12px 24px; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; border: none; transition: all .15s; text-align: center; }
.btn-primary   { background: #1e40af; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: #374151; border: 1.5px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning   { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-large { padding: 16px 36px; font-size: 1.15rem; width: 100%; }
.btn-full  { width: 100%; }
.btn-link  { background: none; color: #6b7280; }
.btn-icon  { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 2px 6px; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.9rem; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px; border: 1.5px solid #d1d5db; border-radius: 8px;
  font-size: 1rem; background: #fff; transition: border .15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.form-error { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px; font-size: 0.95rem; margin-bottom: 12px; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: #fff; border-radius: 16px; padding: 36px; max-width: 600px; width: 92%; max-height: 90vh; overflow-y: auto; z-index: 201; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: #6b7280; }
.modal h2 { font-size: 1.4rem; margin-bottom: 20px; }
.hidden { display: none !important; }

/* ─── Login ─────────────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f0f4f8; }
.login-box { background: #fff; border-radius: 16px; padding: 48px 40px; width: 100%; max-width: 400px; box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.login-logo { display: block; height: 60px; margin: 0 auto 24px; }
.login-box h1 { text-align: center; font-size: 1.5rem; margin-bottom: 28px; color: #111827; }
.back-link { display: block; text-align: center; margin-top: 20px; color: #6b7280; font-size: 0.9rem; }

/* ─── Manager dashboard ─────────────────────────────────────────────────────── */
.manager-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.notifications { background: #fef9c3; border: 1.5px solid #fde047; border-radius: 12px; padding: 16px 20px; margin-bottom: 24px; }
.notifications h3 { margin-bottom: 10px; color: #854d0e; }
.notif-item { padding: 6px 0; border-bottom: 1px solid #fef08a; font-size: 0.95rem; }
.notif-item:last-child { border-bottom: none; }
.notif-time { color: #6b7280; font-size: 0.85rem; margin-left: 8px; }
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; background: #fff; padding: 16px; border-radius: 12px; border: 1px solid #e2e8f0; }
.filter-bar select { padding: 8px 12px; border: 1.5px solid #d1d5db; border-radius: 6px; font-size: 0.95rem; }
.filter-btn { padding: 7px 18px; border: 1.5px solid #d1d5db; border-radius: 20px; background: #fff; font-size: 0.9rem; cursor: pointer; color: #374151; transition: all .15s; }
.filter-btn:hover { border-color: #6366f1; color: #6366f1; }
.filter-btn.active { background: #6366f1; border-color: #6366f1; color: #fff; font-weight: 700; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; border: 1px solid #e2e8f0; }
.prop-table-full { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.prop-table-full th { background: #f8fafc; padding: 12px 14px; text-align: left; font-weight: 700; color: #374151; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
.prop-table-full td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; }
.prop-row { cursor: pointer; transition: background .1s; }
.prop-row:hover { background: #f0f9ff; }
.status-row-booked  { background: #fffbeb; }
.status-row-sold    { background: #fff1f2; }
.status-row-unavailable { background: #f8fafc; color: #94a3b8; }
.status-badge { display: inline-block; padding: 3px 12px; border-radius: 12px; font-size: 0.82rem; font-weight: 700; }
.status-badge.status-free        { background: #dcfce7; color: #166534; }
.status-badge.status-booked      { background: #fef9c3; color: #854d0e; }
.status-badge.status-sold        { background: #fee2e2; color: #991b1b; }
.status-badge.status-unavailable { background: #f1f5f9; color: #475569; }
.empty-msg { text-align: center; color: #9ca3af; padding: 24px; }

/* ─── Manager property page ─────────────────────────────────────────────────── */
.manager-prop-card { display: flex; gap: 40px; background: #fff; border-radius: 16px; padding: 36px; box-shadow: 0 2px 16px rgba(0,0,0,.08); margin-bottom: 32px; }
.manager-prop-left { flex: 1; min-width: 240px; }
.manager-prop-right { flex: 1.5; }
.manager-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.booking-info-block { margin-top: 12px; padding: 12px 16px; background: #fef9c3; border-radius: 8px; font-size: 0.95rem; width: 100%; }
.unavail-comment { margin-top: 8px; padding: 10px; background: #f1f5f9; border-radius: 8px; font-size: 0.95rem; }

/* ─── Buyer & schedule ──────────────────────────────────────────────────────── */
.buyer-section { background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.buyer-section h2 { font-size: 1.3rem; margin: 0 0 20px; color: #111827; }
.buyer-section h2:not(:first-child) { margin-top: 32px; }
.schedule-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; margin-top: 12px; }
.schedule-table th { background: #f8fafc; padding: 10px 12px; text-align: left; font-weight: 700; border-bottom: 2px solid #e2e8f0; }
.schedule-table td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; }
.sched-paid { background: #f0fdf4; }
.sched-overdue { background: #fff1f2; }
.sched-overpaid { background: #eff6ff; }
.payment-row td { font-size: 0.88rem; color: #6b7280; background: #fafafa; }
.payment-date { padding-left: 28px !important; }
.badge-paid     { display:inline-block; padding:3px 10px; border-radius:10px; background:#dcfce7; color:#166534; font-weight:700; font-size:0.85rem; }
.badge-overdue  { display:inline-block; padding:3px 10px; border-radius:10px; background:#fee2e2; color:#991b1b; font-weight:700; font-size:0.85rem; }
.badge-overpaid { display:inline-block; padding:3px 10px; border-radius:10px; background:#dbeafe; color:#1e40af; font-weight:700; font-size:0.85rem; }
.badge-pending  { display:inline-block; padding:3px 10px; border-radius:10px; background:#f1f5f9; color:#475569; font-weight:700; font-size:0.85rem; }
.rollover-note  { color:#2563eb; font-size:0.78rem; }
.btn-icon-sm    { background:none; border:none; cursor:pointer; font-size:1rem; padding:0 3px; opacity:.7; }
.btn-icon-sm:hover { opacity:1; }

/* ─── Payment summary ───────────────────────────────────────────────────────── */
.page-header-row { display:flex; align-items:center; justify-content:space-between; margin-bottom:24px; gap:16px; flex-wrap:wrap; }
.schedule-summary { width:100%; border-collapse:collapse; font-size:0.95rem; }
.schedule-summary th { background:#f8fafc; padding:11px 14px; text-align:left; font-weight:700; border-bottom:2px solid #e2e8f0; cursor:pointer; white-space:nowrap; user-select:none; }
.schedule-summary th:hover { background:#e0e7ff; }
.schedule-summary td { padding:10px 14px; border-bottom:1px solid #f1f5f9; }
.schedule-summary tr { cursor:pointer; }
.schedule-summary tr:hover td { background:#f0f9ff; }
.indicator-overdue td { background:#fff1f2 !important; }
.indicator-paid td { background:#f0fdf4 !important; }
.indicator-overpaid td { background:#eff6ff !important; }

/* ─── Backup ────────────────────────────────────────────────────────────────── */
.backup-section { margin-top: 40px; background:#fff; border-radius:12px; padding:24px; border:1px solid #e2e8f0; }
.backup-section h3 { margin-bottom:16px; }
.backup-section .form-group { display:flex; gap:12px; align-items:center; }
.backup-section select { flex:1; padding:10px 14px; border:1.5px solid #d1d5db; border-radius:8px; font-size:0.95rem; }

/* ─── Sell price preview ────────────────────────────────────────────────────── */
.sell-price-preview { background:#f0f9ff; border:1.5px solid #bae6fd; border-radius:8px; padding:10px 16px; margin-bottom:20px; color:#0369a1; font-size:1rem; }

/* ─── Booking info ──────────────────────────────────────────────────────────── */
.booking-info, .unavailable-info, .sold-info { padding: 16px 20px; border-radius: 10px; margin-top: 8px; }
.booking-info  { background: #fef9c3; }
.unavailable-info { background: #f1f5f9; }
.sold-info { background: #fee2e2; }
.booking-timer { font-size: 0.9rem; font-weight: 700; margin-left: 6px; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  html { font-size: 16px; }
  .header-inner { flex-wrap: wrap; gap: 8px; }
  /* Менеджер і Вийти — тільки для авторизованих на десктопі */
  .nav-manager, .nav-logout { display: none; }
  /* Навігація — Каталог і Документи в рядку, телефон окремим рядком знизу */
  .header-nav { flex-wrap: wrap; gap: 6px; }
  .nav-phone { order: 2; width: 100%; text-align: center; margin-top: 2px; }
  /* Обидва під'їзди поряд */
  .building-nav { flex-direction: row; gap: 12px; align-items: flex-start; }
  .entrance-block { flex: 1; min-width: 0; }
  .floor-btn { padding: 6px 8px; gap: 4px; }
  .floor-num { font-size: .95rem; }
  .floor-label { font-size: .7rem; }
  .dot { min-width: 17px; height: 17px; font-size: .65rem; }
  /* Решта */
  .property-card, .manager-prop-card { flex-direction: column; }
  .floor-plan { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .manager-top { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .modal { padding: 24px 16px; }
}

/* ─── Floor Plan PNG Overlay ────────────────────────────────────────────────── */
.floor-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.floor-layout { display: flex; gap: 20px; align-items: flex-start; }
.floor-apt-list { width: 190px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; max-height: 82vh; overflow-y: auto; }
.floor-apt-list .apt-cell { padding: 8px 10px; border-radius: 8px; border-width: 1.5px; text-align: left; }
.floor-apt-list .apt-number { font-size: 0.85rem; font-weight: 700; }
.floor-apt-list .apt-rooms  { font-size: 0.72rem; }
.floor-apt-list .apt-type-label { color: #6b7280; font-style: italic; }
.floor-apt-list .apt-area   { font-size: 0.78rem; margin: 2px 0; }
.floor-apt-list .apt-status-label { font-size: 0.7rem; margin-top: 2px; }
.floor-apt-list .apt-cell:not(.apt-locked):hover { transform: none; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.plan-container { position: relative; display: inline-block; margin-bottom: 0; background: #f8fafc; border-radius: 12px; border: 1px solid #e2e8f0; overflow: hidden; line-height: 0; }
.plan-bg { display: block; height: 82vh; width: auto; }
.plan-no-coords { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(248,250,252,.85); text-align: center; font-size: 0.9rem; color: #64748b; }
.plan-no-coords a { color: #2563eb; }

/* Apartment overlays on the plan image */
.apt-overlay { position: absolute; display: none; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 50%; border: 2px solid; transform: translate(-50%, -50%); text-align: center; cursor: default; transition: transform .15s, box-shadow .15s; }
.apt-ov-clickable { cursor: pointer; }
.apt-ov-clickable:hover { transform: translate(-50%, -50%) scale(1.12); box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 10; }
.apt-ov-free        { background: rgba(220,252,231,.25); border-color: #16a34a; }
.apt-ov-booked      { background: rgba(254,249,195,.25); border-color: #d97706; }
.apt-ov-sold        { background: rgba(254,226,226,.25); border-color: #dc2626; }
.apt-ov-unavailable { background: rgba(241,245,249,.2);  border-color: #94a3b8; }
.ov-number { font-size: 0.75rem; font-weight: 800; color: #111; line-height: 1; }

/* Fallback list toggle */
.floor-list-toggle { margin-top: 8px; }
.floor-list-toggle summary { cursor: pointer; font-size: 0.9rem; color: #6b7280; padding: 8px 0; user-select: none; }
.floor-list-toggle summary:hover { color: #374151; }

/* ─── Phone in header ───────────────────────────────────────────────────────── */
.nav-phone { color: #166534 !important; font-weight: 700; background: #dcfce7; border-radius: 8px; }
.nav-phone:hover { background: #bbf7d0 !important; }
