/* ═══ Keshavarzi Rebranding Dashboard ═══ */
:root {
  --g: #1a4d44;
  --gd: #0d3b2e;
  --gold: #c5a059;
  --gold-l: #f5e6c8;
  --bg: #eef2f0;
  --sidebar-w: 280px;
  --sidebar-collapsed: 72px;
  --topbar-h: 60px;
  --card: #fff;
  --text: #14271f;
  --muted: #4d5f58;
  --border: #d7e3de;
  --shadow: 0 4px 24px rgba(13, 59, 46, 0.08);
  --radius: 14px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.85;
  font-size: 15px;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100%;
}
img, video, svg { max-width: 100%; height: auto; }

/* ─── Layout ─── */
.app { display: flex; min-height: 100vh; width: 100%; max-width: 100%; overflow-x: hidden; }
.sidebar {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--gd) 0%, #0a2e24 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease, width 0.3s ease;
  overflow: hidden;
}
.sidebar-brand {
  padding: 1rem 1rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
  text-align: center;
}
.sidebar-brand .logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.sidebar-brand .sidebar-logo {
  height: 72px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}
.sidebar-brand .brand-text { text-align: center; }
.sidebar-brand h1 { font-size: 0.82rem; font-weight: 800; line-height: 1.45; }
.sidebar-brand .ver { font-size: 0.65rem; opacity: 0.55; margin-top: 0.2rem; }

.sidebar-search {
  padding: 0.75rem 1rem;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-family: inherit;
  font-size: 0.8rem;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,.45); }
.sidebar-search input:focus { outline: none; border-color: var(--gold); background: rgba(255,255,255,.12); }

.nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0 1.5rem;
}
.nav-scroll::-webkit-scrollbar { width: 4px; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

.nav-group { margin-bottom: 0.35rem; }
.nav-group-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,.62);
  padding: 0.65rem 1.15rem 0.35rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.15rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s;
  border-right: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active {
  background: rgba(197,160,89,.18);
  color: var(--gold-l);
  border-right-color: var(--gold);
  font-weight: 700;
}
.nav-link i { width: 18px; text-align: center; font-size: 0.85rem; opacity: 0.85; flex-shrink: 0; }
.nav-link .badge {
  margin-right: auto;
  font-size: 0.6rem;
  background: rgba(197,160,89,.3);
  color: var(--gold-l);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.nav-link.hidden { display: none; }

.sidebar-footer {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.72);
  flex-shrink: 0;
}

.main-wrap {
  margin-right: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  transition: margin 0.3s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: 0 2px 12px rgba(13,59,46,.04);
}
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1.15rem;
  color: var(--g);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.menu-toggle:hover {
  background: var(--g);
  color: #fff;
  border-color: var(--g);
}
.menu-toggle .icon-close { display: none; }

@media (min-width: 769px) {
  body:not(.sidebar-collapsed) .menu-toggle .icon-open { display: none; }
  body:not(.sidebar-collapsed) .menu-toggle .icon-close { display: inline; }
}

@media (max-width: 768px) {
  body.sidebar-open .menu-toggle .icon-open { display: none; }
  body.sidebar-open .menu-toggle .icon-close { display: inline; }
}

/* ─── Sidebar collapsed (desktop) / hidden default (mobile) ─── */
body.sidebar-collapsed .sidebar {
  transform: translateX(100%);
}
body.sidebar-collapsed .main-wrap {
  margin-right: 0;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  flex: 1;
}
.breadcrumb a { color: var(--g); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb .sep { opacity: 0.4; }
.breadcrumb .current { color: var(--text); font-weight: 700; }
.topbar-actions { display: flex; gap: 0.5rem; }
.topbar-btn {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--g);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s;
}
.topbar-btn:hover { background: var(--g); color: #fff; border-color: var(--g); }
.topbar-admin { color: var(--g); }
.topbar-admin:hover { background: rgba(197, 160, 89, 0.15); color: var(--gd); border-color: var(--gold); }
.topbar-logout { text-decoration: none; color: inherit; }
.topbar-logout:hover { background: rgba(192, 57, 43, 0.1); color: #a93226; border-color: rgba(192, 57, 43, 0.35); }
.logout-form-inline { display: inline; margin: 0; padding: 0; }
.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  background: var(--bg);
  border-radius: 8px;
  margin-left: 0.5rem;
}
.topbar-user i { color: var(--g); }

.content {
  padding: 1.5rem 2rem 3rem;
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

/* ─── Dashboard Home ─── */
.dash-home .dash-hero-inner {
  text-align: center;
}

.dash-home .dash-hero p {
  margin-inline: auto;
}

.dash-home .kpi-card {
  text-align: center;
}

.dash-home .kpi-card .icon {
  margin-inline: auto;
}

.dash-home .quick-card {
  text-align: center;
}

.dash-home .quick-card h3 {
  justify-content: center;
}

.dash-home .progress-section h3 {
  text-align: center;
}

.dash-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--gd) 0%, #0f4a3c 55%, var(--g) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 1.15rem 1.6rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 28px rgba(13, 59, 46, 0.2);
}
.dash-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -5%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(197, 160, 89, 0.12) 0%, transparent 70%);
  pointer-events: none;
}
.dash-hero-accent {
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--gold), rgba(197, 160, 89, 0.35));
  border-radius: 0 var(--radius) var(--radius) 0;
}
.dash-hero-inner { position: relative; z-index: 1; }
.dash-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold-l);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}
.dash-hero h2 {
  font-size: clamp(1.15rem, 2.2vw, 1.42rem);
  font-weight: 900;
  margin-bottom: 0.35rem;
  color: #fff;
  letter-spacing: -0.02em;
}
.dash-hero-lead {
  max-width: 720px;
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.65;
  margin-bottom: 0.65rem;
}
.dash-hero-lead strong { color: #fff; font-weight: 700; }
.dash-hero p { max-width: 720px; font-size: 0.84rem; color: rgba(255, 255, 255, 0.88); line-height: 1.65; }
.dash-hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 0.28rem 0.58rem;
  border-radius: 7px;
}
.hero-tag i { color: var(--gold); font-size: 0.68rem; }
.dash-hero .src { color: rgba(255, 255, 255, 0.78); font-style: normal; }
.dash-home .dash-hero-tags { justify-content: center; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(13,59,46,.12); }
.kpi-card .icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 0.65rem;
}
.kpi-card .icon.green { background: rgba(26,77,68,.12); color: var(--g); }
.kpi-card .icon.gold { background: rgba(197,160,89,.18); color: #7a5f1f; }
.kpi-card .icon.blue { background: rgba(37,99,235,.12); color: #2563eb; }
.kpi-card .icon.red { background: rgba(192,57,43,.1); color: #c0392b; }
.kpi-card .val { font-size: 1.65rem; font-weight: 900; color: var(--g); line-height: 1.1; }
.kpi-card .lbl { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.quick-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}
.quick-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.quick-card h3 { font-size: 0.92rem; color: var(--gd); margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.5rem; }
.quick-card p { font-size: 0.8rem; color: var(--muted); line-height: 1.7; }

.progress-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.progress-section h3 { font-size: 1rem; color: var(--g); margin-bottom: 1rem; border-bottom: 2px solid var(--gold); padding-bottom: 0.5rem; }
.progress-item { margin-bottom: 0.85rem; }
.progress-item .label { display: flex; justify-content: space-between; font-size: 0.82rem; margin-bottom: 0.3rem; }
.progress-item .bar { height: 8px; background: #e2e8e5; border-radius: 4px; overflow: hidden; }
.progress-item .fill { height: 100%; background: linear-gradient(90deg, var(--g), var(--gold)); border-radius: 4px; }

/* ─── Mobile ─── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  body { font-size: 14px; }

  .sidebar {
    transform: translate3d(100%, 0, 0);
    width: min(var(--sidebar-w), 88vw);
    box-shadow: -8px 0 32px rgba(0,0,0,.25);
  }
  body.sidebar-open .sidebar {
    transform: translate3d(0, 0, 0);
  }
  body.sidebar-collapsed .sidebar {
    transform: translate3d(100%, 0, 0);
  }
  body.sidebar-collapsed .main-wrap {
    margin-right: 0 !important;
  }

  .main-wrap {
    margin-right: 0 !important;
    width: 100%;
    max-width: 100vw;
  }

  .topbar {
    padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) 0.5rem max(0.75rem, env(safe-area-inset-left));
    gap: 0.5rem;
    height: auto;
    min-height: 52px;
  }
  .menu-toggle {
    width: 44px;
    height: 44px;
    touch-action: manipulation;
  }
  .breadcrumb {
    font-size: 0.72rem;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }
  .breadcrumb .current {
    display: inline-block;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
  }
  .topbar-actions {
    flex-shrink: 0;
    gap: 0.35rem;
  }
  .topbar-btn {
    padding: 0.45rem 0.55rem;
    font-size: 0.72rem;
  }

  .content {
    padding: 0.85rem max(0.75rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  }

  .dash-hero {
    padding: 0.95rem 1rem 0.85rem;
    margin-bottom: 1rem;
  }
  .dash-hero h2 { font-size: 1.05rem; }
  .dash-hero-lead,
  .dash-hero p { font-size: 0.8rem; line-height: 1.55; }
  .dash-hero-tags { gap: 0.3rem; }
  .hero-tag { font-size: 0.68rem; padding: 0.24rem 0.48rem; }

  .kpi-grid, .quick-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .kpi-card { padding: 1rem; }
  .kpi-card .val { font-size: 1.4rem; }
  .quick-card { padding: 1rem; }

  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
  }
  body.sidebar-open .overlay { display: block; }
}
@media (max-width: 400px) {
  .topbar-btn {
    font-size: 0;
    padding: 0.45rem;
    min-width: 40px;
    justify-content: center;
  }
  .topbar-btn i {
    font-size: 1rem;
    margin: 0;
  }
}
@media print {
  html, body {
    overflow: visible !important;
    background: #fff !important;
  }

  .sidebar,
  .topbar,
  .menu-toggle,
  .overlay,
  .sidebar-footer {
    display: none !important;
  }

  .app {
    display: block !important;
    overflow: visible !important;
    min-height: auto !important;
  }

  .main-wrap {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
  }
}
