:root {
  --brand: #352070;
  --brand-700: #2b1a5c;
  --brand-100: #ece7f7;
  --brand-50: #f6f3fc;
  --accent: #eebb66;
  --accent-700: #d9a94f;
  --text: #1e1b2e;
  --muted: #6b6880;
  --line: #e4e1ec;
  --bg: #f7f6fb;
  --white: #ffffff;
  --ok: #1f7a54;
  --ok-bg: #e6f5ee;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --danger: #a3283a;
  --danger-bg: #fdecef;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(53, 32, 112, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: "Cascadia Mono", Consolas, monospace; direction: ltr; unicode-bidi: embed; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 28px;
  background: var(--brand);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; color: rgba(255, 255, 255, 0.65); font-size: 11px; letter-spacing: 0.06em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--brand);
  font-weight: 800;
  font-size: 18px;
}
.brand-mark-lg { width: 56px; height: 56px; border-radius: 18px; font-size: 26px; }
.topbar-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.account { display: flex; align-items: center; gap: 8px; }
.account-name { font-size: 13px; color: rgba(255, 255, 255, 0.9); }
.avatar {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: var(--white); font-size: 13px;
}
.org-switch { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.org-switch label { color: rgba(255, 255, 255, 0.7); }
.org-switch select {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
}
.inline-form { display: inline; margin: 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 0; min-height: calc(100vh - 62px); }
.sidebar {
  background: var(--white);
  border-inline-end: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
}
.nav-item:hover { background: var(--brand-50); text-decoration: none; }
.nav-item.is-active { background: var(--brand); color: var(--white); }
.nav-item.is-locked { color: var(--muted); background: transparent; cursor: not-allowed; }
.nav-icon { width: 18px; text-align: center; opacity: 0.85; }
.nav-lock {
  margin-inline-start: auto;
  font-size: 10px;
  background: var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
}
.sidebar-note {
  background: var(--brand-50);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
}
.sidebar-note strong { display: block; margin-bottom: 6px; color: var(--brand); }
.sidebar-note p { margin: 0; }
.content { min-width: 0; padding: 26px 32px 60px; max-width: 1240px; }

/* ---------- page ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; color: var(--brand); }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; color: var(--brand); }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.card.notice ul { margin: 0; padding-inline-start: 20px; color: var(--muted); font-size: 13px; }
.card.notice li { margin-bottom: 6px; }

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid .card { margin-bottom: 0; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 30px; font-weight: 800; color: var(--brand); line-height: 1.2; }
.stat-value.sm { font-size: 18px; }
.stat-meta { font-size: 12px; color: var(--muted); }

.quick-links { display: grid; gap: 10px; }
.quick {
  display: flex; flex-direction: column;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}
.quick span { font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.quick:hover { border-color: var(--brand); background: var(--brand-50); text-decoration: none; }

/* ---------- table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--brand-50); color: var(--brand); font-weight: 700; font-size: 12px; }
.table tr:last-child td { border-bottom: none; }
.table.compact th, .table.compact td { padding: 8px 10px; }
.table select { font-family: inherit; font-size: 12px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- pills ---------- */
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-pending { background: var(--warn-bg); color: var(--warn); }
.pill-muted { background: #eeeaf5; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--brand); color: var(--white); }
.btn-primary::before { content: "▸"; color: var(--white); font-size: 13px; }
.btn-primary:hover { background: var(--brand-700); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn-ghost:hover { background: var(--brand-50); text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 10px; }
.btn-block { width: 100%; }
.topbar .btn-ghost { color: var(--white); border-color: rgba(255, 255, 255, 0.35); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------- forms ---------- */
.form-card { max-width: 720px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text); }
.field input, .field select {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(53, 32, 112, 0.12);
}
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.hint { font-size: 11px; color: var(--muted); }
.error { font-size: 11px; color: var(--danger); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.inline-add { display: flex; flex-direction: column; gap: 12px; }
.inline-add-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

/* ---------- alerts ---------- */
.alert { border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- catalog ---------- */
.cat-block { margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--brand-50);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
}
.chip small { color: var(--muted); font-size: 10px; }
.chip em { font-style: normal; color: var(--brand); font-weight: 700; margin-inline-start: 4px; }

/* ---------- auth ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; background: linear-gradient(160deg, var(--brand) 0%, #241551 60%, #1b0f3f 100%); }
.auth-card { width: 100%; max-width: 420px; background: var(--white); border-radius: 22px; padding: 30px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28); }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head h1 { margin: 14px 0 4px; font-size: 20px; color: var(--brand); }
.auth-head p { margin: 0; font-size: 13px; color: var(--muted); }
.auth-head .brand-mark { margin: 0 auto; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

.state-card { text-align: center; max-width: 480px; margin: 80px auto; }
.state-card h1 { font-size: 40px; color: var(--brand); margin: 0 0 8px; }
.muted { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-inline-end: none; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-note { display: none; }
  .content { padding: 18px 16px 48px; }
  .grid-2, .inline-add-fields { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .stat-value { font-size: 24px; }
}

/* ---------- listing and lot management ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.field textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--text);
  resize: vertical;
}
.listing-form { display: grid; gap: 16px; }
.listing-tabs, .pagination { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.listing-tabs a { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); }
.listing-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.listing-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.listing-card h2 { margin: 8px 0; color: var(--brand); font-size: 18px; }
.listing-card h2 a { color: inherit; }
.listing-card-head, .listing-results-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.listing-type { font-weight: 700; color: var(--brand); }
.listing-code { display: block; color: var(--muted); font-size: 12px; margin: 4px 0; }
.listing-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; margin: 12px 0; }
.listing-facts div { min-width: 0; }
.listing-facts dt { color: var(--muted); font-size: 11px; }
.listing-facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.listing-publisher, .listing-date { color: var(--muted); font-size: 12px; }
.listing-results-head { margin: 12px 0; color: var(--muted); }
.spec-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.table-scroll { overflow-x: auto; }
.catalog-evidence-source, .catalog-grade-assessment { max-width: 420px; }
.catalog-evidence-source summary, .catalog-grade-assessment summary { cursor: pointer; white-space: normal; }
.catalog-evidence-source > div, .catalog-grade-assessment small { display: block; max-width: 42vw; white-space: normal; overflow-wrap: anywhere; }
.catalog-evidence-url { display: block; white-space: normal; overflow-wrap: anywhere; }
.empty-state { grid-column: 1 / -1; color: var(--muted); text-align: center; }
.alert-pending { background: var(--warn-bg); color: var(--warn); }
.pagination { justify-content: center; margin-top: 18px; }
@media (max-width: 700px) {
  .form-grid, .listing-grid, .listing-facts, .spec-row { grid-template-columns: 1fr; }
  .listing-card { padding: 14px; }
  .listing-tabs { overflow-x: auto; flex-wrap: nowrap; }
}
