:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: rgba(14, 27, 46, .84);
  --surface-solid: #0e1b2e;
  --surface-light: #14253c;
  --line: rgba(148, 163, 184, .16);
  --text: #eef5ff;
  --muted: #91a4bb;
  --blue: #32a5ff;
  --cyan: #23d2d4;
  --violet: #a78bfa;
  --green: #38d996;
  --amber: #f7bb52;
  --red: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, .3);
  font-family: Vazirmatn, IRANSans, Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 75% -20%, #123d66 0, transparent 36%), radial-gradient(circle at 10% 100%, #1a234e 0, transparent 30%), var(--bg); }
body.modal-open { overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }
svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ambient { position: fixed; z-index: -1; width: 320px; height: 320px; border-radius: 50%; filter: blur(90px); opacity: .18; pointer-events: none; }
.ambient-one { top: -100px; right: 8%; background: var(--blue); }
.ambient-two { bottom: -160px; left: 5%; background: var(--violet); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(145deg, rgba(20, 38, 63, .96), rgba(9, 21, 38, .96)); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.brand-mark { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 24px; border-radius: 19px; color: #03111d; font-size: 31px; font-weight: 900; background: linear-gradient(135deg, #65d8ff, #30a5ff 52%, #8b8efc); box-shadow: 0 12px 32px rgba(50,165,255,.28); }
.brand-mark.small { width: 48px; height: 48px; margin: 0; border-radius: 15px; font-size: 24px; }
.eyebrow { color: #55c8ff; font-size: 12px; font-weight: 800; letter-spacing: .05em; }
.login-card h1 { margin: 9px 0 10px; font-size: clamp(27px, 7vw, 38px); }
.login-card > p { margin: 0 0 30px; color: var(--muted); line-height: 1.9; font-size: 14px; }
.login-card form { display: grid; gap: 10px; }
.login-card label { margin-top: 8px; color: #c8d7e8; font-size: 13px; font-weight: 700; }
.input-wrap { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(4, 13, 25, .55); transition: border-color .2s, box-shadow .2s; }
.input-wrap:focus-within { border-color: rgba(50, 165, 255, .72); box-shadow: 0 0 0 4px rgba(50,165,255,.09); }
.input-wrap svg { color: var(--muted); }
.input-wrap input { min-width: 0; flex: 1; direction: ltr; color: var(--text); border: 0; outline: 0; background: transparent; }
.icon-button { display: grid; place-items: center; padding: 7px; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.primary-button, .secondary-button, .ghost-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; border-radius: 12px; cursor: pointer; transition: transform .16s, opacity .16s, border-color .16s; }
.primary-button { min-height: 54px; margin-top: 12px; border: 0; color: #061321; font-weight: 900; background: linear-gradient(120deg, #53d6ed, #42a5ff 55%, #8b8cf8); box-shadow: 0 12px 30px rgba(50,165,255,.22); }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover { transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: .55; transform: none !important; }
.form-error { min-height: 20px; margin: 0; color: #ff8c9e; font-size: 12px; }
.secure-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 25px; color: var(--muted); font-size: 11px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }

.dashboard { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 30px; min-height: 82px; padding: 14px clamp(20px, 4vw, 64px); border-bottom: 1px solid var(--line); background: rgba(6, 16, 29, .82); backdrop-filter: blur(20px); }
.topbar-brand, .topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar h1 { margin: 4px 0 0; font-size: 18px; }
.topbar h1 span { padding: 0 4px; color: var(--muted); font-weight: 400; }
.last-update { display: grid; grid-template-columns: auto auto; column-gap: 8px; align-items: center; color: var(--muted); font-size: 10px; }
.last-update .status-dot { grid-row: span 2; }
.last-update strong { direction: ltr; color: #d6e2f0; font-size: 11px; font-weight: 500; }
.secondary-button, .ghost-button { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); background: rgba(20, 37, 60, .65); font-size: 12px; font-weight: 700; }
.ghost-button { color: #f3a5b1; background: transparent; }
.secondary-button svg, .ghost-button svg { width: 18px; }

.content { width: min(1540px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 70px; }
.source-alert { margin-bottom: 20px; padding: 14px 18px; border: 1px solid rgba(251,113,133,.25); border-radius: 14px; color: #ffc1ca; background: rgba(138, 28, 48, .18); font-size: 12px; line-height: 1.8; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(170px, 1fr)); gap: 14px; }
.stat-card { position: relative; display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 13px; min-height: 132px; padding: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 19px; background: linear-gradient(145deg, rgba(19, 36, 59, .88), rgba(11, 24, 42, .88)); box-shadow: 0 14px 35px rgba(0,0,0,.13); }
.stat-card::after { position: absolute; content: ''; right: 0; bottom: 0; width: 80px; height: 3px; background: var(--accent); box-shadow: 0 0 20px var(--accent); }
.stat-card .stat-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: var(--accent); font-size: 13px; font-weight: 900; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.stat-card span { display: block; color: var(--muted); font-size: 11px; }
.stat-card strong { display: block; direction: ltr; margin-top: 5px; text-align: right; font-size: 25px; }
.stat-card small { grid-column: 1 / -1; color: #637991; font-size: 10px; }
.accent-blue { --accent: var(--blue); }.accent-cyan { --accent: var(--cyan); }.accent-violet { --accent: var(--violet); }.accent-green { --accent: var(--green); }.accent-amber { --accent: var(--amber); }

.products-section { margin-top: 34px; }
.section-heading, .panel-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 15px; }
.section-heading h2, .panel-heading h2 { margin: 5px 0 0; font-size: 20px; }
.count-pill { padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; background: rgba(20,37,60,.5); }
.product-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 12px; padding-bottom: 8px; overflow-x: auto; scrollbar-color: #29425e transparent; }
.product-card { min-height: 116px; padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: rgba(14, 29, 49, .75); }
.product-card.color-blue { --card-color: #32a5ff; }
.product-card.color-cyan { --card-color: #23d2d4; }
.product-card.color-violet { --card-color: #a78bfa; }
.product-card.color-emerald { --card-color: #38d996; }
.product-card.color-amber { --card-color: #f7bb52; }
.product-card.color-orange { --card-color: #fb923c; }
.product-card.color-rose { --card-color: #fb7185; }
.product-card.color-indigo { --card-color: #818cf8; }
.product-card.color-slate { --card-color: #94a3b8; }
.product-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.product-logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--card-color); font-size: 10px; font-weight: 900; background: color-mix(in srgb, var(--card-color) 12%, transparent); }
.connector-state { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.connector-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.connector-state.pending i { background: var(--amber); }
.product-card h3 { margin: 12px 0 4px; overflow: hidden; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.product-domain { direction: ltr; overflow: hidden; color: var(--muted); font-size: 9px; text-align: right; white-space: nowrap; text-overflow: ellipsis; }
.product-metrics { display: flex; gap: 13px; margin-top: 12px; color: #b9c7d7; font-size: 10px; }
.product-metrics strong { color: white; }

.users-panel { margin-top: 28px; padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: rgba(10, 23, 40, .77); box-shadow: var(--shadow); }
.result-count { color: var(--muted); font-size: 12px; }
.filters { display: grid; grid-template-columns: minmax(260px, 1.8fr) repeat(3, minmax(150px, .7fr)) auto; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(4, 14, 26, .45); }
.search-field { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-light); }
.search-field svg { flex: 0 0 auto; width: 17px; color: var(--muted); }
.search-field input, .filters select { width: 100%; min-height: 43px; border: 0; outline: 0; color: #dbe8f6; background: transparent; font-size: 11px; }
.filters select { padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; background-color: var(--surface-light); }
.filters option { background: #102038; }
.clear-button { padding: 0 14px; border: 0; color: #8da2b8; background: transparent; cursor: pointer; font-size: 11px; }
.table-wrap { margin-top: 18px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 13px; color: #6f839a; font-size: 10px; font-weight: 700; text-align: right; white-space: nowrap; }
td { padding: 15px 13px; border-top: 1px solid rgba(148,163,184,.09); color: #c8d5e4; font-size: 11px; vertical-align: middle; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(50,165,255,.035); }
.user-cell { display: flex; align-items: center; gap: 11px; min-width: 210px; }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #67cffd; font-weight: 900; background: linear-gradient(145deg, rgba(50,165,255,.18), rgba(167,139,250,.15)); }
.user-name { max-width: 210px; overflow: hidden; color: #f1f6fc; font-weight: 800; white-space: nowrap; text-overflow: ellipsis; }
.user-meta { direction: ltr; max-width: 210px; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 9px; text-align: right; white-space: nowrap; text-overflow: ellipsis; }
.brand-chips, .product-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; max-width: 180px; padding: 5px 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; color: #adc0d4; background: rgba(20,37,60,.55); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.chip.brand-tehranhesab { color: #69cbff; border-color: rgba(50,165,255,.22); background: rgba(50,165,255,.08); }
.chip.brand-amardefi { color: #a9e8e1; border-color: rgba(35,210,212,.22); background: rgba(35,210,212,.08); }
.more-chip { color: var(--muted); }
.subscription-active { color: #65e2ad; }
.subscription-inactive { color: #8496aa; }
.subscription-status { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.subscription-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; }
.subscription-plan { max-width: 180px; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.time-cell { direction: ltr; color: #93a7bd; font-size: 10px; text-align: right; white-space: nowrap; }
.view-button { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 10px; color: #8fa7bf; background: transparent; cursor: pointer; }
.view-button:hover { color: var(--blue); border-color: rgba(50,165,255,.3); }
.view-button svg { width: 17px; }
.loading-state, .empty-state { display: grid; place-items: center; min-height: 310px; color: var(--muted); text-align: center; }
.loading-state p, .empty-state p { margin: 10px 0; font-size: 12px; }
.empty-state svg { width: 38px; height: 38px; color: #536d87; }
.empty-state h3 { margin: 15px 0 0; color: #b8c8d9; font-size: 15px; }
.loader { width: 28px; height: 28px; border: 3px solid rgba(50,165,255,.16); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 20px; }
.pagination button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; color: #a9bbcd; background: rgba(20,37,60,.5); cursor: pointer; font-size: 10px; }
.pagination svg { width: 15px; }
.pagination span { min-width: 115px; color: var(--muted); font-size: 10px; text-align: center; }
.mobile-users { display: none; }

.modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 22px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(1,7,15,.78); backdrop-filter: blur(8px); }
.modal-card { position: relative; width: min(790px, 100%); max-height: min(780px, calc(100vh - 44px)); padding: 30px; overflow-y: auto; border: 1px solid var(--line); border-radius: 24px; background: #0d1c30; box-shadow: 0 30px 100px rgba(0,0,0,.55); }
.modal-close { position: absolute; top: 18px; left: 18px; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer; }
.detail-head { display: flex; align-items: center; gap: 15px; padding-left: 45px; }
.detail-head .avatar { width: 54px; height: 54px; font-size: 18px; }
.detail-head h2 { margin: 0; font-size: 21px; }
.detail-head p { direction: ltr; margin: 6px 0 0; color: var(--muted); font-size: 11px; text-align: right; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; }
.detail-field { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5,15,28,.42); }
.detail-field span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 9px; }
.detail-field strong { direction: ltr; display: block; overflow-wrap: anywhere; font-size: 11px; text-align: right; }
.detail-section { margin-top: 27px; }
.detail-section h3 { margin: 0 0 12px; color: #c9d7e6; font-size: 13px; }
.detail-list { display: grid; gap: 8px; }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5,15,28,.35); }
.detail-row-main { min-width: 0; }
.detail-row-main strong { display: block; font-size: 11px; }
.detail-row-main small { direction: ltr; display: block; margin-top: 5px; overflow-wrap: anywhere; color: var(--muted); font-size: 9px; text-align: right; }
.detail-row-side { flex: 0 0 auto; color: var(--muted); font-size: 9px; text-align: left; }
.active-label { display: inline-flex; padding: 5px 8px; border-radius: 7px; color: #64dfaa; background: rgba(56,217,150,.1); }
.inactive-label { display: inline-flex; padding: 5px 8px; border-radius: 7px; color: #91a4b8; background: rgba(148,163,184,.08); }
.detail-json { margin-top: 7px; color: #7890a9; font-size: 8px; }
.toast { position: fixed; z-index: 150; right: 50%; bottom: 28px; padding: 11px 17px; border: 1px solid rgba(50,165,255,.24); border-radius: 12px; color: #d9ebfa; background: #132841; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(50%, 12px); transition: .22s; font-size: 11px; }
.toast.show { opacity: 1; transform: translate(50%, 0); }
.toast.error { border-color: rgba(251,113,133,.3); color: #ffc0ca; }

@media (max-width: 1160px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .search-field { grid-column: span 2; }
}
@media (max-width: 760px) {
  .topbar { position: relative; align-items: flex-start; padding: 14px 16px; }
  .topbar .eyebrow, .topbar h1 span, .topbar h1 { font-size: 10px; }
  .topbar h1 { max-width: 140px; }
  .brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
  .topbar-actions { gap: 6px; }
  .last-update { display: none; }
  .secondary-button, .ghost-button { width: 39px; min-height: 39px; padding: 0; }
  .secondary-button span, .ghost-button span { display: none; }
  .content { width: min(100% - 24px, 700px); padding-top: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stat-card { min-height: 110px; padding: 14px; grid-template-columns: 38px 1fr; }
  .stat-card .stat-icon { width: 37px; height: 37px; border-radius: 11px; }
  .stat-card strong { font-size: 20px; }
  .stat-card small { display: none; }
  .stat-card:last-child { grid-column: span 2; }
  .products-section { margin-top: 25px; }
  .product-strip { grid-auto-columns: 190px; }
  .users-panel { margin-top: 22px; padding: 14px; border-radius: 18px; }
  .filters { grid-template-columns: 1fr 1fr; padding: 9px; }
  .search-field { grid-column: span 2; min-height: 43px; }
  .clear-button { min-height: 42px; }
  .table-wrap { display: none !important; }
  .mobile-users:not([hidden]) { display: grid; gap: 9px; margin-top: 14px; }
  .mobile-card { padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(16,32,53,.62); cursor: pointer; }
  .mobile-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .mobile-card .user-cell { min-width: 0; }
  .mobile-card .user-name, .mobile-card .user-meta { max-width: 180px; }
  .mobile-card-products { margin-top: 12px; }
  .mobile-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
  .pagination { gap: 7px; }
  .pagination span { min-width: 90px; }
  .modal { padding: 10px; }
  .modal-card { max-height: calc(100vh - 20px); padding: 22px 16px; border-radius: 18px; }
  .detail-head { padding-left: 38px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .detail-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .detail-row-side { text-align: right; }
}
@media (max-width: 430px) {
  .login-card { padding: 28px 20px; border-radius: 22px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
}
