:root {
  --bg: #f4f7fb;
  --surface: #fff;
  --surface-soft: #f8fafc;
  --text: #18202f;
  --muted: #64748b;
  --line: #dfe7f1;
  --line-strong: #cbd5e1;
  --primary: #1463ff;
  --primary-dark: #0d47c5;
  --nav: #122033;
  --nav-hover: #213654;
  --danger: #b42318;
  --success: #166534;
  --shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-family: Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

body,
input,
select,
textarea,
button {
  font: inherit;
}

a {
  color: var(--primary);
}

.sidebar {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  width: 260px;
  overflow-y: auto;
  background: var(--nav);
  color: #fff;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
}

.brand::before {
  content: "";
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1463ff, #22c55e);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}

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

nav a {
  color: #dbe7ff;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.55;
}

nav a:hover,
nav a:focus-visible {
  background: var(--nav-hover);
  color: #fff;
  outline: none;
}

.main {
  min-height: 100vh;
  margin-right: 260px;
  padding: 24px clamp(16px, 2.2vw, 32px);
}

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

.topbar h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.35;
}

.topbar form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel,
.card,
.stats article,
.stats-grid .stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel,
.card {
  overflow-x: auto;
  margin-bottom: 18px;
  padding: 18px;
}

.panel h2,
.card h2 {
  margin: 0 0 14px;
  font-size: 19px;
  line-height: 1.4;
}

.stats,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats article,
.stats-grid .stat {
  min-width: 0;
  padding: 18px;
}

.stats span,
.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stats strong,
.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.15;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.panel table,
.card table {
  min-width: 720px;
}

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

th {
  background: var(--surface-soft);
  color: #475569;
  font-size: 13px;
  white-space: nowrap;
}

td {
  line-height: 1.65;
}

code {
  direction: ltr;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: #eef2ff;
  padding: 2px 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 24px;
  border-radius: 999px;
  background: #eef6ff;
  color: #135ea8;
  padding: 4px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
}

input,
select,
textarea {
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input,
select {
  min-height: 40px;
  padding: 0 10px;
}

textarea {
  padding: 10px;
}

.grid-form > input,
.grid-form > select,
.grid-form > button,
label > input,
label > select,
label > textarea,
.login-card input {
  width: 100%;
}

button,
.button-link {
  min-height: 40px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

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

.link {
  color: var(--primary);
  white-space: nowrap;
}

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

.ltr {
  direction: ltr;
  text-align: left;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #edf2f7;
}

.login-card {
  width: min(420px, 92vw);
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-card h1 {
  margin: 0 0 12px;
  font-size: 24px;
}

.error {
  color: var(--danger);
  background: #fff1f0;
  border: 1px solid #ffccc7;
  border-radius: 8px;
  padding: 8px;
}

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

@media (max-width: 900px) {
  .sidebar {
    position: sticky;
    inset: 0 auto auto 0;
    width: 100%;
    max-height: none;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
  }

  .brand {
    justify-content: center;
    margin-bottom: 10px;
    font-size: 18px;
  }

  .brand::before {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  nav a {
    flex: 0 0 auto;
    padding: 8px 10px;
    white-space: nowrap;
  }

  .main {
    margin-right: 0;
    padding: 14px;
  }

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

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

  .topbar form {
    width: 100%;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
  }

  .panel,
  .card {
    margin-bottom: 14px;
    padding: 14px;
  }

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

  table {
    font-size: 13px;
  }

  th,
  td {
    padding: 9px 8px;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 10px;
  }

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

  .panel,
  .card {
    padding: 12px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .topbar form {
    align-items: stretch;
  }

  .topbar form span {
    overflow-wrap: anywhere;
  }

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

  .actions {
    flex-direction: column;
  }

  .actions > *,
  .actions form,
  .actions button,
  .actions .button-link {
    width: 100%;
  }
}
