/* ===== فونت فارسی Vazirmatn (self-hosted) ===== */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* ===== پالت برند ATPG (استخراج‌شده از atpg.co) ===== */
:root {
  --gold-1: #ffd79d;
  --gold-2: #fff0d7;
  --gold-deep: #e0b252;
  --amber: #fbbc34;
  --purple: #694d8c;
  --purple-dark: #533c70;
  --red: #d12c2c;
  --red-dark: #bf2828;
  --green: #459647;

  --title: #242424;
  --text: #555;
  --muted: #888;
  --link: #333;

  --bg: #f7f5f2;
  --surface: #ffffff;
  --border: #ececec;
  --shadow: 0 10px 30px rgba(40, 30, 60, 0.08);
  --shadow-sm: 0 4px 14px rgba(40, 30, 60, 0.06);

  --gold-gradient: linear-gradient(90deg, var(--gold-1), var(--gold-2), var(--gold-1));
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.8;
}

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

h1, h2, h3 { color: var(--title); font-weight: 700; margin: 0 0 .4em; }

/* ===== ناوبار ===== */
.navbar {
  background: var(--surface);
  border-bottom: 3px solid transparent;
  border-image: var(--gold-gradient) 1;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}
.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--title);
}
.brand .logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--gold-gradient);
  color: var(--purple);
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .5px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
}
.brand small { color: var(--muted); font-weight: 400; font-size: .8rem; }

.nav-actions { display: flex; align-items: center; gap: 14px; }
.nav-user { color: var(--title); font-weight: 500; }
.nav-user .role-tag {
  font-size: .72rem;
  background: var(--purple);
  color: #fff;
  padding: 2px 8px;
  border-radius: 20px;
  margin-inline-start: 6px;
}

/* ===== دکمه‌ها ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
}
.btn-gold {
  background: var(--gold-gradient);
  color: var(--purple);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.1);
  font-weight: 700;
}
.btn-gold:hover { filter: brightness(1.03); color: var(--purple-dark); }
.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover { background: var(--purple-dark); color: #fff; }
.btn-light { background: #f1f1f1; color: var(--link); }
.btn-light:hover { background: #e7e7e7; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }

/* ===== صفحه‌ی ورود ===== */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255,215,157,.45), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 38px 34px;
  border-top: 5px solid transparent;
  border-image: var(--gold-gradient) 1;
}
.auth-logo {
  width: 70px; height: 70px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid; place-items: center;
  background: var(--gold-gradient);
  color: var(--purple);
  font-weight: 700;
  font-size: 1.4rem;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08);
}
.auth-card h1 { text-align: center; font-size: 1.4rem; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 26px; font-size: .9rem; }

/* ===== فرم‌ها ===== */
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--title); font-size: .9rem; }
.field input[type="text"],
.field input[type="password"],
.field select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: .95rem;
  background: #fafafa;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(105,77,140,.12);
  background: #fff;
}
.field .err { color: var(--red); font-size: .82rem; margin-top: 5px; display: block; }

.checkbox-line { display: flex; align-items: center; gap: 8px; }
.checkbox-line input { width: auto; }

/* ===== فلش‌مسیج ===== */
.flashes { max-width: 1100px; margin: 18px auto 0; padding: 0 24px; }
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: .9rem;
  border-inline-start: 4px solid;
}
.flash.success { background: #eaf7ea; color: #1f6d24; border-color: var(--green); }
.flash.danger  { background: #fdecec; color: #a31f1f; border-color: var(--red); }
.flash.warning { background: #fff6e6; color: #8a5a00; border-color: var(--amber); }
.flash.info    { background: #eef2f9; color: #2b4a7a; border-color: var(--purple); }

/* ===== چیدمان کلی صفحات داخلی ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 30px 24px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; }
.page-head p { color: var(--muted); margin: 0; }

/* ===== داشبورد: کارت سامانه‌ها ===== */
.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 26px;
}
.system-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  transition: transform .15s ease, box-shadow .15s ease;
  position: relative;
  overflow: hidden;
}
.system-card::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 5px;
  background: var(--card-accent, var(--purple));
}
.system-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.system-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 1.7rem;
  background: color-mix(in srgb, var(--card-accent, var(--purple)) 14%, #fff);
}
.system-card h3 { margin: 0; font-size: 1.15rem; }
.system-card .desc { color: var(--muted); font-size: .88rem; flex: 1; margin: 0; }
.system-card .domain { color: var(--card-accent, var(--purple)); font-size: .8rem; direction: ltr; text-align: right; }
.system-card .go { margin-top: 6px; }

.empty-state {
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 50px 24px;
  text-align: center;
  color: var(--muted);
  margin-top: 26px;
}
.empty-state .big { font-size: 2.5rem; margin-bottom: 10px; }

/* ===== جدول کاربران ===== */
.card-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 22px;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 16px; text-align: right; border-bottom: 1px solid var(--border); }
.table th { background: #faf8f5; color: var(--title); font-weight: 700; font-size: .85rem; }
.table tr:last-child td { border-bottom: none; }
.table td.phone { direction: ltr; text-align: right; font-family: monospace; }
.table .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { font-size: .72rem; padding: 3px 9px; border-radius: 20px; display: inline-block; }
.badge.admin { background: var(--purple); color: #fff; }
.badge.user { background: #eee; color: #555; }
.badge.on { background: #eaf7ea; color: #1f6d24; }
.badge.off { background: #fdecec; color: #a31f1f; }
.count-pill { background: #f0ecf7; color: var(--purple); font-weight: 700; padding: 2px 10px; border-radius: 20px; font-size: .8rem; }

/* فرم درون‌خطی برای دکمه‌های POST */
.inline-form { display: inline; margin: 0; }

/* ===== صفحه‌ی خطا ===== */
.error-wrap { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.error-code { font-size: 4rem; font-weight: 700; color: var(--purple); }

@media (max-width: 640px) {
  .navbar-inner { padding: 12px 16px; }
  .container { padding: 20px 16px 40px; }
  .table { font-size: .85rem; }
  .table th, .table td { padding: 10px; }
}
