:root {
  --bg-0: #07131f;
  --bg-1: #0c1f33;
  --bg-2: #123048;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --line: rgba(168, 214, 214, 0.18);
  --text: #eef7f7;
  --muted: #9db6c4;
  --accent: #1fb8a6;
  --accent-2: #f0b429;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --warn: #ffb020;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --font: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  --fab-space: 96px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 90% -10%, rgba(31, 184, 166, 0.22), transparent 55%),
    radial-gradient(900px 500px at 0% 100%, rgba(240, 180, 41, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
  background-attachment: scroll;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; max-width: 100%; }
.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  width: 100%;
  max-width: 100%;
}
.auth-visual {
  position: relative;
  overflow: hidden;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background:
    linear-gradient(180deg, rgba(7, 19, 31, 0.15), rgba(7, 19, 31, 0.82)),
    url("/static/img/hero-pattern.svg") center/cover;
}
.auth-visual::after {
  content: "";
  position: absolute;
  inset: auto -20% -30% auto;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31,184,166,.35), transparent 70%);
  animation: float 8s ease-in-out infinite;
}
.brand-mark {
  font-size: clamp(2.6rem, 5vw, 4.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}
.brand-mark span { color: var(--accent); }
.auth-visual p {
  max-width: 36ch;
  color: var(--muted);
  line-height: 1.9;
  margin: 0;
  position: relative;
  z-index: 1;
}
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: rise 0.7s ease both;
}
.auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.55rem;
}
.auth-card .sub {
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.8;
  font-size: 0.95rem;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(31,184,166,.7);
  box-shadow: 0 0 0 4px rgba(31,184,166,.15);
}
.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  cursor: pointer;
  background: linear-gradient(135deg, #1fb8a6, #149485);
  color: #04221e;
  font-weight: 700;
  transition: transform .15s ease, filter .15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-block { width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-accent {
  background: linear-gradient(135deg, #f0b429, #d89a12);
  color: #2a1d00;
}
.btn-danger {
  background: rgba(255,107,107,.18);
  color: #ffd4d4;
  border: 1px solid rgba(255,107,107,.35);
}
.btn-sm {
  padding: 7px 12px;
  border-radius: 10px;
  font-size: .82rem;
}
.error-box {
  background: rgba(255,107,107,.12);
  border: 1px solid rgba(255,107,107,.35);
  color: #ffd4d4;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: .9rem;
}
.hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.8;
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
}
.sidebar {
  border-left: 1px solid var(--line);
  background: rgba(7, 19, 31, 0.72);
  backdrop-filter: blur(18px);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.side-brand {
  font-size: 1.45rem;
  font-weight: 800;
  padding: 8px 10px;
}
.side-brand span { color: var(--accent); }
.nav-list { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: .2s ease;
}
.nav-item.active, .nav-item:hover {
  background: var(--panel-strong);
  color: var(--text);
  border-color: var(--line);
}
.side-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.7;
}
.main {
  padding: 22px;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow-x: hidden;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  min-width: 0;
}
.topbar h2 { margin: 0; font-size: 1.35rem; }
.topbar .meta { color: var(--muted); font-size: .9rem; word-break: break-word; }
.period-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.chip.active {
  color: #04221e;
  background: var(--accent);
  border-color: transparent;
  font-weight: 700;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  min-width: 0;
  animation: rise .55s ease both;
}
.card .label { color: var(--muted); font-size: .88rem; margin-bottom: 8px; }
.card .value {
  font-size: clamp(0.95rem, 2.8vw, 1.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.card .delta { margin-top: 8px; font-size: .82rem; color: var(--ok); }
.card .delta.down { color: var(--danger); }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
  min-width: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.panel h3 {
  margin: 0 0 14px;
  font-size: 1rem;
}
.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 280px;
  min-width: 0;
  overflow: hidden;
}
.chart-wrap.doughnut {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
}
.chart-wrap canvas {
  max-width: 100% !important;
  width: 100% !important;
  height: 100% !important;
}
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}
th, td {
  text-align: right;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: .9rem;
  white-space: nowrap;
}
th:first-child, td:first-child {
  position: sticky;
  right: 0;
  background: rgba(12, 31, 51, 0.96);
  z-index: 1;
}
th { color: var(--muted); font-weight: 600; }
.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}
.badge.income { background: rgba(61,220,151,.15); color: var(--ok); }
.badge.expense { background: rgba(255,107,107,.15); color: #ffb4b4; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.forecast-box {
  background: rgba(31,184,166,.08);
  border: 1px dashed rgba(31,184,166,.35);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  line-height: 1.9;
  color: #d9ecec;
}
.forecast-box strong { color: var(--accent); }
.forecast-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 10px 0 8px;
}
.forecast-metrics span { color: var(--muted); }
.forecast-metrics b { color: var(--text); font-weight: 700; }
.voice-box { display: grid; gap: 14px; }
.ai-box { display: grid; gap: 14px; }
.quota-pill {
  border: 1px solid var(--line);
  background: rgba(31,184,166,.12);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: .85rem;
  font-weight: 700;
}
.suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggest-chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: .85rem;
  transition: .15s ease;
}
.suggest-chip:hover {
  color: var(--text);
  border-color: rgba(31,184,166,.5);
}
.ai-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.ai-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
}
.ai-form input:focus {
  border-color: rgba(31,184,166,.7);
  box-shadow: 0 0 0 4px rgba(31,184,166,.15);
}
.chat-thread {
  display: grid;
  gap: 10px;
  max-height: min(55vh, 520px);
  overflow: auto;
  padding-left: 4px;
}
.chat-bubble {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}
.chat-bubble.user {
  background: rgba(31,184,166,.12);
  border-color: rgba(31,184,166,.28);
}
.chat-bubble.bot {
  background: rgba(0,0,0,.22);
}
.chat-bubble .who-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.chat-bubble .who {
  color: var(--muted);
  font-size: .8rem;
}
.chat-bubble .when {
  color: var(--muted);
  font-size: .75rem;
  white-space: nowrap;
  opacity: .9;
}
.report-dates {
  margin: -4px 0 12px;
  font-weight: 600;
}
@media (max-width: 860px) {
  .ai-form { grid-template-columns: 1fr; }
}
.voice-script {
  background: rgba(0,0,0,.22);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  line-height: 2;
  color: #d9ecec;
  text-align: justify;
  text-justify: inter-word;
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.mobile-toggle {
  display: none;
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 40;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #04221e;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 25;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.modal {
  width: min(520px, 100%);
  background: #0c1f33;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  max-height: min(90vh, 720px);
  overflow-y: auto;
  margin: auto;
}
.modal h3 { margin: 0 0 12px; }
.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.mobile-cards { display: none; }
.mobile-card-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(0,0,0,.16);
}
.mobile-card-item .title { font-weight: 700; margin-bottom: 8px; }
.mobile-card-item .meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.7;
}
.mobile-card-item .meta b { color: var(--text); font-weight: 600; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  html, body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { min-height: 34vh; padding: 28px; }
  .app-layout {
    display: block;
    min-height: auto;
    width: 100%;
    max-width: 100%;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: min(82vw, 300px);
    height: 100%;
    max-height: 100dvh;
    transform: translateX(-110%);
    transition: transform .25s ease;
    z-index: 30;
    border-left: 0;
    border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .overlay.show { display: block; }
  .mobile-toggle { display: grid; place-items: center; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .main {
    padding: 14px 12px var(--fab-space);
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .topbar h2 { font-size: 1.15rem; }
  .panel { padding: 12px; }
  .panel h3 { font-size: .95rem; margin-bottom: 10px; }
  .chart-wrap {
    height: 220px;
  }
  .chart-wrap.doughnut {
    height: 260px;
    padding-inline: 4px;
  }
  .table-wrap {
    margin-inline: -2px;
  }
  table { min-width: 480px; }
  th, td { font-size: .82rem; padding: 8px 6px; }
  .desktop-only { display: none !important; }
  .mobile-cards { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

@media (max-width: 420px) {
  .main { padding: 12px 10px var(--fab-space); }
  .card .value { font-size: 1rem; }
  .chip { padding: 7px 11px; font-size: .85rem; }
  table { min-width: 420px; }
}

/* About + external brand link */
.side-ext-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: .88rem;
}
.side-ext-link:hover { text-decoration: underline; }
.about-panel h3 { margin-top: 0; }
.about-panel p {
  color: var(--muted);
  line-height: 2;
  margin: 0 0 12px;
}
.about-panel a { color: var(--accent); }
.about-lead { color: var(--text) !important; font-size: 1.02rem; }
.about-contacts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.about-card {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  min-width: 0;
}
.about-card .label {
  color: var(--muted);
  font-size: .8rem;
  margin-bottom: 6px;
}
.about-card a, .about-card span {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  word-break: break-word;
}
.about-card a:hover { color: var(--accent); }
.user-role {
  color: var(--accent);
  font-weight: 700;
  font-size: .82rem;
  margin-bottom: 4px;
}
.btn-nesfe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-2);
  color: #0c1f33 !important;
  font-weight: 800;
  font-size: 1rem;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  text-decoration: none;
  letter-spacing: 0;
}
.btn-nesfe:hover {
  filter: brightness(1.05);
  color: #061018 !important;
}
@media (max-width: 720px) {
  .about-contacts { grid-template-columns: 1fr; }
}

.auth-foot {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.9;
}
.auth-foot a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

