:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef2f7;
  --text: #18212f;
  --muted: #667085;
  --line: #d9e0ea;
  --gold: #d6a934;
  --gold-dark: #a57916;
  --teal: #0f766e;
  --blue: #2563eb;
  --rose: #be123c;
  --sidebar: #172033;
  --sidebar-hover: #243149;
  --sidebar-expanded-width: 232px;
  --sidebar-collapsed-width: 68px;
  --shadow: 0 14px 35px rgba(15, 23, 42, 0.09);
}

[data-theme="dark"] {
  --bg: #10141d;
  --surface: #171d29;
  --surface-soft: #202839;
  --text: #edf2f7;
  --muted: #aab4c2;
  --line: #2c374a;
  --sidebar: #0d121d;
  --sidebar-hover: #1c2537;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Cairo", system-ui, sans-serif;
}

a {
  text-decoration: none;
}

.app-topbar {
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

.navbar-brand {
  display: inline-flex;
  gap: 0.6rem;
  align-items: center;
  color: var(--text);
  font-weight: 800;
}

.navbar-brand i {
  color: var(--gold);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.topbar-pill,
.topbar-user {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.topbar-pill i {
  color: var(--gold-dark);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-expanded-width) minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  transition: grid-template-columns 0.18s ease;
}

html.sidebar-collapsed .app-shell {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.app-sidebar {
  background: var(--sidebar);
  color: #fff;
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.75rem 0.65rem;
}

.app-sidebar-offcanvas {
  background: var(--sidebar);
  color: #fff;
}

.sidebar-menu {
  min-width: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.sidebar-nav li,
.sidebar-subnav li {
  min-width: 0;
}

.sidebar-link,
.sidebar-group-toggle {
  display: grid;
  width: 100%;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  min-height: 38px;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  color: #c9d3e2;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
}

.sidebar-group-toggle {
  grid-template-columns: 22px minmax(0, 1fr) 16px;
  border: 0;
  background: transparent;
  text-align: start;
}

.sidebar-link span,
.sidebar-group-toggle span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link:hover,
.sidebar-link.active,
.sidebar-group-toggle:hover,
.sidebar-group-toggle:not(.collapsed) {
  color: #fff;
  background: var(--sidebar-hover);
}

.sidebar-link.active i {
  color: var(--gold);
}

.sidebar-chevron {
  font-size: 0.8rem;
  transition: transform 0.16s ease;
}

.sidebar-group-toggle:not(.collapsed) .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-subnav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.2rem 0.65rem 0.25rem 0;
  margin: 0.1rem 1.65rem 0.15rem 0;
  list-style: none;
  border-inline-start: 1px solid rgba(201, 211, 226, 0.2);
}

.sidebar-subnav .sidebar-link {
  min-height: 34px;
  padding: 0.36rem 0.5rem;
  font-size: 0.84rem;
  grid-template-columns: 20px minmax(0, 1fr);
}

.sidebar-section {
  padding: 1rem 0.75rem 0.35rem;
  color: #8fa0b9;
  font-size: 0.78rem;
  font-weight: 800;
}

html.sidebar-collapsed .app-sidebar {
  padding: 0.75rem 0.5rem;
}

html.sidebar-collapsed .app-sidebar .sidebar-link,
html.sidebar-collapsed .app-sidebar .sidebar-group-toggle {
  grid-template-columns: 1fr;
  justify-items: center;
  min-height: 40px;
  padding: 0.5rem 0;
}

html.sidebar-collapsed .app-sidebar .sidebar-link span,
html.sidebar-collapsed .app-sidebar .sidebar-group-toggle span,
html.sidebar-collapsed .app-sidebar .sidebar-chevron,
html.sidebar-collapsed .app-sidebar .sidebar-subnav {
  display: none;
}

html.sidebar-collapsed .app-sidebar .collapse.show {
  display: none;
}

html.sidebar-collapsed .app-sidebar .sidebar-link i,
html.sidebar-collapsed .app-sidebar .sidebar-group-toggle i:first-child {
  font-size: 1.05rem;
}

.app-content {
  min-width: 0;
  padding: 1.5rem;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 800;
}

.page-heading p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.content-panel,
.stat-card,
.card {
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface) !important;
  color: var(--text);
  box-shadow: var(--shadow);
}

.content-panel {
  padding: 1rem;
}

.narrow-panel {
  max-width: 720px;
}

.panel-title {
  margin-bottom: 1rem;
  font-weight: 800;
}

.card-gold-header {
  background: var(--sidebar) !important;
  color: #f6cf63 !important;
  border-bottom: 0 !important;
}

.table {
  color: var(--text);
}

.table > :not(caption) > * > * {
  background: transparent;
  border-bottom-color: var(--line);
}

.form-control,
.form-select,
.btn {
  border-radius: 8px;
}

.form-control,
.form-select {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 0.2rem rgba(214, 169, 52, 0.2);
}

.btn-warning {
  background: var(--gold);
  border-color: var(--gold);
  color: #151515;
}

.btn-warning:hover {
  background: #e4b947;
  border-color: #e4b947;
  color: #151515;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.88rem;
}

.check-chip input {
  margin: 0;
}

.country-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
}

.country-flag-image {
  width: 40px;
  height: 30px;
  flex: 0 0 40px;
  object-fit: cover;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: var(--surface-soft);
}

.permission-group {
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.permission-group:last-of-type {
  border-bottom: 0;
}

.permission-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.empty-state {
  display: grid;
  min-height: 360px;
  place-items: center;
  align-content: center;
  gap: 0.75rem;
  text-align: center;
}

.empty-state i {
  color: var(--gold);
  font-size: 3rem;
}

.empty-state h2 {
  font-weight: 800;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.16), transparent 36%),
    linear-gradient(315deg, rgba(214, 169, 52, 0.2), transparent 42%),
    var(--bg);
}

.auth-card {
  width: min(100%, 430px);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.wide-auth-card {
  width: min(100%, 760px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-brand i {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(214, 169, 52, 0.15);
  color: var(--gold-dark);
  font-size: 1.7rem;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.auth-brand span {
  color: var(--muted);
}

.fingerprint-box {
  display: grid;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px dashed var(--gold-dark);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow-wrap: anywhere;
}

.fingerprint-box label {
  color: var(--muted);
  font-weight: 700;
}

.fingerprint-box code {
  color: var(--text);
}

.toast {
  border-radius: 8px;
}

.dx-datagrid {
  /*font-size: 0.54rem;*/
}

.dx-datagrid-headers .dx-row > td {
    min-width: 58px !important;
    padding: 5px 4px !important;
    vertical-align: middle !important;
    white-space: normal !important;
    font-size: 0.76rem;
}

.dx-datagrid-headers .dx-datagrid-text-content {
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

.dx-header-caption-two-lines {
  display: flex;
  min-height: 2.55em;
  align-items: center;
  justify-content: center;
  overflow: visible;
  text-align: center;
  white-space: normal;
  line-height: 1.16;
}

.dx-header-caption-two-lines span {
  display: block;
  max-width: 100%;
  overflow: visible;
  overflow-wrap: normal;
  word-break: normal;
}

.dx-datagrid-headers .dx-column-indicators {
  float: none !important;
  display: inline-flex;
  max-width: 18px;
  vertical-align: top;
}

.dx-datagrid-headers .dx-sort,
.dx-datagrid-headers .dx-header-filter {
  margin: 0 !important;
}

.dx-datagrid-rowsview .dx-row > td {
  padding: 5px 7px !important;
  overflow: visible !important;
  max-width: 260px;
  vertical-align: middle !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

.dx-datagrid-filter-row > td {
  padding: 2px 4px !important;
}

.dx-datagrid-filter-row .dx-texteditor-input,
.dx-datagrid-search-panel .dx-texteditor-input {
  min-height: 28px;
  padding: 3px 6px;
  font-size: 0.82rem;
}

.dx-datagrid-search-panel {
  width: 165px !important;
}

.dx-datagrid .dx-command-select,
.dx-datagrid .dx-command-expand {
  width: 34px !important;
  min-width: 34px !important;
}

.dx-datagrid .btn.btn-sm {
  width: 32px;
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 7px;
  font-size: 0;
  line-height: 1;
}

.dx-datagrid .btn.btn-sm i {
  margin: 0 !important;
  font-size: 0.9rem;
}

.dx-datagrid .d-flex.gap-2,
.dx-datagrid .d-flex.gap-1 {
  gap: 0.25rem !important;
}

.dx-datagrid .badge.fs-6 {
  padding: 0.25rem 0.45rem;
  font-size: 0.78rem !important;
}

.dx-datagrid .country-flag-image {
  width: 34px;
  height: 24px;
  flex-basis: 34px;
}

@media (max-width: 991.98px) {
  .app-shell {
    display: block;
  }

  html.sidebar-collapsed .app-shell {
    display: block;
  }

  .app-content {
    padding: 1rem;
  }

  .topbar-actions {
    width: 100%;
    margin-top: 0.75rem;
  }
}

@media (max-width: 575.98px) {
  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-pill,
  .topbar-user {
    width: 100%;
    justify-content: center;
  }
}
