:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1e2a3b;
  --muted: #6b7a90;
  --blue: #2f80ed;
  --green: #27ae60;
  --red: #e74c3c;
  --purple: #9b51e0;
  --orange: #f2994a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  font-family: 'Cairo', 'Nunito', 'Tahoma', 'Arial', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  text-align: right;
}

.topbar {
  background: linear-gradient(90deg, #1c4da1, #2f80ed);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.title {
  font-size: 20px;
  font-weight: 800;
  display: flex;
  gap: 10px;
  align-items: center;
}

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

.topbar .actions .btn {
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 13px;
  gap: 6px;
}

.topbar .actions .pill {
  padding: 5px 11px;
  font-size: 13px;
}

.btn {
  background: linear-gradient(135deg, #1c4da1, #2461c5);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.25);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn.secondary {
  background: #fff;
  color: #1c4da1;
  border: 1px solid #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}
.btn:not(.ghost):hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 26px rgba(15, 23, 42, 0.3);
}

.container {
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 16px 24px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 12px;
  align-items: end;
  margin: 12px 0 8px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.filters .filter-group {
  min-width: 0;
}

@media (min-width: 980px) {
  .filters.filters-row {
    grid-template-columns:
      minmax(180px, 2fr)
      minmax(110px, 1fr)
      minmax(110px, 1fr)
      minmax(100px, 0.9fr)
      minmax(100px, 0.9fr)
      minmax(130px, 1fr)
      minmax(120px, 0.9fr);
  }
}

.filter-summary {
  display: none;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.filter-summary.active {
  display: flex;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  font-size: 13px;
  line-height: 1.2;
  color: var(--text);
}

.filter-pill-text {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.filter-pill-key {
  color: var(--muted);
  font-weight: 800;
}

.filter-pill-sep {
  color: rgba(107, 122, 144, 0.7);
  font-weight: 900;
}

.filter-pill-value {
  color: var(--text);
  font-weight: 900;
}

.filter-pill .count {
  background: rgba(47, 128, 237, 0.12);
  color: #1c4da1;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid rgba(47, 128, 237, 0.18);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.filters input,
.filters select {
  width: 100%;
  height: 42px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
  font-weight: 700;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.filters input::placeholder {
  color: rgba(107, 122, 144, 0.8);
  font-weight: 700;
}

.filters input:focus,
.filters select:focus {
  outline: none;
  border-color: rgba(47, 128, 237, 0.7);
  box-shadow: 0 0 0 4px rgba(47, 128, 237, 0.12), inset 0 1px 2px rgba(15, 23, 42, 0.05);
  background: #fff;
}

.filters .btn {
  height: 42px;
  padding: 8px 14px;
  border-radius: 14px;
  justify-content: center;
  white-space: nowrap;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.14);
  width: 100%;
}

.sort-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filters .sort-buttons .btn {
  width: 100%;
  min-width: 0;
}

.sort-btn.is-active {
  background: linear-gradient(135deg, #1c4da1, #2461c5);
  color: #fff;
  border: none;
}

.filters #resetFilters,
.filters #wideReset {
  background: rgba(255, 255, 255, 0.9);
  color: #1c4da1;
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
}

.filters #resetFilters:hover,
.filters #wideReset:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.1);
}

@media (max-width: 780px) {
  .filters {
    grid-template-columns: 1fr;
  }
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ccc;
}

.month-switcher {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
  flex-wrap: wrap;
}

.month-switcher select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d9e1ec;
  background: #fff;
  min-width: 180px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

.month-switcher .month-upload-btn {
  padding: 8px 12px;
  border-radius: 10px;
  white-space: nowrap;
  order: -1;
}

.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  gap: 12px;
  box-shadow: var(--shadow);
  align-items: center;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.bg-blue { background: var(--blue); }
.bg-green { background: var(--green); }
.bg-red { background: var(--red); }
.bg-purple { background: var(--purple); }
.bg-orange { background: var(--orange); }

.card-content p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.card-content h2 {
  margin: 2px 0 0;
  font-size: 24px;
}

#cardTopCompany {
  font-size: 20px;
  line-height: 1.25;
}

.grid.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.panel-header-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.panel-header-actions .btn {
  font-size: 14px;
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.device-table-sticky {
  position: sticky;
  top: 8px;
  z-index: 35;
  background: var(--card);
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.table-wrapper {
  overflow-x: auto;
}

.table-wrapper.wide {
  overflow-x: auto;
  position: relative;
  padding-top: 20px;
  padding-bottom: 20px;
}

.scrollbar-sync {
  overflow-x: auto;
  height: 14px;
  margin: 4px 0;
}

.scrollbar-sync .scrollbar-inner {
  height: 1px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #eef1f7;
}

thead {
  background: #f6f8fc;
}

tbody tr:nth-child(odd) {
  background: #fbfcff;
}

tbody tr.zero {
  background: #ffeaea;
  color: #9b1b1b;
}

.selection-col {
  width: 46px;
  text-align: center !important;
}

#deviceTable input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #1c4da1;
  cursor: pointer;
}

#deviceTable tr.row-excluded {
  opacity: 0.52;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
}

.badge.high { background: var(--green); }
.badge.medium { background: var(--blue); }
.badge.low { background: var(--orange); }
.badge.zero { background: var(--red); }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 12px;
  background: #eef1f7;
  color: var(--text);
}

.status-chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.status-chip.active { background: #eaf7f1; color: var(--green); }
.status-chip.returned { background: #fef3e6; color: var(--orange); }
.status-chip.office { background: #e9f1ff; color: #1c4da1; }
.status-chip.broken { background: #ffeaea; color: var(--red); }
.status-chip.maintenance { background: #f6e8ff; color: var(--purple); }
.status-chip.pending { background: #fff4e6; color: #f2994a; }
.status-chip.unknown { background: #f1f2f6; color: var(--muted); }

.link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.table-device-link {
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
  border-radius: 6px;
  padding: 1px 4px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.table-device-link:hover {
  color: #1c4da1;
  background: rgba(28, 77, 161, 0.12);
}

.last-update-cell {
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.last-update-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.last-update-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: #fff;
  color: #1c4da1;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.last-update-btn:hover {
  background: #eef4ff;
}

.table-device-link:focus-visible {
  outline: 2px solid rgba(28, 77, 161, 0.35);
  outline-offset: 1px;
}

.pill {
  background: #e9f1ff;
  color: #1c4da1;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
}

.auth-topbar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.auth-topbar .auth-user-pill {
  white-space: nowrap;
}

.auth-topbar .auth-logout-btn {
  white-space: nowrap;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.info-card {
  background: #f7f9fd;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #eef1f7;
}

.info-card .label {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.info-card .value {
  margin: 4px 0 0;
  font-weight: 800;
  word-break: break-word;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.panel form input,
.panel form textarea,
.panel form select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #d9e1ec;
  font-size: 14px;
  font-family: inherit;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

.panel form textarea {
  resize: vertical;
}

.drawer form label {
  font-weight: 700;
  color: #475569;
  font-size: 13px;
}

.drawer form input,
.drawer form textarea,
.drawer form select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #dfe4ef;
  background: #f7f9fd;
  font-size: 14px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.drawer form input:focus,
.drawer form textarea:focus,
.drawer form select:focus {
  border-color: #1c4da1;
  box-shadow: 0 0 0 3px rgba(28, 77, 161, 0.12);
  outline: none;
}

.drawer form textarea {
  min-height: 90px;
  resize: vertical;
}

.divider {
  margin: 16px 0;
  border-top: 1px dashed #d9e1ec;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#deviceLogsList.timeline {
  max-height: 55vh;
  overflow-y: auto;
  padding-inline-end: 4px;
}

.event-item {
  background: #f7f9fd;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #eef1f7;
}

.event-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.event-type {
  font-weight: 800;
}

.event-meta {
  color: var(--muted);
  font-size: 12px;
}

.event-text {
  margin: 0 0 6px;
  color: var(--text);
}

.muted {
  color: var(--muted);
}

.flash {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #e9f1ff;
  color: #1c4da1;
  font-weight: 700;
}

.flash.error {
  background: #ffeaea;
  color: #9b1b1b;
}

.flash.flash-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  margin: 0;
  min-width: 280px;
  max-width: min(92vw, 440px);
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  z-index: 95;
  transition: opacity 0.18s ease, transform 0.2s ease;
  backdrop-filter: blur(4px);
}

.flash.flash-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.flash.flash-toast.success {
  background: linear-gradient(135deg, #1c4da1, #2461c5);
  color: #fff;
}

.flash.flash-toast.error {
  background: linear-gradient(135deg, #b42318, #dc2626);
  color: #fff;
}

.flash.flash-toast::before {
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  content: '\f00c';
  font-size: 14px;
}

.flash.flash-toast.error::before {
  content: '\f071';
}

@media (max-width: 640px) {
  .flash.flash-toast {
    min-width: auto;
    width: calc(100vw - 30px);
    font-size: 14px;
  }
}

.btn.ghost {
  background: #f5f7fb;
  color: #1c4da1;
  border: 1px solid #cbd5e1;
}

.modal-actions .btn {
  min-width: 130px;
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: 0 10px 20px rgba(28, 77, 161, 0.15);
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.modal-actions .btn:not(.ghost) {
  background: linear-gradient(135deg, #1c4da1, #2461c5);
  color: #fff;
  border: none;
}
.modal-actions .btn:not(.ghost):hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(28, 77, 161, 0.25);
}
.modal-actions .btn.ghost {
  background: #fff;
  color: #1c4da1;
  border: 1px solid #d2d9e4;
  box-shadow: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top center, rgba(15, 23, 42, 0.65), rgba(15, 23, 42, 0.85)),
    rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}
.modal.hidden {
  display: none;
}
.modal-content {
  width: min(640px, 90vw);
  background: #fefefe;
  border-radius: 24px;
  box-shadow: 0 35px 60px rgba(15, 23, 42, 0.28);
  padding: 28px 32px;
  max-height: 72vh;
  overflow-y: auto;
  position: relative;
  font-family: 'Cairo', 'Nunito', 'Tahoma', 'Arial', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-close {
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: #475569;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
body.modal-open {
  overflow: hidden;
}

.revenue-upload-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.revenue-upload-file-name {
  font-weight: 700;
  color: #334155;
  word-break: break-word;
}

.revenue-upload-hint {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.revenue-upload-hint.error {
  color: #9b1b1b;
}

.revenue-upload-hint.success {
  color: #0f766e;
}

.revenue-preview {
  border: 1px solid #dbe7f8;
  background: #f8fbff;
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.revenue-preview h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: #1c4da1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.revenue-preview-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.revenue-stat {
  background: #fff;
  border: 1px solid #dbe7f8;
  border-radius: 10px;
  padding: 8px 10px;
}

.revenue-stat .label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.revenue-stat .value {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.revenue-preview-missing {
  border-top: 1px dashed #cbd5e1;
  padding-top: 8px;
}

.revenue-preview-title {
  margin: 0 0 6px;
  color: #9b1b1b;
  font-weight: 800;
  font-size: 13px;
}

.revenue-preview-missing ul {
  margin: 0;
  padding: 0 18px 0 0;
  display: grid;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.revenue-preview-missing li {
  font-size: 13px;
  color: #334155;
  font-weight: 700;
}

.settings-page .settings-hint {
  margin: -4px 0 14px;
  font-weight: 700;
}

.settings-page .settings-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.settings-page .settings-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.settings-page .settings-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-page .settings-card-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-page .settings-card-title h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
}

.settings-page .settings-card-title .muted {
  margin: 2px 0 0;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
}

.settings-page .settings-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(47, 128, 237, 0.12);
  color: #1c4da1;
  border: 1px solid rgba(47, 128, 237, 0.18);
}

.settings-page .settings-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(148, 163, 184, 0.45);
}

.settings-page .settings-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-page .settings-item-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
}

.settings-page .settings-handle {
  text-align: center;
  color: rgba(107, 122, 144, 0.75);
  font-weight: 900;
  user-select: none;
}

.settings-page .settings-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
  font-weight: 800;
  font-family: inherit;
}

.settings-page .settings-input:focus {
  outline: none;
  border-color: rgba(47, 128, 237, 0.7);
  box-shadow: 0 0 0 4px rgba(47, 128, 237, 0.12);
  background: #fff;
}

.settings-page .settings-del {
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 900;
  cursor: pointer;
  border: 1px solid rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.10);
  color: #9b1b1b;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.settings-page .settings-del:hover {
  background: rgba(239, 68, 68, 0.14);
}

.settings-page .settings-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

.settings-page .settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.settings-page .settings-btn-sm {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.10);
}

.settings-page .users-table th,
.settings-page .users-table td {
  text-align: right;
}

.settings-page .settings-user-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 12px;
  align-items: end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(148, 163, 184, 0.45);
}

.settings-page .settings-user-submit {
  height: 42px;
  width: 100%;
  justify-content: center;
}

.settings-page .settings-footnote {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 700;
}

.text-red {
  color: #e74c3c;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.drawer.hidden {
  display: none;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
}
.drawer-panel {
  position: relative;
  width: min(920px, 98vw);
  max-height: 92vh;
  background: #fefefe;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.22);
  padding: 30px 36px;
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-radius: 30px;
  border: 1px solid rgba(28, 77, 161, 0.15);
}
.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 72vh;
  overflow-y: auto;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.drawer-close {
  border: none;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
  color: #475569;
  line-height: 1;
}
.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.drawer-map-card {
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(135deg, #f8fbff, #eef3ff);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  border: 1px solid #e0e7ff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
.contact-line {
  line-height: 1.4;
  display: block;
}
.contact-block {
  margin-bottom: 4px;
}
.contact-phone {
  color: #1c4da1;
  font-weight: 700;
}
.contact-extra {
  margin-top: 6px;
  color: #1c4da1;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.contact-repeater {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.contact-repeater-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.contact-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.contact-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d9e1ec;
  font-family: inherit;
  font-size: 14px;
}
.contact-remove {
  padding: 8px 10px;
  border-radius: 10px;
}
.drawer-map {
  min-height: 180px;
  border-radius: 14px;
  overflow: hidden;
  background: #e2e8f0;
  border: 1px solid #d1d9e3;
}
.drawer-map-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drawer-map-label {
  margin: 0;
  font-size: 13px;
  color: #6b7a90;
}
.drawer-map-detail {
  font-weight: 700;
  margin: 0;
  color: #111a2b;
}
.location-summary {
  border-radius: 20px;
  background: #fff;
  padding: 14px 18px 18px;
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}
.location-summary h4 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: #1c4da1;
}
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: #1f2a37;
}
.summary-table th,
.summary-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #edf1f7;
  text-align: right;
}
.summary-table th {
  font-weight: 800;
  color: #1c4da1;
  width: 25%;
  white-space: nowrap;
}
.summary-table td {
  font-weight: 600;
}
.summary-table .contact-phone {
  color: #1f2a37;
  font-weight: 700;
}
.summary-table td a {
  color: #1c4da1;
  font-weight: 700;
}
.summary-table tbody tr:last-child td,
.summary-table tbody tr:last-child th {
  border-bottom: none;
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.status-form.locked .form-actions {
  display: none;
}
.status-form.locked select,
.status-form.locked textarea,
.status-form.locked input {
  background: #f7f9fd;
  color: #6b7a90;
  cursor: not-allowed;
}
.settings-grid textarea {
  min-height: 90px;
}
.hidden {
  display: none !important;
}
.location-request-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  direction: rtl;
  table-layout: auto;
}
.location-request-panel th,
.location-request-panel td {
  padding: 8px;
  border-bottom: 1px solid #eef1f7;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
.location-request-panel th {
  font-weight: 800;
  color: #475569;
  background: #f7f9fd;
}
.location-request-panel td {
  background: #fff;
  font-weight: 600;
}
.location-request-panel td .small-text {
  font-size: 12px;
  color: #8f9fb8;
  display: inline-block;
  margin-left: 6px;
  font-weight: 500;
}
.location-request-detail-table {
  table-layout: fixed;
}
.location-request-detail-table th {
  white-space: normal;
}
.location-request-detail-table td {
  white-space: normal;
  padding: 10px;
  background: #fff;
}
.location-request-detail {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.location-request-meta {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #334155;
}
.location-request-meta strong {
  color: #1c4da1;
  font-weight: 800;
}
.location-request-detail .summary-table {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}
.location-request-detail .summary-table th,
.location-request-detail .summary-table td {
  padding: 7px 8px;
}
.location-request-note {
  border: 1px dashed #d1d9e3;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  color: #334155;
  font-size: 13px;
}
.location-history-panel {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.location-history-panel .panel-header h3 {
  font-size: 15px;
}
.location-history-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.location-history-panel th,
.location-history-panel td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #eef1f7;
}
.location-history-panel tbody tr:last-child td {
  border-bottom: none;
}
.radio-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.radio-row label {
  font-size: 13px;
  font-weight: 700;
  color: #1c4da1;
}
.radio-row input {
  margin-left: 6px;
}

.modal-content label {
  font-weight: 700;
  color: #314155;
  font-size: 14px;
}
.modal-content input,
.modal-content textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d1d9e3;
  background: #fff;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.modal-content select {
  width: 100%;
  height: 44px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-family: inherit;
}
.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
  border-color: #1c4da1;
  box-shadow: 0 0 0 3px rgba(28, 77, 161, 0.12);
  outline: none;
}
.modal-content textarea {
  resize: vertical;
}

.smartbox-wrap {
  position: relative;
}

.smartbox-list {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 14px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
  max-height: 240px;
  overflow-y: auto;
  z-index: 80;
  padding: 6px;
}

.smartbox-list.hidden {
  display: none;
}

.smartbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 800;
  color: var(--text);
}

.smartbox-item:hover,
.smartbox-item.active {
  background: rgba(47, 128, 237, 0.10);
}

.smartbox-item .muted {
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
  .actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .topbar .actions .btn {
    padding: 7px 11px;
    font-size: 12px;
  }
  .topbar .actions .pill {
    padding: 5px 10px;
    font-size: 12px;
  }
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .card {
    flex-direction: row;
  }
  .drawer-panel {
    width: 100%;
    border-radius: 0;
    padding: 20px;
  }
  .drawer-map-card {
    grid-template-columns: 1fr;
  }
  .location-request-meta {
    flex-direction: column;
    gap: 6px;
  }
}
