:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --border: #e5eaf1;
  --border-soft: #eef2f7;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;

  --success: #16a34a;
  --success-soft: #dcfce7;

  --warning: #d97706;
  --warning-soft: #fef3c7;

  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.07);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
}

/* ========= BASE ========= */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--text);
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 10px;
}

h2 {
  font-size: 22px;
  margin-bottom: 14px;
}

h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

p {
  margin-top: 0;
}

pre {
  margin: 0;
}

.muted,
.muted-text {
  color: var(--muted);
  font-size: 14px;
}

/* ========= LAYOUT ========= */

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 20px 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar h1 {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  padding: 0 8px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar nav a {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  background: var(--sidebar-active);
  color: #fff;
}

.main {
  padding: 20px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}

.topbar h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.topbar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text-soft);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

.topbar a:hover {
  background: #eef2f7;
}

/* ========= PAGE SECTIONS ========= */

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

.page-header p {
  margin: 6px 0 0;
}

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

.section-header h2,
.section-header h3 {
  margin-bottom: 0;
}

/* ========= GRID ========= */

.grid,
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

/* ========= CARDS ========= */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 18px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card h2,
.card h3,
.card h4 {
  margin-bottom: 12px;
}

/* ========= STATS ========= */

.stat-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.mini-stat,
.stat-card {
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px 14px;
  min-width: 0;
}

.mini-stat-label,
.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.mini-stat-value,
.stat-value,
.metric {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 600;
  color: var(--text);
}

/* ========= LISTS / KV ========= */

.kv-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.kv-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
}

.kv-list li:last-child {
  border-bottom: none;
}

.kv-list span {
  color: var(--muted);
  font-size: 14px;
}

.kv-list strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

/* ========= FLASH ========= */

.flash {
  margin-bottom: 16px;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: pre-wrap;
}

.flash.success {
  background: var(--success-soft);
  color: #166534;
  border-color: #bbf7d0;
}

.flash.error {
  background: var(--danger-soft);
  color: #991b1b;
  border-color: #fecaca;
}

.flash.info {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #bfdbfe;
}

/* ========= FORMS ========= */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.form-group {
  min-width: 0;
}

.form-group label,
label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.checkbox-group {
  display: flex;
  align-items: flex-end;
}

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

input,
select,
button,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input[disabled],
select[disabled],
textarea[disabled] {
  background: #f8fafc;
  color: #64748b;
}

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

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.inline-form .form-group {
  min-width: 240px;
  flex: 1 1 260px;
}

/* ========= BUTTONS ========= */

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  min-width: 96px;
  padding: 0 14px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.15);
}

button:hover,
.btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

button.secondary,
.btn-secondary {
  background: #e2e8f0;
  color: #334155;
  box-shadow: none;
}

button.secondary:hover,
.btn-secondary:hover {
  background: #cbd5e1;
}

button.warning,
.btn-warning {
  background: #fff7ed;
  color: #9a3412;
  box-shadow: none;
  border: 1px solid #fed7aa;
}

button.warning:hover,
.btn-warning:hover {
  background: #ffedd5;
}

button.danger,
.btn-danger {
  background: var(--danger-soft);
  color: #991b1b;
  box-shadow: none;
  border: 1px solid #fecaca;
}

button.danger:hover,
.btn-danger:hover {
  background: #fecaca;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-small {
  min-width: 72px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 12px;
}

/* ========= ACTION LAYOUT ========= */

.actions,
.actions-row,
.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actions > *,
.actions-row > * {
  flex: 0 0 auto;
}

.table-actions a,
.table-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

/* ========= TABLES ========= */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

.compact-table {
  min-width: 680px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: right;
  vertical-align: middle;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: var(--text-soft);
  font-weight: 800;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fbff;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ========= BADGES / STATUS ========= */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}

.badge.active {
  background: var(--success-soft);
  color: #166534;
  border-color: #bbf7d0;
}

.badge.inactive {
  background: var(--danger-soft);
  color: #991b1b;
  border-color: #fecaca;
}

.badge.unknown {
  background: #ede9fe;
  color: #6d28d9;
  border-color: #ddd6fe;
}

/* ========= LOGS ========= */

pre.log {
  background: #0b1220;
  color: #dbeafe;
  padding: 16px;
  border-radius: 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.6;
}

/* ========= MISC ========= */

form.inline {
  display: inline;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-soft);
  margin: 16px 0;
}

/* ========= RESPONSIVE ========= */

@media (max-width: 1100px) {
  .stat-grid,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-3,
  .span-4,
  .span-6,
  .span-8 {
    grid-column: span 12;
  }
}

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

  .sidebar {
    padding: 14px 12px;
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form .form-group {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 700px) {
  body {
    font-size: 14px;
  }

  .main {
    padding: 10px;
  }

  .card {
    padding: 14px;
    border-radius: 16px;
    margin-bottom: 14px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .stat-grid,
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mini-stat-value,
  .stat-value,
  .metric {
    font-size: 22px;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 640px;
  }

  th,
  td {
    padding: 10px;
    font-size: 13px;
  }

  .actions,
  .actions-row,
  .table-actions,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .actions > *,
  .actions-row > *,
  .table-actions > *,
  .form-actions > * {
    width: 100%;
  }

  button,
  .btn {
    width: 100%;
  }
}

/* ========= UI-2A: Site Monitor refinements ========= */

.desktop-only {
  display: block;
}

.mobile-only {
  display: none !important;
}

.compact-actions {
  gap: 6px;
}

.mobile-cards {
  flex-direction: column;
  gap: 12px;
}

.mobile-cards.mobile-only {
  display: none !important;
}

.compact-actions .btn,
.compact-actions button,
.compact-actions a {
  width: auto !important;
  min-width: 72px;
  max-width: 130px;
  padding: 0 10px;
  flex: 0 0 auto !important;
}

.mobile-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 14px;
}

.mobile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.mobile-card-header h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}

.mobile-card-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}

.mobile-card-row:last-of-type {
  border-bottom: none;
}

.mobile-card-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.mobile-card-actions .btn,
.mobile-card-actions button,
.mobile-card-actions a {
  width: 100%;
  min-height: 40px;
}

@media (max-width: 900px) {
  .compact-actions .btn,
  .compact-actions button,
  .compact-actions a {
    max-width: none;
  }
}

@media (max-width: 700px) {
.desktop-only {
  display: none !important;
}

.mobile-only {
  display: block !important;
}

.mobile-cards.mobile-only {
  display: flex !important;
}

  .table-wrap.desktop-only {
    display: none !important;
  }

  .section-header .actions-row {
    width: 100%;
  }

  .section-header .actions-row form,
  .section-header .actions-row a {
    width: 100%;
  }

  .inline-form {
    margin-top: 12px;
  }

  .inline-form .form-actions,
  .inline-form .form-group {
    width: 100%;
  }
}

/* ========= UI-2B: mobile app-like site monitor ========= */

.site-monitor-top-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.site-monitor-top-actions > * {
  min-width: 0;
}

.site-monitor-top-actions form,
.site-monitor-top-actions a {
  width: 100%;
}

.site-monitor-top-actions .btn,
.site-monitor-top-actions button {
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  font-size: 14px;
}

.site-monitor-import-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-monitor-import-form input[type="file"] {
  font-size: 12px;
  background: #fff;
}

.site-card-mobile {
  border-radius: 20px;
  padding: 16px;
}

.site-card-mobile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.site-card-mobile-title-wrap {
  text-align: right;
  flex: 1;
  min-width: 0;
}

.site-card-mobile-title-wrap h4 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.25;
  word-break: break-word;
}

.site-card-mobile-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-weight: 800;
  font-size: 14px;
}

.status-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 16px;
  border: 2px solid rgba(0,0,0,0.08);
}

.status-dot-online {
  background: #22c55e;
}

.status-dot-offline {
  background: #ef4444;
}

.status-dot-unknown {
  background: #94a3b8;
}

.site-card-mobile-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.site-card-mobile-meta > div {
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

.site-card-mobile-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.site-card-mobile-actions .btn,
.site-card-mobile-actions button,
.site-card-mobile-actions a {
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  font-size: 14px;
  padding: 0 10px;
}

.site-card-mobile-actions .site-card-delete {
  grid-column: span 2;
}

.recipient-card-mobile h4 {
  font-size: 17px;
  line-height: 1.35;
  word-break: break-word;
}

@media (max-width: 900px) {
  .site-monitor-top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .site-monitor-top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .site-monitor-top-actions .btn,
  .site-monitor-top-actions button {
    min-height: 48px;
    font-size: 15px;
  }

  .mobile-card {
    border-radius: 20px;
    padding: 16px;
  }

  .site-card-mobile-title-wrap h4 {
    font-size: 18px;
  }

  .site-card-mobile-meta > div {
    font-size: 15px;
  }

  .site-card-mobile-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-card-mobile-actions .btn,
  .site-card-mobile-actions button,
  .site-card-mobile-actions a {
    min-height: 46px;
    font-size: 15px;
  }
}

/* ========= UI-3A: compact admin site-monitor ========= */

.compact-page-header {
  margin-bottom: 12px;
}

.compact-card {
  padding: 14px 16px;
  margin-bottom: 14px;
}

.compact-section-title {
  font-size: 18px;
  margin-bottom: 10px;
  font-weight: 700;
}

.compact-stats-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

.compact-stat {
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 0;
  text-align: center;
}

.compact-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
  font-weight: 700;
}

.compact-stat strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.compact-inline-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-field {
  min-width: 0;
  flex: 1 1 180px;
}

.compact-small-field {
  flex: 0 0 90px;
}

.compact-field label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
}

.compact-field input,
.compact-field select {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
}

.compact-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}

.compact-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.compact-btn {
  min-width: 92px !important;
  width: auto !important;
  min-height: 38px !important;
  height: 38px;
  padding: 0 12px !important;
  font-size: 13px !important;
  border-radius: 10px !important;
  flex: 0 0 auto !important;
  white-space: nowrap;
}

.compact-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-toolbar > * {
  flex: 0 0 auto;
}

.import-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.import-inline-form .compact-file-field {
  flex: 1 1 260px;
}

.import-inline-form input[type="file"] {
  min-height: 38px;
  padding: 7px 10px;
}

.compact-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.compact-filter-field {
  flex: 1 1 220px;
}

.site-table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  overflow: auto;
  max-height: 560px;
}

.compact-admin-table {
  min-width: 720px;
}

.compact-admin-table th,
.compact-admin-table td {
  font-size: 13px;
  padding: 9px 10px;
  vertical-align: middle;
}

.compact-admin-table th {
  font-weight: 700;
  color: var(--text-soft);
  background: #f8fafc;
}

.compact-table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.compact-table-actions .btn,
.compact-table-actions button,
.compact-table-actions a {
  width: auto !important;
  min-width: 66px !important;
  max-width: 110px;
  min-height: 32px !important;
  height: 32px;
  padding: 0 10px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  flex: 0 0 auto !important;
  white-space: nowrap;
}

.mobile-site-list,
.mobile-recipient-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-site-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 14px;
}

.mobile-site-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.mobile-site-title {
  flex: 1;
  min-width: 0;
  text-align: right;
}

.mobile-site-title h4 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 800;
  color: var(--text);
}

.mobile-site-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
  border: 2px solid rgba(0, 0, 0, 0.08);
}

.status-dot-online { background: #22c55e; }
.status-dot-offline { background: #ef4444; }
.status-dot-unknown { background: #94a3b8; }

.mobile-site-meta {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.mobile-site-meta > div {
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 14px;
}

.mobile-site-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mobile-site-actions .btn,
.mobile-site-actions button,
.mobile-site-actions a {
  width: 100%;
  min-height: 40px;
  border-radius: 12px;
  font-size: 14px;
  padding: 0 10px;
}

.mobile-site-delete {
  grid-column: span 2;
}

@media (max-width: 1200px) {
  .compact-stats-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .compact-inline-form {
    align-items: stretch;
  }

  .compact-field,
  .compact-small-field {
    flex: 1 1 180px;
  }

  .compact-toolbar {
    gap: 8px;
  }

  .compact-stats-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .compact-card {
    padding: 12px;
    border-radius: 16px;
  }

  .compact-section-title {
    font-size: 17px;
    margin-bottom: 8px;
  }

  .compact-stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-inline-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .compact-field,
  .compact-small-field {
    flex: initial;
    width: 100%;
  }

  .compact-btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  .compact-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .compact-toolbar > * {
    width: 100%;
  }

  .compact-toolbar .compact-btn,
  .compact-toolbar button,
  .compact-toolbar a {
    width: 100% !important;
    min-height: 42px !important;
    border-radius: 12px !important;
  }

  .site-table-wrap.desktop-only,
  .table-wrap.desktop-only {
    display: none !important;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: block !important;
  }

  .mobile-site-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ========= UI-3B.1 based on local sites/history mobile ========= */

.mobile-cards-view {
  display: none;
}

.mobile-card {
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.mobile-card-header h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  word-break: break-word;
}

.mobile-card-badge {
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.mobile-card-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.mobile-card-label {
  font-weight: 700;
  white-space: nowrap;
}

.mobile-card-actions {
  margin-top: 12px;
}

.users-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.users-card-actions button,
.users-card-actions a {
  width: 100%;
  margin: 0;
}

.mini-action-btn {
  width: 100% !important;
  min-width: 0 !important;
  padding: 8px 8px !important;
  font-size: 12px !important;
  line-height: 1.2;
  border-radius: 10px !important;
  white-space: nowrap;
}

.mobile-sites-cards {
  display: none;
}

.site-card-mobile {
  background: #ffffff;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.site-card-mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.site-card-mobile-header h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}

.site-card-mobile-status {
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.site-card-mobile-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}

.site-card-mobile-label {
  font-weight: 700;
  white-space: nowrap;
}

.compact-grid-actions,
.site-card-mobile-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 12px;
}

.compact-grid-actions button,
.compact-grid-actions a,
.site-card-mobile-actions button,
.site-card-mobile-actions a {
  width: 100%;
  margin: 0;
}

.sites-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.upload-mini-btn,
.mobile-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100% !important;
  padding: 8px 10px !important;
  font-size: 12px !important;
  border-radius: 10px !important;
  line-height: 1.2;
  white-space: nowrap;
}

.history-cards .mobile-card:last-child {
  margin-bottom: 0;
}

@media (max-width: 700px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only,
  .mobile-cards-view,
  .mobile-sites-cards {
    display: block !important;
  }

  .sites-actions-row {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sites-actions-row > form,
  .sites-actions-row > a,
  .sites-actions-row > button {
    width: 100% !important;
    min-width: 0;
    margin: 0;
  }

  .sites-actions-row .mobile-mini-btn,
  .sites-actions-row .upload-mini-btn {
    width: 100% !important;
    min-width: 0 !important;
    text-align: center;
  }

  .compact-inline-form {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .compact-stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* ========= SITE MONITOR - FULL COMPAT CSS ========= */

.compact-page-header {
  margin-bottom: 12px;
}

.compact-card {
  padding: 14px 16px;
  margin-bottom: 14px;
}

.compact-section-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.compact-stats-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

.compact-stats-row-lite {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-stat {
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: center;
  min-width: 0;
}

.compact-stat span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.compact-stat strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  color: var(--text);
}

.compact-help-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.compact-help-row span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.compact-inline-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-inline-form-tight {
  gap: 8px;
}

.compact-field {
  min-width: 0;
  flex: 1 1 180px;
}

.compact-xs-field {
  flex: 0 0 110px;
}

.compact-small-field {
  flex: 0 0 90px;
}

.compact-file-field {
  flex: 1 1 260px;
}

.compact-field label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
}

.compact-field input,
.compact-field select {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 10px;
}

.compact-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}

.compact-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.compact-btn {
  width: auto !important;
  min-width: 88px !important;
  min-height: 36px !important;
  height: 36px;
  padding: 0 12px !important;
  font-size: 13px !important;
  border-radius: 10px !important;
  flex: 0 0 auto !important;
  white-space: nowrap;
}

.compact-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-toolbar > * {
  flex: 0 0 auto;
}

.file-trigger-btn {
  cursor: pointer;
}

.import-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.compact-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.compact-filter-field {
  flex: 1 1 220px;
}

.site-table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  overflow: auto;
  max-height: 560px;
  background: #fff;
}

.compact-admin-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.compact-admin-table th,
.compact-admin-table td {
  padding: 9px 10px;
  font-size: 13px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-soft);
}

.compact-admin-table th {
  background: #f8fafc;
  color: var(--text-soft);
  font-weight: 700;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.compact-admin-table tbody tr:hover {
  background: #f8fbff;
}

.compact-admin-table .actions-col {
  text-align: center;
}

.compact-table-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.compact-table-actions .btn,
.compact-table-actions button,
.compact-table-actions a {
  width: auto !important;
  min-width: 64px !important;
  min-height: 31px !important;
  height: 31px;
  padding: 0 10px !important;
  font-size: 12px !important;
  border-radius: 8px !important;
  flex: 0 0 auto !important;
  white-space: nowrap;
}

.status-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  font-family: inherit !important;
}

.status-online-text {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.status-offline-text {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.status-unknown-text {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* ========= MOBILE CARDS ========= */

.mobile-cards-view {
  display: none;
}

.mobile-card {
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.mobile-card-header h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  word-break: break-word;
}

.mobile-card-badge {
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.mobile-card-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.mobile-card-label {
  font-weight: 700;
  white-space: nowrap;
}

.mobile-card-actions {
  margin-top: 12px;
}

.users-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.users-card-actions button,
.users-card-actions a {
  width: 100%;
  margin: 0;
}

.mini-action-btn {
  width: 100% !important;
  min-width: 0 !important;
  padding: 8px 8px !important;
  font-size: 12px !important;
  line-height: 1.2;
  border-radius: 10px !important;
  white-space: nowrap;
}

/* ========= MOBILE SITES ========= */

.mobile-sites-cards {
  display: none;
}

.site-card-mobile {
  background: #ffffff;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.site-card-mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.site-card-mobile-header h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  word-break: break-word;
}

.site-card-mobile-status {
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.site-card-mobile-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.site-card-mobile-label {
  font-weight: 700;
  white-space: nowrap;
}

.compact-grid-actions,
.site-card-mobile-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 12px;
}

.compact-grid-actions button,
.compact-grid-actions a,
.site-card-mobile-actions button,
.site-card-mobile-actions a {
  width: 100%;
  margin: 0;
}

.sites-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.upload-mini-btn,
.mobile-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100% !important;
  padding: 8px 10px !important;
  font-size: 12px !important;
  border-radius: 10px !important;
  line-height: 1.2;
  white-space: nowrap;
}

.history-card .table-scroll-wrap {
  max-height: 700px;
  overflow-y: auto;
  overflow-x: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.history-cards .mobile-card:last-child {
  margin-bottom: 0;
}

/* ========= RESPONSIVE ========= */

@media (max-width: 1200px) {
  .compact-stats-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .compact-stats-row-lite {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .compact-inline-form {
    align-items: stretch;
  }

  .compact-field,
  .compact-xs-field,
  .compact-small-field {
    flex: 1 1 160px;
  }
}

@media (max-width: 700px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only,
  .mobile-cards-view,
  .mobile-sites-cards {
    display: block !important;
  }

  .compact-card {
    padding: 12px;
    border-radius: 16px;
  }

  .compact-section-title {
    font-size: 17px;
    margin-bottom: 8px;
  }

  .compact-stats-row,
  .compact-stats-row-lite {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-help-row {
    flex-direction: column;
    gap: 6px;
  }

  .compact-inline-form {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .compact-field,
  .compact-xs-field,
  .compact-small-field,
  .compact-file-field {
    width: 100%;
    flex: initial;
  }

  .compact-btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  .compact-toolbar {
    display: none;
  }

  .sites-actions-row {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sites-actions-row > form,
  .sites-actions-row > a,
  .sites-actions-row > label,
  .sites-actions-row > button {
    width: 100% !important;
    min-width: 0;
    margin: 0;
  }

  .sites-actions-row .mobile-mini-btn,
  .sites-actions-row .upload-mini-btn {
    width: 100% !important;
    min-width: 0 !important;
    text-align: center;
  }

  .site-card-mobile-header h4 {
    font-size: 15px;
  }

  .site-card-mobile-status,
  .site-card-mobile-row,
  .mobile-card-row {
    font-size: 13px;
  }

  .compact-grid-actions,
  .site-card-mobile-actions,
  .users-card-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-grid-actions button,
  .compact-grid-actions a,
  .site-card-mobile-actions button,
  .site-card-mobile-actions a,
  .users-card-actions button,
  .users-card-actions a {
    width: 100%;
  }
}

/* ========= SITE MONITOR FIX PACK ========= */

/* top stats */
.compact-stats-row-top {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.compact-stats-row-top .compact-stat {
  padding: 14px 12px;
}

/* CSV import button alignment */
.compact-toolbar label.compact-btn,
.compact-toolbar .file-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  top: 0;
  margin: 0;
}

/* table status text */
.compact-admin-table .status-text {
  font-family: inherit !important;
  font-size: 12px;
  font-weight: 700;
}

/* center the "actions" column title */
.compact-admin-table th.actions-col {
  text-align: center !important;
}

/* mobile site card header */
.site-card-mobile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.site-card-mobile-title-wrap {
  flex: 1;
  min-width: 0;
  text-align: right;
}

.site-card-mobile-title-wrap h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}

.site-card-mobile-status {
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* smaller mobile action buttons */
.mobile-mini-btn {
  min-height: 34px !important;
  height: 34px !important;
  padding: 6px 8px !important;
  font-size: 11px !important;
  border-radius: 9px !important;
}

.site-card-mobile-actions button,
.site-card-mobile-actions a {
  min-height: 34px !important;
  height: 34px !important;
  padding: 6px 8px !important;
  font-size: 11px !important;
  border-radius: 9px !important;
}

/* keep cards tighter on mobile */
@media (max-width: 700px) {
  .compact-stats-row-top {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .site-card-mobile {
    padding: 12px;
  }

  .site-card-mobile-row {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .site-card-mobile-actions {
    gap: 6px;
  }

  .compact-toolbar label.compact-btn,
  .compact-toolbar .file-trigger-btn {
    top: 0;
  }
}

.compact-toolbar .btn-danger {
  min-width: 110px !important;
}

.compact-admin-table th.actions-col {
  text-align: center !important;
}

@media (max-width: 700px) {
  .sites-actions-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* ===== site monitor mobile header final fix ===== */

@media (max-width: 700px) {
  .site-card-mobile-header {
    display: flex !important;
    direction: ltr !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 10px !important;
  }

  .site-card-mobile-status {
    direction: rtl !important;
    text-align: left !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
    font-size: 13px !important;
    font-weight: 700 !important;
  }

  .site-card-mobile-title-wrap {
    direction: rtl !important;
    text-align: right !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  .site-card-mobile-title-wrap h4 {
    margin: 0 !important;
    font-size: 15px !important;
    line-height: 1.35 !important;
    word-break: break-word !important;
  }

  .site-card-mobile-actions button,
  .site-card-mobile-actions a,
  .mobile-mini-btn {
    min-height: 32px !important;
    height: 32px !important;
    padding: 5px 8px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
  }
}

@media (max-width: 700px) {
  .site-card-mobile-actions-3top {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
    margin-top: 12px !important;
  }

  .site-card-mobile-actions-3top > form,
  .site-card-mobile-actions-3top > a {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* שורה ראשונה: בדוק | נפילה | חזרה */
  .site-card-mobile-actions-3top > :nth-child(1),
  .site-card-mobile-actions-3top > :nth-child(2),
  .site-card-mobile-actions-3top > :nth-child(3) {
    grid-column: span 2;
  }

  /* שורה שנייה: עריכה | מחק */
  .site-card-mobile-actions-3top > :nth-child(4),
  .site-card-mobile-actions-3top > :nth-child(5) {
    grid-column: span 3;
  }

  .site-card-mobile-actions-3top button,
  .site-card-mobile-actions-3top a {
    width: 100% !important;
    min-height: 32px !important;
    height: 32px !important;
    padding: 5px 8px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
    margin: 0 !important;
  }
}

/* =========================================================
   Site Monitor subpages - dedicated design pass
========================================================= */

.site-monitor-subpage-header {
  margin-bottom: 14px;
}

.subpage-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-monitor-form-card,
.site-monitor-selection-card {
  padding: 16px 18px;
}

.site-monitor-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  align-items: end;
}

.site-monitor-form-grid .compact-field {
  min-width: 0;
}

.form-field-wide {
  flex: 1 1 320px;
}

.compact-check-wrap {
  display: flex;
  align-items: center;
}

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

.subpage-sticky-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.site-monitor-table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  overflow: auto;
  background: #fff;
}

.site-monitor-table-wrap-tall {
  max-height: 560px;
}

.checkbox-cell {
  text-align: center;
  width: 70px;
}

.checkbox-cell input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

@media (max-width: 900px) {
  .site-monitor-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .site-monitor-form-card,
  .site-monitor-selection-card {
    padding: 12px;
  }

  .subpage-top-actions,
  .subpage-form-actions,
  .subpage-sticky-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .subpage-top-actions > *,
  .subpage-form-actions > *,
  .subpage-sticky-actions > * {
    width: 100%;
  }

  .site-monitor-table-wrap-tall {
    max-height: 420px;
  }
}

/* =========================================================
   Camera Links - dedicated design pass
========================================================= */

.camera-links-page .compact-field,
.camera-links-edit-page .compact-field {
  min-width: 0;
}

.camera-links-table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  overflow: auto;
  background: #fff;
}

.camera-links-table-wrap table {
  min-width: 720px;
}

@media (max-width: 700px) {
  .camera-links-page .subpage-form-actions,
  .camera-links-edit-page .subpage-form-actions,
  .camera-links-edit-page .subpage-top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .camera-links-page .subpage-form-actions > *,
  .camera-links-edit-page .subpage-form-actions > *,
  .camera-links-edit-page .subpage-top-actions > * {
    width: 100%;
  }
}

/* =========================================================
   Settlements - dedicated design pass
========================================================= */

.settlements-page .compact-field,
.edit-settlement-page .compact-field {
  min-width: 0;
}

.settlements-table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  overflow: auto;
  background: #fff;
}

.settlements-table-wrap table {
  min-width: 820px;
}

@media (max-width: 700px) {
  .settlements-page .subpage-form-actions,
  .edit-settlement-page .subpage-form-actions,
  .edit-settlement-page .subpage-top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .settlements-page .subpage-form-actions > *,
  .edit-settlement-page .subpage-form-actions > *,
  .edit-settlement-page .subpage-top-actions > * {
    width: 100%;
  }
}

/* =========================================================
   Auth / Logs / Maintenance / Dashboard polish
========================================================= */

.auth-shell {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.auth-card-narrow {
  max-width: 420px;
}

.auth-header {
  margin-bottom: 18px;
  text-align: center;
}

.auth-header h1 {
  margin-bottom: 8px;
  font-size: 28px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-submit-btn {
  width: 100% !important;
}

.auth-actions {
  display: grid;
  gap: 10px;
}

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

.maintenance-actions > form {
  flex: 0 0 auto;
}

@media (max-width: 700px) {
  .auth-card {
    padding: 18px 16px;
    border-radius: 18px;
  }

  .auth-header h1 {
    font-size: 24px;
  }

  .maintenance-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .maintenance-actions > form {
    width: 100%;
  }
}

/* =========================================================
   Sidebar + Topbar polishing
========================================================= */

.sidebar {
  padding: 18px 14px;
}

.sidebar-brand {
  padding: 8px 10px 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.2px;
}

.sidebar-brand-subtitle {
  margin-top: 6px;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.18s ease;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
  background: var(--sidebar-active);
  color: #fff;
}

.polished-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 18px;
}

.topbar-side {
  min-width: 0;
}

.topbar-right {
  text-align: right;
}

.topbar-center {
  text-align: center;
}

.topbar-left {
  display: flex;
  justify-content: flex-start;
}

.polished-topbar h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.topbar-time {
  font-size: 13px;
  font-weight: 600;
}

.topbar-logout-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  background: #f8fafc !important;
  color: var(--text-soft) !important;
  border: 1px solid var(--border) !important;
  font-size: 13px;
  font-weight: 700;
  box-shadow: none !important;
}

.topbar-logout-btn:hover {
  background: #eef2f7 !important;
}

@media (max-width: 900px) {
  .sidebar-brand {
    padding: 4px 6px 12px;
  }

  .sidebar-brand h1 {
    font-size: 20px;
  }

  .sidebar-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sidebar-nav a {
    justify-content: center;
    text-align: center;
    padding: 10px 12px;
    min-height: 42px;
  }

  .polished-topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    text-align: center;
  }

  .topbar-right,
  .topbar-center,
  .topbar-left {
    text-align: center;
    justify-content: center;
  }

  .polished-topbar h2 {
    font-size: 22px;
  }
}

@media (max-width: 700px) {
  .sidebar {
    padding: 12px 10px;
  }

  .sidebar-brand {
    padding: 0 4px 10px;
    margin-bottom: 8px;
  }

  .sidebar-brand-subtitle {
    font-size: 11px;
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .polished-topbar {
    padding: 12px 14px;
    border-radius: 16px;
  }

  .polished-topbar h2 {
    font-size: 20px;
  }

  .topbar-time {
    font-size: 12px;
  }

  .topbar-logout-btn {
    width: 100%;
    max-width: 180px;
  }
}

/* ===== Mobile cleanup pass v1 ===== */
.auth-layout {
  grid-template-columns: 1fr;
}

.auth-main {
  padding: 24px 16px;
}

.dashboard-mobile-cards .mobile-card h4,
.dashboard-mobile-cards .mobile-card span[dir="ltr"] {
  word-break: break-word;
}

.selection-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

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

  .sidebar {
    padding: 10px 0 6px;
    border-left: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .sidebar-brand {
    padding: 0 16px 10px;
    margin-bottom: 6px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding: 0 12px 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    grid-template-columns: none !important;
  }

  .sidebar-nav a {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 14px;
    white-space: nowrap;
    border-radius: 999px;
    font-size: 13px;
  }

  .main {
    padding: 14px;
  }

  .page-header,
  .section-header,
  .site-monitor-subpage-header {
    flex-direction: column;
    align-items: stretch;
  }

  .kv-list li {
    grid-template-columns: 1fr;
    gap: 4px;
    text-align: right;
  }

  .kv-list strong {
    justify-self: start;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .responsive-table,
  .camera-links-table-wrap,
  .settlements-table-wrap,
  .site-monitor-table-wrap {
    overflow-x: visible;
  }

  .compact-table,
  .compact-admin-table {
    min-width: 0 !important;
  }

  .subpage-sticky-actions {
    position: static;
    padding: 12px 0 0;
    background: transparent;
    border-top: 0;
  }

  .selection-tools > * ,
  .subpage-sticky-actions > * {
    width: 100%;
  }
}


/* ===== Focused mobile menu fix ===== */
.mobile-top-nav {
  display: none;
}

@media (max-width: 700px) {
  .sidebar {
    display: none !important;
  }

  .layout {
    grid-template-columns: 1fr !important;
  }

  .main {
    padding: 14px !important;
  }

  .polished-topbar {
    grid-template-columns: 1fr auto !important;
    gap: 8px 12px !important;
    padding: 14px !important;
    border-radius: 18px !important;
    margin-bottom: 14px !important;
  }

  .topbar-right {
    grid-column: 1 / 2;
    grid-row: 1;
    text-align: right !important;
  }

  .topbar-left {
    grid-column: 2 / 3;
    grid-row: 1;
    justify-content: flex-start !important;
    align-self: start;
  }

  .topbar-center {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: right !important;
    justify-content: flex-start !important;
  }

  .polished-topbar h2 {
    font-size: 18px !important;
    line-height: 1.15 !important;
  }

  .topbar-time {
    font-size: 11px !important;
    opacity: 0.78;
  }

  .topbar-logout-btn {
    min-width: 76px !important;
    height: 34px !important;
    padding: 0 12px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    width: auto !important;
    max-width: none !important;
  }

  .mobile-top-nav {
    display: flex !important;
    grid-column: 1 / -1;
    grid-row: 3;
    gap: 8px;
    overflow-x: auto;
    padding-top: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-top-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-top-nav a {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: none;
  }

  .mobile-top-nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: #c7d2fe;
  }
}


/* ===== Focused patch v1: dashboard + camera-links + offline sort support ===== */

.dashboard-grid > .card,
.dashboard-mobile-cards .mobile-card,
.dashboard-mobile-cards .mobile-card-header,
.dashboard-mobile-cards .mobile-card-row {
  min-width: 0;
}

.responsive-table {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: #fff;
}

.dashboard-disk-table-wrap {
  overflow-x: hidden;
}

.dashboard-disk-table {
  width: 100%;
  min-width: 0 !important;
  table-layout: fixed;
}

.dashboard-disk-table th,
.dashboard-disk-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dashboard-mobile-cards .mobile-card {
  overflow: hidden;
}

.dashboard-mobile-cards .mobile-card-header h4 {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dashboard-mobile-cards .mobile-card-badge,
.dashboard-mobile-cards .mobile-card-row span[dir="ltr"] {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 700px) {
  .dashboard-disk-table-wrap {
    overflow-x: visible !important;
    border: 0;
    background: transparent;
  }

  .dashboard-mobile-cards .mobile-card-header {
    align-items: flex-start;
  }

  .dashboard-mobile-cards .mobile-card-badge {
    flex: 0 0 auto;
    max-width: 42%;
    text-align: left;
  }
}


/* Compact status lists in maintenance cards */
.compact-status-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.compact-status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.compact-status-list div:last-child {
  border-bottom: 0;
}

.compact-status-list strong {
  font-weight: 700;
}

.compact-status-list span {
  text-align: left;
  color: #334155;
}

/* Alerts mailbox maintenance panel */
.alerts-mailbox-table th,
.alerts-mailbox-table td,
.alerts-mailbox-mobile .mobile-card,
.alerts-mailbox-mobile .mobile-card h4,
.alerts-mailbox-mobile .mobile-card span[dir="ltr"] {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Camera billing dashboard panel */
.camera-billing-table th,
.camera-billing-table td,
.camera-billing-mobile .mobile-card,
.camera-billing-mobile .mobile-card h4,
.camera-billing-mobile .mobile-card span[dir="ltr"] {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Camera identity update card */
.camera-identity-update-form {
  margin: 12px 0;
  display: flex;
  justify-content: flex-start;
}

.camera-identity-update-button {
  width: auto;
  max-width: 100%;
}

.camera-identity-summary-row {
  align-items: center;
  gap: 8px;
}

@media (max-width: 700px) {
  .camera-identity-update-form {
    justify-content: stretch;
  }

  .camera-identity-update-button {
    width: 100%;
  }

  .camera-identity-summary-row {
    align-items: flex-start;
  }
}

/* Camera identity maintenance table */
.camera-identity-maintenance-table th,
.camera-identity-maintenance-table td,
.camera-identity-maintenance-mobile .mobile-card,
.camera-identity-maintenance-mobile .mobile-card h4,
.camera-identity-maintenance-mobile .mobile-card span[dir="ltr"] {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.camera-identity-maintenance-table th,
.camera-identity-maintenance-table td {
  text-align: center;
  vertical-align: middle;
}

.camera-identity-maintenance-table th:first-child,
.camera-identity-maintenance-table td:first-child {
  text-align: right;
}
