@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-VariableFont_wght.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary: #004151;
  --dark: #002028;
  --bg: #001A20;
  --panel: #002832;
  --panel-2: #00323d;
  --line: #174B57;
  --text: #D7E6E8;
  --muted: #9DBFC4;
  --accent: #B7D7DB;
  --danger: #F08989;
  --warning: #F3CA7A;
  --success: #8DDFA9;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { direction: rtl; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.8;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #fff; }

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--dark);
  border-left: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--primary);
  display: grid;
  place-items: center;
  color: var(--text);
  font-weight: 700;
}

.brand strong { display: block; font-size: 15px; }
.brand span { color: var(--muted); font-size: 12px; }

.nav-group-title {
  color: var(--muted);
  font-size: 12px;
  margin: 18px 10px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 6px;
  margin: 2px 0;
}

.nav-link:hover,
.nav-link.active {
  background: var(--primary);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 18px 24px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.userbox {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  margin: 0 0 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat-card,
.item-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card span {
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

.stat-card strong {
  font-size: 25px;
  display: block;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
  width: 100%;
}

label { color: var(--muted); display: block; font-size: 13px; margin-bottom: 5px; }

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #001f27;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  min-height: 42px;
}

textarea { min-height: 112px; resize: vertical; }
input[type="checkbox"] { width: auto; min-height: auto; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text);
}

.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: var(--dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.btn:hover { color: var(--dark); filter: brightness(1.06); }
.btn.secondary { background: transparent; border-color: var(--line); color: var(--text); }
.btn.danger { background: transparent; border-color: #7a2e35; color: #ffd4d8; }
.btn.small { min-height: 32px; padding: 5px 9px; font-size: 12px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.compact-table table { min-width: 560px; }

th,
td {
  padding: 12px 13px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 400;
  background: #00232b;
}

tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.badge-success { color: var(--success); border-color: rgba(141,223,169,.4); background: rgba(141,223,169,.08); }
.badge-warning { color: var(--warning); border-color: rgba(243,202,122,.4); background: rgba(243,202,122,.08); }
.badge-danger { color: var(--danger); border-color: rgba(240,137,137,.4); background: rgba(240,137,137,.08); }
.badge-neutral { color: var(--muted); }

.flash {
  border-radius: 6px;
  padding: 11px 13px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

.flash.success { color: var(--success); background: rgba(141,223,169,.08); border-color: rgba(141,223,169,.35); }
.flash.error { color: var(--danger); background: rgba(240,137,137,.08); border-color: rgba(240,137,137,.35); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.detail-item {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.detail-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.detail-item strong {
  font-weight: 400;
  white-space: pre-wrap;
}

.reply {
  border: 1px solid var(--line);
  background: #00232b;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.reply.internal {
  border-color: rgba(243,202,122,.5);
  background: rgba(243,202,122,.08);
}

.muted { color: var(--muted); }
.ltr { direction: ltr; text-align: left; }
.mt { margin-top: 14px; }

.code-box {
  background: #001f27;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  margin: 0;
  max-height: 520px;
  overflow: auto;
  padding: 13px;
  white-space: pre-wrap;
}

.ordered-help {
  margin: 0;
  padding: 0 22px 0 0;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
  max-width: 100%;
  flex-wrap: wrap;
}

.mobile-toggle { display: none; }

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .main { padding: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .userbox { align-items: stretch; flex-direction: column; width: 100%; }
  .grid.cards,
  .grid.two,
  .grid.three,
  .detail-list,
  .filters { grid-template-columns: 1fr; }
  .actions,
  .toolbar { align-items: stretch; flex-direction: column; }
  .pagination { align-items: stretch; }
  .btn { width: 100%; }
  table { min-width: 620px; }
  .compact-table table { min-width: 520px; }
}
