:root {
  --bg: #081221;
  --bg-card: #0f2038;
  --bg-elevated: #142a49;
  --border: rgba(212, 175, 55, 0.22);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --text: #f1f5f9;
  --text-muted: #9fb2cc;
  --gold: #d4af37;
  --gold-hover: #e5c354;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, 0.14);
  --blue-soft: rgba(56, 189, 248, 0.14);
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at top right, #122949 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Heebo", "Rubik", Arial, sans-serif;
  line-height: 1.55;
  direction: rtl;
}

.hidden {
  display: none !important;
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-image:
    radial-gradient(rgba(212, 175, 55, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 20% 20%, rgba(45, 212, 191, 0.08), transparent 45%);
  background-size: 28px 28px, 100% 100%;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(15, 32, 56, 0.94);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.brand-emblem {
  width: 74px;
  height: 74px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-emblem img {
  border-radius: 12px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #ffffff;
}

.login-subtitle {
  margin: 0 0 26px;
  font-size: 0.94rem;
  color: var(--text-muted);
}

.login-form {
  text-align: right;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #dbe7f7;
}

.password-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #091526;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 4px 10px 4px 6px;
  margin-bottom: 14px;
}

.password-wrap:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.16);
}

.password-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1rem;
  padding: 10px 4px;
  outline: none;
  direction: ltr;
  text-align: right;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 1rem;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.alert-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
  font-size: 0.9rem;
}

.login-footnote {
  margin: 20px 0 0;
  font-size: 0.8rem;
  color: #7c93b2;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-full {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.98rem;
}

.btn-sm {
  padding: 7px 11px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), #b89124);
  color: #0b1322;
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-hover), var(--gold));
}

.btn-teal {
  background: var(--teal-soft);
  border-color: rgba(45, 212, 191, 0.38);
  color: #99f6e4;
}

.btn-teal:hover {
  background: rgba(45, 212, 191, 0.24);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-subtle);
  color: #e2e8f0;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

/* Portal Topbar */
.portal-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 24px;
  background: rgba(8, 18, 33, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.topbar-title {
  font-size: 1.08rem;
  font-weight: 800;
  color: #ffffff;
}

.topbar-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tab-switcher {
  display: inline-flex;
  background: #0d1d35;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--gold);
  color: #091322;
}

.count-pill {
  background: rgba(0, 0, 0, 0.22);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.76rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-wrap input {
  background: #0d1d35;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 8px 12px;
  color: #ffffff;
  font-size: 0.86rem;
  width: 240px;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--gold);
}

/* Main Content */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.section-intro {
  margin-bottom: 20px;
}

.section-intro h2 {
  margin: 0 0 4px;
  font-size: 1.45rem;
  font-weight: 800;
}

.section-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Case Cards */
.cases-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.case-card {
  background: linear-gradient(180deg, rgba(20, 42, 73, 0.92), rgba(13, 28, 50, 0.96));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-gold {
  background: var(--gold-soft);
  color: #f6dc88;
  border: 1px solid rgba(212, 175, 55, 0.35);
}

.badge-slate {
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  border: 1px solid var(--border-subtle);
}

.coords-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 0.76rem;
  cursor: pointer;
  direction: ltr;
}

.coords-btn:hover {
  color: #ffffff;
  border-color: var(--gold);
}

.card-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.38;
}

.card-parcel {
  font-size: 0.82rem;
  color: #b7c9e2;
  background: rgba(8, 18, 33, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 10px;
}

.card-summary {
  margin: 0;
  font-size: 0.91rem;
  color: #d6e2f2;
}

.highlights-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.highlight-chip {
  font-size: 0.77rem;
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--blue-soft);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #bae6fd;
}

.actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(8, 18, 33, 0.48);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 12px;
}

.action-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f8fafc;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.map-actions-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-actions-footer .btn {
  flex: 1;
}

/* Map Tab */
.map-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  height: calc(100vh - 140px);
  min-height: 540px;
}

.map-sidebar {
  background: rgba(15, 32, 56, 0.94);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h3 {
  margin: 0 0 4px;
  font-size: 1.08rem;
}

.sidebar-header p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.map-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-list-item {
  text-align: right;
  width: 100%;
  background: rgba(8, 18, 33, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.map-list-item:hover,
.map-list-item.active {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.1);
}

.map-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.map-item-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold);
  color: #091322;
  font-weight: 800;
  font-size: 0.8rem;
}

.map-item-town {
  font-size: 0.82rem;
  color: #f6dc88;
  font-weight: 700;
}

.map-item-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.map-item-coords {
  font-size: 0.76rem;
  color: var(--text-muted);
  direction: ltr;
  text-align: right;
}

.map-stage {
  position: relative;
  z-index: 1;
  isolation: isolate;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #0a1628;
}

.cases-map {
  width: 100%;
  height: 100%;
}

/* Custom Leaflet Pin */
.custom-pin {
  background: transparent;
  border: none;
}

.pin-bubble {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: linear-gradient(135deg, var(--gold), #b48a1c);
  border: 2px solid #091322;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-bubble span {
  transform: rotate(45deg);
  color: #091322;
  font-weight: 900;
  font-size: 0.86rem;
}

.pin-secondary .pin-bubble {
  width: 26px;
  height: 26px;
  background: #38bdf8;
}

.pin-secondary .pin-bubble span {
  font-size: 0.72rem;
}

.leaflet-popup-content-wrapper {
  background: #0f2038;
  color: #f8fafc;
  border: 1px solid var(--gold);
  border-radius: 12px;
  direction: rtl;
  text-align: right;
}

.leaflet-container a.btn-outline {
  color: #e2e8f0;
}

.leaflet-container a.btn-teal {
  color: #99f6e4;
}

.leaflet-container a.btn-gold {
  color: #0b1322;
}

.leaflet-control-layers-toggle,
.leaflet-retina .leaflet-control-layers-toggle {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='%230f2038' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='12 2 2 7 12 12 22 7 12 2'/%3E%3Cpolyline points='2 12 12 17 22 12'/%3E%3Cpolyline points='2 17 12 22 22 17'/%3E%3C/svg%3E") !important;
  background-size: 20px 20px !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

.leaflet-popup-tip {
  background: #0f2038;
}

.popup-box {
  min-width: 260px;
  max-width: 330px;
  font-family: inherit;
}

.popup-box h4 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  color: #f6dc88;
}

.popup-box p {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: #cbd5e1;
}

.popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.popup-actions .btn-full-span {
  grid-column: 1 / -1;
}

/* Modal PDF Viewer */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(3, 8, 17, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 1360px;
  height: 92vh;
  background: #0e1e34;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: #091526;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.modal-title-group h3 {
  margin: 0;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.modal-kind-switch {
  display: inline-flex;
  background: #0e1e34;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}

.switch-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.switch-pill.active {
  background: var(--gold);
  color: #091322;
}

.modal-body {
  flex: 1;
  background: #1a2433;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  background: rgba(15, 32, 56, 0.5);
  border: 1px dashed var(--border-subtle);
  border-radius: 14px;
}

/* Responsive */
@media (max-width: 900px) {
  .cases-grid {
    grid-template-columns: 1fr;
  }
  .map-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .map-stage {
    height: 460px;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 12px 14px;
  }
  .main-content {
    padding: 14px;
  }
  .search-wrap input {
    width: 170px;
  }
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }
}
