@font-face {
  font-family: IRANSans;
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("/fonts/IRANSansWeb(FaNum)_Light.woff2") format("woff2");
}

@font-face {
  font-family: IRANSans;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/IRANSansWeb(FaNum).woff2") format("woff2");
}

@font-face {
  font-family: IRANSans;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/IRANSansWeb(FaNum)_Medium.woff2") format("woff2");
}

@font-face {
  font-family: IRANSans;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/IRANSansWeb(FaNum)_Bold.woff2") format("woff2");
}

:root {
  --charcoal: #1a1a1a;
  --charcoal-mid: #2d2d2d;
  --teal: #006d6d;
  --teal-deep: #0a5c63;
  --teal-bright: #0e8a8a;
  --teal-mist: rgba(0, 109, 109, 0.14);
  --cream: #f5f3e7;
  --cream-deep: #e8e4d9;
  --panel-glass: rgba(232, 236, 234, 0.72);
  --panel-edge: rgba(26, 26, 26, 0.08);
  --text: #1a1a1a;
  --text-muted: #5c6366;
  --danger: #b42318;
  --rail-w: 4.25rem;
  --panel-w: min(22rem, 38vw);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font-family: IRANSans, "Segoe UI", Tahoma, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.55;
  background: var(--cream);
}

button,
input,
select {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Login —— */
.login {
  display: none;
  min-height: 100dvh;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 70% 55% at 18% 42%, rgba(14, 138, 138, 0.28), transparent 62%),
    radial-gradient(ellipse 55% 50% at 88% 18%, rgba(0, 109, 109, 0.16), transparent 55%),
    linear-gradient(125deg, var(--cream) 0%, var(--cream-deep) 48%, #d9e4e2 100%);
}

.login.is-open {
  display: grid;
}

.login__card {
  width: min(100%, 22rem);
  padding: 2rem 1.5rem 1.75rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--panel-edge);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login__title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--charcoal);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field__label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--teal-deep);
}

.field__input {
  min-height: 3rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--panel-edge);
  background: #fff;
  color: var(--text);
  border-radius: 0;
}

.field__input:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.field--apps {
  border: none;
  margin: 0;
  padding: 0;
}

.field__hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.check-grid {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.5rem;
}

.btn {
  min-height: 3rem;
  padding: 0.65rem 1.1rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

.btn--primary {
  background: var(--teal);
  color: #fff;
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--teal-deep);
  outline: none;
}

.btn--ghost {
  background: transparent;
  color: var(--charcoal);
  border: 1px solid var(--panel-edge);
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  background: rgba(255, 255, 255, 0.55);
  outline: none;
}

.btn--danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.35);
  margin-inline-start: auto;
}

.btn--danger:hover,
.btn--danger:focus-visible {
  background: rgba(180, 35, 24, 0.08);
  outline: none;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.form-ok {
  margin: 0;
  color: var(--teal-deep);
  font-size: 0.9rem;
}

/* Physical LTR shell (rail | panel | stage); copy stays RTL */
.shell {
  display: none;
  grid-template-columns: var(--rail-w) var(--panel-w) minmax(0, 1fr);
  grid-template-areas: "rail panel stage";
  min-height: 100dvh;
  direction: ltr;
  transition: grid-template-columns 280ms var(--ease);
}

.shell.is-open {
  display: grid;
}

.shell.is-panel-collapsed {
  grid-template-columns: var(--rail-w) 0 minmax(0, 1fr);
}

.icon-rail,
.panel,
.stage {
  direction: rtl;
}

/* —— Icon rail —— */
.icon-rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 1.15rem 0.55rem;
  background: var(--charcoal);
  z-index: 3;
}

.icon-rail__top,
.icon-rail__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.icon-rail__item {
  width: 2.85rem;
  height: 2.85rem;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 0;
  padding: 0;
  transition:
    color 160ms var(--ease),
    background 160ms var(--ease);
}

.icon-rail__item svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-rail__item.is-active {
  background: var(--teal);
  color: #fff;
}

.icon-rail__item:not(.is-active):hover,
.icon-rail__item:not(.is-active):focus-visible {
  color: #fff;
  background: var(--charcoal-mid);
  outline: none;
}

.icon-rail__avatar .icon-rail__initials {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: inherit;
}

/* —— Frosted secondary panel —— */
.panel {
  grid-area: panel;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.35rem 1.75rem;
  background:
    linear-gradient(180deg, rgba(245, 243, 231, 0.35), rgba(0, 109, 109, 0.06)),
    var(--panel-glass);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border-inline-end: 1px solid var(--panel-edge);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.35);
  z-index: 2;
  overflow: hidden;
  min-width: 0;
  animation: panel-in 700ms var(--ease) both;
}

.shell.is-panel-collapsed .panel {
  padding: 0;
  border: none;
  box-shadow: none;
  animation: none;
  pointer-events: none;
}

.panel__collapse {
  position: absolute;
  inset-block-start: 1rem;
  inset-inline-start: 0.35rem;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 1;
}

.panel__collapse:hover,
.panel__collapse:focus-visible {
  color: var(--charcoal);
  background: rgba(255, 255, 255, 0.45);
  outline: none;
}

.panel__collapse svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel__body {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.panel__head {
  margin-bottom: 1.75rem;
  padding-inline: 0.35rem 2rem;
}

.panel__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--teal-deep);
}

.panel__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--charcoal);
  letter-spacing: -0.02em;
}

.panel__username {
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--charcoal);
}

.panel__block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-inline: 0.35rem;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-block: 1px solid var(--panel-edge);
}

.panel__list > li + li {
  border-top: 1px solid var(--panel-edge);
}

.panel__link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  min-height: 4.5rem;
  padding: 1rem 0.35rem;
  color: inherit;
  text-decoration: none;
  text-align: start;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 160ms var(--ease);
}

.panel__link:hover,
.panel__link:focus-visible,
.panel__link.is-active {
  background: rgba(255, 255, 255, 0.45);
  outline: none;
}

.panel__icon {
  width: 2.65rem;
  height: 2.65rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  flex-shrink: 0;
}

.panel__icon svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel__copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.panel__name {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--charcoal);
}

.panel__desc {
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.45;
}

/* —— Brand stage —— */
.stage {
  grid-area: stage;
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-start;
  justify-content: stretch;
  padding: clamp(2rem, 5vw, 3.5rem);
  overflow: auto;
  background: var(--cream);
  z-index: 1;
}

.stage__wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 18% 42%, rgba(14, 138, 138, 0.28), transparent 62%),
    radial-gradient(ellipse 55% 50% at 88% 18%, rgba(0, 109, 109, 0.16), transparent 55%),
    linear-gradient(125deg, var(--cream) 0%, var(--cream-deep) 48%, #d9e4e2 100%);
  z-index: -1;
}

.stage__wash::after {
  content: "";
  position: absolute;
  inset-inline-start: -8%;
  inset-block-end: -12%;
  width: min(52vw, 28rem);
  height: min(52vw, 28rem);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 109, 109, 0.2), transparent 68%);
  filter: blur(2px);
  animation: wash-drift 12s var(--ease) infinite alternate;
}

.stage__inner {
  width: min(100%, 44rem);
  animation: rise 720ms var(--ease) both;
  animation-delay: 60ms;
}

.brand {
  margin: 0 0 1.5rem;
  font-size: clamp(2.75rem, 8vw, 4.25rem);
  font-weight: 300;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--charcoal);
}

.brand--compact {
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}

.app-card-wrap {
  position: relative;
  animation: rise 640ms var(--ease) both;
}

.app-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: center;
  min-height: 5.25rem;
  padding: 1.1rem 1rem;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--panel-edge);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    background 160ms var(--ease),
    transform 160ms var(--ease),
    box-shadow 160ms var(--ease);
}

.app-card-wrap:hover .app-card,
.app-card:hover,
.app-card:focus-visible {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 10px 28px rgba(26, 26, 26, 0.08);
  outline: none;
}

.app-card__remove {
  position: absolute;
  inset-block-start: 0.35rem;
  inset-inline-end: 0.35rem;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--danger);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 160ms var(--ease),
    background 160ms var(--ease);
  z-index: 1;
}

.app-card-wrap:hover .app-card__remove,
.app-card__remove:focus-visible {
  opacity: 1;
  outline: none;
}

.app-card__remove:hover,
.app-card__remove:focus-visible {
  background: rgba(180, 35, 24, 0.12);
}

.app-card__icon {
  width: 2.85rem;
  height: 2.85rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
}

.app-card__icon svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-card__copy {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.app-card__name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--charcoal);
}

.app-card__desc {
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.45;
}

.empty-hint {
  margin: 0;
  color: var(--text-muted);
  font-weight: 300;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.admin-head .brand {
  margin-bottom: 0;
}

.user-list {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.45);
}

.user-row + .user-row {
  border-top: 1px solid var(--panel-edge);
}

.user-row__btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-height: 3.5rem;
  padding: 0.85rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: start;
  color: inherit;
}

.user-row__btn:hover,
.user-row__btn:focus-visible {
  background: rgba(255, 255, 255, 0.65);
  outline: none;
}

.user-row__name {
  font-weight: 700;
  color: var(--charcoal);
}

.user-row__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.user-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.25rem 1rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--panel-edge);
}

.user-form__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.user-form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.7rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateX(-0.75rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes wash-drift {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(6%, -4%) scale(1.06);
  }
}

.fab {
  position: fixed;
  /* Physical right: shell rail is always on the left; avoid RTL mirroring over it */
  right: 1.25rem;
  left: auto;
  bottom: 1.25rem;
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 109, 109, 0.35);
  z-index: 20;
  transition:
    background 160ms var(--ease),
    transform 160ms var(--ease),
    box-shadow 160ms var(--ease);
}

.fab[hidden] {
  display: none;
}

.fab svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.fab:hover,
.fab:focus-visible {
  background: var(--teal-deep);
  transform: scale(1.04);
  box-shadow: 0 14px 32px rgba(0, 109, 109, 0.42);
  outline: none;
}

.app-dialog {
  width: min(100% - 2rem, 22rem);
  padding: 0;
  border: 1px solid var(--panel-edge);
  background: transparent;
  color: inherit;
}

.app-dialog::backdrop {
  background: rgba(26, 26, 26, 0.45);
  backdrop-filter: blur(4px);
}

.app-dialog .user-form {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .stage__inner,
  .app-card-wrap,
  .stage__wash::after {
    animation: none;
  }

  .shell,
  .fab {
    transition: none;
  }
}

/* —— Mobile: stack —— */
@media (max-width: 52rem) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto auto;
    grid-template-areas:
      "stage"
      "panel"
      "rail";
  }

  .shell.is-panel-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "stage"
      "rail";
  }

  .shell.is-panel-collapsed .panel {
    display: none;
  }

  .fab {
    right: 1rem;
    left: auto;
    bottom: calc(4.75rem + env(safe-area-inset-bottom));
  }

  .app-card__remove {
    opacity: 1;
  }

  .icon-rail {
    flex-direction: row;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
  }

  .icon-rail__top,
  .icon-rail__bottom {
    flex-direction: row;
  }

  .panel {
    border-inline-end: none;
    border-block-start: 1px solid var(--panel-edge);
    padding-block: 1.5rem 1.25rem;
    max-height: 42dvh;
    animation: rise 640ms var(--ease) both;
  }

  .panel__collapse {
    inset-inline-start: auto;
    inset-inline-end: 0.5rem;
  }

  .panel__collapse svg {
    transform: rotate(-90deg);
  }

  .stage {
    min-height: 42dvh;
    padding: 2rem 1.25rem 1.5rem;
  }

  .brand {
    font-size: clamp(2.4rem, 12vw, 3.25rem);
  }

  .brand--compact {
    font-size: clamp(1.45rem, 6vw, 1.85rem);
  }
}

@media (min-width: 72rem) {
  :root {
    --rail-w: 4.75rem;
    --panel-w: 24rem;
  }

  .panel {
    padding-inline: 1.75rem;
  }
}
