@font-face {
  font-family: "IRANSansXFaNum";
  src: url("/assets/fonts/IRANSansXFaNum-Light.woff") format("woff");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSansXFaNum";
  src: url("/assets/fonts/IRANSansXFaNum-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSansXFaNum";
  src: url("/assets/fonts/IRANSansXFaNum-Regular.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSansXFaNum";
  src: url("/assets/fonts/IRANSansXFaNum-Bold.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSansXFaNum";
  src: url("/assets/fonts/IRANSansXFaNum-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSansXFaNum";
  src: url("/assets/fonts/IRANSansXFaNum-Bold.woff") format("woff");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
:root {
  color-scheme: light;
  --primary: #1B3A6B;
  --primary-dark: #12284A;
  --primary-light: #2C5282;
  --gold: #C9A227;
  --gold-soft: #F6E7B8;
  --gold-text: #A07B12;
  --bg: #F3F5F8;
  --card: #FFFFFF;
  --border: #E6EAF0;
  --text: #1A2332;
  --muted: #6B7280;
  --danger: #C2414A;
  --danger-soft: #FDE8EA;
  --success: #2F7D57;
  --success-soft: #E6F6EE;
  --warning: #C9891A;
  --warning-soft: #FFF4D6;
  --info: #3B6FA8;
  --info-soft: #E8F1FB;
  --pink: #C45C78;
  --pink-soft: #FCE8EE;
  --purple: #6B5B95;
  --shadow: 0 8px 24px rgba(27, 58, 107, 0.06);
  --shadow-sm: 0 2px 8px rgba(27, 58, 107, 0.05);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --sidebar: 260px;
  --header: 72px;
  --font: "IRANSansXFaNum", "Tahoma", sans-serif;
  --hover: #F4F7FB;
  --soft: #F4F6F9;
  --input: #FFFFFF;
  --active-fg: #FFFFFF;
  --logo-bg: #0A0A0A;
  --hero-from: #1B3A6B;
  --hero-to: #12284A;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --primary: #E8C547;
  --primary-dark: #C9A227;
  --primary-light: #F6E7B8;
  --gold: #E8C547;
  --gold-soft: #3A3014;
  --gold-text: #F0D47A;
  --bg: #0D1118;
  --card: #161C27;
  --border: #2A3344;
  --text: #F2F4F8;
  --muted: #9BA6B7;
  --danger: #E06B73;
  --danger-soft: #3A1C20;
  --success: #5CB88A;
  --success-soft: #163226;
  --warning: #E0B04A;
  --warning-soft: #3A2E12;
  --info: #7BA3D4;
  --info-soft: #1A2838;
  --pink: #E08AA3;
  --pink-soft: #3A222A;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --hover: #1E2634;
  --soft: #1A2230;
  --input: #121821;
  --active-fg: #0D1118;
  --logo-bg: #000000;
  --hero-from: #12284A;
  --hero-to: #0A1220;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { direction: rtl; scrollbar-color: var(--border) var(--bg); font-family: var(--font); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
a, button { -webkit-tap-highlight-color: transparent; }
::placeholder { color: var(--muted); opacity: 1; }
::selection { background: var(--gold-soft); color: var(--text); }
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill,
html[data-theme="dark"] textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--input) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; accent-color: var(--primary); }
img { max-width: 100%; }
.icon { display: inline-flex; width: 1.15em; height: 1.15em; vertical-align: -0.15em; }
.icon svg { width: 100%; height: 100%; }

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 30;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
}
.brand-mark {
  width: 48px; height: 48px; border-radius: 0; overflow: visible;
  background: transparent; flex-shrink: 0;
  display: grid; place-items: center;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sidebar-brand strong { font-size: 1.15rem; color: var(--primary); }
.nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 14px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--primary);
  font-weight: 500;
}
.nav a:hover { background: var(--hover); }
.nav a.active { background: var(--primary); color: var(--active-fg); }
.sidebar-logout {
  margin: 8px 16px 20px;
}
.sidebar-logout .btn { justify-content: center; gap: 8px; color: var(--danger); }
.logout-form { display: grid; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title { font-size: 1.15rem; font-weight: 700; color: var(--primary); margin: 0 auto; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.topbar-right { justify-content: flex-start; }
.topbar-left { justify-content: flex-end; min-width: 240px; }
.menu-btn {
  display: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 1.4rem;
  cursor: pointer;
}
.user-chip { display: flex; align-items: center; gap: 10px; text-align: left; color: inherit; }
.user-chip .meta { display: flex; flex-direction: column; line-height: 1.3; }
.user-chip .name { font-weight: 700; font-size: 0.92rem; }
.user-chip .gold { color: var(--gold-text); font-size: 0.78rem; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: var(--active-fg);
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
}
.avatar.gold { background: var(--gold); color: var(--primary-dark); }
.bell { position: relative; color: var(--primary); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; }
.bell:hover { background: var(--hover); }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card);
  color: var(--primary); cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.theme-toggle:hover { background: var(--hover); }
.theme-toggle .icon { width: 20px; height: 20px; }
.logout-btn { color: var(--danger); }
.theme-toggle .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-sun { display: inline-flex; }
.bell .badge {
  position: absolute; top: 4px; left: 4px;
  background: #E11D48; color: #fff; border-radius: 50%;
  min-width: 18px; height: 18px; font-size: 0.7rem;
  display: grid; place-items: center; padding: 0 4px;
  animation: badgePop .45s cubic-bezier(.22, 1, .36, 1), pulseSoft 2s ease-in-out .45s infinite;
}
.theme-toggle { transition: transform .25s ease, background .2s ease; }
.theme-toggle:active { transform: rotate(-18deg) scale(.92); }

.content { padding: 28px 32px 48px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-pad { padding: 22px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 16px;
  gap: 12px;
}
.section-head h2, .section-head h3 { margin: 0; font-size: 1.05rem; color: var(--primary); }
.link { color: var(--primary); font-size: 0.9rem; }

.hero {
  background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 100%);
  color: #fff;
  border-radius: 22px;
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  animation: riseIn .55s cubic-bezier(.22, 1, .36, 1);
}
.hero::after {
  content: "";
  position: absolute;
  inset: -30% auto auto -8%;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  pointer-events: none;
  animation: drift 8s ease-in-out infinite;
}
.hero h1 { margin: 0 0 8px; font-size: 1.6rem; }
.hero-box {
  background: rgba(0,0,0,.18);
  border-radius: 16px;
  padding: 16px 22px;
  min-width: 180px;
  text-align: center;
  animation: floatSoft 4.2s ease-in-out infinite;
}
.hero-box strong { display: block; font-size: 1.6rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  animation: riseIn .5s both;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stats .stat:nth-child(1) { animation-delay: .04s; }
.stats .stat:nth-child(2) { animation-delay: .1s; }
.stats .stat:nth-child(3) { animation-delay: .16s; }
.stats .stat:nth-child(4) { animation-delay: .22s; }
.stats .stat:nth-child(5) { animation-delay: .28s; }
.stats .stat:nth-child(6) { animation-delay: .34s; }
.stats .stat:nth-child(7) { animation-delay: .4s; }
.stats .stat:nth-child(8) { animation-delay: .46s; }
.stat .n { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat .l { color: var(--muted); font-size: 0.9rem; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }

.case-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  animation: riseIn .5s both;
  animation-delay: calc(var(--i, 0) * 55ms);
  transition: transform .22s ease, box-shadow .22s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 4px solid var(--primary);
}
.case-card.accent-pink { border-right-color: var(--pink); }
.case-card.accent-red { border-right-color: var(--danger); }
.case-card.accent-blue { border-right-color: var(--info); }
.case-card h3 { margin: 0; font-size: 1rem; line-height: 1.6; }
.muted { color: var(--muted); font-size: 0.85rem; }
.row-actions { display: flex; gap: 8px; margin-top: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; cursor: pointer; border-radius: 12px;
  padding: 9px 14px; font-weight: 600; font-size: 0.9rem;
  background: var(--primary); color: var(--active-fg);
  touch-action: manipulation;
  transition: transform .16s ease, filter .16s ease, background .16s ease, box-shadow .16s ease;
}
.btn:active { transform: scale(.96); }
.btn:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--card); color: var(--primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--hover); }
.btn-gold { background: var(--gold); color: #1A2332; }
html[data-theme="dark"] .btn-gold { color: #0D1118; }
.btn-gold:hover { filter: brightness(0.95); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; border-radius: 10px; }
.btn-block { width: 100%; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-pink { background: var(--pink-soft); color: var(--pink); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-blue { background: var(--info-soft); color: var(--info); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-gold { background: var(--warning-soft); color: var(--warning); }
.badge-gray { background: var(--soft); color: var(--muted); }

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  animation: riseIn .35s both;
}
.list .list-row:nth-child(1) { animation-delay: .03s; }
.list .list-row:nth-child(2) { animation-delay: .07s; }
.list .list-row:nth-child(3) { animation-delay: .11s; }
.list .list-row:nth-child(4) { animation-delay: .15s; }
.list .list-row:nth-child(5) { animation-delay: .19s; }
.list .list-row:nth-child(6) { animation-delay: .23s; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.circle-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--info-soft); color: var(--info);
}

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 12px;
  margin: 0 0 16px;
  align-items: end;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.filter-field > span {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
}
.filter-bar .search,
.filter-bar .input,
.filter-bar select,
.filter-bar .btn { width: 100%; min-width: 0; }
.filter-bar select.input {
  text-overflow: ellipsis;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.chip {
  border: 1px solid var(--border); background: var(--input); color: var(--text);
  border-radius: var(--radius-pill); padding: 6px 12px; cursor: pointer; font-size: 0.85rem;
}
.chip.active { background: var(--primary); color: var(--active-fg); border-color: var(--primary); }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-row label { font-size: 0.85rem; color: var(--muted); }
.input, select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; background: var(--input); color: var(--text); outline: none;
}
.input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--input); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; min-width: 240px;
}
.search input { border: 0; outline: 0; width: 100%; background: transparent; color: var(--text); }

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: right; padding: 12px 10px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
table.data tr:hover td { background: var(--hover); }

.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { display: flex; gap: 12px; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }

.stages {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stage {
  position: relative;
  text-align: right;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
  width: 100%;
  appearance: none;
}
.stage.clickable { cursor: pointer; }
.stage.clickable:hover { border-color: var(--primary); background: var(--hover); }
.stage .dot {
  width: 28px; height: 28px; border-radius: 50%; margin: 0 0 8px auto;
  display: grid; place-items: center; background: var(--card); color: var(--muted);
  border: 2px solid var(--border); font-size: 0.75rem; font-weight: 800;
}
.stage.done { background: var(--success-soft); border-color: transparent; color: var(--success); }
.stage.done .dot { background: var(--success); color: #fff; border-color: var(--success); }
.stage { transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.stage.clickable:active { transform: scale(.98); }
.stage.current {
  background: linear-gradient(180deg, var(--gold-soft), var(--card));
  border-color: var(--gold);
  color: var(--gold-text);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  animation: stageGlow 2.4s ease-in-out infinite;
}
.stage.current .dot { background: var(--gold); color: #1A2332; border-color: var(--gold); }

.thread { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow: auto; padding: 4px; }
.composer { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.chart-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin: 8px 0 20px; }
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 8px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; height: 100%; }
.chart-bar {
  width: 100%; max-width: 36px; border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  min-height: 6px;
  transform-origin: bottom;
  animation: barGrow .75s cubic-bezier(.22, 1, .36, 1) both;
}
.chart-bar-col .chart-n { font-size: 0.75rem; font-weight: 700; color: var(--text); }
.chart-bar-col .chart-l { font-size: 0.72rem; color: var(--muted); text-align: center; }
.chart-legend { display: flex; flex-direction: column; gap: 8px; }
.chart-legend-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chart-swatch { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.chart-donut {
  width: 160px; height: 160px; border-radius: 50%; margin: 0 auto 14px;
  mask: radial-gradient(circle at center, transparent 52%, #000 53%);
  -webkit-mask: radial-gradient(circle at center, transparent 52%, #000 53%);
}

.login-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 20px;
  padding: 5px;
  background: var(--soft);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.login-tabs-glider {
  position: absolute;
  top: 5px; bottom: 5px;
  width: calc(50% - 5px);
  right: 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #F0D47A, #C9A227 55%, #A07B12);
  box-shadow: 0 8px 18px rgba(201, 162, 39, .35);
  transition: right .4s cubic-bezier(.22, 1, .36, 1), left .4s cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}
.login-tabs[data-tab="register"] .login-tabs-glider {
  right: auto;
  left: 5px;
}
.login-tab {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 10px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .25s ease;
}
.login-tab.active { color: #1A2332; }
.login-body { min-height: 380px; }
.login-panel { display: none; }
.login-panel.active {
  display: flex;
  flex-direction: column;
  min-height: 380px;
  animation: loginIn .45s cubic-bezier(.22, 1, .36, 1);
}
.login-panel.active > .login-submit { margin-top: auto; }
.reg-step {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 380px;
}
.reg-step[hidden] { display: none !important; }
.reg-step > .login-submit,
.reg-step > .login-actions { margin-top: auto; }
.reg-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}
.reg-progress span:first-child { font-weight: 700; color: var(--text); }
.reg-type {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.reg-type-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 9px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
}
.reg-type-opt:has(input:checked) {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--primary);
}
.reg-type-opt input { accent-color: var(--gold); }
.reg-company-slot.is-idle { display: none; }
.reg-id-grid { display: grid; grid-template-columns: 1fr; }
.reg-id-grid.is-company { grid-template-columns: 1fr 1fr; gap: 10px; }
.reg-id-grid .form-row { margin-bottom: 12px; }
.reg-pass-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.reg-pass-grid .form-row { margin-bottom: 12px; }
.login-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  margin-top: auto;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.login-submit {
  position: relative;
  overflow: hidden;
  margin-top: 6px;
  background: linear-gradient(135deg, #F0D47A, #C9A227 45%, #8C6A0F);
  color: #1A2332;
  box-shadow: 0 10px 22px rgba(201, 162, 39, .32);
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(201, 162, 39, .45);
  filter: brightness(1.05);
}
.login-submit:active { transform: translateY(0); }
.login-submit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.5) 50%, transparent 65%);
  transform: translateX(130%);
}
.login-submit:hover::after { animation: loginShine .75s ease; }
@keyframes loginShine {
  from { transform: translateX(130%); }
  to { transform: translateX(-130%); }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(18px, 12px); }
}
@keyframes floatSoft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes stageGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, .28); }
  50% { box-shadow: 0 0 0 8px rgba(201, 162, 39, 0); }
}
@keyframes barGrow {
  from { transform: scaleY(.06); opacity: .35; }
  to { transform: none; opacity: 1; }
}
@keyframes fadeDim {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popCard {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes badgePop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
@keyframes pulseSoft {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@keyframes tabPop {
  0% { transform: translateY(0); }
  45% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}
@keyframes iconBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.alert-ok { background: var(--success-soft); color: var(--success); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }

.empty, .error-box, .loading-box {
  text-align: center; padding: 48px 16px; color: var(--muted);
}
.loading-box::before {
  content: "";
  display: block; width: 28px; height: 28px; margin: 0 auto 12px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { color: var(--danger); }

.modal-back {
  position: fixed; inset: 0; background: rgba(18, 40, 74, .35);
  display: none; align-items: center; justify-content: center; z-index: 80; padding: 20px;
}
html[data-theme="dark"] .modal-back { background: rgba(0, 0, 0, .55); }
.modal-back.open { display: flex; animation: fadeDim .2s ease; }
.modal {
  background: var(--card); border-radius: 18px; width: min(520px, 100%);
  padding: 22px; box-shadow: var(--shadow); color: var(--text);
  animation: popCard .32s cubic-bezier(.22, 1, .36, 1);
}
.modal h3 { margin: 0 0 12px; }
.toast-wrap {
  position: fixed; bottom: 20px; left: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--primary); color: var(--active-fg); padding: 10px 14px;
  border-radius: 12px; box-shadow: var(--shadow); min-width: 220px;
  animation: toastIn .35s cubic-bezier(.22, 1, .36, 1);
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

.profile-hero {
  background: var(--primary); color: var(--active-fg); border-radius: 18px 18px 0 0;
  padding: 24px; display: flex; align-items: center; gap: 14px;
}
.kv { display: flex; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.logout-row { color: var(--danger); padding-top: 8px; }

.urgent {
  border: 1px solid var(--gold);
  background: var(--gold-soft);
}
.expert-check {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.expert-check:last-of-type { border-bottom: 0; }
.chip input { margin-left: 6px; }
.pager button[disabled] { opacity: .4; cursor: default; }

.thread { display: flex; flex-direction: column; gap: 10px; }
.bubble {
  max-width: 80%; padding: 10px 14px; border-radius: 14px; background: var(--soft);
}
.bubble.mine { background: var(--primary); color: var(--active-fg); align-self: flex-start; }
.bubble.theirs { align-self: flex-end; }

.overlay-nav {
  display: none;
}
.tabbar, .more-sheet { display: none; }

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 420px at 100% 0%, rgba(201, 162, 39, .16), transparent 55%),
    radial-gradient(800px 500px at 0% 100%, rgba(27, 58, 107, .12), transparent 50%),
    var(--bg);
}
.login-card { width: min(460px, 100%); padding: 28px; animation: loginIn .5s ease; }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-card .brand-mark { width: 56px; height: 56px; }
.login-card h1 { margin: 0 0 6px; font-size: 1.3rem; color: var(--primary); }

@media (hover: hover) {
  .stat:hover { transform: translateY(-3px); }
  .case-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
}
@media (hover: none) {
  .btn:hover { background: var(--primary); }
  .btn-ghost:hover { background: var(--card); }
  .login-submit:hover { transform: none; filter: none; }
  .login-submit:hover::after { animation: none; }
  .nav a:hover { background: transparent; }
  .nav a.active:hover { background: var(--primary); }
}
.hint { background: var(--soft); border-radius: 12px; padding: 12px; font-size: 0.82rem; color: var(--muted); margin-top: 16px; }
.alert { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }

@media (max-width: 1100px) {
  .stats, .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2, .chart-grid { grid-template-columns: 1fr; }
  .stages { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  :root {
    --header: 56px;
    --tabbar: 64px;
  }
  html.app-shell.nav-open, html.app-shell.nav-open body { overflow: hidden; }
  html.app-shell, html.app-shell body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  html.app-shell body {
    min-height: 100dvh;
  }
  .app {
    min-height: 0;
    height: 100%;
    height: 100dvh;
    height: 100svh;
  }
  .sidebar {
    display: none;
  }
  .menu-btn { display: none; }
  .topbar-right { display: none; min-width: 0; }
  .topbar {
    height: calc(var(--header) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    border-bottom: 0;
    box-shadow: 0 1px 0 var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: var(--card);
    background: color-mix(in srgb, var(--card) 88%, transparent);
  }
  .topbar-title {
    font-size: 1.02rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52vw;
  }
  .topbar-left {
    min-width: 0;
    gap: 6px;
  }
  .logout-form { display: none; }
  .user-chip .meta { display: none; }
  .theme-toggle, .bell, .avatar {
    width: 40px;
    height: 40px;
  }
  .main {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }
  .content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px calc(var(--tabbar) + 20px + env(safe-area-inset-bottom));
    overscroll-behavior-y: contain;
  }
  .stats, .grid-3, .grid-2, .chart-grid, .stages { grid-template-columns: 1fr; }
  .hero {
    flex-direction: column;
    align-items: stretch;
    padding: 18px 16px;
    border-radius: 18px;
    gap: 14px;
  }
  .hero h1 { font-size: 1.25rem; }
  .hero-box { min-width: 0; padding: 12px 14px; }
  .stat { padding: 14px; }
  .stat .n { font-size: 1.45rem; }
  .card-pad { padding: 16px; }
  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .section-head .btn,
  .section-head .filters,
  .section-head .filter-bar { width: 100%; }
  .search { min-width: 0; width: 100%; }
  .filters,
  .filter-bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
    overflow: visible;
  }
  .filters .input,
  .filters select,
  .filters .search,
  .filters .btn {
    width: 100% !important;
    max-width: none;
  }
  .chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .chip {
    flex: 1 1 calc(50% - 8px);
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .muted { font-size: 0.9rem; }
  .list-row {
    flex-wrap: wrap;
    padding: 14px 0;
    gap: 10px;
  }
  .list-row .btn, .row-actions .btn { min-height: 42px; }
  .row-actions {
    flex-wrap: wrap;
    width: 100%;
  }
  .row-actions .btn { flex: 1 1 calc(50% - 8px); }
  .btn, .login-tab, .login-submit {
    min-height: 46px;
  }
  .btn-sm { min-height: 40px; }
  .input, select, textarea, .search input {
    font-size: 16px;
    padding: 12px 14px;
    min-height: 46px;
  }
  textarea { min-height: 96px; }
  .table-wrap {
    margin: 0 -4px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  table.data { min-width: 560px; }
  .bubble { max-width: 92%; }
  .thread { max-height: none; }
  .composer { position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; }
  .pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .pager .btn { flex: 1; }
  .overlay-nav.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 16, 28, .4);
    z-index: 70;
  }
  .tabbar {
    display: flex;
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom));
    padding: 4px 6px env(safe-area-inset-bottom);
    background: var(--card);
    background: color-mix(in srgb, var(--card) 92%, transparent);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: stretch;
  }
  .tabbar-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 2px;
    border-radius: 12px;
    cursor: pointer;
  }
  .tabbar-item { transition: color .2s ease, transform .2s ease; }
  .tabbar-item.active { color: var(--primary); animation: tabPop .38s cubic-bezier(.22, 1, .36, 1); }
  .tabbar-item.active .tabbar-icon { animation: iconBounce .38s cubic-bezier(.22, 1, .36, 1); }
  .tabbar-icon { display: grid; place-items: center; width: 24px; height: 24px; }
  .tabbar-icon .icon { width: 22px; height: 22px; }
  .tabbar-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .more-sheet {
    display: block;
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    z-index: 75;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
    transform: translateY(110%);
    transition: transform .28s cubic-bezier(.22, 1, .36, 1);
    box-shadow: 0 -8px 32px rgba(18, 40, 74, .12);
    max-height: 78dvh;
    overflow-y: auto;
  }
  .more-sheet.open { transform: none; }
  .more-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: var(--border);
    margin: 4px auto 14px;
  }
  .more-sheet h3 { margin: 0 0 10px; font-size: 1rem; color: var(--primary); }
  .more-sheet-list { display: flex; flex-direction: column; gap: 4px; }
  .more-sheet-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 10px;
    border-radius: 12px;
    color: var(--text);
    font-weight: 600;
    min-height: 48px;
  }
  .more-sheet-list a.active { background: var(--hover); color: var(--primary); }
  .modal-back {
    align-items: flex-end;
    padding: 0;
    background: rgba(10, 16, 28, .45);
  }
  .modal {
    width: 100%;
    max-width: none;
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
    overflow: auto;
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  }
  .modal::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: var(--border);
    margin: 0 auto 14px;
  }
  .toast-wrap {
    left: 12px;
    right: 12px;
    bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom));
  }
  .toast { min-width: 0; width: 100%; }
  .login-page {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }
  .login-card {
    width: 100%;
    flex: 1;
    border-radius: 0;
    box-shadow: none;
    border: 0;
    padding: 22px 18px 28px;
    display: flex;
    flex-direction: column;
    animation: none;
  }
  .login-body,
  .login-panel.active,
  .reg-step { min-height: 0; }
  .login-panel.active { min-height: 0; flex: 1; }
  .reg-id-grid.is-company,
  .reg-pass-grid,
  .login-actions { grid-template-columns: 1fr; }
  .profile-hero { padding: 18px 16px; }
  .kv { padding: 12px 0; gap: 12px; }
  .kv strong { word-break: break-word; text-align: left; }
}

@media (max-width: 430px) {
  .topbar-title { font-size: 0.95rem; max-width: 44vw; }
  .hero h1 { font-size: 1.12rem; }
  .tabbar-label { font-size: 0.62rem; }
  .content { padding-right: 12px; padding-left: 12px; }
}

@media (max-width: 860px) and (max-height: 500px) {
  .tabbar-label { display: none; }
  :root { --tabbar: 48px; }
  .hero { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
