:root {
  --ink: #0f172a;
  --muted: #5b6b7b;
  --accent: #c2410c;
  --accent-2: #9a3412;
  --accent-soft: #fff7ed;
  --link: #0f766e;
  --success: #16a34a;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --line: #e2e8f0;
  --sidebar: #14202f;
  --sidebar-2: #1e293b;
  --sidebar-text: #cbd5e1;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: "Vazirmatn", "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.8;
  font-size: 14px;
}

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

/* ============ LAYOUT ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 272px;
  flex: 0 0 272px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 0 14px 28px;
  z-index: 40;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  margin-bottom: 14px;
}

.sidebar .brand .logo {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f97316, #c2410c);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.sidebar .brand h1 { font-size: 14px; color: #fff; line-height: 1.5; }
.sidebar .brand p { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.nav-group { margin-bottom: 16px; }
.nav-group .nav-title {
  font-size: 11px;
  color: #64748b;
  padding: 4px 12px 6px;
  letter-spacing: .5px;
}
.nav-group a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--sidebar-text);
  transition: .15s;
  margin-bottom: 2px;
}
.nav-group a .ic { font-size: 17px; width: 22px; text-align: center; }
.nav-group a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-group a.active {
  background: rgba(249, 115, 22, .16);
  color: #fdba74;
  font-weight: 600;
}
.nav-group .nav-sub {
  display: flex;
  flex-direction: column;
  margin: 2px 0 4px 14px;
  padding-left: 10px;
  border-inline-start: 1px solid rgba(255, 255, 255, .12);
}
.nav-group .nav-sub a {
  padding: 7px 12px;
  font-size: 12.5px;
  color: #94a3b8;
}
.nav-group .nav-sub a.active {
  color: #fdba74;
  font-weight: 600;
  background: rgba(249, 115, 22, .12);
}

/* ============ MAIN ============ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .burger {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 40px; height: 38px;
  font-size: 18px;
}

.topbar .page-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.topbar .page-title small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }

.topbar .user {
  display: flex; align-items: center; gap: 10px;
}
.topbar .user .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #c2410c);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.topbar .user .meta { line-height: 1.3; }
.topbar .user .meta strong { display: block; font-size: 13px; }
.topbar .user .meta span { font-size: 11px; color: var(--muted); }
.topbar .logout {
  background: none; border: none; color: var(--danger);
  font-size: 13px; padding: 6px 10px; border-radius: 8px;
}
.topbar .logout:hover { background: #fef2f2; }

.content { padding: 26px 28px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ============ CARDS & GRID ============ */
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

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

.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-card .ic {
  width: 52px; height: 52px; flex: 0 0 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  background: var(--accent-soft);
}
.stat-card .meta .num { font-size: 22px; font-weight: 800; line-height: 1.2; }
.stat-card .meta .lbl { font-size: 12.5px; color: var(--muted); }

/* ============ PAGE HEAD ============ */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-head h2 { font-size: 20px; font-weight: 800; }
.page-head .sub { font-size: 13px; color: var(--muted); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  transition: .15s;
}
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); }

/* ============ TABLE ============ */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  background: #f8fafc;
  color: var(--muted);
  text-align: right;
  padding: 12px 14px;
  font-size: 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fbfcfe; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  font-size: 13.5px;
}

/* ============ FORMS ============ */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.field label.required::after { content: " *"; color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--ink);
  transition: .15s;
  direction: rtl;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 65, 12, .12);
}
.field input[type="date"] { direction: ltr; text-align: right; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ============ MODAL ============ */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal.open { display: flex; }
.modal .box {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  padding: 24px;
  box-shadow: 0 30px 60px rgba(0,0,0,.25);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .box-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal .box-head h3 { font-size: 16px; font-weight: 800; }
.modal .box-head button { background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; }
.modal .box-foot { display: flex; gap: 10px; justify-content: flex-start; margin-top: 8px; }

/* ============ BADGES ============ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge.ok { background: #f0fdf4; color: var(--success); }
.badge.muted { background: #f1f5f9; color: var(--muted); }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  z-index: 200;
  opacity: 0;
  transform: translateY(14px);
  transition: .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ============ CHART BOX ============ */
.chart-box .chart-title { font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.chart-box .chart-sub { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.chart-wrap { position: relative; height: 300px; }

/* ============ MAP ============ */
.map-card { padding: 0; overflow: hidden; }
#map { height: 560px; width: 100%; border-radius: var(--radius); z-index: 1; }

/* ============ AUTH ============ */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(249,115,22,.25), transparent 60%),
    linear-gradient(135deg, #0f172a, #1e293b);
}
.auth-box {
  width: 100%; max-width: 430px;
  background: var(--surface);
  border-radius: 18px;
  padding: 36px 30px;
  box-shadow: 0 30px 60px rgba(0,0,0,.35);
}
.auth-box .brand { text-align: center; margin-bottom: 24px; }
.auth-box .brand .logo {
  width: 64px; height: 64px; margin: 0 auto 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f97316, #c2410c);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}
.auth-box .brand h1 { font-size: 18px; }
.auth-box .brand p { font-size: 12.5px; color: var(--muted); }
.auth-box .errors {
  background: #fef2f2; border: 1px solid #fecaca;
  color: #b91c1c; border-radius: 10px;
  padding: 10px 14px; font-size: 12.5px; margin-bottom: 16px;
}

/* ============ LIBRARY ============ */
.file-row { display: flex; align-items: center; gap: 14px; }
.file-row .fic { font-size: 26px; }
.file-row .meta strong { display: block; font-size: 14px; }
.file-row .meta span { font-size: 11.5px; color: var(--muted); }
.actions { display: flex; gap: 6px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-105%);
    transition: .25s;
  }
  .sidebar.open { transform: none; }
  .topbar .burger { display: block; }
  .topbar .user .meta { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  #map { height: 420px; }
}

/* scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }