:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #d8e0ea;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-2: #0f766e;
  --accent-3: #f59e0b;
  --accent-4: #7c3aed;
  --side: #101828;
  --side-2: #1d2939;
  --warn: #b54708;
  --bad: #b42318;
  --good: #067647;
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 4px 14px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  background:
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 320px),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

[dir="rtl"] body {
  direction: rtl;
}

body.signed-out {
  display: block;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(145deg, #101828 0%, #172554 100%);
}

.login-screen.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.login-panel {
  width: min(100%, 380px);
  display: grid;
  gap: 15px;
  padding: 22px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 8px;
  color: var(--ink);
}

.form-error {
  min-height: 20px;
  color: var(--bad);
  font-size: 13px;
}

.muted-text {
  color: var(--muted);
  margin-top: 8px;
}

.setup-box {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.qr-panel {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

#twofa-qr {
  width: 220px;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
}

.sidebar {
  background: var(--side);
  color: #eef2f7;
  padding: 24px 18px;
  box-shadow: 6px 0 22px rgba(15, 23, 42, 0.14);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 36px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
}

.brand small {
  display: block;
  color: #aab3c2;
  margin-top: 2px;
}

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

nav {
  scrollbar-width: none;
}

nav::-webkit-scrollbar {
  display: none;
}

.nav-item {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  text-align: left;
  color: #d4dbe7;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
}

.nav-item.active,
.nav-item:hover {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.24), rgba(15, 118, 110, 0.16));
  color: #fff;
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--accent-3);
}

[dir="rtl"] .nav-item.active {
  box-shadow: inset -3px 0 0 var(--accent-3);
}

main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 222, 231, 0.8);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 18px;
}

.topbar p,
.session,
label {
  color: var(--muted);
}

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

.impersonation-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  font-size: 12px;
  font-weight: 800;
}

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

button.secondary:hover {
  background: #f8fafc;
}

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

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

.toolbar-actions input {
  width: 160px;
}

.secondary-toolbar {
  margin-top: 20px;
}

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

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

.summary-tile {
  min-height: 94px;
  display: grid;
  gap: 4px;
  align-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
  border-left: 4px solid var(--accent);
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 18px;
  color: #fff;
  background: #111827;
  border: 1px solid #263244;
  border-left: 4px solid var(--accent-3);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dashboard-hero span {
  display: block;
  margin-bottom: 5px;
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-hero h2 {
  font-size: 24px;
}

.dashboard-health-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.health-chip {
  min-width: 130px;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.health-chip span {
  margin: 0;
  color: #dbeafe;
  font-size: 11px;
}

.health-chip strong {
  color: #fff;
  font-size: 15px;
}

.health-chip.good {
  box-shadow: inset 0 -3px 0 #34d399;
}

.health-chip.warn {
  box-shadow: inset 0 -3px 0 #fbbf24;
}

.alerts-panel {
  margin-bottom: 14px;
}

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

.alert-item {
  min-height: 98px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  align-content: center;
  padding: 13px;
  border: 1px solid #fed7aa;
  border-left: 4px solid var(--accent-3);
  border-radius: 8px;
  background: #fffaf3;
  color: var(--ink);
  text-align: left;
}

.alert-item.error {
  border-color: #fecaca;
  border-left-color: var(--bad);
  background: #fff7f7;
}

.alert-item:hover {
  background: #fff4e5;
}

.alert-item.error:hover {
  background: #feecec;
}

.alert-item span {
  font-weight: 850;
}

.alert-item strong {
  font-size: 22px;
}

.alert-item small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.metric-card {
  position: relative;
  align-content: end;
  min-height: 112px;
}

.metric-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.metric-1 .metric-icon,
.metric-4 .metric-icon {
  background: var(--accent-2);
}

.metric-2 .metric-icon,
.metric-5 .metric-icon {
  background: var(--accent-3);
}

.summary-tile:nth-child(2n) {
  border-left-color: var(--accent-2);
}

.summary-tile:nth-child(3n) {
  border-left-color: var(--accent-3);
}

.summary-tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.summary-tile strong {
  font-size: 30px;
  color: var(--ink);
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

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

.chart-panel {
  min-height: 350px;
}

.chart-panel h2,
.flow-panel h2 {
  margin-bottom: 10px;
}

.chart-surface {
  min-height: 278px;
  display: grid;
  align-items: center;
}

.line-chart-svg {
  width: 100%;
  height: auto;
  min-height: 250px;
}

.line-chart-svg .axis {
  stroke: #d8e0ea;
  stroke-width: 1;
}

.line-area {
  fill: rgba(37, 99, 235, 0.12);
}

.line-stroke {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-points circle {
  fill: #fff;
  stroke: var(--accent-2);
  stroke-width: 3;
}

.line-points text,
.chart-labels text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.line-chart-svg .empty-note {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.donut-chart {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 18px;
  align-items: center;
}

.donut-chart svg {
  width: 100%;
  max-width: 220px;
}

.donut-chart circle {
  fill: none;
  stroke: #edf2f7;
  stroke-width: 22;
}

.donut-chart path {
  fill: none;
  stroke-width: 22;
  stroke-linecap: round;
}

.donut-chart text {
  fill: var(--ink);
  font-size: 28px;
  font-weight: 800;
}

.donut-chart .donut-caption {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.donut-legend {
  display: grid;
  gap: 9px;
}

.donut-legend-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eef2f7;
}

.donut-legend-row span {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.donut-legend-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.donut-legend-row em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.flow-panel {
  overflow: hidden;
}

.flow-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  position: relative;
}

.flow-node {
  min-height: 128px;
  display: grid;
  gap: 5px;
  align-content: center;
  position: relative;
  padding: 15px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #f8fafc;
}

.flow-node:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -13px;
  width: 13px;
  height: 2px;
  background: var(--accent);
}

[dir="rtl"] .flow-node:not(:last-child)::after {
  right: auto;
  left: -13px;
}

.flow-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.flow-node span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.flow-node strong {
  font-size: 24px;
}

.flow-node small {
  color: var(--muted);
}

.bar-chart {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr 54px;
  gap: 10px;
  align-items: center;
  min-height: 28px;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: #eef2f7;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.bar-row strong {
  text-align: right;
}

.search-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.search-actions {
  align-self: end;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: 16px;
  min-height: 16px;
}

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

.form-section-title {
  padding-top: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.table-panel {
  overflow: auto;
  padding: 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8fafc;
}

td {
  font-size: 14px;
}

code {
  display: inline-block;
  max-width: 260px;
  overflow-wrap: anywhere;
  padding: 3px 6px;
  border-radius: 6px;
  background: #f2f4f7;
  color: #344054;
  font-size: 12px;
}

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

.status.online {
  background: #dcfae6;
  color: var(--good);
}

.connector-package-panel {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  align-items: end;
  margin-bottom: 18px;
}

.status.offline,
.status.error {
  background: #fee4e2;
  color: var(--bad);
}

.status.warning {
  background: #fef0c7;
  color: var(--warn);
}

.readiness-cell {
  min-width: 130px;
  display: grid;
  gap: 7px;
}

.readiness-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #edf2f7;
}

.readiness-bar span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent-2);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow: hidden;
    padding: 12px;
  }

  .brand {
    margin-bottom: 14px;
  }

  nav {
    display: flex;
    gap: 8px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    flex: 0 0 auto;
    min-width: max-content;
    white-space: nowrap;
  }

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

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

  .dashboard-layout,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    min-height: 300px;
  }

  .donut-chart {
    grid-template-columns: 180px 1fr;
  }

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

  .flow-node:not(:last-child)::after {
    display: none;
  }

  .dashboard-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-health-strip {
    justify-content: stretch;
  }

  .health-chip {
    flex: 1 1 150px;
  }

  .alerts-list {
    grid-template-columns: 1fr;
  }

  .search-panel {
    grid-template-columns: 1fr;
  }

  .connector-package-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .session {
    width: 100%;
    flex-wrap: wrap;
  }

  #user-name {
    width: 100%;
    color: var(--ink);
    font-weight: 700;
  }

  .session select,
  .session button {
    flex: 1 1 140px;
    min-width: 0;
  }

  main {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    padding: 14px;
  }

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

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions input,
  .toolbar-actions button {
    flex: 1 1 140px;
  }

  .panel {
    padding: 14px;
  }

  table {
    min-width: 620px;
  }

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

  .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .bar-row {
    grid-template-columns: minmax(72px, 110px) 1fr 42px;
  }
}

@media (max-width: 560px) {
  body {
    background: #f6f8fb;
  }

  .sidebar {
    padding: 10px 10px 8px;
  }

  .brand {
    gap: 9px;
    margin-bottom: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }

  .nav-item {
    min-height: 38px;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 13px;
  }

  main {
    padding: 10px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
    border-radius: 8px;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 16px;
  }

  button,
  input,
  select {
    min-height: 42px;
  }

  .session select,
  .session button,
  .toolbar-actions input,
  .toolbar-actions button,
  .actions button {
    flex: 1 1 100%;
    width: 100%;
  }

  .actions {
    width: 100%;
  }

  .summary-tile {
    min-height: 78px;
    padding: 13px;
    border-radius: 8px;
  }

  .metric-card {
    min-height: 98px;
  }

  .dashboard-hero {
    padding: 14px;
  }

  .dashboard-hero h2 {
    font-size: 19px;
  }

  .summary-tile strong {
    font-size: 25px;
  }

  .split,
  .dashboard-layout {
    gap: 12px;
  }

  .panel {
    border-radius: 8px;
  }

  .chart-panel {
    min-height: auto;
  }

  .chart-surface {
    min-height: 220px;
  }

  .line-chart-svg {
    min-height: 210px;
  }

  .donut-chart {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .donut-legend {
    width: 100%;
  }

  .flow-map {
    grid-template-columns: 1fr;
  }

  .flow-node {
    min-height: 104px;
  }

  .table-panel::before {
    content: "";
    display: block;
    height: 0;
  }

  code {
    max-width: 190px;
  }
}
