/* ============================================================
   HD Screen - Design System
   main.css - Dashboard - Full Design System
   ============================================================ */

/* -- Google Fonts ------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Readex+Pro:wght@300;400;500;600&display=swap');

/* -- CSS Variables ------------------------------------------ */
:root {
  /* Brand */
  --primary:        #1B6FD8;
  --primary-dark:   #0C4FA3;
  --primary-light:  #E6F1FB;
  --primary-mid:    #378ADD;

  /* Sidebar */
  --sidebar-bg:     #1B6FD8;
  --sidebar-active: rgba(255,255,255,0.18);
  --sidebar-hover:  rgba(255,255,255,0.10);
  --sidebar-text:   rgba(255,255,255,0.90);
  --sidebar-muted:  rgba(255,255,255,0.55);
  --sidebar-border: rgba(255,255,255,0.12);
  --sidebar-width:  240px;

  /* Neutral */
  --white:          #FFFFFF;
  --bg-page:        #F4F6F9;
  --bg-card:        #FFFFFF;
  --bg-surface:     #F8F9FB;

  /* Text */
  --text-primary:   #111827;
  --text-secondary: #4B5563;
  --text-muted:     #9CA3AF;
  --text-hint:      #C4CAD4;

  /* Border */
  --border:         #E5E7EB;
  --border-focus:   #1B6FD8;

  /* Semantic */
  --success:        #639922;
  --success-bg:     #EAF3DE;
  --success-text:   #3B6D11;
  --danger:         #E24B4A;
  --danger-bg:      #FCEBEB;
  --danger-text:    #A32D2D;
  --warning:        #BA7517;
  --warning-bg:     #FAEEDA;
  --warning-text:   #854F0B;
  --info:           #1B6FD8;
  --info-bg:        #E6F1FB;
  --info-text:      #0C4FA3;

  /* Typography */
  --font-heading:   'Readex Pro', sans-serif;
  --font-body:      'Readex Pro', sans-serif;

  /* Radius */
  --radius-sm:      6px;
  --radius-md:      8px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --radius-full:    9999px;

  /* Shadow */
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);

  /* Topbar */
  --topbar-h:       60px;

  /* Transition */
  --transition:     0.18s ease;
}

/* -- Reset -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* الأرقام الإنجليزية في الجداول والقيم الرقمية تظهر بأرقام مصطفّة (Tabular + Lining) */
table, .table, .data-table,
.stat-card-value, .progress-value, .progress-label,
.sub-card-days,
[class*="num"], [class*="value"], [class*="count"], [class*="amount"] {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* -- App Shell ---------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* -- Sidebar ------------------------------------------------ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

/* LTR override */
[dir="ltr"] .sidebar { right: auto; left: 0; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.18);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-logo-text .brand-hd {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-logo-text .brand-screen {
  font-size: 10px;
  font-weight: 400;
  color: var(--sidebar-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-business {
  padding: 14px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-business-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-business-role {
  font-size: 11px;
  color: var(--sidebar-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--sidebar-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 400;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(255,255,255,0.22);
  color: #fff;
  font-weight: 600;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 1px 3px rgba(0,0,0,0.15);
}

/* Vertical indicator bar — RTL default: sidebar on right → bar on left inner edge */
.sidebar-link.active::before {
  content: '';
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 0;
  width: 3px;
  background: #fff;
  border-radius: 0 3px 3px 0;
}

/* LTR: sidebar on left → bar on right inner edge */
[dir="ltr"] .sidebar-link.active::before {
  left: auto;
  right: 0;
  border-radius: 3px 0 0 3px;
}

.sidebar-link svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 12px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-muted);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  background: none;
  border: none;
  width: 100%;
  text-align: right;
}

[dir="ltr"] .sidebar-logout { text-align: left; }

.sidebar-logout:hover {
  background: rgba(226,75,74,0.18);
  color: #fca5a5;
}

.sidebar-logout svg { width: 16px; height: 16px; stroke: currentColor; }

/* -- Main Area ---------------------------------------------- */
.main-area {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

[dir="ltr"] .main-area { margin-right: 0; margin-left: var(--sidebar-width); }

/* -- Topbar ------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 160px;
  min-width: 0;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
}

.topbar-role-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

/* -- Topbar Business Badge ---------------------------------- */
.topbar-biz-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid rgba(27,111,216,0.2);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* -- Lang Toggle -------------------------------------------- */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.lang-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* -- Page Content ------------------------------------------- */
/* -- Breadcrumb Bar ----------------------------------------- */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  min-height: 36px;
}

.bc-item {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.bc-link {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.bc-link:hover { color: var(--primary); }

.bc-current {
  color: var(--text-primary);
  font-weight: 500;
}

.bc-sep {
  display: inline-flex;
  align-items: center;
  color: var(--text-hint);
  padding: 0 5px;
  font-size: 13px;
  user-select: none;
  line-height: 1;
}

.bc-sep::before { content: '/'; }

/* -- Page Content ------------------------------------------- */
.page-content {
  flex: 1;
  padding: 28px;
  max-width: 1280px;
  width: 100%;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* -- Cards -------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* -- Stat Cards --------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow var(--transition);
}

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

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon svg { width: 18px; height: 18px; }

.stat-card-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-card-icon.green  { background: var(--success-bg);    color: var(--success); }
.stat-card-icon.red    { background: var(--danger-bg);     color: var(--danger);  }
.stat-card-icon.amber  { background: var(--warning-bg);    color: var(--warning); }

.stat-card-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
}

.stat-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* -- Buttons ------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn svg { width: 15px; height: 15px; stroke: currentColor; flex-shrink: 0; }

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

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-secondary:hover { background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-surface); color: var(--text-primary); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #c73a39; border-color: #c73a39; }

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger-ghost:hover { background: var(--danger-bg); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }

.btn-lg { padding: 11px 24px; font-size: 15px; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* -- Badges ------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-text);  }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-info    { background: var(--info-bg);    color: var(--info-text);    }
.badge-green   { background: #D1FAE5;           color: #065F46;             }
.badge-orange  { background: #FEF3C7;           color: #92400E;             }
.badge-gray    { background: #F3F4F6;           color: #374151;             }
.badge-blue    { background: var(--primary-light); color: var(--primary-dark); }

/* Status badges with dots */
.badge-online  { background: var(--success-bg); color: var(--success-text); }
.badge-online .badge-dot  { background: var(--success); }
.badge-offline { background: #F3F4F6; color: #6B7280; }
.badge-offline .badge-dot { background: #9CA3AF; }

/* -- Forms -------------------------------------------------- */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label .req { color: var(--danger); margin-right: 2px; }

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,111,216,0.12);
}

.form-control::placeholder { color: var(--text-hint); }

.form-control:disabled {
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: not-allowed;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 34px;
}

[dir="ltr"] select.form-control {
  background-position: right 12px center;
  padding-left: 13px;
  padding-right: 34px;
}

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

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 5px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  padding: 4px 0;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* -- Tables ------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: right;
}

[dir="ltr"] .table { text-align: left; }

.table thead tr {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.table th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table td {
  padding: 13px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-variant-numeric: lining-nums tabular-nums;
}

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

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover { background: var(--bg-surface); }

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

[dir="ltr"] .table-actions { justify-content: flex-start; }

.table-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.table-empty svg {
  width: 40px;
  height: 40px;
  stroke: var(--text-hint);
  margin: 0 auto 12px;
}

/* -- Alerts ------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-bg); color: var(--success-text); border-color: #c0dd97; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: #f7c1c1; }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: #fac775; }
.alert-info    { background: var(--info-bg);    color: var(--info-text);    border-color: #b5d4f4; }

/* -- Progress Bars ------------------------------------------ */
.progress-wrap { margin-bottom: 16px; }

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

.progress-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.progress-value { font-size: 13px; color: var(--text-primary); font-weight: 600; }

.progress-bar {
  height: 8px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width 0.4s ease;
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger  { background: var(--danger);  }

/* -- Modals ------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-close svg { width: 16px; height: 16px; stroke: currentColor; }

.modal-body { padding: 20px 24px; flex: 1; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* -- Tabs / Filters ----------------------------------------- */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  width: fit-content;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
  border: none;
  white-space: nowrap;
}

.filter-tab:hover { color: var(--text-primary); }

.filter-tab.active {
  background: var(--white);
  color: var(--primary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* -- Screen Cards ------------------------------------------- */
.screen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.screen-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

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

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

.screen-card-name {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.screen-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.screen-card-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.screen-pin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  font-family: monospace;
  letter-spacing: 0.1em;
}

/* -- Group Cards -------------------------------------------- */
.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.group-card-header {
  background: var(--primary-light);
  border-bottom: 1px solid #b5d4f4;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.group-card-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-card-title svg { width: 16px; height: 16px; stroke: currentColor; }
.group-card-body { padding: 16px 20px; }

/* -- Activity List ------------------------------------------ */
.activity-list { display: flex; flex-direction: column; gap: 0; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon svg { width: 15px; height: 15px; stroke: currentColor; }
.activity-icon.blue   { background: var(--primary-light); color: var(--primary); }
.activity-icon.green  { background: var(--success-bg); color: var(--success); }
.activity-icon.red    { background: var(--danger-bg); color: var(--danger); }
.activity-icon.amber  { background: var(--warning-bg); color: var(--warning); }

.activity-content { flex: 1; min-width: 0; }

.activity-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* -- Subscription Card -------------------------------------- */
.sub-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.sub-card::before {
  content: '';
  position: absolute;
  top: -40px;
  left: -40px;
  width: 150px;
  height: 150px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}

.sub-card-title {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 6px;
}

.sub-card-days {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1;
}

.sub-card-label {
  font-size: 13px;
  opacity: 0.75;
  margin-top: 4px;
}

.sub-card-danger { background: linear-gradient(135deg, var(--danger) 0%, #a32d2d 100%); }
.sub-card-warning { background: linear-gradient(135deg, var(--warning) 0%, #633806 100%); }

/* -- Pagination --------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  justify-content: center;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.pagination-btn:hover { border-color: var(--primary); color: var(--primary); }
.pagination-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* -- Support Chat ------------------------------------------- */
.chat-thread { display: flex; flex-direction: column; gap: 14px; }

.chat-bubble-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-bubble-wrap.is-admin { flex-direction: row-reverse; }

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.chat-avatar.user  { background: var(--primary-light); color: var(--primary-dark); }
.chat-avatar.admin { background: var(--primary); color: #fff; }

.chat-bubble {
  max-width: 70%;
  padding: 11px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
}

.chat-bubble.user-bubble  { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-primary); }
.chat-bubble.admin-bubble { background: var(--primary); color: #fff; }

.chat-bubble-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

/* -- Empty State -------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-hint);
  margin: 0 auto 16px;
}

.empty-state-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

/* -- Login Page --------------------------------------------- */
.login-page {
  min-height: 100vh;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 40px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

/* Brand */
.login-brand        { text-align: center; margin-bottom: 28px; }
.login-brand-logo   { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
.login-brand-icon   {
  width: 44px; height: 44px; background: var(--primary);
  border-radius: var(--radius-lg); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.login-brand-icon svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login-brand-name   { font-size: 22px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; line-height: 1; }
.login-brand-name .hd { color: var(--primary); }
.login-subtitle     { font-size: 13px; color: var(--text-muted); margin-top: 5px; }

/* Heading */
.login-heading    { font-size: 1.2rem; font-weight: 600; color: var(--text-primary); margin: 0 0 4px; text-align: center; }
.login-subheading { font-size: 0.875rem; color: var(--text-secondary); text-align: center; margin: 0 0 22px; }

/* Password toggle */
.login-input-wrap { position: relative; }
.toggle-pw {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  width: 38px; height: 38px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: color var(--transition), background var(--transition);
}
.toggle-pw:hover        { color: var(--text-primary); background: var(--bg-surface); }
.toggle-pw svg          { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
[dir="rtl"] .toggle-pw { left: 4px; }
[dir="ltr"] .toggle-pw { right: 4px; }
[dir="rtl"] .pw-field   { padding-left: 44px; }
[dir="ltr"] .pw-field   { padding-right: 44px; }

/* Footer */
.login-footer {
  text-align: center; margin-top: 20px; font-size: .82rem;
  color: var(--text-muted); display: flex; justify-content: center;
  gap: .25rem; flex-wrap: wrap; align-items: center;
}
.login-footer a {
  color: var(--primary); padding: .45rem .75rem;
  border-radius: var(--radius-sm); text-decoration: none;
  transition: background var(--transition);
  min-height: 44px; display: inline-flex; align-items: center;
}
.login-footer a:hover { background: var(--primary-light); }

/* -- Utilities ---------------------------------------------- */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.text-center { text-align: center; }
.font-mono { font-family: monospace; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--transition);
}

.copy-btn:hover { border-color: var(--primary); color: var(--primary); }
.copy-btn svg { width: 12px; height: 12px; stroke: currentColor; }

/* -- Responsive --------------------------------------------- */
@media (max-width: 900px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(100%); transition: transform 0.25s ease; }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); --sidebar-width: 240px; }
  .main-area { margin-right: 0 !important; margin-left: 0 !important; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
}

@media (max-width: 600px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 28px 20px; }
  .modal { max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; margin-top: auto; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* -- Ads Grid ----------------------------------------------- */
.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.ad-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.06));
  display: flex;
  flex-direction: column;
  transition: box-shadow .18s ease;
}

.ad-card:hover { box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,.1)); }

.ad-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #0f172a;
  position: relative;
  min-height: 140px;
  flex-shrink: 0;
}

.ad-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ad-thumb-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-hint, #C4CAD4);
  font-size: 32px;
}

.ad-status-overlay {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
}

.ad-body {
  padding: 14px 16px;
  flex: 1;
}

.ad-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary, #111827);
}

.ad-meta {
  font-size: 12px;
  color: var(--text-muted, #9CA3AF);
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ad-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--border, #E5E7EB);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--bg-surface, #F8F9FB);
  align-items: center;
}

/* -- HD Card (ads grid - conflict-free names) --------------- */
.hd-grid       { display:grid; grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:16px; margin-top:16px; }
.hd-card       { background:var(--bg-card,#fff); border:1px solid var(--border,#E5E7EB); border-radius:var(--radius-lg,12px); overflow:hidden; display:flex; flex-direction:column; box-shadow:var(--shadow-sm,0 1px 3px rgba(0,0,0,.06)); transition:box-shadow .18s ease; }
.hd-card:hover { box-shadow:var(--shadow-md,0 4px 12px rgba(0,0,0,.1)); }
.hd-thumb      { width:100%; aspect-ratio:16/9; overflow:hidden; background:#0f172a; position:relative; min-height:140px; flex-shrink:0; }
.hd-thumb img  { width:100%; height:100%; object-fit:cover; display:block; }
.hd-thumb-ph   { width:100%; height:100%; display:none; align-items:center; justify-content:center; color:var(--text-hint,#C4CAD4); font-size:32px; }
.hd-overlay    { position:absolute; top:8px; inset-inline-end:8px; }
.hd-body       { padding:14px 16px; flex:1; }
.hd-title      { font-weight:600; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--text-primary,#111827); }
.hd-meta       { font-size:12px; color:var(--text-muted,#9CA3AF); margin-top:6px; display:flex; flex-direction:column; gap:3px; }
.hd-actions    { padding:10px 12px; border-top:1px solid var(--border,#E5E7EB); display:flex; gap:6px; flex-wrap:wrap; background:var(--bg-surface,#F8F9FB); align-items:center; }

/* -- Upload Area -------------------------------------------- */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition);
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* -- Schedule & Days ---------------------------------------- */
.days-grid { display: flex; gap: 6px; flex-wrap: wrap; }

.day-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-card);
  user-select: none;
}

.day-label:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.schedule-section {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* -- Filter tab count --------------------------------------- */
.filter-tab .cnt {
  opacity: 0.6;
  font-size: 11px;
  margin-right: 3px;
}
