:root {
  --bg: #eef4f8;
  --surface: #ffffff;
  --surface-soft: #f8fbfd;
  --text: #10233f;
  --muted: #5f738d;
  --line: #d6e3ee;
  --primary: #0f82e6;
  --primary-strong: #0a66c2;
  --sidebar-bg: #0e1f37;
  --sidebar-line: #22395a;
  --sidebar-text: #d7e5f4;
  --sidebar-muted: #9fb5cf;
  --success: #0f9f6e;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 12px 32px rgba(16, 35, 63, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top right, rgba(15, 130, 230, 0.12), transparent 28%),
    linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}

a {
  color: inherit;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #102949 100%);
  border-inline-end: 1px solid var(--sidebar-line);
  color: var(--sidebar-text);
}

.sidebar h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  color: #f8fbff;
}

.sidebar .brand-note {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--sidebar-muted);
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar a {
  display: block;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.sidebar a:hover {
  background: rgba(123, 195, 255, 0.12);
  border-color: rgba(123, 195, 255, 0.22);
  transform: translateX(-2px);
}

.sidebar a.active {
  background: linear-gradient(90deg, rgba(15, 130, 230, 0.44), rgba(15, 130, 230, 0.18));
  border-color: rgba(123, 195, 255, 0.42);
  color: #ffffff;
  box-shadow: inset 3px 0 0 #7bc3ff;
}

.content {
  min-width: 0;
  padding: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  padding: 22px 24px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(214, 227, 238, 0.92);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 800;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: #e8f4ff;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 700;
}

.admin-auth-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-secret-input,
.header-button {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}

.admin-secret-input {
  min-width: 220px;
  padding: 0 14px;
  color: var(--text);
}

.header-button {
  padding: 0 14px;
  color: var(--text);
  cursor: pointer;
}

.header-button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.header-button.subtle {
  background: var(--surface-soft);
}

.header-status {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef4f8;
  color: var(--muted);
}

.header-status[data-state="ready"] {
  background: #e7f8f0;
  color: var(--success);
}

.header-status[data-state="error"] {
  background: #fdecec;
  color: var(--danger);
}

.header-status[data-state="loading"] {
  background: #e8f4ff;
  color: var(--primary-strong);
}

.header-status[data-state="warning"] {
  background: #fff5e8;
  color: var(--warning);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card,
.panel,
.chart,
.table-card,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card,
.panel,
.stat-card {
  padding: 18px;
}

.card-label,
.stat-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.card-value,
.stat-value {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.card-footnote,
.stat-footnote {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

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

.chart {
  min-height: 280px;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(15, 130, 230, 0.08), transparent),
    linear-gradient(180deg, #ffffff 0%, #f5f9fc 100%);
  color: var(--muted);
  font-weight: 700;
}

.panel h2,
.table-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 800;
}

.panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.table-card {
  overflow: hidden;
}

.table-card-header {
  padding: 18px 18px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  text-align: right;
  border-bottom: 1px solid #edf2f7;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-soft);
}

tbody tr {
  cursor: pointer;
  transition: background-color 0.16s ease;
}

tbody tr:hover {
  background: #f7fbff;
}

.stack {
  display: grid;
  gap: 16px;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.list li {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.user-hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.meta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.primary {
  background: #e8f4ff;
  color: var(--primary-strong);
}

.badge.success {
  background: #e7f8f0;
  color: var(--success);
}

.badge.warning {
  background: #fff5e8;
  color: var(--warning);
}

.badge.danger {
  background: #fdecec;
  color: var(--danger);
}

.section-space {
  margin-top: 18px;
}

.summary-grid,
.key-value-grid,
.mini-cards {
  display: grid;
  gap: 14px;
}

.summary-grid,
.mini-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.key-value-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kv-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.kv-item .label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.kv-item .value {
  font-size: 18px;
  font-weight: 800;
}

.empty-state,
.loading-state,
.error-state {
  padding: 28px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.error-state {
  border-color: rgba(220, 38, 38, 0.22);
  color: var(--danger);
}

.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #0f172a;
}

.login-box {
  background: #fff;
  width: min(92vw, 320px);
  padding: 30px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(2, 6, 23, 0.35);
}

.login-box h2 {
  margin: 0 0 12px;
}

.login-box input {
  width: 100%;
  min-height: 42px;
  padding: 10px;
  margin: 10px 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
}

.login-box button {
  width: 100%;
  min-height: 42px;
  padding: 10px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.error {
  color: #dc2626;
  min-height: 20px;
  margin: 8px 0 0;
}

.chart-bars {
  display: grid;
  gap: 14px;
  width: 100%;
}

.chart-row {
  display: grid;
  grid-template-columns: 130px 1fr 60px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.chart-track {
  height: 12px;
  border-radius: 999px;
  background: #e9f0f5;
  overflow: hidden;
}

.chart-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f82e6, #5cb7ff);
}

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

.text-input {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}

.inline-note {
  font-size: 12px;
  color: var(--muted);
}

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

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

.metric-list {
  display: grid;
  gap: 10px;
}

.metric-list .list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.overview-page {
  display: grid;
  gap: 18px;
}

.overview-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f8fbfd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.overview-state .dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
}

.overview-state[data-state="loading"] {
  background: #e8f4ff;
  color: var(--primary-strong);
}

.overview-state[data-state="success"] {
  background: #e7f8f0;
  color: var(--success);
}

.overview-state[data-state="error"] {
  background: #fdecec;
  color: var(--danger);
}

.overview-state[data-state="empty"] {
  background: #f6f8fb;
  color: #6b7280;
}

.overview-state p {
  margin: 0;
}

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

.overview-kpi,
.overview-kpi-skeleton,
.overview-panel {
  border: 1px solid rgba(214, 227, 238, 0.9);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 253, 0.98));
  box-shadow: var(--shadow);
}

.overview-kpi {
  padding: 16px;
  display: grid;
  gap: 7px;
}

.overview-kpi-title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.overview-kpi-value {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #0b2b4a;
}

.overview-kpi-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.overview-indicator {
  justify-self: flex-start;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}

.overview-indicator.up {
  background: #e7f8f0;
  color: var(--success);
  border-color: rgba(15, 159, 110, 0.25);
}

.overview-indicator.down {
  background: #fdecec;
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.22);
}

.overview-indicator.flat {
  background: #f1f5f9;
  color: #64748b;
  border-color: rgba(100, 116, 139, 0.25);
}

.overview-kpi-skeleton {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.overview-kpi.is-loading {
  position: relative;
  overflow: hidden;
}

.skeleton-line,
.skeleton-pill,
.chart-skeleton-head,
.chart-skeleton-foot {
  border-radius: 999px;
  background: linear-gradient(90deg, #e9f1f8 0%, #f5f9fd 45%, #e9f1f8 100%);
  background-size: 180% 100%;
  animation: skeleton-wave 1.2s ease-in-out infinite;
}

.skeleton-line {
  height: 11px;
}

.skeleton-pill {
  height: 26px;
  width: 92px;
}

.w-40 {
  width: 40%;
}

.w-55 {
  width: 55%;
}

.w-65 {
  width: 65%;
}

.w-70 {
  width: 70%;
}

.w-75 {
  width: 75%;
}

.w-80 {
  width: 80%;
}

@keyframes skeleton-wave {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

.overview-charts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.overview-panel {
  padding: 16px;
}

.overview-panel-header h2 {
  margin: 0;
  font-size: 17px;
  color: #10233f;
}

.overview-panel-header p {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.overview-chart-area {
  min-height: 260px;
  border-radius: 14px;
  border: 1px solid #e6eef5;
  background: linear-gradient(180deg, #ffffff 0%, #f6fafe 100%);
  padding: 12px;
  display: grid;
  align-content: start;
}

.overview-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.overview-chart-head strong {
  font-size: 13px;
}

.overview-chart-head span {
  color: var(--muted);
  font-size: 12px;
}

.overview-chart-canvas-wrap {
  border: 1px solid #e7edf4;
  border-radius: 12px;
  overflow: hidden;
  background: #fbfdff;
  height: 190px;
}

.overview-chart-canvas-wrap canvas {
  width: 100%;
  height: 100%;
}

.overview-chart-foot {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.overview-chart-empty,
.overview-chart-error,
.chart-skeleton {
  min-height: 180px;
  border-radius: 12px;
  border: 1px dashed #d7e5f2;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 8px;
  color: var(--muted);
  background: #fbfdff;
  padding: 14px;
}

.overview-chart-error {
  border-color: rgba(220, 38, 38, 0.24);
  color: var(--danger);
}

.overview-chart-error p {
  margin: 0;
  font-weight: 700;
}

.overview-chart-error small {
  font-size: 11px;
}

.overview-chart-empty strong {
  font-size: 14px;
}

.overview-chart-empty p {
  margin: 0;
  font-size: 12px;
}

.chart-skeleton {
  padding: 18px;
}

.chart-skeleton-head {
  width: 46%;
  height: 12px;
  justify-self: center;
}

.chart-skeleton-plot {
  height: 110px;
  border-radius: 10px;
  background: linear-gradient(90deg, #edf3f9 0%, #f8fbff 45%, #edf3f9 100%);
  background-size: 180% 100%;
  animation: skeleton-wave 1.2s ease-in-out infinite;
}

.chart-skeleton-foot {
  width: 62%;
  height: 10px;
  justify-self: center;
}

.overview-bottom-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

.overview-list {
  display: grid;
  gap: 10px;
}

.overview-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e6edf4;
  border-radius: 12px;
  background: #fbfdff;
}

.overview-list-item strong {
  display: block;
  font-size: 14px;
}

.overview-list-item p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.overview-list-meta {
  text-align: left;
  display: grid;
  gap: 6px;
  justify-items: end;
}

.overview-list-meta small {
  color: var(--muted);
  font-size: 11px;
}

.overview-insights ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.overview-insights li {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #e8edf4;
  background: #f9fbfe;
  font-size: 13px;
  line-height: 1.65;
}

.overview-insights-grid {
  display: grid;
  gap: 10px;
}

.insight-card {
  border-radius: 12px;
  border: 1px solid #e6edf4;
  background: #f9fbff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.insight-card h3 {
  margin: 0;
  font-size: 14px;
}

.insight-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}

.insight-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.insight-severity {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.insight-meta {
  display: grid;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.insight-meta small {
  font-size: 11px;
}

.insight-card.severity-warning {
  background: #fffaf2;
  border-color: rgba(217, 119, 6, 0.26);
}

.insight-card.severity-warning .insight-severity {
  background: #fff2df;
  color: #b45309;
}

.insight-card.severity-success {
  background: #f3fcf8;
  border-color: rgba(15, 159, 110, 0.28);
}

.insight-card.severity-success .insight-severity {
  background: #e4f8ef;
  color: #0b8f63;
}

.insight-card.severity-info {
  background: #f4f9ff;
  border-color: rgba(15, 130, 230, 0.25);
}

.insight-card.severity-info .insight-severity {
  background: #e8f4ff;
  color: #0a66c2;
}

.overview-list-skeleton {
  display: grid;
  gap: 10px;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .cards,
  .grid-2,
  .user-hero,
  .summary-grid,
  .key-value-grid,
  .mini-cards {
    grid-template-columns: 1fr;
  }

  .overview-kpis,
  .overview-charts-grid,
  .overview-bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 16px;
  }

  .page-header {
    padding: 18px;
  }

  .admin-secret-input {
    min-width: 100%;
  }

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

  .chart-row {
    grid-template-columns: 1fr;
  }

  .overview-panel {
    padding: 14px;
  }

  .overview-chart-foot {
    flex-direction: column;
    gap: 4px;
  }

  .overview-list-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .overview-list-meta {
    justify-items: start;
    text-align: right;
  }

  th,
  td {
    padding: 12px 14px;
  }
}