@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-FD-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-FD-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-FD-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-FD-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f6fb;
  --bg-accent: #e9eef8;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --ink: #1a1f2e;
  --ink-soft: #2d3548;
  --muted: #6b7388;
  --line: #dde3f0;
  --line-strong: #c8d0e3;
  --brand: #9b59b6;
  --brand-2: #3498db;
  --brand-dark: #6c3483;
  --brand-soft: #f3eaf8;
  --accent: #3498db;
  --accent-soft: #e8f4fc;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --ok: #1f7a4d;
  --ok-soft: #e8f6ee;
  --warn: #b7791f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(26, 31, 46, 0.04), 0 18px 40px rgba(52, 73, 94, 0.06);
  --shadow-soft: 0 1px 2px rgba(26, 31, 46, 0.04);
  --font: "Vazirmatn", Tahoma, sans-serif;
  --sidebar-w: 272px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  line-height: 1.75;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(155, 89, 182, 0.14), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(52, 152, 219, 0.12), transparent 50%),
    linear-gradient(165deg, #f8f7fc 0%, var(--bg) 45%, #eef2fa 100%);
  background-attachment: fixed;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* —— App shell (modern floating rail) —— */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  gap: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px 18px 10px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.sidebar-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 0;
}

.sidebar .brand,
.sidebar a.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  color: inherit;
  text-decoration: none;
  transform: none;
  background: transparent;
  justify-content: flex-start;
}
.sidebar a.brand:hover,
.sidebar a.brand:focus {
  background: transparent;
  color: inherit;
  text-decoration: none;
  transform: none;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #fff;
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-copy {
  min-width: 0;
}
.brand-copy strong {
  display: block;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--brand-dark);
}
.brand-copy span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow: auto;
  padding: 12px 10px 8px;
  scrollbar-width: thin;
}

.nav-section {
  margin: 10px 8px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.sidebar a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-soft);
  padding: 9px 12px;
  border-radius: 12px;
  margin: 2px 0;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .2s var(--ease), color .2s ease, border-color .2s ease, transform .2s var(--ease);
}
.sidebar a:hover {
  background: var(--surface-2);
  color: var(--brand-dark);
  text-decoration: none;
  transform: translateX(-2px);
}
.sidebar a.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: rgba(155, 89, 182, 0.16);
  font-weight: 700;
}

.sidebar-foot {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--line);
}

.main {
  padding: 18px 22px 40px 18px;
  width: 100%;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px 18px;
  background: rgba(255,255,255,.65);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
}
.topbar-title {
  min-width: 0;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.topbar-logo {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.topbar-kicker {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}
.topbar strong {
  font-size: 18px;
  color: var(--brand-dark);
  letter-spacing: -0.02em;
}
.topbar .user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(145deg, #e8d5f2, #d6ebf8);
  color: var(--brand-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}
.card h1, .card h2 {
  margin-top: 0;
  color: var(--brand-dark);
  letter-spacing: -0.02em;
}
.card h1 { font-size: 1.35rem; }
.card h2 { font-size: 1.05rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  transition: transform .15s var(--ease), filter .2s ease, opacity .2s ease;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn.is-loading {
  opacity: .7;
  cursor: wait;
  transform: none;
  pointer-events: none;
}
.btn-light {
  background: #fff;
  color: var(--brand-dark);
  border: 1px solid var(--line-strong);
  filter: none;
}
.btn-light:hover { background: var(--surface-2); filter: none; }
.btn-danger {
  background: linear-gradient(180deg, #d45345, var(--danger));
}
.btn-danger:hover { filter: brightness(1.04); }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
}
.form-control {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-family: var(--font);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.16);
  background: #fff;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13.5px;
}
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 8px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid rgba(155, 89, 182, 0.12);
  min-width: 1.4em;
}

/* KPI / modern tiles */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-tile {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-soft);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform .18s var(--ease), border-color .18s ease, box-shadow .18s ease;
  cursor: pointer;
}
a.stat-tile:hover {
  text-decoration: none;
  color: inherit;
  transform: translateY(-2px);
  border-color: rgba(155, 89, 182, 0.35);
  box-shadow: 0 12px 28px rgba(26, 31, 46, 0.1);
}
a.stat-tile.danger:hover {
  border-color: rgba(192, 57, 43, 0.35);
}
a.stat-tile.warn:hover {
  border-color: rgba(52, 152, 219, 0.4);
}
.stat-tile::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: var(--brand);
}
.stat-tile.warn::before { background: var(--accent); }
.stat-tile.danger::before { background: var(--danger); }
.stat-tile .label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}
.stat-tile .value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat-tile.danger .value { color: var(--danger); }

.panel-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-grid.two { grid-template-columns: 1.2fr 1fr; }
.panel-grid.equal { grid-template-columns: 1fr 1fr; }

.list-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }

.hero-welcome {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 16px;
  margin-bottom: 14px;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(155, 89, 182, 0.14);
  background:
    linear-gradient(120deg, rgba(255,255,255,.94), rgba(243,234,248,.88)),
    radial-gradient(420px 180px at 100% 0%, rgba(52,152,219,.14), transparent 60%);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  position: relative;
}
.hero-welcome-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.hero-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
}
.hero-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.hero-welcome h1 {
  margin: 0 0 8px;
  font-size: 1.55rem;
  color: var(--brand-dark);
  letter-spacing: -0.03em;
}
.hero-welcome p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}
.hero-side {
  align-self: center;
  justify-self: start;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* Auth — split cinematic */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  padding: 0;
}
.auth-visual {
  position: relative;
  overflow: hidden;
  padding: 48px 42px;
  color: #f8fbff;
  background:
    radial-gradient(700px 420px at 20% 10%, rgba(255,255,255,.16), transparent 50%),
    linear-gradient(155deg, #6c3483 0%, #9b59b6 45%, #3498db 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 30% 20%, #000 20%, transparent 75%);
  pointer-events: none;
}
.auth-visual-inner { position: relative; z-index: 1; max-width: 420px; }
.auth-visual .mark {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid rgba(255,255,255,.55);
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.2);
}
.auth-visual .mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.auth-visual h1 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1.35;
  letter-spacing: -0.03em;
}
.auth-visual p {
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
  color: rgba(248, 251, 255, 0.84);
  max-width: 34ch;
}
.auth-visual .foot {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  color: rgba(248, 251, 255, 0.68);
}
.auth-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
  background:
    radial-gradient(500px 280px at 90% 10%, rgba(155,89,182,.1), transparent 60%),
    radial-gradient(400px 220px at 10% 90%, rgba(52,152,219,.1), transparent 55%),
    #f6f7fb;
}
.auth-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 30px 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: fade-up .5s var(--ease) both;
}
.auth-card h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  color: var(--brand-dark);
  letter-spacing: -0.02em;
}
.auth-card .sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 22px;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    padding: 12px 12px 0;
  }
  .sidebar-panel { border-radius: 20px; }
  .sidebar-nav { max-height: 220px; }
  .main { padding: 14px; }
  .stat-grid, .stat-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .panel-grid.two, .panel-grid.equal, .hero-welcome { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-visual { min-height: 280px; padding: 28px 22px; }
  .hero-welcome-main { align-items: flex-start; }
}

@media (max-width: 640px) {
  .stat-grid, .stat-grid.cols-3 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

/* —— Motion & loading —— */
@keyframes page-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes soft-pulse {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bar-slide {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}
@keyframes shell-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.main > *:not(.topbar) {
  animation: page-in .5s var(--ease) both;
}
.sidebar-panel { animation: shell-in .55s var(--ease) both; }
.card {
  transition: border-color .25s ease, transform .25s var(--ease), box-shadow .25s ease;
}
.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.badge { transition: transform .2s ease, background .2s ease; }

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.page-loader.is-on {
  opacity: 1;
  pointer-events: auto;
}
.page-loader::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand), var(--brand-2), var(--brand), transparent);
  animation: bar-slide 1.1s linear infinite;
}
.page-loader-panel {
  position: absolute;
  inset: 0;
  background: rgba(244, 246, 251, .55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
}
.page-loader-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 13.5px;
  animation: fade-up .35s var(--ease) both;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(155, 89, 182, .22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.btn .spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
  border-color: rgba(255,255,255,.35);
  border-top-color: #fff;
}

.swal2-popup {
  font-family: var(--font) !important;
  border-radius: 18px !important;
  padding: 1.4em 1.2em !important;
}
.swal2-title { font-size: 1.15rem !important; color: var(--brand-dark) !important; }
.swal2-html-container { font-size: .95rem !important; color: var(--ink) !important; }
.swal2-confirm {
  background: var(--brand) !important;
  border-radius: 10px !important;
  font-family: var(--font) !important;
  box-shadow: none !important;
}
.swal2-cancel, .swal2-deny {
  border-radius: 10px !important;
  font-family: var(--font) !important;
}
.swal2-icon.swal2-success [class^=swal2-success-line],
.swal2-icon.swal2-success .swal2-success-ring { border-color: var(--ok) !important; }
.swal2-icon.swal2-success [class^=swal2-success-line] { background-color: var(--ok) !important; }
.swal2-icon.swal2-error { border-color: var(--danger) !important; color: var(--danger) !important; }
.swal2-icon.swal2-error [class^=swal2-x-mark-line] { background-color: var(--danger) !important; }

jdp-container, .jdp-container {
  font-family: var(--font) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow) !important;
  border: 1px solid var(--line) !important;
}
input[data-jdp], input[data-jdp-time] {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%239b59b6' stroke-width='1.6'%3E%3Crect x='2.5' y='3.5' width='13' height='12' rx='2'/%3E%3Cpath d='M2.5 7.5h13M6 2v3M12 2v3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
