/* ==========================================================================
   دستجان - پنل مدیریت | Design system (hand-authored, no build step)
   Apex-dashboard inspired: dark sidebar, light content, brand navy + sage.
   ========================================================================== */

@font-face {
  font-family: "Vazirmatn";
  src: url("/assets/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* پالت دستجان: کرم گرم + سرمه‌ای + سبز مریمی/هلویی/آبی ملایم + ترکوتا */
  --brand-50: #EEF5F0;
  --brand-100: #CFE3D3;
  --brand-400: #8FB89E;
  --brand-500: #6E9C80;
  --brand-600: #1F2A3C;
  --brand-700: #2B3950;

  /* سایدبار روشن و گرم (شنی/قهوه‌ای روشن) هماهنگ با زمینه‌ی کرم */
  --sidebar-bg: #F1E4D3;
  --sidebar-bg-2: #EBDAC5;
  --sidebar-muted: #6F5E4F;
  --sidebar-active: rgba(217, 136, 95, 0.16);
  --sidebar-line: #DDC9B1;

  --ink: #1F2A3C;
  --muted: #6B7280;
  --line: #EADFD2;
  --canvas: #FBF6EF;
  --surface: #FFFFFF;

  --amber: #D9A441;
  --sky: #5B8DB8;
  --violet: #8C7AA8;
  --rose: #C8553D;
  --accent: #D9885F;

  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(31, 42, 60, 0.06), 0 1px 3px rgba(31, 42, 60, 0.05);
  --shadow: 0 4px 16px rgba(31, 42, 60, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- layout shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--ink);
  border-inline-end: 1px solid var(--sidebar-line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #D3BDA3; border-radius: 3px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px;
  border-bottom: 1px solid var(--sidebar-line);
  margin-bottom: 12px;
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #C9754B);
  display: grid; place-items: center; color: #fff; font-weight: 800;
}
.brand b { font-size: 15px; display: block; }
.brand .brand-mark { width: 56px; height: 56px; object-fit: contain; flex-shrink: 0; }
.brand .brand-word { height: 26px; width: auto; display: block; margin-bottom: 3px; }
.brand span { font-size: 10px; letter-spacing: 2px; color: var(--sidebar-muted); }

.nav-group { margin: 16px 0 6px; padding: 0 10px; font-size: 10px; letter-spacing: 1px; color: #A18B73; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 10px; color: var(--sidebar-muted);
  font-size: 13px; margin-bottom: 2px; transition: all .15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--sidebar-active); color: var(--ink); }
.nav-link.active { background: linear-gradient(90deg, #C9754B, var(--accent)); color: #fff; }
.nav-link .badge-count {
  margin-inline-start: auto; background: var(--rose); color: #fff;
  font-size: 11px; border-radius: 999px; padding: 1px 7px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .search {
  flex: 1; max-width: 380px; display: flex; align-items: center; gap: 8px;
  background: var(--canvas); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.topbar .search input { border: 0; background: transparent; outline: none; width: 100%; font-family: inherit; }
.topbar .search svg, .topbar .icon-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link svg, .btn svg { width: 18px; height: 18px; }
.btn svg { width: 15px; height: 15px; }
.stat .ico svg { width: 20px; height: 20px; }
.topbar .spacer { flex: 1; }
.topbar .icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; position: relative;
}
.topbar .icon-btn .dot { position: absolute; top: 7px; inset-inline-end: 7px; width: 8px; height: 8px; background: var(--rose); border-radius: 50%; }
.topbar .avatar { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-weight: 700; }

.content { padding: 24px; flex: 1; }
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card h3 { margin: 0 0 2px; font-size: 15px; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }

.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.stat .row { display: flex; justify-content: space-between; align-items: flex-start; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 800; margin: 8px 0 6px; }
.stat .chip { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.stat .chip.up { color: #4F7F63; }
.stat .chip.down { color: var(--rose); }
.stat .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.ico.emerald { background: var(--brand-50); color: var(--brand-600); }
.ico.sky { background: #DCE9F3; color: var(--sky); }
.ico.violet { background: #E9E3F0; color: var(--violet); }
.ico.amber { background: #F8E8C8; color: var(--amber); }

/* ---------- charts ---------- */
.chart-wrap { position: relative; height: 300px; }
.tabs { display: inline-flex; background: var(--canvas); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }

.donut-legend { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.donut-legend .li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend .li .k { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .li .v { margin-inline-start: auto; font-weight: 700; }

.goal { margin-bottom: 16px; }
.goal .g-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.goal .g-top b { color: #4F7F63; }
.bar { height: 8px; border-radius: 999px; background: var(--canvas); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-500), var(--brand-400)); }
.goal .g-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.table-card { overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 12px 16px; text-align: right; font-size: 13px; }
table.data thead th { background: var(--canvas); color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); }
table.data tbody tr { border-bottom: 1px solid var(--line); }
table.data tbody tr:last-child { border-bottom: 0; }
table.data tbody tr:hover { background: #FFFBF6; }
.table-scroll { overflow-x: auto; }

.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: var(--canvas); border: 1px solid var(--line); }

/* ---------- badges / pills ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: #DDEBE0; color: #3F6B52; }
.badge.amber { background: #F8E8C8; color: #8A5A12; }
.badge.sky { background: #DCE9F3; color: #2F5F86; }
.badge.rose { background: #F9DDD5; color: #A23B26; }
.badge.gray { background: #F1EBE3; color: #5B6472; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; transition: all .15s;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand-400); }
.btn-danger { background: #FDEEE8; color: var(--rose); border-color: #F2C9BA; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: #3F4A5C; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field input[type=datetime-local], .field input[type=date],
.field select, .field textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-family: inherit; font-size: 13px; outline: none; background: var(--surface); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-500); }
.field textarea { resize: vertical; min-height: 90px; }
.field .hint { font-size: 11px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- alerts ---------- */
.alert { padding: 12px 16px; border-radius: 12px; font-size: 13px; margin-bottom: 16px; }
.alert.success { background: #EEF5F0; color: #3F6B52; border: 1px solid var(--brand-100); }
.alert.error { background: #FDEEE8; color: var(--rose); border: 1px solid #F2C9BA; }
.field-error { color: var(--rose); font-size: 11px; }

/* ---------- pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 36px; height: 36px; display: grid; place-items: center; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 13px; background: var(--surface);
}
.pagination .active span, .pagination span[aria-current] { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.pagination .disabled span { opacity: .4; }

/* ---------- login (warm sketchbook design — no navy) ---------- */
.lg-body { background: #FBF6EF; }
.lg-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 520px at 100% 0%, rgba(207, 227, 211, .75), transparent 62%),
    radial-gradient(800px 520px at 0% 20%, rgba(248, 225, 208, .8), transparent 62%),
    radial-gradient(800px 500px at 100% 100%, rgba(241, 216, 223, .55), transparent 62%),
    #FBF6EF;
}
.lg-blob { position: absolute; z-index: 0; border-radius: 58% 42% 46% 54% / 52% 44% 56% 48%; filter: blur(2px); }
.lg-blob--a { width: 340px; height: 340px; background: #E4EEE6; top: -90px; right: -70px; }
.lg-blob--b { width: 280px; height: 280px; background: #FCECE0; bottom: -80px; left: -60px; }
.lg-blob--c { width: 160px; height: 160px; background: #EEE3F0; bottom: 22%; right: 6%; opacity: .7; }

.lg-card {
  position: relative; z-index: 1; width: 100%; max-width: 940px;
  display: grid; grid-template-columns: 1fr 1fr; min-height: 560px;
  background: rgba(255, 255, 255, .78); backdrop-filter: blur(8px);
  border: 1px solid #fff; border-radius: 36px; overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(120, 84, 50, .28), 0 2px 6px rgba(120, 84, 50, .06);
}
.lg-form { padding: 40px 44px; display: flex; flex-direction: column; justify-content: center; }
.lg-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 26px; }
.lg-brand .lg-mark { width: 62px; height: 62px; object-fit: contain; flex-shrink: 0; }
.lg-brand .lg-word { height: 32px; width: auto; display: block; margin-bottom: 4px; }
.lg-brand b { display: block; font-size: 17px; color: #3B2F25; }
.lg-brand span { font-size: 10px; letter-spacing: 2px; color: #A18B73; }
.lg-form h1 { margin: 0 0 6px; font-size: 26px; color: #3B2F25; font-weight: 800; }
.lg-sub { margin: 0 0 22px; color: #8A7968; font-size: 13px; line-height: 1.9; }
.lg-form .field label { color: #5C4B3C; }
.lg-form .field input[type=email], .lg-form .field input[type=password] {
  background: #FFFBF6; border: 1px solid #E8D9C6; border-radius: 14px; padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.lg-form .field input:focus { outline: none; border-color: #D9885F; box-shadow: 0 0 0 4px rgba(217, 136, 95, .18); }
.lg-form .switch { color: #6F5E4F; }
.lg-submit {
  width: 100%; margin-top: 22px; padding: 13px 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(90deg, #C9754B, #D9885F); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 12px 24px -10px rgba(201, 117, 75, .7); transition: transform .15s, box-shadow .15s, filter .15s;
}
.lg-submit:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 16px 28px -10px rgba(201, 117, 75, .8); }
.lg-foot { margin: 26px 0 0; text-align: center; font-size: 11px; color: #B3A08A; }

.lg-art {
  position: relative; padding: 36px 32px 0; display: flex; flex-direction: column;
  background: linear-gradient(160deg, #DCE9F3 0%, #F8E1D0 100%);
  border-inline-start: 1px solid rgba(255, 255, 255, .8);
}
.lg-art::before {
  content: ""; position: absolute; inset: auto -60px -80px auto; width: 260px; height: 260px;
  border-radius: 50%; background: rgba(255, 255, 255, .35);
}
.lg-art-text { position: relative; z-index: 1; }
.lg-chip {
  display: inline-block; padding: 5px 14px; border-radius: 999px; background: rgba(255, 255, 255, .8);
  color: #8A5A3C; font-size: 11px; font-weight: 700; margin-bottom: 12px;
}
.lg-art h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.7; color: #3B2F25; font-weight: 800; }
.lg-art p { margin: 0; color: #6F5E4F; font-size: 13px; line-height: 1.9; max-width: 300px; }
.lg-illus { position: relative; z-index: 1; width: 100%; max-width: 380px; margin: auto auto 0; display: block; }

@media (max-width: 820px) {
  .lg-card { grid-template-columns: 1fr; max-width: 460px; min-height: 0; border-radius: 30px; }
  .lg-art { display: none; }
  .lg-form { padding: 32px 26px; }
}

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; direction: ltr; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap { gap: 10px; }
.mt { margin-top: 16px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }

/* ---------- home sections (drag-and-drop layout builder) ---------- */
.sections-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.section-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  cursor: grab; transition: box-shadow .15s, opacity .15s;
}
.section-row.is-inactive { opacity: .55; }
.section-row.dragging { opacity: .4; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.section-row .drag-handle { color: var(--muted); flex: 0 0 auto; display: flex; }
.section-row .drag-handle svg { width: 20px; height: 20px; }
.section-row-main { flex: 1; min-width: 0; }
.section-row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-row-meta { font-size: 12px; margin-top: 4px; }
.section-row-actions { flex: 0 0 auto; }
.section-row-actions form { display: contents; }

/* ---------- notification bell ---------- */
.topbar .icon-btn .badge-dot {
  position: absolute; top: -5px; inset-inline-end: -5px; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 999px; background: var(--rose); color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center; line-height: 1;
  border: 2px solid var(--surface);
}
.topbar .icon-btn .badge-dot[hidden] { display: none; }
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 10px); width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.18); z-index: 50; overflow: hidden;
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.notif-panel-head b { font-size: 13px; }
.notif-panel-head button {
  background: none; border: 0; color: var(--brand-600); font-size: 12px; cursor: pointer; padding: 0;
}
.notif-panel-head button:disabled { color: var(--muted); cursor: default; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: block; padding: 11px 14px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; position: relative;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--canvas); }
.notif-item.is-unread { background: var(--brand-50); }
.notif-item.is-unread:hover { background: var(--brand-100); }
.notif-item .notif-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.notif-item .notif-title .unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-600); flex-shrink: 0; }
.notif-item .notif-body { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.notif-item .notif-time { font-size: 11px; color: var(--muted); margin-top: 5px; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }
