:root {
  --bg: #e8edf2;
  --bg-accent: #dfe7ee;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --surface-3: #eef3f7;
  --ink: #102033;
  --ink-soft: #243447;
  --muted: #5f7185;
  --line: #d7e0ea;
  --line-soft: #e8eef4;
  --brand: #0d7377;
  --brand-dark: #095456;
  --brand-soft: rgba(13, 115, 119, 0.12);
  --accent: #1d4e89;
  --accent-soft: rgba(29, 78, 137, 0.1);
  --wa: #128c7e;
  --danger: #c0392b;
  --ok: #1f7a4d;
  --warn: #b7791f;
  --sidebar: #0c1624;
  --sidebar-2: #132033;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 51, 0.04), 0 10px 28px rgba(16, 32, 51, 0.05);
  --shadow-lg: 0 8px 30px rgba(16, 32, 51, 0.08);
  --font: "Estedad", "Vazirmatn", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(13, 115, 119, 0.08), transparent 50%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(29, 78, 137, 0.06), transparent 45%),
    linear-gradient(180deg, #eef3f7 0%, var(--bg) 40%, #e4ebf2 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(16, 32, 51, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 32, 51, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.45), transparent 85%);
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84em;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ——— Sidebar ——— */
.sidebar {
  background:
    radial-gradient(circle at 20% 0%, rgba(18, 140, 126, 0.22), transparent 42%),
    radial-gradient(circle at 90% 80%, rgba(29, 78, 137, 0.18), transparent 40%),
    linear-gradient(175deg, var(--sidebar-2), var(--sidebar));
  color: #b7c4d4;
  padding: 20px 14px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-left: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  margin-bottom: 16px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #1aa39a, #0d7377 55%, #0a5c5f);
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.04em;
  box-shadow: 0 12px 28px rgba(13, 115, 119, 0.35);
}

.brand {
  margin: 0;
  color: #f4f8fb;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin: 3px 0 0;
  color: #8494a8;
  font-size: 0.74rem;
  font-weight: 500;
}

.nav { flex: 1; }

.nav-group { margin: 0 0 18px; }

.nav-label {
  display: block;
  padding: 0 12px 8px;
  color: #6b7c90;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 3px;
  color: #c5d0dc;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav a .ico {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav a .ico svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav a:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
  transform: translateX(-2px);
}

.nav a.active {
  background: linear-gradient(90deg, rgba(26, 163, 154, 0.22), rgba(26, 163, 154, 0.08));
  color: #7ee0d6;
  box-shadow: inset 3px 0 0 #1aa39a;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.sidebar-foot .btn {
  width: 100%;
  background: rgba(255,255,255,0.04);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-foot .btn:hover {
  background: rgba(255,255,255,0.08);
}

/* ——— Main ——— */
.content {
  padding: 28px 34px 48px;
  max-width: 1440px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(215, 224, 234, 0.8);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.topbar .sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 640px;
  line-height: 1.55;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.user-chip .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1aa39a, #0d7377);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ——— Panels / Cards ——— */
.panel,
.card {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-hd,
.card-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fff, var(--surface-2));
}

.panel-hd h3,
.card-hd h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.panel-hd .muted,
.panel-hd .hint-line {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.panel-bd,
.card-bd { padding: 20px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .title-block h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 750;
}

.filter-bar {
  display: grid;
  gap: 12px;
  grid-template-columns: 1.4fr auto;
  align-items: end;
}

.filter-bar.wide {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* ——— Stats ——— */
.stats {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.stat {
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, #fff 0%, #f7fafc 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand);
}

.stat.danger::before { background: var(--danger); }
.stat.warn::before { background: var(--warn); }
.stat.info::before { background: var(--accent); }

.stat .label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.stat .value {
  margin-top: 8px;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.045em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat .hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.meter {
  margin-top: 12px;
  height: 6px;
  border-radius: 999px;
  background: #e4ebf2;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #1d4e89);
  min-width: 0;
  transition: width 0.28s ease;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: linear-gradient(180deg, #129399, var(--brand));
  color: #fff;
  cursor: pointer;
  font-weight: 650;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 6px 14px rgba(13, 115, 119, 0.22);
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn.secondary {
  background: linear-gradient(180deg, #3d4f63, #2a3a4c);
  box-shadow: 0 6px 14px rgba(16, 32, 51, 0.18);
}

.btn.danger {
  background: linear-gradient(180deg, #d45245, var(--danger));
  box-shadow: 0 6px 14px rgba(192, 57, 43, 0.2);
}

.btn.ghost {
  background: #fff;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.ghost:hover { background: var(--surface-2); }

.btn.wa {
  background: linear-gradient(180deg, #1aaa9b, var(--wa));
  box-shadow: 0 6px 14px rgba(18, 140, 126, 0.25);
}

.btn.sm { padding: 7px 11px; font-size: 0.8rem; border-radius: 8px; }

/* ——— Tables ——— */
.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: right;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

th {
  background: var(--surface-2);
  color: #4a5d73;
  font-size: 0.74rem;
  font-weight: 750;
  white-space: nowrap;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover { background: rgba(13, 115, 119, 0.035); }

td.phone, .ltr { direction: ltr; text-align: left; unicode-bidi: plaintext; }

.row-title {
  font-weight: 700;
  color: var(--ink);
}

.row-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

/* ——— Badges ——— */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #e8eef4;
  color: #334155;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.ok { background: #e4f6ec; color: #145c38; border-color: #c6ead4; }
.badge.warn { background: #fff6e5; color: #8a5a12; border-color: #f5dfb3; }
.badge.err { background: #fdeceb; color: #8f2a22; border-color: #f5c4bf; }
.badge.info { background: #e8f0fa; color: #1a3f6d; border-color: #c5d7ee; }
.badge.wa { background: #e4f6f2; color: #0b5c52; border-color: #bfe8df; }

/* ——— Forms ——— */
.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-panel {
  max-width: 920px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 650;
  color: #334155;
}

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1aa39a;
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.15);
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.checks label {
  flex-direction: row;
  align-items: center;
  font-weight: 500;
}

/* ——— Alerts / misc ——— */
.alert {
  padding: 13px 15px;
  border-radius: 12px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  font-size: 0.9rem;
}

.alert.success { background: #ecf8f1; color: #145c38; border-color: #bfe8cf; }
.alert.error { background: #fdf1f0; color: #8f2a22; border-color: #f0c4bf; }
.alert.warn {
  background: #fff8eb;
  color: #8a5a12;
  border-color: #f5dfb3;
}

.muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.split {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.35fr 1fr;
}

.split-3 {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.qr {
  width: 260px;
  max-width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
  box-shadow: var(--shadow);
}

/* ——— Account cards ——— */
.account-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.account-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(165deg, #fff, #f6f9fb);
  box-shadow: var(--shadow);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.account-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.account-card .head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.account-card h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
}

.account-card .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 14px;
}

/* ——— Timeline / empty ——— */
.timeline-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.timeline-item:last-child { border-bottom: 0; }

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
}

.empty-state .icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
}

.empty-state h4 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  color: var(--ink);
}

.empty-state p {
  margin: 0 auto;
  max-width: 360px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ——— Steps / info list ——— */
.steps {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  line-height: 1.95;
}

.steps li { margin-bottom: 6px; }
.steps strong { color: var(--ink-soft); }

.flow-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.flow-card {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.flow-card .kicker {
  font-size: 0.72rem;
  font-weight: 750;
  color: var(--brand);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.flow-card h4 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.flow-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

/* ——— Pagination ——— */
.pagination {
  display: flex;
  gap: 6px;
  list-style: none;
  padding: 14px 18px;
  margin: 0;
  flex-wrap: wrap;
  border-top: 1px solid var(--line-soft);
}

.pagination .page-link {
  display: inline-block;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 600;
}

.pagination .active .page-link {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ——— Login ——— */
.login-page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  background: #0c1624;
}

.login-visual {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(155deg, rgba(12, 22, 36, 0.72), rgba(13, 115, 119, 0.55)),
    url('/images/login-bg.jpg') center/cover no-repeat;
  min-height: 100vh;
  padding: 48px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(26, 163, 154, 0.25), transparent 40%),
    linear-gradient(180deg, transparent 30%, rgba(8, 14, 24, 0.75));
  pointer-events: none;
}

.login-visual > div { position: relative; z-index: 1; }

.login-visual h2 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  max-width: 540px;
  line-height: 1.25;
}

.login-visual p {
  margin: 0;
  max-width: 480px;
  color: rgba(255,255,255,0.88);
  font-size: 1.02rem;
  line-height: 1.7;
}

.login-side {
  display: grid;
  place-items: center;
  padding: 36px;
  background:
    radial-gradient(circle at top left, rgba(13, 115, 119, 0.1), transparent 40%),
    linear-gradient(180deg, #f4f8fb, #eef3f7);
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

/* ——— Customer dossier ——— */
.dossier-head {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ——— Motion ——— */
@media (prefers-reduced-motion: no-preference) {
  .panel, .card, .stat, .account-card {
    animation: rise 0.45s ease both;
  }
  .stats .stat:nth-child(2) { animation-delay: 0.04s; }
  .stats .stat:nth-child(3) { animation-delay: 0.08s; }
  .stats .stat:nth-child(4) { animation-delay: 0.12s; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ——— Responsive ——— */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dossier-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-3 { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    height: auto;
    position: static;
    border-left: 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { min-height: 300px; padding: 32px; }
  .content { padding: 18px 16px 32px; }
  .topbar { flex-direction: column; }
  .dossier-head { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
}
