:root {
  --bg: #0b1020;
  --bg-deep: #080d18;
  --surface: #121a2c;
  --surface-raised: #172138;
  --surface-hover: #1b2740;
  --surface-input: #0c1324;
  --surface-readonly: #0a1222;
  --border: #26324d;
  --border-control: #33405f;
  --border-hover: #465677;
  --text: #eef2ff;
  --text-secondary: #cbd4ea;
  --muted: #8f9bb6;
  --primary: #7c4dff;
  --primary-hover: #9b6cff;
  --primary-soft: rgba(124, 77, 255, .16);
  --success: #3ddc97;
  --warning: #ffc267;
  --danger: #ff6b6b;
  --info: #67b7ff;
  --accent: var(--primary);
  --accent2: var(--primary-hover);
  --ok: var(--success);
  --line: var(--border);
  --font-family: Tahoma, Arial, sans-serif;
  --sidebar-width: 240px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, .12);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  direction: rtl;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  direction: rtl;
  text-align: right;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  direction: rtl;
}

.sidebar {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow: hidden;
  border-inline-end: 1px solid var(--border);
  background: var(--bg-deep);
}

.brand {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 6px;
  white-space: nowrap;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: #c9b7ff;
  font-size: 16px;
  font-weight: 700;
}

.brand-text {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3px;
}

.role {
  margin-block: 2px 16px;
  padding-inline: 48px 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.sidebar-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 12px;
  border-radius: 8px;
  color: #c5cee0;
  text-decoration: none;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease;
}

.sidebar-item svg,
.menu-toggle svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, .04);
  color: white;
}

.sidebar-item[aria-current="page"] {
  background: var(--primary-soft);
  color: #e8e0ff;
}

.logout {
  width: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
  color: #ff9696;
}

.logout-form { margin-block-start: auto; }

.logout:hover { background: rgba(255, 107, 107, .08); }

.content {
  width: 100%;
  min-width: 0;
  padding: 0 20px 24px;
  direction: rtl;
}

.content > * {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
}

.top {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-block-end: 16px;
  padding-inline: 0;
  border-block-end: 1px solid var(--border);
}

.top-primary,
.user-area {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-heading { min-width: 0; }

.page-title {
  display: block;
  margin: 0 0 2px;
  overflow: hidden;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.menu-toggle {
  width: 36px;
  min-width: 36px;
  height: 36px;
  display: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.user-role { color: var(--muted); font-size: 11px; white-space: nowrap; }

.chip {
  max-width: 190px;
  padding: 4px 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: #d7cbff;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-backdrop { display: none; }

.card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-block-start: 4px; font-size: 22px; font-weight: 700; line-height: 1.2; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1,
h2,
h3,
p { overflow-wrap: anywhere; }
h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

.form { max-width: 1080px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.form label,
.modal-form label,
.login-card label {
  display: grid;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: right;
}

.alert,
.runtime-notice { line-height: 1.65; }

.alert {
  margin-block-end: 12px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 107, 107, .3);
  border-radius: 8px;
  background: rgba(255, 107, 107, .1);
  color: #ffb1b1;
}

.empty {
  color: var(--muted);
}

table td.empty { padding: 24px 16px; text-align: center; }

.compact { max-width: none; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: min(400px, 100%);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-modal);
}

.login-card h1 { margin: 12px 0 4px; font-size: 22px; font-weight: 700; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 12px; }
.login-card label { margin-block-end: 12px; }

.logo-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  color: #d7cbff;
  font-size: 18px;
  font-weight: 700;
}

.modal-card {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-modal);
}

.modal-card::backdrop {
  background: rgba(3, 7, 16, .75);
  backdrop-filter: blur(2px);
}

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

@media (max-width: 980px) {
  :root { --sidebar-width: 76px; }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand-text,
  .role,
  .sidebar-item span { display: none; }
  .sidebar-item { justify-content: center; padding-inline: 0; }
}

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

@media (max-width: 720px) {
  :root { --sidebar-width: 240px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: 240px;
    min-width: 240px;
    height: 100dvh;
    padding: 16px 12px;
    transform: translateX(105%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-modal);
  }
  .brand { justify-content: flex-start; padding-inline: 6px; }
  .brand-text,
  .role,
  .sidebar-item span { display: initial; }
  .role { display: block; }
  .sidebar-item { justify-content: flex-start; padding-inline: 12px; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(3, 7, 16, .68);
  }
  .sidebar-open .sidebar-backdrop { display: block; }
  .menu-toggle { display: inline-grid; }
  .content { padding: 0 14px 20px; }
  .top { position: relative; min-height: 60px; }
  .page-title { font-size: 17px; }
}

@media (max-width: 480px) {
  .content { padding: 0 12px 18px; }
  .top { gap: 8px; }
  .user-role { display: none; }
  .chip { max-width: 30vw; }
}

@media (max-width: 400px) {
  .content { padding-inline: 10px; }
  .breadcrumb { display: none; }
  .avatar { display: none; }
  .page-title { font-size: 15px; }
  .chip { max-width: 34vw; }
}
