@font-face {
  font-family: "Yekan";
  src: url("./fonts/Yekan.woff2") format("woff2"),
    url("./fonts/Yekan.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --blue: #23527c;
  --blue-deep: #1a4063;
  --blue-soft: #e7eef4;
  --ink: #1c2434;
  --muted: #8b95a8;
  --text: #526178;
  --line: #e5edf6;
  --bg: #f3f5f7;
  --card: #ffffff;
  --shadow: 0 18px 44px rgba(55, 78, 98, 0.1);
  --radius: 28px;
  font-family: "Yekan", Tahoma, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Yekan", Tahoma, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.page-app,
body.page-login {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 8% 0%, rgba(176, 192, 206, 0.45), transparent 32%),
    radial-gradient(circle at 96% 18%, rgba(150, 170, 188, 0.22), transparent 26%),
    radial-gradient(circle at 80% 100%, rgba(168, 184, 198, 0.28), transparent 34%),
    #f3f5f7;
}

body.page-app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-frame {
  width: min(1600px, calc(100% - 28px));
  height: calc(100vh - 28px);
  height: calc(100dvh - 28px);
  margin: 14px auto;
  display: flex;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.8);
  animation: frameIn 0.45s ease both;
  position: relative;
  z-index: 1;
}

@keyframes frameIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sidebar {
  width: 252px;
  flex: 0 0 252px;
  background: linear-gradient(180deg, #2c6394 0%, #23527c 58%, #1c466a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 14px 12px 14px;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin: 2px 6px 10px;
}

.brand img {
  width: 100%;
  max-height: 92px;
  object-fit: contain;
  background: #fff;
  border-radius: 16px;
  padding: 8px 10px 6px;
  box-shadow: 0 10px 22px rgba(12, 58, 140, 0.18);
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 99px;
}

.nav-label {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.62);
  padding: 12px 12px 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.94);
  text-decoration: none;
  text-align: start;
  font-size: 15.5px;
  line-height: 1.45;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease, transform 0.22s ease;
}

.nav-item i {
  width: 20px;
  font-size: 16px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.16); }

.nav-item.active {
  background: #fff;
  color: var(--blue-deep);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(10, 52, 130, 0.16);
}

.sidebar-user {
  margin-top: 10px;
  background: #fff;
  color: var(--ink);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 12px 26px rgba(9, 48, 120, 0.18);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar,
.avatar-sm {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  flex-shrink: 0;
}

.avatar-sm { width: 42px; height: 42px; font-size: 22px; }

.who strong { display: block; font-size: 15.5px; font-weight: 700; }
.who small { display: block; margin-top: 2px; color: var(--muted); font-size: 13.5px; }

.help-btn {
  width: 100%;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  background: #f3f6fb;
  color: #52627a;
  text-decoration: none;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.help-btn:hover { background: var(--blue-soft); color: var(--blue-deep); }

.workspace {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #f7f9fc;
}

.workspace-top {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 8px;
  background: #fff;
}

.icon-round.menu-toggle { display: none; }

.icon-round {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-size: 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.icon-round.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 16px rgba(35, 82, 124, 0.22);
}

.icon-round.primary:hover { transform: translateY(-2px); }

.icon-round.ghost {
  background: #fff;
  color: var(--blue);
  border: 1px solid var(--line);
}

.search-pill {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 4px 14px 4px 6px;
  background: #f4f7fb;
  border: 1px solid #e6edf5;
  border-radius: 999px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.search-pill:focus-within {
  background: #fff;
  border-color: #9ec4ff;
  box-shadow: 0 0 0 4px rgba(35, 82, 124, 0.16);
}

.search-pill > i { color: #98a2b3; font-size: 15px; }

.search-pill input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.search-pill input::placeholder { color: #a0aabe; }

.search-clear {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #98a2b3;
  cursor: pointer;
}

.search-clear:hover { background: #fff; color: #e11d48; }

.workspace-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 18px 28px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #d3e0f0 transparent;
}

.workspace-scroll::-webkit-scrollbar { width: 10px; }
.workspace-scroll::-webkit-scrollbar-thumb {
  background: #d3e0f0;
  border-radius: 99px;
  border: 2px solid #f7f9fc;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 2px 12px;
  margin-bottom: 4px;
  background: #f7f9fc;
}

.count-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
}

.count-label i { color: var(--blue); font-size: 20px; }

.count-sub {
  margin-top: 2px;
  padding-inline-start: 28px;
  color: var(--muted);
  font-size: 14px;
}

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

.pill-select,
.field-control {
  font-size: 15.5px;
  color: var(--ink);
  border: 1px solid var(--line);
  background-color: #fff;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.pill-select {
  appearance: none;
  min-height: 40px;
  padding: 8px 12px 8px 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b95a8' d='M1.2.8 6 5.6 10.8.8 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 10px center;
  cursor: pointer;
}

.field-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: #f6f8fb;
}

.pill-select:focus,
.field-control:focus {
  border-color: #8eb7ff;
  background-color: #fff;
  box-shadow: 0 0 0 4px rgba(35, 82, 124, 0.16);
}

.view-toggle {
  display: flex;
  padding: 3px;
  gap: 2px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.view-toggle button {
  width: 36px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #8b95a8;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.view-toggle button.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 10px rgba(35, 82, 124, 0.22);
}

.group + .group { margin-top: 22px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 2px 12px;
  font-size: 18px;
  font-weight: 700;
  animation: cardIn 0.4s ease both;
}

.group-title i { color: var(--blue); }

.people-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.person-card {
  position: relative;
  background: var(--card);
  border: 1px solid #e8eef6;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(23, 74, 163, 0.05);
  text-align: center;
  animation: cardIn 0.48s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (hover: hover) {
  .person-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 34px rgba(23, 92, 196, 0.12);
    border-color: #d5e4fb;
  }
}

.person-card.is-editing {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 82, 124, 0.2);
}

.person-banner {
  height: 64px;
  background: var(--blue);
}

.person-avatar {
  width: 78px;
  height: 78px;
  margin: -39px auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef3fa;
  color: var(--blue);
  border: 4px solid #fff;
  box-shadow: 0 6px 16px rgba(16, 62, 140, 0.16);
  font-size: 34px;
  position: relative;
  z-index: 1;
}

.person-name {
  margin: 0 12px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
}

.person-role {
  margin: 2px 12px 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.person-ext {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 14px 0;
  color: #23527c;
}

.person-ext span {
  font-family: Tahoma, "Yekan", sans-serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  direction: ltr;
  color: #23527c;
}

.person-ext i,
.meta i {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.person-ext i {
  width: 28px;
  height: 28px;
  font-size: 14px;
  color: #23527c;
}

.meta {
  list-style: none;
  margin: 12px 0 14px;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.meta li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 15.5px;
}

.meta i {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta .ltr {
  direction: ltr;
  text-align: right;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 12px 14px;
}

.act {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: #eef2f5;
  color: #3e5164;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.act:hover { background: var(--blue-soft); color: var(--blue); transform: translateY(-2px); }
.act.primary { background: var(--blue-soft); color: var(--blue); }
.act.danger:hover { background: #fde8ea; color: #e11d48; }
.act:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.directory.list-mode .people-grid { grid-template-columns: 1fr; }

.directory.list-mode .person-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: start;
  padding: 12px 14px 12px 16px;
}

.directory.list-mode .person-banner {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  height: auto;
}

.directory.list-mode .person-avatar {
  width: 58px;
  height: 58px;
  margin: 0;
  font-size: 28px;
  flex-shrink: 0;
}

.directory.list-mode .person-main {
  flex: 1;
  min-width: 0;
}

.directory.list-mode .person-name,
.directory.list-mode .person-role { margin-inline: 0; }

.directory.list-mode .person-ext {
  justify-content: flex-start;
  margin: 6px 0 0;
}

.directory.list-mode .person-ext span { font-size: 20px; }

.directory.list-mode .meta {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 8px 0 0;
  padding: 0;
}

.directory.list-mode .meta li { max-width: 100%; }
.directory.list-mode .meta li span { max-width: 220px; }

.directory.list-mode .actions {
  padding: 0;
  margin-inline-start: auto;
  flex-shrink: 0;
}

.sentinel {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 56px;
}

.dots { display: inline-flex; gap: 6px; align-items: center; }

.dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  animation: bounce 0.9s infinite ease-in-out;
}

.dots span:nth-child(2) { animation-delay: 0.12s; }
.dots span:nth-child(3) { animation-delay: 0.24s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.end-note {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  padding-bottom: 8px;
}

.boot-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 16px;
}

.empty-icon {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef3f9;
  color: #a8b4c4;
  font-size: 34px;
  margin-bottom: 12px;
}

.empty-state h3 { margin: 0 0 6px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 15.5px; }

.form-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin: 8px 0 14px;
  box-shadow: 0 8px 22px rgba(23, 74, 163, 0.05);
  animation: cardIn 0.45s ease both;
}

.form-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 18px;
}

.form-card h2 i { color: var(--blue); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field label { font-size: 15px; color: #52627a; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #2c6394 0%, #23527c 100%);
  color: #fff;
  box-shadow: 0 8px 16px rgba(35, 82, 124, 0.22);
}

.btn-primary:hover { transform: translateY(-1px); }

.btn-warning {
  background: linear-gradient(180deg, #23527c 0%, #1a4063 100%);
  color: #fff;
}

.btn-secondary { background: #eef2f7; color: #425066; }
.btn-secondary:hover { background: #e4ebf4; }
.btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.toast {
  position: fixed;
  z-index: 80;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1c2434;
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: min(420px, calc(100% - 32px));
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 35, 70, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 40;
}

.backdrop.show { opacity: 1; pointer-events: auto; }

.page-login { display: grid; place-items: center; padding: 24px 16px; }

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 28px;
  padding: 28px 26px 22px;
  box-shadow: var(--shadow);
  animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-logo {
  display: block;
  width: min(180px, 70%);
  margin: 0 auto 8px;
}

.login-title { margin: 0; text-align: center; font-size: 26px; }
.login-sub { margin: 6px 0 20px; text-align: center; color: var(--muted); font-size: 15.5px; }

.login-card .field { margin-bottom: 12px; }

.input-wrap { position: relative; }

.input-wrap > i {
  position: absolute;
  top: 50%;
  inset-inline-start: 12px;
  transform: translateY(-50%);
  color: #9aa5b5;
}

.input-wrap .field-control { padding-inline-start: 38px; padding-inline-end: 40px; }

.toggle-pass {
  position: absolute;
  top: 50%;
  inset-inline-end: 8px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #9aa5b5;
  cursor: pointer;
}

.login-card .btn { width: 100%; margin-top: 6px; }

.error-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fdecec;
  color: #c0392b;
  border: 1px solid #f5c6c6;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 14px;
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.back-link {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  color: var(--blue-deep);
  text-decoration: none;
  font-size: 15.5px;
}

.back-link:hover { text-decoration: underline; }

.spinner {
  width: 16px;
  height: 16px;
  display: inline-block;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.noscript {
  margin: 16px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 12px;
  text-align: center;
}

@media (min-width: 1680px) {
  .people-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .people-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  body.page-app { overflow: hidden; }

  .app-frame {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
    border: none;
    overflow: visible;
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(300px, 86vw);
    flex-basis: auto;
    height: 100dvh;
    transform: translateX(105%);
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: -16px 0 40px rgba(8, 30, 70, 0.22);
  }

  .sidebar.open { transform: translateX(0); }

  .icon-round.menu-toggle { display: grid; }

  .sidebar {
    overflow: hidden;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .workspace-top { padding: 12px 12px 6px; }
  .workspace-scroll { padding: 4px 12px 24px; }
}

@media (max-width: 720px) {
  .people-grid,
  .directory.list-mode .people-grid { grid-template-columns: 1fr; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-tools { width: 100%; }
  .pill-select { flex: 1; min-width: 0; }

  .directory.list-mode .person-card { flex-wrap: wrap; }
  .directory.list-mode .meta { display: grid; grid-template-columns: 1fr; }
  .directory.list-mode .actions {
    width: 100%;
    justify-content: flex-start;
    margin-inline-start: 0;
  }

  .form-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .count-label { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
