:root {
  --red: #e31e24;
  --red-2: #ff4d52;
  --red-hover: #c41920;
  --red-soft: rgba(227, 30, 36, 0.12);
  --green: #1b8a4b;
  --green-soft: rgba(27, 138, 75, 0.12);
  --orange: #ed6c02;
  --orange-soft: rgba(237, 108, 2, 0.14);
  --bg: #f0f1f6;
  --bg-subtle: #e6e8ef;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --sidebar: #121218;
  --sidebar-2: #1a1a22;
  --text: #14141a;
  --muted: #6b6b78;
  --border: rgba(15, 15, 20, 0.08);
  --border-strong: rgba(15, 15, 20, 0.12);
  --shadow: 0 10px 40px rgba(20, 20, 30, 0.06);
  --shadow-lg: 0 20px 50px rgba(20, 20, 30, 0.1);
  --radius: 16px;
  --radius-sm: 11px;
  --font: "Vazirmatn", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body.dark {
  --bg: #0a0a0e;
  --bg-subtle: #121218;
  --surface: #16161e;
  --surface-2: #1c1c26;
  --sidebar: #0c0c10;
  --sidebar-2: #14141c;
  --text: #f2f2f7;
  --muted: #9494a3;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --red-soft: rgba(227, 30, 36, 0.16);
  --green-soft: rgba(52, 211, 153, 0.12);
  --orange-soft: rgba(251, 191, 36, 0.12);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
  --green: #34d399;
  --orange: #fbbf24;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 268px 1fr;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  background:
    radial-gradient(400px 240px at 50% 0%, rgba(227, 30, 36, 0.18), transparent 60%),
    linear-gradient(180deg, var(--sidebar-2), var(--sidebar));
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 16px 0 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 2;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 18px 20px;
}
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(145deg, #ff3d42, #9e1016);
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.14), 0 10px 24px rgba(227,30,36,0.4);
  position: relative;
  overflow: hidden;
}
.brand-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.3), transparent 50%);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; letter-spacing: -0.02em; }
.brand-text span { font-size: 11.5px; opacity: 0.55; font-weight: 500; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 12px;
  flex: 1;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.68);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font: 500 13.5px var(--font);
  cursor: pointer;
  text-align: right;
  transition: background 0.18s var(--ease), color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: linear-gradient(180deg, #ff3d42, var(--red));
  color: #fff;
  box-shadow: 0 10px 28px rgba(227, 30, 36, 0.38);
}
.nav-item .ico {
  width: 22px;
  text-align: center;
  opacity: 0.9;
  font-size: 14px;
}

.sidebar-foot {
  padding: 12px 14px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  margin-top: 8px;
}
.user-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(255,255,255,0.16), rgba(255,255,255,0.04));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}
.user-chip strong { display: block; font-size: 12.5px; }
.user-chip span { font-size: 11px; opacity: 0.5; }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.crumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13.5px;
}
.muted { color: var(--muted); }
.sep { color: var(--muted); opacity: 0.4; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.clock {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 500;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 15px;
  position: relative;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.icon-btn:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.icon-btn.bell .badge {
  position: absolute;
  top: -5px;
  left: -5px;
  background: linear-gradient(180deg, #ff4d52, var(--red));
  color: #fff;
  font-size: 10px;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(227, 30, 36, 0.4);
}

.content {
  flex: 1;
  overflow: auto;
  padding: 24px;
  scrollbar-width: thin;
}

.page-header { margin-bottom: 20px; }
.page-header h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
  border-color: color-mix(in srgb, var(--red) 25%, var(--border));
  box-shadow: var(--shadow-lg);
}
.stat .label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
  font-weight: 500;
}
.stat .value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat .icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 16px;
  border: 1px solid color-mix(in srgb, var(--red) 20%, transparent);
}
.stat.warn .icon {
  background: var(--orange-soft);
  color: var(--orange);
  border-color: color-mix(in srgb, var(--orange) 25%, transparent);
}
.stat.danger .value { color: var(--red-2); }

.row-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 190px;
  padding: 10px 4px 28px;
}
.bar {
  flex: 1;
  border-radius: 10px 10px 5px 5px;
  background: linear-gradient(180deg, #ff7a7e 0%, var(--red) 100%);
  position: relative;
  min-height: 12px;
  box-shadow: 0 8px 18px rgba(227, 30, 36, 0.2);
  transition: transform 0.2s var(--ease), filter 0.2s;
  animation: barIn 0.7s var(--ease) both;
}
.bar:hover { filter: brightness(1.08); transform: scaleY(1.03); transform-origin: bottom; }
@keyframes barIn {
  from { transform: scaleY(0.2); opacity: 0; transform-origin: bottom; }
  to { transform: scaleY(1); opacity: 1; transform-origin: bottom; }
}
.bar span {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}

.pie-wrap {
  display: flex;
  gap: 20px;
  align-items: center;
  min-height: 190px;
}
.pie {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background: conic-gradient(
    var(--red) 0 38%,
    #1b8a4b 38% 62%,
    #ed6c02 62% 80%,
    #0078d4 80% 100%
  );
  box-shadow:
    inset 0 0 0 22px var(--surface),
    0 12px 30px rgba(0, 0, 0, 0.08);
  position: relative;
}
.legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-left: 8px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
}

.table-wrap { overflow: auto; padding: 6px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 13px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: var(--surface-2);
}
tr:last-child td { border-bottom: 0; }
tr:hover td {
  background: color-mix(in srgb, var(--red) 4%, transparent);
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  border: 1px solid transparent;
}
.tag.ok {
  background: var(--green-soft);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 25%, transparent);
}
.tag.warn {
  background: var(--orange-soft);
  color: var(--orange);
  border-color: color-mix(in srgb, var(--orange) 25%, transparent);
}
.tag.bad {
  background: var(--red-soft);
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 25%, transparent);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font: 650 13px var(--font);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, #ff3d42, var(--red));
  color: #fff;
  box-shadow: 0 8px 22px rgba(227, 30, 36, 0.3);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { border-color: color-mix(in srgb, var(--red) 30%, var(--border)); }
.input {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 11px 14px;
  font: 400 13px var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: color-mix(in srgb, var(--red) 50%, var(--border));
  box-shadow: 0 0 0 3px var(--red-soft);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
  font-weight: 550;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 11px 13px;
  font: 400 13px var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus {
  border-color: color-mix(in srgb, var(--red) 50%, var(--border));
  box-shadow: 0 0 0 3px var(--red-soft);
}
.alert {
  border-radius: 13px;
  padding: 13px 15px;
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert.danger {
  border-color: color-mix(in srgb, var(--red) 30%, var(--border));
  background: var(--red-soft);
}

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
  font-size: 12px;
}
.cal .d {
  aspect-ratio: 1;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  color: var(--muted);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.cal .d:hover:not(.today) {
  background: color-mix(in srgb, var(--red) 10%, var(--bg-subtle));
  color: var(--text);
}
.cal .d.today {
  background: linear-gradient(180deg, #ff3d42, var(--red));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(227, 30, 36, 0.35);
}

.demo-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  font-size: 12px;
  background: linear-gradient(90deg, #0c0c10, #1a0a0c 55%, #0c0c10);
  color: rgba(255, 255, 255, 0.88);
  border-top: 1px solid rgba(227, 30, 36, 0.35);
  flex-wrap: wrap;
}
.demo-banner a {
  color: #ffb4b6;
  text-decoration: none;
  font-weight: 650;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 182, 0.25);
  background: rgba(227, 30, 36, 0.12);
  transition: background 0.15s;
}
.demo-banner a:hover { background: rgba(227, 30, 36, 0.22); }

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #121218;
  color: #fff;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: 13px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
  z-index: 50;
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  max-width: min(420px, 92vw);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Page enter */
.content > * {
  animation: pageIn 0.4s var(--ease) both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1100px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .row-2 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 76px 1fr; }
  .brand-text,
  .nav-item span:not(.ico),
  .user-chip div:last-child { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .brand { justify-content: center; padding-inline: 8px; }
  .form-grid { grid-template-columns: 1fr; }
}
