@font-face {
  font-family: "Vazirmatn FD";
  src: url("../fonts/Vazirmatn-FD-Regular.e0e713cd90d9.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn FD";
  src: url("../fonts/Vazirmatn-FD-Medium.746006b64c8e.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn FD";
  src: url("../fonts/Vazirmatn-FD-SemiBold.3c59bb69635a.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn FD";
  src: url("../fonts/Vazirmatn-FD-Bold.49790e8b277d.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn FD";
  src: url("../fonts/Vazirmatn-FD-ExtraBold.46cceb844b23.woff2") format("woff2");
  font-style: normal;
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn FD";
  src: url("../fonts/Vazirmatn-FD-Black.33a07e1a1f3b.woff2") format("woff2");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #183153;
  --ink-deep: #10233d;
  --paper: #f3f6f8;
  --surface: #fff;
  --soft-surface: #fbfcfd;
  --line: #d8e0e6;
  --line-dark: #bdcad4;
  --muted: #647487;
  --marker: #f15f22;
  --marker-soft: #ffe4d6;
  --success: #2b7a5a;
  --success-soft: #e8f5ef;
  --danger: #b64545;
  --danger-soft: #fcecec;
  --shadow: 0 18px 50px rgba(24, 49, 83, .09);
  --radius: 16px;
  --header-bg: rgba(243, 246, 248, .92);
  --header-border: rgba(216, 224, 230, .9);
  --grid-line: rgba(24, 49, 83, .025);
  --panel-tint: rgba(255, 255, 255, .55);
  --page-tint: rgba(255, 255, 255, .45);
  --glass: rgba(255, 255, 255, .72);
  --ink-rgb: 24, 49, 83;
  /* پس‌زمینهٔ توپر برند؛ در هر دو تم تیره می‌ماند تا متن سفید خوانا بماند */
  --fill: #183153;
  --on-fill: #fff;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #d7e2ee;
  --ink-deep: #eef3f8;
  --paper: #0f1722;
  --surface: #1a2433;
  --soft-surface: #212e40;
  --line: #2c3b4d;
  --line-dark: #3d4f63;
  --muted: #9aabbc;
  --marker: #f15f22;
  --marker-soft: #3d281f;
  --success: #5dba8f;
  --success-soft: #163528;
  --danger: #e07a7a;
  --danger-soft: #3a2222;
  --shadow: 0 18px 50px rgba(0, 0, 0, .4);
  --header-bg: rgba(15, 23, 34, .92);
  --header-border: rgba(44, 59, 77, .95);
  --grid-line: rgba(232, 238, 245, .04);
  --panel-tint: rgba(26, 36, 51, .72);
  --page-tint: rgba(26, 36, 51, .55);
  --glass: rgba(33, 46, 64, .92);
  --ink-rgb: 215, 226, 238;
  --fill: #2f4f78;
  --on-fill: #fff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink-deep);
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--paper);
  font-family: "Vazirmatn FD", Tahoma, Arial, sans-serif;
  line-height: 1.7;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.container { width: min(1160px, calc(100% - 32px)); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; z-index: 100; top: 12px; right: 12px; padding: 10px 14px;
  background: var(--marker); transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid var(--marker); outline-offset: 3px; }

.site-header {
  position: sticky; z-index: 50; top: 0; border-bottom: 1px solid var(--header-border);
  background: var(--header-bg); backdrop-filter: blur(14px);
}
.nav-shell { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 112px;
  height: auto;
  max-height: 48px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow: 3px 3px 0 var(--marker);
}
.brand-logo-dark { display: none; }
html[data-theme="dark"] .brand-logo-light { display: none; }
html[data-theme="dark"] .brand-logo-dark { display: block; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.4px; }
.brand small { color: var(--muted); font-size: 11px; }
.main-nav { display: flex; align-items: center; gap: 22px; }
.main-nav > a:not(.button) { font-size: 14px; font-weight: 700; }
.theme-toggle {
  width: 38px; aspect-ratio: 1; display: grid; place-items: center;
  border: 1px solid var(--line-dark); border-radius: 50%;
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.theme-toggle-icon { display: grid; place-items: center; line-height: 0; }
.theme-toggle-sun { display: none; }
html[data-theme="dark"] .theme-toggle-moon { display: none; }
html[data-theme="dark"] .theme-toggle-sun { display: grid; }
.button {
  border: 1px solid var(--fill); border-radius: 9px; padding: 11px 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--fill); color: var(--on-fill); font-weight: 800; cursor: pointer;
  box-shadow: 3px 3px 0 var(--marker); transition: transform .15s ease, box-shadow .15s ease;
}
.button:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--marker); }
.button-small { padding: 7px 13px; font-size: 13px; box-shadow: 2px 2px 0 var(--marker); }
.button-secondary { color: var(--ink); background: var(--surface); box-shadow: none; }
.button-block { width: 100%; }
.text-link, .back-link {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  border-bottom: 3px solid var(--marker);
  padding-bottom: 2px;
}
.back-link { display: inline-block; margin-bottom: 15px; font-size: 13px; }
.link-button { padding: 0; border: 0; color: var(--ink); background: none; font-weight: 700; cursor: pointer; }

.user-menu, .notification-menu { position: relative; }
.user-menu-trigger,
.notification-menu > summary {
  position: relative; width: 38px; aspect-ratio: 1; display: grid; place-items: center;
  border: 1px solid var(--line-dark); border-radius: 50%; background: var(--surface); color: var(--ink);
  cursor: pointer;
}
.user-menu-trigger::-webkit-details-marker,
.notification-menu > summary::-webkit-details-marker { display: none; }
.nav-icon { display: grid; place-items: center; line-height: 0; }
.nav-icon svg { display: block; }
.menu-panel, .notification-panel {
  position: absolute; top: calc(100% + 14px); left: 0; min-width: 190px; padding: 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
}
.menu-panel a, .menu-panel form { display: block; padding: 8px; }
.user-menu-identity {
  padding: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 12px; font-weight: 700; word-break: break-word;
}
.notification-menu > summary b {
  position: absolute; top: -6px; left: -4px; min-width: 19px; height: 19px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 10px; background: var(--danger); color: white; font-size: 10px;
}
.notification-panel { width: min(360px, calc(100vw - 32px)); }
.notification-head { display: flex; justify-content: space-between; padding: 5px 8px 10px; border-bottom: 1px solid var(--line); }
.notification-item { width: 100%; padding: 12px 9px; border: 0; border-bottom: 1px solid var(--line); text-align: right; background: var(--surface); cursor: pointer; }
.notification-item.unread { background: color-mix(in srgb, var(--ink) 10%, var(--surface)); }
.notification-item span, .notification-item small { display: block; }
.notification-item span { font-weight: 700; }
.notification-item small { color: var(--muted); }
.notification-list { display: grid; }
.notification-pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 8px 4px; border-top: 1px solid var(--line); font-size: 12px; font-weight: 700;
}
.notification-pagination a { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 2px; }
.notification-pagination .is-disabled { color: var(--muted); opacity: 0.55; }
.notification-page-status { color: var(--muted); font-variant-numeric: tabular-nums; }

.messages { position: fixed; z-index: 60; top: 88px; right: 50%; transform: translateX(50%); pointer-events: none; }
.message { width: fit-content; margin-right: auto; padding: 11px 17px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; }
.message-success { border-color: #a5d7c2; background: var(--success-soft); }
.message-error { border-color: #e8aaaa; background: var(--danger-soft); }

.hero { min-height: 680px; display: grid; align-items: center; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 90px; align-items: center; }
.eyebrow { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .04em; }
.hero h1 {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .12em;
  font-size: clamp(42px, 5vw, 72px);
  line-height: 1.15;
  letter-spacing: -3px;
}
.hero h1 .hero-title-lead,
.hero h1 .hero-title-trail {
  font-size: clamp(18px, 2.2vw, 28px);
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--muted);
}
.hero h1 .hero-title-brand {
  position: relative;
  z-index: 0;
  font-size: 1em;
  font-weight: 900;
  color: var(--ink);
}
.hero h1 .hero-title-brand::after {
  content: ""; position: absolute; z-index: -1; right: -4px; bottom: 8px;
  width: calc(100% + 8px); height: 16px; background: var(--marker); transform: rotate(-1deg);
}
.hero-lead { max-width: 620px; margin: 26px 0; color: var(--muted); font-size: 19px; }
.hero-actions { display: flex; align-items: center; gap: 24px; }
.hero-ledger {
  position: relative; padding: 28px 32px; border: 1px solid var(--line-dark); border-radius: 4px 22px 22px 4px;
  background: var(--surface); box-shadow: 18px 22px 0 rgba(var(--ink-rgb), .08), var(--shadow);
  transform: rotate(-1.5deg);
}
.hero-ledger::before {
  content: ""; position: absolute; top: 0; right: 17px; width: 2px; height: 100%; background: #efb4b4;
}
.ledger-header { display: flex; align-items: center; justify-content: space-between; }
.ledger-header > span:first-child { font-family: "Vazirmatn FD", sans-serif; color: var(--muted); font-size: 12px; }
.hero-ledger h2 { margin: 20px 0 26px; font-size: 25px; }
.mini-timeline, .activity-timeline { padding: 0; margin: 0; list-style: none; }
.mini-timeline li, .activity-timeline li { position: relative; padding: 0 30px 22px 0; }
.mini-timeline li::before, .activity-timeline li i {
  content: ""; position: absolute; top: 6px; right: 0; width: 11px; height: 11px;
  border: 2px solid var(--line-dark); border-radius: 50%; background: var(--surface);
}
.mini-timeline li::after, .activity-timeline li::after {
  content: ""; position: absolute; top: 19px; right: 6px; width: 1px; height: calc(100% - 8px); background: var(--line-dark);
}
.mini-timeline li:last-child::after, .activity-timeline li:last-child::after { display: none; }
.mini-timeline li.done::before { border-color: var(--success); background: var(--success); }
.mini-timeline li.current::before { border-color: var(--marker); background: var(--marker); box-shadow: 0 0 0 5px var(--marker-soft); }
.mini-timeline strong, .mini-timeline small, .activity-timeline strong, .activity-timeline small { display: block; }
.mini-timeline small, .activity-timeline small { color: var(--muted); font-size: 11px; }

.principles { padding: 70px 0; border-top: 1px solid var(--line); background: var(--panel-tint); }
.principle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.principle-grid article { padding-left: 20px; border-left: 1px solid var(--line-dark); }
.principle-grid span { color: var(--marker); font-family: "Vazirmatn FD", sans-serif; font-size: 28px; font-weight: 900; line-height: 1; }
.principle-grid h2 { margin: 12px 0 4px; font-size: 19px; }
.principle-grid p { margin: 0; color: var(--muted); font-size: 14px; }

.site-footer { padding: 24px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.site-footer .container { display: flex; justify-content: center; text-align: center; }
.page-head { padding: 60px 0 38px; border-bottom: 1px solid var(--line); background: var(--page-tint); }
.page-head-grid, .detail-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; }
.page-head h1, .page-title h1, .ticket-detail-head h1 { margin: 0; font-size: clamp(32px, 4vw, 52px); letter-spacing: -1.5px; }
.page-head p:last-child, .page-title > p:last-child { margin: 8px 0 0; color: var(--muted); }
.create-drawer { position: relative; }
.drawer-panel {
  position: absolute; z-index: 20; top: calc(100% + 16px); left: 0; width: min(520px, calc(100vw - 32px));
  max-height: 75vh; overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.ticket-workspace { padding-block: 32px 70px; }
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 25px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat-strip div { padding: 16px 22px; display: flex; align-items: baseline; gap: 10px; border-left: 1px solid var(--line); }
.stat-strip div:last-child { border-left: 0; }
.stat-strip strong { font-family: "Vazirmatn FD", sans-serif; font-size: 26px; font-weight: 900; line-height: 1; }
.stat-strip span { color: var(--muted); font-size: 12px; }
.filter-bar { display: grid; grid-template-columns: 1fr 180px 180px; gap: 10px; margin-bottom: 22px; }
.search-field { position: relative; }
.search-field span { position: absolute; top: 50%; left: 14px; transform: translateY(-50%); font-size: 22px; }
.filter-bar input, .filter-bar select {
  width: 100%; height: 44px; border: 1px solid var(--line-dark); border-radius: 9px; background: var(--surface); color: var(--ink-deep);
}
.filter-bar input { padding-inline: 14px; }
.filter-bar .search-field input { padding-left: 44px; }
.filter-bar select { padding-inline: 10px; }
.ticket-list { display: grid; gap: 10px; }
.ticket-row {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 280px;
  border: 1px solid var(--line); border-right: 5px solid var(--line-dark);
  border-radius: 14px; background: var(--surface);
  transition: border-color .15s, transform .15s, box-shadow .15s;
  overflow: hidden;
}
.ticket-row:hover {
  border-color: var(--line-dark); transform: translateX(-2px);
  box-shadow: 0 10px 24px rgba(var(--ink-rgb), .06);
}
.ticket-row.priority-high { border-right-color: #e28c3c; }
.ticket-row.priority-urgent { border-right-color: var(--danger); }
.ticket-row-main { padding: 18px 22px; text-decoration: none; color: inherit; }
.ticket-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ticket-reference { font-family: "Vazirmatn FD", sans-serif; font-size: 12px; font-weight: 800; line-height: 1.3; color: var(--muted); direction: ltr; }
.status-chip {
  width: fit-content; padding: 4px 9px; display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; background: #edf1f5; color: #40536a; font-size: 11px; font-weight: 800;
}
.status-chip i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-open { background: #e8f0fb; color: #315f9a; }
.status-in_progress { background: var(--marker-soft); color: #a83d14; }
.status-waiting { background: #f4eafb; color: #765092; }
.status-resolved { background: var(--success-soft); color: var(--success); }
.status-closed { background: #eceff1; color: #52616b; }
.priority-label { color: var(--muted); font-size: 11px; }
.ticket-row h2 { margin: 9px 0 3px; font-size: 18px; }
.ticket-row-main > p { max-width: 750px; margin: 0; color: var(--muted); font-size: 13px; }
.ticket-row-side {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px; align-items: center;
  padding: 14px 12px 14px 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 88%, var(--paper)) 0%, var(--paper) 100%);
}
.ticket-side-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; min-width: 0;
}
.ticket-side-item { min-width: 0; }
.ticket-side-item small {
  display: block; margin-bottom: 3px;
  color: var(--muted); font-size: 10px; font-weight: 700;
}
.ticket-side-item strong,
.ticket-side-item time {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-deep); font-size: 12px; font-weight: 800;
}
.reply-chip {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap;
}
.reply-awaiting { background: #ffe4d6; color: #a83d14; }
.reply-replied { background: var(--success-soft); color: var(--success); }
.reply-closed { background: #eef1f5; color: #5a6b7d; }
.row-arrow {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); color: var(--ink); text-decoration: none;
  transition: background .15s ease, transform .15s ease;
}
.row-arrow:hover { background: var(--marker-soft); transform: translateX(-2px); }
.empty-state { padding: 70px 20px; border: 1px dashed var(--line-dark); border-radius: var(--radius); text-align: center; }
.empty-state > span { font-size: 42px; color: var(--line-dark); }
.empty-state h2 { margin: 5px 0; }
.empty-state p, .empty-note, .empty-inline { color: var(--muted); }
.pagination { margin-top: 25px; display: flex; align-items: center; justify-content: center; gap: 18px; font-size: 13px; }
.pagination a { font-weight: 800; text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 3px; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px rgba(var(--ink-rgb),.045); }
.narrow-page { max-width: 760px; padding-block: 60px 90px; }
.page-title { margin-bottom: 26px; }
.form-panel, .auth-card { padding: 30px; }
.ticket-form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 800; }
.form-control, .auth-card input:not([type=checkbox]), .auth-card select, .auth-card textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-dark);
  border-radius: 9px; color: var(--ink-deep); background: var(--soft-surface);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.auth-card input[type=hidden] {
  display: none; width: 0; min-height: 0; padding: 0; border: 0;
}
textarea.form-control { resize: vertical; }
.form-control:focus, .auth-card input:not([type=checkbox]):focus {
  border-color: var(--ink); background: var(--surface); outline: 3px solid rgba(241,95,34,.35);
}
.form-checkbox, .auth-card input[type=checkbox] {
  width: 18px; height: 18px; margin: 0; accent-color: var(--ink); flex-shrink: 0; cursor: pointer;
}
.field-check {
  display: flex; align-items: center; gap: 10px;
  grid-template-columns: none;
}
.field-check label { order: 2; margin: 0; font-weight: 700; cursor: pointer; }
.field-help { color: var(--muted); font-size: 11px; }
.field-error, .form-errors { color: var(--danger); font-size: 12px; font-weight: 700; }
.form-errors { padding: 10px 12px; border: 1px solid #e8aaaa; border-radius: 8px; background: var(--danger-soft); }
.form-actions { display: flex; align-items: center; gap: 20px; margin-top: 5px; }
.htmx-indicator { display: none; color: var(--muted); font-size: 12px; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

.auth-page .site-footer { margin-top: auto; }
.auth-shell {
  min-height: calc(100vh - 180px); padding-block: 70px;
  display: grid; grid-template-columns: 1fr minmax(320px, 420px); align-items: center; gap: 72px;
}
.auth-note h1 {
  margin: 0; max-width: 600px;
  font-size: clamp(24px, 3vw, 34px); line-height: 1.35; letter-spacing: -1px;
}
.auth-note > p { max-width: 460px; color: var(--muted); font-size: 17px; }
.auth-highlights {
  margin: 28px 0 0; padding: 0; list-style: none;
  display: grid; gap: 12px; max-width: 420px;
}
.auth-highlights li {
  position: relative; padding: 12px 18px 12px 14px;
  border: 1px solid var(--line); border-right: 4px solid var(--marker);
  border-radius: 10px; background: var(--glass);
  color: var(--ink-deep); font-size: 13px; font-weight: 700;
}
.auth-card {
  position: relative; display: grid; gap: 16px; padding: 28px 28px 24px;
  overflow: hidden; box-shadow: 10px 14px 0 rgba(var(--ink-rgb), .06), var(--shadow);
}
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 0 auto; width: 5px; background: var(--marker);
}
.auth-card-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 4px;
}
.auth-card-head .eyebrow { margin: 0 0 2px; }
.auth-card-head h2 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.auth-card .helptext, .auth-card .helptext ul { color: var(--muted); font-size: 11px; }
.auth-card .helptext { margin: 0; }
.password-field { position: relative; }
.password-field input { padding-left: 72px; }
.password-toggle {
  position: absolute; top: 50%; left: 8px; transform: translateY(-50%);
  min-height: 32px; padding: 0 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 800;
  cursor: pointer;
}
.password-toggle:hover,
.password-toggle[aria-pressed="true"] { color: var(--ink); background: var(--marker-soft); }
.auth-captcha-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.auth-captcha-row img.captcha {
  display: block;
  width: auto;
  height: 48px;
  min-height: 48px;
  max-width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}
.auth-captcha-row input[type="text"] {
  flex: 1 1 120px;
  min-width: 120px;
}
.auth-captcha-refresh {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  background: var(--soft-surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.auth-captcha-refresh:hover {
  background: var(--marker-soft);
  border-color: var(--ink);
}
.auth-remember { margin-top: 2px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--soft-surface); }
.auth-submit { margin-top: 6px; min-height: 48px; }
.form-foot {
  margin: 4px 0 0; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.8;
}
.form-foot a {
  color: var(--ink); font-weight: 800;
  text-decoration: underline; text-decoration-color: var(--marker);
  text-decoration-thickness: 3px; text-underline-offset: 4px;
}

.profile-page { padding-block: 36px 80px; }
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.profile-card { padding: 24px 26px; }
.profile-card-wide { grid-column: 1 / -1; }
.profile-card-head { margin-bottom: 18px; }
.profile-card-head h2 { margin: 0; font-size: 18px; letter-spacing: -.3px; }
.profile-facts {
  margin: 0; padding: 0;
  display: grid; gap: 14px;
}
.profile-facts > div {
  padding-bottom: 12px; border-bottom: 1px dashed var(--line);
}
.profile-facts > div:last-child { padding-bottom: 0; border-bottom: 0; }
.profile-facts dt { margin: 0; color: var(--muted); font-size: 12px; font-weight: 800; }
.profile-facts dd { margin: 0; font-size: 15px; font-weight: 700; }
.profile-fact-row {
  display: flex;
  align-items: baseline;
  gap: 10px 14px;
}
.profile-fact-row dt { flex: 0 0 auto; }
.profile-fact-row dt::after { content: ":"; }
.profile-fact-row dd {
  flex: 0 1 auto;
  min-width: 0;
  word-break: break-word;
}
.profile-fact-stack {
  display: grid;
  gap: 8px;
}
.profile-phone-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.profile-phone-list li {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.profile-alert { color: var(--danger); }
.profile-product-list {
  margin: 0; padding: 0; list-style: none;
  display: grid; gap: 12px;
}
.profile-product-list li {
  display: grid; gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-right: 4px solid var(--marker);
  border-radius: 10px;
  background: var(--soft-surface);
}
.profile-product-list strong { font-size: 15px; }
.profile-product-list span { color: var(--muted); font-size: 13px; }
@media (prefers-reduced-motion: reduce) {
  .button, .form-control, .auth-card input:not([type=checkbox]) {
    transition: none;
  }
  .button:hover { transform: none; }
}

.ticket-detail-head { padding: 42px 0 30px; border-bottom: 1px solid var(--line); background: var(--page-tint); }
.ticket-detail-head h1 { margin-top: 12px; font-size: clamp(28px, 4vw, 44px); }
.detail-grid { padding-block: 32px 80px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 25px; align-items: start; }
.detail-main { min-width: 0; display: grid; gap: 34px; }
.description-card { padding: 28px; }
.description-card h2, .detail-sidebar h2, .chat-aside h2 { margin: 0 0 16px; font-size: 16px; }
.prose { overflow-wrap: anywhere; }
.prose p { margin: 0 0 10px; }
.ticket-facts { display: grid; grid-template-columns: repeat(3, 1fr); margin: 28px 0 0; padding-top: 20px; border-top: 1px solid var(--line); }
.ticket-facts div { padding-left: 15px; border-left: 1px solid var(--line); }
.ticket-facts div:last-child { border: 0; }
.ticket-facts dt { color: var(--muted); font-size: 10px; }
.ticket-facts dd { margin: 2px 0 0; font-size: 12px; font-weight: 800; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 15px; }
.section-heading h2 { margin: 0; font-size: 24px; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.comment-list { display: grid; gap: 12px; margin-bottom: 15px; }
.comment { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.comment-internal { border-color: #f0a080; background: color-mix(in srgb, var(--marker) 18%, var(--surface)); }
.comment header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.avatar { width: 36px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: var(--fill); color: var(--on-fill); font-weight: 900; }
.comment header strong, .comment header small { display: block; }
.comment header small { color: var(--muted); font-size: 10px; }
.internal-badge { margin-right: auto; color: #a83d14; font-size: 10px; font-weight: 800; }
.comment-form { padding: 22px; }
.comment-form h3 { margin: 0; }
.empty-inline { padding: 22px; border: 1px dashed var(--line-dark); border-radius: 10px; text-align: center; font-size: 12px; }
.detail-sidebar { position: sticky; top: 100px; display: grid; gap: 16px; }
.detail-sidebar .panel { padding: 22px; }
.activity-timeline li { padding-bottom: 18px; }
.activity-timeline li i { top: 7px; width: 9px; height: 9px; border: 0; background: var(--marker); }
.activity-timeline li::after { right: 4px; top: 18px; }
.activity-timeline strong { font-size: 11px; }
.attachment-list {
  padding: 0;
  margin: 0 0 18px;
  list-style: none;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.attachment-list li {
  min-width: 0;
  max-width: 100%;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.attachment-list a,
.attachment-list small {
  display: block;
  min-width: 0;
  max-width: 100%;
}
.attachment-list a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}
.attachment-list small { color: var(--muted); font-size: 10px; }
.attachment-form { display: grid; gap: 9px; }
.attachment-form input { width: 100%; font-size: 11px; }
.attachment-form small { color: var(--muted); font-size: 9px; }

/* Ticket chat (WhatsApp/Telegram-like) — lock page, scroll only the thread */
body.ticket-chat-page {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 12% 0%, rgba(241,95,34,.16), transparent 34%),
    radial-gradient(circle at 90% 8%, rgba(24,49,83,.08), transparent 28%),
    var(--paper);
}
body.ticket-chat-page .site-header { flex-shrink: 0; }
body.ticket-chat-page .site-footer { display: none; }
body.ticket-chat-page #main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.ticket-chat-page .chat-shell {
  flex: 1;
  min-height: 0;
  width: min(1160px, calc(100% - 32px));
  margin-inline: auto;
  padding-block: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.num-fa { font-family: "Vazirmatn FD", sans-serif; font-variant-numeric: normal; }

.chat-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px 16px;
  flex-shrink: 0;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 10px 28px rgba(var(--ink-rgb),.05);
}
.chat-back {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--soft-surface); color: var(--ink); text-decoration: none;
  transition: background .15s ease, transform .15s ease;
}
.chat-back:hover { background: var(--marker-soft); transform: translateX(-1px); }
.chat-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-avatar {
  width: 44px; aspect-ratio: 1; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 14px; background: var(--fill); color: var(--on-fill);
  font-size: 18px; font-weight: 900;
  box-shadow: 3px 3px 0 var(--marker);
}
.chat-identity-text { min-width: 0; }
.chat-identity-text h1 {
  margin: 0; font-size: clamp(16px, 2.2vw, 20px);
  letter-spacing: -.3px; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-topbar-sub {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  margin: 4px 0 0; color: var(--muted); font-size: 11px; font-weight: 700;
}
.chat-topbar-sub span {
  position: relative; padding-inline-end: 10px;
}
.chat-topbar-sub span:not(:last-child)::after {
  content: ""; position: absolute; inset-inline-end: 0; top: 50%;
  width: 3px; height: 3px; border-radius: 50%;
  background: #9db0bf; transform: translateY(-50%);
}
.chat-topbar-chips {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; flex-wrap: wrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--soft-surface); color: var(--ink); font-size: 11px; font-weight: 800;
}
.chip-ref {
  font-family: "Vazirmatn FD", sans-serif;
  direction: ltr; color: var(--muted);
}
.chip-priority {
  border-color: transparent; background: var(--marker-soft); color: #a83d14;
}
.chat-topbar-chips .status-chip { margin: 0; }

.chat-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px; align-items: stretch;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.chat-main {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 12px;
  overflow: hidden;
}
.chat-context-facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px; margin: 0; padding: 12px 14px;
  flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  box-shadow: 0 8px 20px rgba(24,49,83,.04);
}
.chat-context-facts div {
  min-width: 0; padding: 4px 10px 4px 0;
  border-inline-end: 1px solid var(--line);
}
.chat-context-facts div:last-child { border: 0; padding-inline-end: 0; }
.chat-context-facts dt {
  margin: 0; color: var(--muted); font-size: 10px; font-weight: 700;
}
.chat-context-facts dd {
  margin: 4px 0 0; font-size: 13px; font-weight: 800; color: var(--ink-deep);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-panel {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  background: linear-gradient(180deg, #edf3f7 0%, #e7eef4 100%);
  box-shadow: 0 14px 36px rgba(24,49,83,.06);
}
.chat-thread {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 18px 12px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
  background-image:
    radial-gradient(rgba(24,49,83,.035) 1px, transparent 1px);
  background-size: 18px 18px;
}
.chat-empty {
  margin: auto; padding: 16px 18px;
  border: 1px dashed #b7c5d1; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--muted);
  font-size: 12px; font-weight: 700;
}
.chat-day-separator {
  display: flex;
  align-items: center;
  gap: 14px;
  align-self: stretch;
  width: 100%;
  max-width: none;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}
.chat-day-separator::before,
.chat-day-separator::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: rgba(24, 49, 83, .18);
  border-radius: 1px;
}
.chat-day-separator span {
  flex: 0 0 auto;
  padding: 0 2px;
  white-space: nowrap;
}
.chat-bubble {
  max-width: min(78%, 560px); padding: 10px 12px 8px;
  border-radius: 16px; background: var(--surface);
  border: 1px solid rgba(24,49,83,.06);
  box-shadow: 0 4px 14px rgba(24,49,83,.05);
  /* Physical sides (RTL-safe): others on the left */
  margin-right: auto;
  margin-left: 0;
  border-bottom-left-radius: 5px;
}
.chat-bubble-mine {
  /* Own messages on the physical right */
  margin-left: auto;
  margin-right: 0;
  background: #dff0ff;
  border-color: rgba(24,49,83,.1);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 5px;
}
.chat-bubble-theirs {
  margin-right: auto;
  margin-left: 0;
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 5px;
}
.chat-bubble-internal {
  background: #fff8e3; border-color: #e5c96a;
}
.chat-bubble-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.chat-bubble-meta strong { font-size: 11px; color: var(--ink); }
.chat-bubble-meta .internal-badge { margin: 0; }
.chat-bubble-meta time {
  margin-inline-start: auto;
  color: var(--muted); font-size: 10px; font-weight: 700;
  font-family: "Vazirmatn FD", sans-serif; white-space: nowrap;
}
.chat-bubble-body {
  margin: 0; color: var(--ink-deep); font-size: 13.5px; line-height: 1.75;
  overflow-wrap: anywhere;
}
.chat-bubble-files {
  margin: 10px 0 0; padding: 0; list-style: none;
}
.chat-bubble-files li { margin-top: 4px; }
.chat-bubble-files a {
  display: block;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  padding: 4px 8px; border-radius: 8px;
  background: rgba(24,49,83,.06); color: var(--ink);
  font-size: 11px; font-weight: 800; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-composer {
  display: grid; gap: 8px; padding: 12px 14px 14px; flex-shrink: 0;
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent);
}
.chat-locked-note {
  margin: 0; padding: 14px 16px; flex-shrink: 0;
  border-top: 1px solid var(--line); background: #f7f8fa;
  color: var(--muted); font-size: 13px; font-weight: 700; text-align: center;
}
.chat-composer-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px; align-items: end;
}
.chat-input {
  min-height: 48px; max-height: 140px; resize: none;
  border-radius: 14px !important; padding: 12px 14px !important;
  background: #f7fafc !important;
}
.chat-send {
  min-width: 88px; min-height: 48px; border-radius: 14px;
}
.chat-internal-toggle {
  width: fit-content; margin: 0; padding: 6px 10px;
  border-radius: 999px; background: var(--marker-soft);
  font-size: 12px; font-weight: 700;
}
.chat-aside {
  display: grid; gap: 14px; align-content: start;
  min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-aside .panel {
  min-width: 0;
  max-width: 100%;
  padding: 18px;
  overflow: hidden;
}
.activity-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
}
.activity-panel-head h2 { margin: 0; }
.activity-expand {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--line-dark); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 20px; font-weight: 800;
  line-height: 1; cursor: pointer; box-shadow: 2px 2px 0 var(--marker);
}
.activity-expand:hover { transform: translate(-1px, -1px); }
.activity-timeline-latest li { padding-bottom: 0; }
.activity-timeline-latest li::after { display: none; }
.activity-dialog {
  width: min(520px, calc(100vw - 28px)); max-height: min(78vh, 640px);
  padding: 0; border: 1px solid var(--line-dark); border-radius: 16px;
  background: var(--surface); color: var(--ink-deep);
  box-shadow: 0 24px 60px rgba(24,49,83,.18);
}
.activity-dialog::backdrop { background: rgba(16, 35, 61, .45); }
.activity-dialog-inner { margin: 0; }
.activity-dialog-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 18px 12px; border-bottom: 1px solid var(--line);
}
.activity-dialog-head h2 { margin: 4px 0 0; font-size: 18px; }
.activity-dialog-close {
  width: 34px; height: 34px; border: 0; border-radius: 10px;
  background: #f3f6f8; color: var(--ink); font-size: 22px; cursor: pointer;
}
.activity-timeline-full { padding: 16px 18px 8px; overflow: auto; max-height: min(58vh, 480px); }
.related-help ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.related-help li a { display: block; font-size: 12px; font-weight: 800; }
.related-help li small { color: var(--muted); font-size: 10px; }

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

.kb-hero {
  padding: 76px 0 58px; border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 80%, transparent), rgba(241,95,34,.08));
  text-align: center;
}
.kb-hero h1, .dashboard-head h1, .article-head h1 {
  margin: 0; font-size: clamp(38px, 5vw, 62px); letter-spacing: -2px;
}
.kb-hero > .container > p:last-of-type { margin: 10px auto 30px; color: var(--muted); font-size: 17px; }
.kb-search {
  max-width: 850px; margin: 0 auto; padding: 10px; display: grid;
  grid-template-columns: minmax(0, 1fr) 210px auto; gap: 8px;
  border: 1px solid var(--line-dark); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
}
.kb-search input, .kb-search select {
  width: 100%; height: 48px; padding-inline: 14px; border: 0; border-radius: 8px;
  color: var(--ink-deep); background: #f7f9fa;
}
.kb-search input:focus, .kb-search select:focus { outline: 3px solid rgba(241,95,34,.35); }
.kb-workspace { padding-block: 45px 85px; }
.featured-strip { margin-bottom: 48px; }
.featured-grid, .article-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.featured-grid .article-card { border-top: 5px solid var(--marker); }
.kb-list-heading { margin-top: 10px; }
.article-card {
  min-width: 0; padding: 23px; display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 13px; background: var(--surface);
  box-shadow: 0 8px 24px rgba(24,49,83,.04); transition: transform .15s, border-color .15s;
}
.article-card:hover { border-color: #9db0bf; transform: translateY(-2px); }
.article-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.category-pill, .featured-label {
  width: fit-content; padding: 4px 10px; border-radius: 999px; font-size: 10px; font-weight: 800;
}
.category-pill { color: #315f9a; background: #e8f0fb; }
.featured-label { color: #a83d14; background: var(--marker-soft); }
.article-card h2 { margin: 18px 0 8px; font-size: 19px; line-height: 1.5; }
.article-card > p { flex: 1; margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.article-card footer {
  padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 11px;
}
.article-card footer .text-link { color: var(--ink); }
.article-empty { grid-column: 1 / -1; }

.article-head { padding: 58px 0 38px; border-bottom: 1px solid var(--line); background: var(--panel-tint); }
.article-container { max-width: 920px; }
.article-head h1 { margin-top: 15px; font-size: clamp(34px, 5vw, 54px); line-height: 1.35; }
.article-head .article-container > p { max-width: 760px; margin: 14px 0; color: var(--muted); font-size: 18px; }
.article-byline { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.article-layout {
  max-width: 1040px; padding-block: 35px 90px; display: grid;
  grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start;
}
.article-body { padding: 34px; }
.article-prose { color: #263d59; font-size: 16px; line-height: 2.05; }
.article-prose p { margin-bottom: 20px; }
.article-feedback {
  margin-top: 42px; padding-top: 22px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; border-top: 1px solid var(--line);
}
.article-feedback strong, .article-feedback small { display: block; }
.article-feedback small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.article-feedback form { display: flex; gap: 8px; }
.feedback-button {
  min-width: 58px; padding: 7px 12px; border: 1px solid var(--line-dark);
  border-radius: 8px; color: var(--ink); background: var(--surface); font-weight: 800; cursor: pointer;
}
.feedback-button.selected { border-color: var(--ink); background: var(--marker-soft); }
.article-sidebar { position: sticky; top: 100px; display: grid; gap: 15px; }
.article-sidebar .panel { padding: 20px; }
.article-admin-actions { display: grid; gap: 12px; }
.article-admin-actions h2 { margin: 0; font-size: 15px; }
.related-help ul { padding: 0; margin: 0; list-style: none; }
.related-help li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.related-help li:last-child { border-bottom: 0; }
.related-help a, .related-help small { display: block; }
.related-help a { font-size: 12px; font-weight: 800; }
.related-help small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.kb-suggestions:empty { display: none; }
.suggestion-box {
  padding: 13px; border: 1px solid #d9c06d; border-radius: 10px;
  background: color-mix(in srgb, var(--marker) 18%, var(--surface)); color: var(--ink-deep);
}
.suggestion-box > strong { display: block; margin-bottom: 7px; font-size: 11px; }
.suggestion-box ul { padding: 0; margin: 0; list-style: none; }
.suggestion-box li + li { border-top: 1px solid #eadcae; }
.suggestion-box a { padding: 7px 2px; display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.suggestion-box a span { font-weight: 800; }
.suggestion-box a small { color: var(--muted); white-space: nowrap; }

.manage-workspace { padding-block: 32px 80px; }
.manage-filter { grid-template-columns: minmax(0, 1fr) 220px auto; }
.manage-table-wrap { overflow-x: auto; }
.manage-table { width: 100%; border-collapse: collapse; text-align: right; }
.manage-table th, .manage-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.manage-table th { color: var(--muted); background: #f8fafb; font-size: 10px; }
.manage-table td { font-size: 12px; }
.manage-table td:first-child { min-width: 260px; white-space: normal; }
.manage-table td strong, .manage-table td small { display: block; }
.manage-table td small { color: var(--muted); font-size: 10px; }
.manage-table tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; align-items: center; gap: 10px; }
.row-actions a, .row-actions button {
  padding: 0; border: 0; color: var(--ink); background: none; font-size: 11px;
  font-weight: 800; text-decoration: underline; text-decoration-color: var(--marker);
  text-decoration-thickness: 2px; cursor: pointer;
}
.content-status { padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-content-draft { color: #52616b; background: #eceff1; }
.status-content-review { color: #765092; background: #f4eafb; }
.status-content-published { color: var(--success); background: var(--success-soft); }
.status-content-archived { color: #765d5d; background: #f4ecec; }
.content-form-page { max-width: 920px; padding-block: 58px 90px; }
.content-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.content-form .field:nth-child(4), .content-form .field:nth-child(5),
.content-form .field:nth-child(6), .content-form .form-errors, .content-form .form-actions {
  grid-column: 1 / -1;
}

.dashboard-head { padding: 58px 0 38px; border-bottom: 1px solid var(--line); background: var(--page-tint); }
.dashboard-head p:last-child { margin: 8px 0 0; color: var(--muted); }
.dashboard-workspace { padding-block: 32px 85px; }
.metric-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 20px; }
.metric-grid article {
  min-width: 0; padding: 18px; border: 1px solid var(--line); border-top: 4px solid var(--ink);
  border-radius: 12px; background: var(--surface);
}
.metric-grid article > span, .metric-grid article > strong, .metric-grid article > small { display: block; }
.metric-grid article > span { color: var(--muted); font-size: 10px; font-weight: 800; }
.metric-grid article > strong { margin: 5px 0; font-size: 30px; line-height: 1.2; }
.metric-grid article > small { overflow: hidden; color: var(--muted); font-size: 9px; white-space: nowrap; }
.metric-grid .metric-danger { border-top-color: var(--danger); }
.metric-grid .metric-success { border-top-color: var(--success); }
.dashboard-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; margin-top: 18px; }
.dashboard-grid-wide { grid-template-columns: 1.4fr .6fr; }
.dashboard-panel { min-width: 0; padding: 22px; }
.dashboard-panel .section-heading { margin-bottom: 18px; }
.trend-chart { height: 230px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; }
.trend-column { height: 100%; display: grid; grid-template-rows: 22px 1fr 22px; gap: 5px; text-align: center; }
.trend-column > span { color: var(--muted); font-size: 10px; }
.trend-column > div { min-height: 150px; display: flex; align-items: end; border-radius: 6px; background: #f0f3f6; overflow: hidden; }
.trend-column i { width: 100%; min-height: 3px; display: block; background: var(--fill); border-top: 4px solid var(--marker); }
.trend-column small { color: var(--muted); font-size: 9px; }
.compact-list { display: grid; }
.compact-list > a {
  min-width: 0; padding: 11px 0; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; border-bottom: 1px solid var(--line);
}
.compact-list > a:last-child { border-bottom: 0; }
.compact-list > a span { min-width: 0; }
.compact-list strong, .compact-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-list strong { font-size: 12px; }
.compact-list small { color: var(--muted); font-size: 9px; }
.compact-list b { color: var(--muted); font-size: 9px; white-space: nowrap; }
.workload-list { display: grid; gap: 10px; }
.workload-list > div { padding: 8px 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.workload-list span strong, .workload-list span small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workload-list span strong { font-size: 11px; }
.workload-list span small { color: var(--muted); font-size: 9px; }
.workload-list b { padding: 4px 8px; border-radius: 999px; color: #315f9a; background: #e8f0fb; font-size: 9px; }
.knowledge-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 15px; border: 1px solid var(--line); border-radius: 10px; }
.knowledge-stats div { padding: 12px; border-left: 1px solid var(--line); text-align: center; }
.knowledge-stats div:last-child { border-left: 0; }
.knowledge-stats strong, .knowledge-stats span { display: block; }
.knowledge-stats strong { font-size: 21px; }
.knowledge-stats span { color: var(--muted); font-size: 8px; }
.user-summary > strong { display: block; margin-top: 20px; font-size: 62px; line-height: 1; }
.user-summary > p { margin: 5px 0 22px; color: var(--muted); }
.user-summary > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
.user-summary > div:last-child span { padding: 6px 9px; border-radius: 999px; color: #315f9a; background: #e8f0fb; font-size: 10px; }

@media (max-width: 900px) {
  .hero-grid, .auth-shell { grid-template-columns: 1fr; gap: 45px; }
  .auth-card { order: -1; }
  .hero { padding-block: 70px; }
  .hero-ledger { max-width: 620px; }
  .ticket-row { grid-template-columns: 1fr; }
  .ticket-row-side { border-top: 1px solid var(--line); border-right: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-card-wide { grid-column: auto; }
  .chat-layout { grid-template-columns: 1fr; min-height: 0; overflow: visible; }
  body.ticket-chat-page .chat-shell { overflow-y: auto; }
  .chat-panel { height: min(58dvh, 520px); min-height: 0; flex: none; }
  .chat-topbar {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .chat-topbar-chips { grid-column: 1 / -1; justify-content: flex-start; }
  .detail-sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .featured-grid, .article-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-layout { grid-template-columns: 1fr; }
  .article-sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid, .dashboard-grid-wide { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .container { width: min(100% - 22px, 1160px); }
  .nav-shell { min-height: 66px; }
  .brand small, .main-nav > a:not(.button):not(.knowledge-nav-link) { display: none; }
  .main-nav { gap: 10px; }
  .knowledge-nav-link { font-size: 11px !important; }
  .hero h1 { font-size: 36px; letter-spacing: -2px; }
  .hero h1 .hero-title-lead,
  .hero h1 .hero-title-trail { font-size: 17px; }
  .hero-actions, .page-head-grid, .detail-title-row { align-items: stretch; flex-direction: column; }
  .hero-ledger { padding: 22px; }
  .principle-grid, .stat-strip, .ticket-facts, .detail-sidebar, .chat-context-facts { grid-template-columns: 1fr; }
  .principle-grid article { border-left: 0; border-bottom: 1px solid var(--line); padding: 0 0 20px; }
  .stat-strip div { border-left: 0; border-bottom: 1px solid var(--line); }
  .filter-bar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .ticket-row-side { grid-template-columns: minmax(0, 1fr) auto; }
  .ticket-side-grid { grid-template-columns: 1fr 1fr; }
  .ticket-facts div { padding: 9px 0; border-left: 0; border-bottom: 1px solid var(--line); }
  .chat-context-facts div {
    padding: 8px 0; border-inline-end: 0; border-bottom: 1px solid var(--line);
  }
  .chat-context-facts div:last-child { border-bottom: 0; }
  .chat-identity-text h1 { white-space: normal; }
  .drawer-panel { position: fixed; inset: 80px 11px auto; width: auto; }
  .auth-shell { padding-block: 36px 56px; gap: 28px; }
  .auth-note h1 { font-size: 32px; letter-spacing: -1.5px; }
  .auth-highlights { margin-top: 18px; }
  .form-panel, .auth-card, .description-card { padding: 20px; }
  .auth-card { box-shadow: 6px 8px 0 rgba(24, 49, 83, .05), var(--shadow); }
  .password-field input { padding-left: 68px; }
  .kb-hero { padding-block: 50px 38px; }
  .kb-search { grid-template-columns: 1fr; }
  .featured-grid, .article-grid, .article-sidebar { grid-template-columns: 1fr; }
  .article-body { padding: 21px; }
  .article-feedback { align-items: stretch; flex-direction: column; }
  .article-feedback form { width: 100%; }
  .feedback-button { flex: 1; }
  .heading-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .manage-filter { grid-template-columns: 1fr; }
  .content-form { grid-template-columns: 1fr; }
  .content-form .field { grid-column: 1 !important; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .knowledge-stats { grid-template-columns: repeat(2, 1fr); }
  .knowledge-stats div:nth-child(2) { border-left: 0; }
  .knowledge-stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

html[data-theme="dark"] .status-chip { background: #243246; color: #c5d2e0; }
html[data-theme="dark"] .status-open { background: #1d2f48; color: #8fb6e8; }
html[data-theme="dark"] .status-in_progress { background: var(--marker-soft); color: #f5a070; }
html[data-theme="dark"] .status-waiting { background: #2d2440; color: #c3a4e4; }
html[data-theme="dark"] .status-closed { background: #24303a; color: #9aabbc; }
html[data-theme="dark"] .reply-awaiting { background: var(--marker-soft); color: #f5a070; }
html[data-theme="dark"] .reply-closed { background: #24303a; color: #9aabbc; }

/* گفتگوی تیکت + دیالوگ سابقه در دارک مود */
html[data-theme="dark"] .chat-panel {
  background: linear-gradient(180deg, #152033 0%, #121c2c 100%);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .28);
}
html[data-theme="dark"] .chat-thread {
  background-image: radial-gradient(rgba(215, 226, 238, .06) 1px, transparent 1px);
}
html[data-theme="dark"] .chat-empty {
  border-color: var(--line-dark);
}
html[data-theme="dark"] .chat-day-separator::before,
html[data-theme="dark"] .chat-day-separator::after {
  background: rgba(215, 226, 238, .2);
}
html[data-theme="dark"] .chat-bubble {
  border-color: rgba(215, 226, 238, .1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
}
html[data-theme="dark"] .chat-bubble-mine {
  background: #243a55;
  border-color: rgba(147, 197, 253, .28);
}
html[data-theme="dark"] .chat-bubble-theirs {
  background: var(--surface);
  border-color: rgba(215, 226, 238, .12);
}
html[data-theme="dark"] .chat-bubble-internal {
  background: var(--marker-soft);
  border-color: #a8892e;
}
html[data-theme="dark"] .chat-bubble-files a {
  background: rgba(215, 226, 238, .1);
}
html[data-theme="dark"] .chat-composer {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}
html[data-theme="dark"] .chat-locked-note {
  background: var(--soft-surface);
  color: var(--muted);
}
html[data-theme="dark"] .chat-input {
  background: var(--soft-surface) !important;
  color: var(--ink-deep) !important;
  border-color: var(--line-dark) !important;
}
html[data-theme="dark"] .activity-dialog-close {
  background: var(--soft-surface);
  color: var(--ink-deep);
}
html[data-theme="dark"] .activity-dialog-close:hover {
  background: #2c3b4d;
}
html[data-theme="dark"] .activity-dialog::backdrop {
  background: rgba(0, 0, 0, .55);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
