﻿:root {
  color-scheme: light;
  --bg: #f4ede3;
  --bg-2: #efe4d5;
  --panel: rgba(255, 250, 243, 0.88);
  --panel-strong: #fffaf2;
  --panel-soft: #f6ecdf;
  --text: #35271e;
  --muted: #7f6a57;
  --line: rgba(124, 92, 64, 0.18);
  --line-strong: rgba(108, 74, 44, 0.32);
  --accent: #6f4b2f;
  --accent-2: #9a6b45;
  --accent-3: #c89d72;
  --danger: #9f3d2e;
  --ok: #49684b;
  --soft: #efe2d0;
  --shadow: 0 18px 42px rgba(74, 46, 23, 0.11);
  --shadow-lg: 0 30px 70px rgba(74, 46, 23, 0.16);
  font-family: Vazirmatn, "IRANSansX", "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
*::before,
*::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.75), transparent 34%),
    linear-gradient(180deg, #fbf5ec 0%, #f2e7d9 52%, #ecdfd0 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255,255,255,.22), transparent 28%),
    linear-gradient(315deg, rgba(111,75,47,.05), transparent 30%);
}

body.logged-out {
  grid-template-columns: 1fr;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 248, 238, 0.5);
}

*::-webkit-scrollbar-thumb {
  background: rgba(111, 75, 47, 0.26);
  border-radius: 999px;
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 22px 16px;
  color: #f6e9d8;
  background:
    linear-gradient(180deg, rgba(86,58,36,.98) 0%, rgba(62,41,26,.98) 100%);
  border-left: 1px solid rgba(255,255,255,.08);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
  z-index: 2;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 18px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  pointer-events: none;
}

.brand {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 12px 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,.11);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #d1a77a 0%, #a16f49 100%);
  color: #fff7ee;
  font-size: 18px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 10px 18px rgba(14,8,5,.2);
}

.brand strong {
  display: block;
  font-size: 15px;
  color: #fff7eb;
}

.brand small {
  display: block;
  margin-top: 5px;
  color: rgba(246, 233, 216, 0.72);
  line-height: 1.6;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  border: 1px solid transparent;
  background: rgba(255,255,255,.02);
  color: rgba(247, 236, 224, 0.84);
  text-align: right;
  border-radius: 14px;
  min-height: 46px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: .18s ease;
}

.nav-btn:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.08);
  color: #fff8ef;
  transform: translateY(-1px);
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(211,170,127,.28), rgba(171,117,77,.22));
  border-color: rgba(219, 180, 139, 0.3);
  color: #fffaf1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.shell {
  position: relative;
  padding: 28px;
  min-width: 0;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
  padding: 22px 24px;
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 22px;
  background: rgba(255, 249, 240, 0.64);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0 0 8px;
  font-size: 31px;
  line-height: 1.2;
  color: #2f2118;
}

h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.35;
}

h3 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.5;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.actions,
.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.66);
  color: #654c38;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.download-app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid rgba(72, 111, 83, 0.42);
  border-radius: 8px;
  background: #e9f4eb;
  color: #285a37;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.download-app-btn:hover {
  border-color: #487456;
  background: #dceee0;
  transform: translateY(-1px);
}

.download-app-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 21px;
  line-height: 1;
}

.language-switcher {
  display: inline-grid;
  grid-template-columns: repeat(3, 42px);
  direction: ltr;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,.66);
}

.language-switcher button {
  min-height: 40px;
  padding: 6px;
  border: 0;
  border-inline-end: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
}

.language-switcher button:last-child { border-inline-end: 0; }
.language-switcher button.active { background: var(--accent); color: #fff; }

[dir="ltr"] .nav-btn { text-align: left; }
[dir="ltr"] input,
[dir="ltr"] select,
[dir="ltr"] textarea { text-align: left; }
[dir="ltr"] .sidebar { border-left: 0; border-right: 1px solid rgba(255,255,255,.08); }

.required-field { outline: 2px solid rgba(159,61,46,.28); outline-offset: 4px; }

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(247, 236, 223, .92));
  color: var(--text);
  border-radius: 14px;
  min-height: 42px;
  padding: 9px 15px;
  cursor: pointer;
  transition: .18s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85);
}

button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.primary {
  color: #fff8ee;
  border-color: rgba(84, 54, 34, 0.7);
  background: linear-gradient(180deg, #8d6140 0%, #6f4b2f 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 12px 20px rgba(89, 55, 30, .16);
}

.primary:hover {
  border-color: #70492d;
  background: linear-gradient(180deg, #966746 0%, #754e31 100%);
}

.ghost {
  background: rgba(255,255,255,.4);
}

.small-btn {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 11px;
}

.danger-btn {
  color: var(--danger);
  border-color: rgba(159, 61, 46, 0.22);
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(252, 238, 235, .92));
}

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 19px;
  border-radius: 14px;
}

.grid {
  display: grid;
  gap: 16px;
}

.stats {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

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

.card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  padding: 18px;
  min-width: 0;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.24), transparent 38%);
  pointer-events: none;
}

.stat {
  padding: 18px;
}

.stat span {
  color: #775e49;
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  color: var(--accent);
}

.two {
  grid-template-columns: 1fr 1fr;
}

.compact-card {
  padding: 14px;
  min-width: 0;
}

.compact-toolbar {
  margin-bottom: 10px;
}

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

.subtabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.subtab-btn {
  min-height: 38px;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255,255,255,.56);
}

.subtab-btn.active {
  color: #fff8ee;
  border-color: rgba(84, 54, 34, 0.7);
  background: linear-gradient(180deg, #8d6140 0%, #6f4b2f 100%);
}

.search {
  min-width: min(420px, 100%);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}

.check-report-summary,
.check-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.check-report-summary div,
.check-summary div,
.empty-state {
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,.62);
}

.check-report-summary span,
.check-summary span {
  display: block;
  color: #856956;
  font-size: 12px;
  margin-bottom: 6px;
}

.check-report-summary strong,
.check-summary strong {
  color: #4d3525;
  font-size: 15px;
}

.empty-state {
  color: #856956;
  line-height: 1.9;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(124, 92, 64, 0.16);
  border-radius: 14px;
  padding: 11px 12px;
  background: rgba(255, 252, 247, 0.96);
  color: var(--text);
  min-height: 42px;
  box-shadow: inset 0 1px 1px rgba(107, 76, 48, 0.03);
  transition: .16s ease;
}

input::placeholder,
textarea::placeholder {
  color: #a18975;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(140, 95, 58, 0.62);
  box-shadow: 0 0 0 4px rgba(170, 124, 82, 0.12);
  background: #fffdf8;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #624d3c;
  font-size: 13px;
  min-width: 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  width: 100%;
  min-width: 0;
}

.full {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 16px;
  background: rgba(255,255,255,.7);
}

table {
  width: 100%;
  min-width: 720px;
  table-layout: auto;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(124, 92, 64, 0.1);
  text-align: right;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.45;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #f3e5d6 0%, #efdfcc 100%);
  color: #5a402c;
  font-weight: 700;
  font-size: 12px;
  z-index: 1;
}

tbody tr {
  transition: .12s ease;
}

tbody tr:nth-child(even) {
  background: rgba(250, 243, 233, 0.58);
}

tbody tr:hover {
  background: rgba(241, 227, 210, 0.7);
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #ead7c1;
  color: #6f4b2f;
  border: 1px solid rgba(138, 99, 68, 0.12);
}

.cell-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.danger { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--accent-2); }

.credit-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 32px;
  border-radius: 999px;
  background: rgba(255,255,255,.65);
  font-weight: 800;
}

.credit-score.ok {
  background: rgba(37, 123, 92, 0.14);
  color: var(--ok);
}

.credit-score.warn {
  background: rgba(186, 128, 52, 0.16);
  color: #9b6526;
}

.credit-score.danger {
  background: rgba(179, 67, 67, 0.14);
  color: var(--danger);
}

.credit-badge.ok {
  background: rgba(37, 123, 92, 0.12);
  color: var(--ok);
}

.credit-badge.warn {
  background: rgba(186, 128, 52, 0.14);
  color: #9b6526;
}

.credit-badge.danger {
  background: rgba(179, 67, 67, 0.12);
  color: var(--danger);
}

.credit-detail {
  margin-top: 14px;
}

.credit-hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 18px;
  background: rgba(255,255,255,.62);
}

.credit-hero span,
.credit-hero small {
  display: block;
  color: #856956;
}

.credit-hero strong {
  display: block;
  margin: 4px 0;
  font-size: 24px;
  color: #3a2a20;
}

.credit-meter {
  text-align: center;
}

.credit-note {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(234, 215, 193, 0.45);
  color: #5a402c;
}

.credit-risks {
  margin: 12px 0 0;
  padding: 12px 28px 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(179, 67, 67, 0.14);
  background: rgba(179, 67, 67, 0.06);
  color: var(--danger);
  line-height: 2;
}

.advisor-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.advisor-hero p {
  max-width: 860px;
  margin-top: 6px;
  color: #7a614e;
  line-height: 1.9;
}

.advisor-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.advisor-trust span {
  padding: 6px 10px;
  border: 1px solid rgba(37, 123, 92, .24);
  border-radius: 999px;
  background: rgba(37, 123, 92, .08);
  color: #246b52;
  font-size: 12px;
  font-weight: 700;
}

.intelligence-stats .stat:first-child {
  border-color: rgba(37, 123, 92, .26);
  background: linear-gradient(145deg, rgba(37, 123, 92, .10), rgba(255,255,255,.72));
}

.advisor-insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.advisor-insight {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(124, 92, 64, 0.14);
  background: rgba(255,255,255,.62);
}

.advisor-insight.high {
  border-color: rgba(179, 67, 67, .28);
  background: rgba(179, 67, 67, .06);
}

.advisor-insight.medium {
  border-color: rgba(186, 128, 52, .28);
  background: rgba(186, 128, 52, .07);
}

.advisor-insight h3 {
  margin-top: 8px;
  color: #3f2f24;
}

.advisor-insight p {
  color: #715947;
  line-height: 1.85;
}

.advisor-insight strong {
  color: #4d3525;
  line-height: 1.8;
}

.advisor-priority.danger {
  background: rgba(179, 67, 67, 0.12);
  color: var(--danger);
}

.advisor-priority.warn {
  background: rgba(186, 128, 52, 0.14);
  color: #9b6526;
}

.advisor-priority.ok {
  background: rgba(37, 123, 92, 0.12);
  color: var(--ok);
}

.intelligence-footnote {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.intelligence-footnote ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.intelligence-footnote li,
.intelligence-policy,
.intelligence-ready {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.9;
}

.intelligence-footnote li {
  border: 1px solid rgba(186, 128, 52, .24);
  background: rgba(186, 128, 52, .07);
  color: #815824;
}

.intelligence-policy {
  border: 1px solid rgba(45, 89, 142, .22);
  background: rgba(45, 89, 142, .06);
}

.intelligence-policy p {
  margin: 8px 0;
  color: #654f3d;
}

.intelligence-policy strong {
  color: #2d598e;
}
.ai-analysis-card .primary:disabled { opacity: .65; cursor: wait; }
.ai-advisor-result { margin-top: 12px; }
.ai-narrative-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 12px; }
.ai-narrative-grid article { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface-soft); }
.ai-narrative-grid h4 { margin: 0 0 8px; }
.ai-narrative-grid p, .ai-narrative-grid li { line-height: 1.9; }
.ai-narrative-grid strong { color: var(--primary); }
.ai-analysis-error { color: var(--danger); background: #fff2f1; border: 1px solid #f1b8b2; border-radius: 12px; padding: 12px; }
@media (max-width: 900px) { .ai-narrative-grid { grid-template-columns: 1fr; } }

.intelligence-ready {
  margin-top: 12px;
  border: 1px solid rgba(37, 123, 92, .24);
  background: rgba(37, 123, 92, .07);
  color: #246b52;
}

.toast {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(130, 97, 66, 0.14);
  background: rgba(255, 249, 240, 0.82);
  color: #5a402c;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

.login-shell {
  min-height: calc(100vh - 146px);
  display: grid;
  align-items: center;
}

.login-stage {
  width: min(1080px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr .9fr;
  gap: 22px;
  min-width: 0;
}

.auth-stack {
  display: grid;
  gap: 20px;
  align-content: start;
}

.login-hero,
.login-card {
  background: rgba(255, 249, 240, 0.78);
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 28px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
}

.login-hero {
  padding: 34px;
  position: relative;
  overflow: hidden;
}

.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,.42), transparent 30%),
    linear-gradient(180deg, rgba(200,157,114,.16), transparent 62%);
  pointer-events: none;
}

.login-eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(111, 75, 47, 0.08);
  color: #7a5638;
  margin-bottom: 18px;
}

.login-hero h2 {
  font-size: 34px;
  margin-bottom: 12px;
  color: #2f2118;
}

.login-hero p {
  max-width: 52ch;
}

.login-features {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.feature-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.56);
  border: 1px solid rgba(124, 92, 64, 0.12);
}

.feature-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
  color: #533726;
}

.login-card {
  width: min(460px, 100%);
  justify-self: stretch;
  padding: 28px;
  overflow: hidden;
  min-width: 0;
}

.login-card .form-grid {
  grid-template-columns: 1fr;
}

.login-card label,
.login-card input,
.login-card select,
.login-card textarea,
.login-card .modal-actions,
.login-note {
  width: 100%;
  max-width: 100%;
}

.login-card h2 {
  margin-bottom: 8px;
}

.login-card p {
  margin-bottom: 18px;
}

.login-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(234, 215, 193, 0.44);
  color: #6a4d38;
}

.invite-login-note {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(124, 92, 64, 0.14);
  background: rgba(214, 188, 154, 0.2);
}

.invite-login-note strong {
  color: #4f3423;
}

.invite-steps {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.invite-steps > div {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.invite-steps span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #805537;
  color: white;
  font-weight: 800;
}

.invite-steps p {
  margin: 0;
  line-height: 1.9;
}

.credential-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.credential-card {
  width: min(460px, 100%);
}

.credential-result {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.credential-result > div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(124, 92, 64, 0.12);
}

.credential-result span {
  font-size: 12px;
  color: #81604a;
}

.credential-result strong {
  font-size: 15px;
  color: #3f2a1c;
  word-break: break-word;
}

dialog {
  border: 0;
  padding: 16px;
  background: transparent;
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

dialog[open] {
  display: grid;
  place-items: center;
}

dialog::backdrop {
  background: rgba(39, 24, 13, 0.36);
  backdrop-filter: blur(5px);
}

.modal-card {
  width: min(1480px, 100%);
  min-width: 0;
  background: var(--panel-strong);
  border-radius: 24px;
  border: 1px solid rgba(124, 92, 64, 0.16);
  box-shadow: var(--shadow-lg);
  padding: 18px;
  max-height: calc(100dvh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  overflow-x: hidden;
}

#modalBody {
  min-width: 0;
  overflow: auto;
  overflow-x: auto;
  padding-inline: 2px;
}

.modal-card .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
}

.modal-card label,
.modal-card input,
.modal-card select,
.modal-card textarea {
  min-width: 0;
  max-width: 100%;
}

.modal-head,
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-head {
  margin-bottom: 16px;
}

.modal-actions {
  margin-top: 18px;
  justify-content: flex-start;
  padding-top: 12px;
  border-top: 1px solid rgba(124, 92, 64, 0.12);
}

.items-box {
  border: 1px dashed rgba(124, 92, 64, 0.28);
  border-radius: 18px;
  padding: 14px;
  background: rgba(250, 242, 232, 0.62);
}

.invoice-shell {
  display: grid;
  gap: 14px;
}

.invoice-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(243, 229, 214, 0.72);
  color: #6b4a32;
}

.invoice-summary strong {
  font-size: 16px;
}

.invoice-summary span {
  color: #856956;
}

.sale-sheet {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.sale-sheet.credit-ok .sale-sheet__meta,
#saleCustomer.credit-ok {
  border-color: rgba(37, 123, 92, 0.52);
  background: rgba(37, 123, 92, 0.08);
}

.sale-sheet.credit-warn .sale-sheet__meta,
#saleCustomer.credit-warn {
  border-color: rgba(186, 128, 52, 0.62);
  background: rgba(186, 128, 52, 0.12);
}

.sale-sheet.credit-danger .sale-sheet__meta,
#saleCustomer.credit-danger {
  border-color: rgba(179, 67, 67, 0.62);
  background: rgba(179, 67, 67, 0.12);
}

.sale-credit-alert {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 800;
  line-height: 1.8;
  width: 100%;
  min-width: 220px;
  white-space: normal;
}

.sale-credit-alert.warn {
  background: rgba(186, 128, 52, 0.14);
  color: #9b6526;
}

.sale-credit-alert.danger {
  background: rgba(179, 67, 67, 0.14);
  color: var(--danger);
}

.sale-sheet__head,
.sale-sheet__meta,
.sale-sheet__foot {
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 252, 247, 0.82);
}

.sale-sheet__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.sale-sheet__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.sale-sheet__meta label,
.sale-settlement label,
.sale-sheet__foot > label {
  font-size: 14px;
}

.sale-sheet__meta input,
.sale-sheet__meta select,
.sale-settlement input,
.sale-settlement select,
.sale-settlement textarea,
.sale-line input,
.sale-line select {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
}

.sale-balance {
  display: grid;
  gap: 8px;
  align-items: center;
  justify-content: stretch;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(237, 222, 205, 0.65);
  color: #654b37;
  font-size: 14px;
  line-height: 1.8;
  min-width: 230px;
  align-self: stretch;
}

.sale-balance > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sale-items__table {
  border: 1px solid rgba(124, 92, 64, 0.16);
  border-radius: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

.sale-items__header,
.sale-line {
  display: grid;
  grid-template-columns: 42px minmax(160px, 1.5fr) minmax(130px, 1.1fr) minmax(118px, 1fr) minmax(94px, .8fr) minmax(104px, .9fr) minmax(76px, .7fr) minmax(76px, .7fr) minmax(90px, .85fr) minmax(104px, 1fr) 58px;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  min-width: 1180px;
  width: 100%;
}

.purchase-items__header,
.purchase-line {
  grid-template-columns: 42px minmax(160px, 1.5fr) minmax(130px, 1.1fr) minmax(118px, 1fr) minmax(104px, .9fr) minmax(76px, .7fr) minmax(76px, .7fr) minmax(90px, .85fr) minmax(104px, 1fr) 58px;
  min-width: 1080px;
}

.sale-line__stock {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(124, 92, 64, 0.14);
  background: rgba(255,255,255,.62);
  font-size: 12px;
  color: #6e5746;
  white-space: normal;
  text-align: center;
}

.sale-items__header {
  background: linear-gradient(180deg, #f3e5d6 0%, #efdfcc 100%);
  color: #5a402c;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.4;
}

.sale-line {
  border-top: 1px solid rgba(124, 92, 64, 0.1);
  background: rgba(255,255,255,.66);
  font-size: 14px;
}

.sale-line output,
.sale-line__index {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  font-size: 13px;
}

.sale-line__effect {
  color: #7a5638;
  font-size: 14px;
}

.sale-items > button {
  margin-top: 10px;
}

.invoice-print-options {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.sale-stock-warning {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(179, 67, 67, 0.32);
  border-radius: 14px;
  background: rgba(179, 67, 67, 0.1);
  color: var(--danger);
  font-weight: 800;
  line-height: 1.9;
}

.sale-stock-warning span {
  color: #6f332d;
  font-weight: 700;
}

.stock-report-box {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.stock-report-box .compact-card {
  box-shadow: none;
  overflow-x: auto;
}

.stock-chain-card {
  margin-top: 0;
}

.sale-settlement {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.sale-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.sale-totals div {
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255,255,255,.62);
}

.sale-totals span {
  display: block;
  color: #856956;
  margin-bottom: 6px;
  font-size: 13px;
}

.sale-totals strong {
  font-size: 20px;
  color: #5b3b24;
}

.settlement-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 252, 247, 0.78);
  overflow-x: auto;
  max-width: 100%;
}

.warehouse-price-grid {
  display: grid;
  gap: 10px;
  min-width: 1080px;
}

.warehouse-price-row {
  display: grid;
  grid-template-columns: 150px 100px repeat(7, minmax(120px, 1fr));
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.warehouse-price-row label {
  font-size: 12px;
}

.settlement-head,
.settlement-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
  align-items: center;
  min-width: 0;
  width: 100%;
}

.settlement-head {
  display: none;
}

.settlement-row input,
.settlement-row select {
  min-height: 40px;
  font-size: 13px;
  padding: 8px 10px;
}

.settlement-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.settlement-field span {
  color: #6c513d;
  font-size: 12px;
  font-weight: 700;
}

.settlement-row .settlement-remove {
  align-self: end;
  width: 100%;
}

.item-row {
  display: grid;
  grid-template-columns: 1.5fr 1.2fr 1fr 1fr 1fr 1.3fr 44px;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 980px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px 14px;
  border: 1px solid rgba(124, 92, 64, 0.14);
  border-radius: 16px;
  padding: 14px;
  background: rgba(250, 243, 233, 0.58);
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.permission-item input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

code {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(111, 75, 47, 0.08);
  color: #6f4b2f;
}

@media (max-width: 1360px) {
  dialog {
    padding: 12px;
  }

  .modal-card {
    padding: 14px;
    max-height: calc(100dvh - 24px);
  }

  .sale-items__header,
  .sale-line {
    min-width: 1180px;
  }

  .purchase-items__header,
  .purchase-line {
    min-width: 1080px;
  }

  .settlement-head,
  .settlement-row {
    min-width: 0;
  }
}

@media (max-width: 1120px) {
  .stats {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .compact-grid,
  .two,
  .form-grid,
  .advisor-insights,
  .intelligence-footnote,
  .login-stage {
    grid-template-columns: 1fr;
  }

  .advisor-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .sale-sheet__meta,
  .sale-settlement,
  .sale-totals,
  .filter-bar,
  .check-report-summary,
  .check-summary {
    grid-template-columns: 1fr 1fr;
  }

  dialog {
    padding: 10px;
  }

  .login-card {
    justify-self: stretch;
    width: 100%;
  }
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    min-height: auto;
    padding-bottom: 16px;
  }

  .sidebar::before {
    inset: 12px;
  }

  nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .shell {
    padding: 16px;
  }

  .topbar {
    padding: 18px;
  }

  .item-row {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .sale-items__header,
  .sale-line {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .settlement-head,
  .settlement-row {
    min-width: 0;
  }

  .permission-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 24px;
  }

  .topbar,
  .card,
  .modal-card,
  .login-card,
  .login-hero {
    border-radius: 18px;
  }

  .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .sale-sheet__head,
  .sale-sheet__meta,
  .sale-settlement,
  .sale-totals,
  .filter-bar,
  .check-report-summary,
  .check-summary {
    grid-template-columns: 1fr;
  }

  dialog {
    padding: 6px;
  }

  .modal-card {
    max-height: calc(100dvh - 12px);
  }

  .login-features {
    grid-template-columns: 1fr;
  }
}

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

.sync-summary > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  padding: 16px 20px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sync-summary span,
.bank-sync-item small,
.pair-result span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.sync-summary strong { font-size: 26px; }
.sync-connect-band { margin-bottom: 14px; }
.sync-connect-band > .primary { margin-top: 12px; }
.bank-sync-scroll {
  max-height: min(62vh, 680px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.bank-sync-list {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.32);
}
.bank-sync-item {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(150px, 0.35fr);
  gap: 12px;
  align-items: stretch;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}
.bank-sync-item__identity {
  display: grid;
  grid-template-columns: minmax(92px, 0.55fr) minmax(100px, 0.65fr) minmax(160px, 1.25fr) minmax(88px, 0.5fr);
  gap: 10px;
  min-width: 0;
}
.bank-sync-item__assignment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}
.bank-sync-field {
  display: block;
  min-width: 0;
  margin: 0;
}
.bank-sync-field strong,
.bank-sync-field small {
  overflow-wrap: anywhere;
}
.bank-sync-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.bank-sync-field select {
  width: 100%;
  min-width: 0;
}
.bank-sync-item__actions {
  display: flex;
  align-items: center;
  min-width: 0;
}
.bank-sync-item__actions .row-actions {
  width: 100%;
  flex-wrap: wrap;
}
.bank-sync-item__actions button {
  flex: 1 1 110px;
}
.sync-direction { margin-top: 4px; font-weight: 700; }
.sync-direction.in { color: var(--ok); }
.sync-direction.out { color: var(--danger); }

.pair-result { margin-top: 16px; }
.pair-result img {
  display: block;
  width: min(280px, 100%);
  aspect-ratio: 1;
  border: 10px solid #fff;
  margin-bottom: 10px;
}

.pair-result strong { display: block; margin-bottom: 4px; }
.sync-admin-grid { margin-top: 14px; align-items: start; }

.bank-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 12px;
  margin-top: 14px;
}
.bank-account-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}
.bank-account-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.bank-account-card__head span,
.bank-account-card small,
.bank-account-card__balance span,
.bank-account-card__metrics span {
  color: var(--muted);
  font-size: 11px;
}
.bank-account-card__head h3 { margin: 3px 0 0; font-size: 17px; overflow-wrap: anywhere; }
.bank-account-card__balance { margin: 16px 0; }
.bank-account-card__balance span { display: block; margin-bottom: 4px; }
.bank-account-card__balance strong { font-size: 26px; }
.bank-account-card__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.bank-account-card__metrics > div {
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  background: rgba(124, 92, 64, 0.07);
}
.bank-account-card__metrics span,
.bank-account-card__metrics strong { display: block; overflow-wrap: anywhere; }
.bank-transactions-card { margin-top: 14px; }
.compact-filter { min-width: min(100%, 240px); }
.bank-transaction-list {
  display: grid;
  gap: 8px;
  max-height: min(62vh, 680px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.bank-transaction-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 0.22fr) minmax(110px, 0.18fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}
.bank-transaction-item__main,
.bank-transaction-item__amount,
.bank-transaction-item__status { min-width: 0; }
.bank-transaction-item__main span,
.bank-transaction-item__main strong,
.bank-transaction-item__main small,
.bank-transaction-item__amount strong,
.bank-transaction-item__status small { display: block; overflow-wrap: anywhere; }
.bank-transaction-item__main span,
.bank-transaction-item__main small,
.bank-transaction-item__status small { color: var(--muted); font-size: 11px; }
.bank-transaction-item__main strong { margin: 3px 0; }
.bank-transaction-item__amount { text-align: center; }
.bank-transaction-item__status { display: grid; justify-items: start; gap: 5px; }
.empty-state { padding: 28px 16px; color: var(--muted); text-align: center; }

@media (max-width: 980px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .sync-summary { grid-template-columns: 1fr; }
  .bank-sync-scroll { max-height: 58vh; }
	.bank-sync-item { grid-template-columns: 1fr; }
	.bank-transaction-item { grid-template-columns: minmax(0, 1fr) minmax(100px, 0.25fr); }
	.bank-transaction-item__status { grid-column: 1 / -1; grid-template-columns: max-content minmax(0, 1fr); align-items: center; }
}

@media (max-width: 680px) {
	.bank-sync-item__identity { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.bank-sync-field--description { grid-column: 1 / -1; }
	.bank-sync-item__assignment { grid-template-columns: 1fr; }
	.bank-account-card__metrics { grid-template-columns: 1fr; }
	.bank-transaction-item { grid-template-columns: 1fr; }
	.bank-transaction-item__amount { text-align: start; }
	.bank-transaction-item__status { grid-column: auto; }
}

@media (max-width: 420px) {
	.bank-sync-item__identity { grid-template-columns: 1fr; }
	.bank-sync-field--description { grid-column: auto; }
}

@media print {
  .sidebar,
  .topbar .actions,
  .toolbar,
  .filter-bar input,
  .filter-bar select,
  .filter-bar button,
  dialog {
    display: none !important;
  }

  body {
    display: block;
    background: white;
  }

  body::before {
    display: none;
  }

  .shell {
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 0;
    background: white;
  }
}

.telegram-report-grid {
  align-items: stretch;
}

.telegram-warning,
.telegram-success {
  margin: 14px 0;
  border: 1px solid #d69e2e;
  border-radius: 12px;
  background: #fff8dd;
  color: #744210;
  padding: 12px 14px;
  line-height: 1.9;
}

.telegram-success {
  border-color: #38a169;
  background: #e6ffed;
  color: #22543d;
}

.telegram-actions {
  margin-top: 16px;
  flex-wrap: wrap;
}

.telegram-qr-card {
  min-height: 390px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.telegram-empty-qr {
  max-width: 430px;
  color: var(--muted, #64748b);
  text-align: center;
  line-height: 2;
}

.telegram-pair-result {
  align-items: center;
}

.telegram-pair-result img {
  width: min(100%, 360px);
  border-radius: 18px;
}

.telegram-deep-link {
  display: inline-block;
  margin-top: 14px;
  text-decoration: none;
}
