@font-face {
  font-family: "Vazirmatn UI FD";
  src: url("../fonts/Vazirmatn-UI-FD-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn UI FD";
  src: url("../fonts/Vazirmatn-UI-FD-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn UI FD";
  src: url("../fonts/Vazirmatn-UI-FD-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn UI FD";
  src: url("../fonts/Vazirmatn-UI-FD-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1a2a28;
  --ink-soft: #3d524e;
  --muted: #6a7f7a;
  --paper: #f3efe6;
  --paper-2: #ebe4d6;
  --sea: #0d6e6e;
  --sea-deep: #0a5555;
  --sea-soft: #d7ece9;
  --sand: #c4a574;
  --sand-bright: #e8c992;
  --danger: #a33b2d;
  --line: rgba(26, 42, 40, 0.12);
  --shadow: 0 18px 40px rgba(26, 42, 40, 0.08);
  --radius: 14px;
  --font: "Vazirmatn UI FD", "Tahoma", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(13, 110, 110, 0.18), transparent 55%),
    radial-gradient(900px 500px at -10% 100%, rgba(196, 165, 116, 0.22), transparent 50%),
    linear-gradient(165deg, #f7f3eb 0%, #ebe6da 45%, #e4efe9 100%);
  direction: rtl;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--sea);
}

.hidden {
  display: none !important;
}

/* —— Login —— */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 36px 32px 28px;
  background: rgba(255, 252, 246, 0.88);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-glyph {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:
    linear-gradient(145deg, var(--sea) 0%, var(--sea-deep) 100%);
  position: relative;
  overflow: hidden;
}

.brand-glyph::after {
  content: "";
  position: absolute;
  inset: 10px 8px auto auto;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  border-left-color: transparent;
  transform: rotate(-25deg);
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.brand-tag {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.15);
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.15s, opacity 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(160deg, var(--sea) 0%, var(--sea-deep) 100%);
  color: #f7fffe;
  width: 100%;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.5);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(163, 59, 45, 0.35);
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 0 0 10px;
}

/* —— App shell —— */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.side {
  padding: 22px 16px;
  border-left: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.72);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side .brand-mark {
  padding: 0 6px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  text-align: right;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 500;
}

.nav button:hover {
  background: var(--sea-soft);
  color: var(--sea-deep);
}

.nav button.active {
  background: var(--sea);
  color: #f4fffd;
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.main {
  padding: 22px 28px 40px;
  min-width: 0;
}

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

.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
}

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

.chip-select {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.9);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--ink);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  background: rgba(255, 252, 246, 0.82);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  animation: rise 0.45s ease both;
}

.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--sea), var(--sand));
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-value {
  margin: 6px 0 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-delta {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-delta.up { color: var(--sea-deep); }
.stat-delta.down { color: var(--danger); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

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

.panel {
  background: rgba(255, 252, 246, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  animation: rise 0.5s ease both;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}

.chart-wrap {
  height: 220px;
  position: relative;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  text-align: right;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}

.table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
}

.table tr:last-child td {
  border-bottom: none;
}

.bar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sea), var(--sand-bright));
  min-width: 4px;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 18px 4px;
}

.sites-list {
  display: grid;
  gap: 10px;
}

.site-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
}

.site-row h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.site-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.code-block {
  margin-top: 10px;
  background: #1a2a28;
  color: #d7ece9;
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 42, 40, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
  animation: fade 0.2s ease;
}

.modal {
  width: min(460px, 100%);
  background: #fffdf8;
  border-radius: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.25s ease;
}

.modal h2 {
  margin: 0 0 14px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  margin-top: 8px;
}

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

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .side {
    border-left: none;
    border-bottom: 1px solid var(--line);
  }
  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }
  .side-foot {
    margin-top: 0;
    grid-auto-flow: column;
    justify-content: start;
  }
  .stats-row,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}
