/* ظاهر هماهنگ با سایت کاریاحساب — همان فونت و همان پالت رنگی */

@font-face {
  font-family: "Yekan Bakh";
  src: url("fonts/sakou-font-1.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Yekan Bakh";
  src: url("fonts/sakou-font-2.woff2") format("woff2");
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: "Yekan Bakh";
  src: url("fonts/sakou-font-3.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}

:root {
  --bg: #eef2f4;
  --bg-glow: radial-gradient(1100px 460px at 78% -12%, #dae6ff 0%, transparent 62%),
             radial-gradient(760px 380px at 0% 100%, #dff0ea 0%, transparent 58%);
  --surface: #ffffff;
  --surface-2: #f3f7f9;
  --surface-3: #e2eaef;
  --ink: #0c1e21;
  --ink-soft: #364e52;
  --ink-faint: #67787a;
  --ink-ghost: #a9b8b8;
  --brand: #124497;
  --brand-2: #4d84e8;
  --brand-3: #86acea;
  --brand-soft: #e7eefb;
  --brand-deep: #0d3272;
  --brand-grad: linear-gradient(135deg, #124497, #3d78dd);
  --ok: #0e8a5f;
  --ok-soft: #ddf3ea;
  --warn: #a4650c;
  --warn-soft: #fcf0dd;
  --err: #c23b34;
  --err-soft: #fbeae9;
  /* رنگ‌های کمکی برای برچسب‌ها و کارت‌های آمار */
  --c1: #1f7a8c; --c1-soft: #dcf0f3;
  --c2: #6b4ea8; --c2-soft: #ece6f8;
  --c3: #b0553a; --c3-soft: #f9e8e2;
  --c4: #2f7d4f; --c4-soft: #e0f2e7;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 4px rgba(12, 30, 33, .06);
  --shadow: 0 6px 18px rgba(12, 30, 33, .09);
  --shadow-lift: 0 10px 26px rgba(18, 68, 151, .16);
  --ease: cubic-bezier(.22, .72, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101a1c;
    --bg-glow: radial-gradient(1100px 460px at 78% -12%, #16304f 0%, transparent 62%),
               radial-gradient(760px 380px at 0% 100%, #14322c 0%, transparent 58%);
    --surface: #18262a;
    --surface-2: #1f2f33;
    --surface-3: #26383d;
    --ink: #e7eeee;
    --ink-soft: #b6c6c6;
    --ink-faint: #8b9d9d;
    --ink-ghost: #67787a;
    --brand: #5f8de0;
    --brand-2: #86acea;
    --brand-3: #a9c5f3;
    --brand-soft: #1b2c48;
    --brand-deep: #9dbdf2;
    --brand-grad: linear-gradient(135deg, #2a5cb0, #5f8de0);
    --ok: #3cc394; --ok-soft: #14322a;
    --warn: #d79b3f; --warn-soft: #322813;
    --err: #e8756c; --err-soft: #33201e;
    --c1: #4fb3c4; --c1-soft: #15343a;
    --c2: #a98ee0; --c2-soft: #2a2340;
    --c3: #dd8f74; --c3-soft: #3a2620;
    --c4: #5cb583; --c4-soft: #163224;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, .3);
    --shadow: 0 6px 18px rgba(0, 0, 0, .4);
    --shadow-lift: 0 10px 26px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Yekan Bakh", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.65;
  direction: rtl;
}

h1, h2, h3 { color: var(--ink); font-weight: 700; }

summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }

a { color: var(--brand); text-decoration: none; transition: color .16s var(--ease); }
a:hover { color: var(--brand-deep); }

/* ---------- چیدمان ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px; flex-shrink: 0; padding: 16px 12px;
  background: var(--surface); box-shadow: var(--shadow-sm);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px; color: var(--ink);
  margin-bottom: 16px; padding-inline-start: 4px;
}
.brand .dot {
  width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 10px rgba(18, 68, 151, .3);
  transition: transform .3s var(--ease);
}
.brand:hover .dot { transform: rotate(-10deg) scale(1.06); }

/* ---------- انتخابگر میز کار ---------- */
.ws-picker { margin-bottom: 14px; }
.ws-current {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  background: var(--brand-soft); border-radius: var(--radius);
  padding: 8px 12px; cursor: pointer;
  transition: background .16s var(--ease), transform .16s var(--ease);
}
.ws-current:hover { background: var(--surface-3); transform: translateY(-1px); }
.ws-label { font-size: 10.5px; color: var(--ink-faint); line-height: 1.4; }
.ws-name { font-weight: 700; font-size: 13.5px; color: var(--brand-deep); }
.ws-picker[open] .ws-current .caret { transform: rotate(180deg); }
.ws-picker .caret { color: var(--ink-faint); font-size: 10px; transition: transform .2s var(--ease); }
.ws-list { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.ws-list a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  transition: background .16s var(--ease), transform .16s var(--ease);
}
.ws-list a:hover { background: var(--surface-2); transform: translateX(-3px); }
.ws-list .ws-manage { color: var(--brand); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: var(--radius);
  color: var(--ink-soft); font-weight: 600; font-size: 13.5px;
  transition: background .16s var(--ease), color .16s var(--ease), transform .16s var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); transform: translateX(-3px); }
.nav a.active { background: var(--brand-grad); color: #fff; box-shadow: 0 5px 14px rgba(18, 68, 151, .3); }
.nav a.active:hover { color: #fff; }
.nav .ico { font-size: 15px; width: 16px; text-align: center; }
.nav .sep { height: 1px; background: var(--surface-3); margin: 8px 6px; border-radius: 2px; }

.main { flex: 1; padding: 18px 22px 40px; min-width: 0; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.page-head h1 {
  margin: 0; font-size: 18px; position: relative; padding-inline-start: 11px;
}
.page-head h1::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 4px; bottom: 4px;
  width: 4px; border-radius: 3px; background: var(--brand-grad);
}
.page-head .sub { color: var(--ink-faint); font-size: 12px; margin-top: 1px; padding-inline-start: 11px; }

/* ---------- کارت ---------- */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 14px 16px; margin-bottom: 12px;
  transition: box-shadow .25s var(--ease);
}
.card:hover { box-shadow: var(--shadow); }
.card h2 { margin: 0 0 2px; font-size: 14px; }
.card .hint { color: var(--ink-faint); font-size: 11.5px; line-height: 1.6; margin-bottom: 10px; }

.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* ---------- آمار ---------- */
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 11px 14px 11px 14px; box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.stat::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
  width: 4px; background: var(--brand-grad); opacity: .9;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat .num { font-size: 21px; font-weight: 700; color: var(--brand); line-height: 1.3; }
.stat .lbl { color: var(--ink-faint); font-size: 11.5px; }
.stat.ok .num { color: var(--ok); }
.stat.ok::before { background: linear-gradient(180deg, #17b07c, #0e8a5f); }
.stat.warn .num { color: var(--warn); }
.stat.warn::before { background: linear-gradient(180deg, #e0a13c, #a4650c); }
.stat.err .num { color: var(--err); }
.stat.err::before { background: linear-gradient(180deg, #e07068, #c23b34); }
.stat.c1 .num { color: var(--c1); } .stat.c1::before { background: var(--c1); }
.stat.c2 .num { color: var(--c2); } .stat.c2::before { background: var(--c2); }
.stat.c3 .num { color: var(--c3); } .stat.c3::before { background: var(--c3); }
.stat.c4 .num { color: var(--c4); } .stat.c4::before { background: var(--c4); }

/* ---------- فرم ---------- */
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-faint); margin-bottom: 3px; }

input[type=text], input[type=password], input[type=number], input[type=search],
input[type=file], select, textarea {
  width: 100%; padding: 7px 11px;
  background: var(--surface-2);
  border: 1.5px solid transparent; border-radius: var(--radius);
  color: var(--ink); font: inherit; font-size: 13px;
  transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; background: var(--surface);
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { min-height: 130px; resize: vertical; line-height: 1.85; }
textarea.tall { min-height: 240px; }
input[type=range] { padding: 0; background: none; }

.field { margin-bottom: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row.tight > * { flex: 0 1 auto; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 15px; border: none; border-radius: var(--radius);
  background: var(--brand-grad); color: #fff;
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  box-shadow: 0 3px 10px rgba(18, 68, 151, .24);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), filter .16s var(--ease);
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; transform: none; filter: none; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 16px rgba(18, 68, 151, .3); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: var(--surface-2); color: var(--ink-soft); box-shadow: none; }
.btn.ghost:hover { background: var(--brand-soft); color: var(--brand-deep); }
.btn.danger { background: var(--err); box-shadow: 0 3px 10px rgba(194, 59, 52, .22); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }

/* ---------- جدول ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0 5px; }
.table th {
  text-align: right; font-size: 11.5px; color: var(--ink-faint);
  font-weight: 600; padding: 0 11px 2px;
}
.table td { background: var(--surface-2); padding: 8px 11px; font-size: 12.5px; vertical-align: middle; }
.table tbody tr { transition: transform .16s var(--ease); }
.table tbody tr:hover td { background: var(--brand-soft); }
.table td:first-child { border-radius: 0 var(--radius) var(--radius) 0; }
.table td:last-child { border-radius: var(--radius) 0 0 var(--radius); }
.table .muted { color: var(--ink-faint); font-size: 11.5px; }

.muted { color: var(--ink-faint); font-size: 11.5px; }

/* ---------- برچسب ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-faint);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.c1 { background: var(--c1-soft); color: var(--c1); }
.pill.c2 { background: var(--c2-soft); color: var(--c2); }
.pill.c3 { background: var(--c3-soft); color: var(--c3); }
.pill.c4 { background: var(--c4-soft); color: var(--c4); }

/* ---------- پیام ---------- */
.flash {
  padding: 9px 14px; border-radius: var(--radius); margin-bottom: 12px;
  font-weight: 600; font-size: 12.5px;
  background: var(--ok-soft); color: var(--ok);
  animation: slide-in .3s var(--ease);
}
.flash.error { background: var(--err-soft); color: var(--err); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.empty { text-align: center; padding: 28px 16px; color: var(--ink-ghost); font-size: 12.5px; }
.empty .big { font-size: 28px; opacity: .55; margin-bottom: 4px; }

/* ---------- ورود ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 25% 15%, var(--brand-soft), var(--bg) 65%);
}
.login-card {
  width: 100%; max-width: 340px; background: var(--surface);
  padding: 26px 24px; border-radius: 20px; box-shadow: var(--shadow-lift);
  animation: rise .4s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- ردیف بازشونده ---------- */
.item {
  background: var(--surface); border-radius: var(--radius-lg);
  margin-bottom: 7px; box-shadow: var(--shadow-sm);
  transition: box-shadow .22s var(--ease), transform .22s var(--ease);
  overflow: hidden;
}
.item:hover { box-shadow: var(--shadow); transform: translateX(-2px); }
.item[open] { box-shadow: var(--shadow); }
.item > summary { list-style: none; cursor: pointer; padding: 9px 14px; }
.item > summary::-webkit-details-marker { display: none; }
.item-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.item-head .t { font-weight: 600; font-size: 13.5px; color: var(--ink); flex: 1; min-width: 140px; }
.item-head .q { color: var(--ink-faint); font-size: 11.5px; width: 100%; margin-top: -2px; }
.item-head .caret { color: var(--ink-ghost); font-size: 11px; transition: transform .2s var(--ease); }
.item[open] .item-head .caret { transform: rotate(180deg); }
.item-body {
  padding: 0 14px 12px; border-top: 1px solid var(--surface-2); margin-top: 8px; padding-top: 10px;
  animation: fade-in .25s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.item-text {
  background: var(--surface-2); border-radius: var(--radius); padding: 9px 12px;
  font-size: 12.5px; line-height: 1.9; white-space: pre-wrap;
  max-height: 220px; overflow-y: auto;
}

/* ---------- نتیجه جستجو ---------- */
.hit {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 10px 14px; margin-bottom: 7px; box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.hit:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.hit .head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 4px; }
.hit .head .t { font-weight: 600; font-size: 13.5px; }
.hit .body { color: var(--ink-soft); font-size: 12.5px; white-space: pre-wrap; line-height: 1.85; }
.hit .meta { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- «هوش مصنوعی در حال نوشتن» ---------- */
.typing {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  color: var(--c2); font-size: 13px; font-weight: 600;
}
.typing .dots { display: inline-flex; gap: 4px; }
.typing .dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--c2); display: block;
  animation: typing-bounce 1.25s infinite ease-in-out;
}
.typing .dots i:nth-child(2) { animation-delay: .18s; }
.typing .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-5px); opacity: 1; }
}
.typing .spark {
  width: 24px; height: 24px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px;
  background: var(--c2-soft); color: var(--c2);
  animation: spark-pulse 1.8s infinite ease-in-out;
}
@keyframes spark-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(107, 78, 168, .28); }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 7px rgba(107, 78, 168, 0); }
}
.typing .step { color: var(--ink-faint); font-weight: 500; font-size: 12px; }

.answer-box {
  background: linear-gradient(140deg, var(--brand-soft), var(--surface-2));
  border-radius: var(--radius-lg); padding: 13px 16px;
  white-space: pre-wrap; line-height: 1.95; font-size: 13px;
  animation: rise .35s var(--ease);
}

/* ---------- ردیف ساده ---------- */
.slot, .chain-slot, .tree-row {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: var(--radius);
  padding: 7px 12px; margin-bottom: 5px;
  transition: background .16s var(--ease), transform .16s var(--ease);
}
.slot:hover, .chain-slot:hover, .tree-row:hover {
  background: var(--brand-soft); transform: translateX(-2px);
}
.slot .idx, .chain-slot .idx {
  width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 11.5px;
  background: var(--brand); color: #fff;
}
.slot.empty-slot, .chain-slot.empty-slot { opacity: .55; }
.slot.empty-slot .idx, .chain-slot.empty-slot .idx { background: var(--surface-3); color: var(--ink-faint); }
.slot .spacer, .chain-slot .spacer, .tree-row .spacer { flex: 1; }
.slot strong, .chain-slot strong, .tree-row .name { color: var(--ink); font-size: 13px; font-weight: 600; }

.bar { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s var(--ease); }

.code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--surface-2); padding: 7px 11px; border-radius: var(--radius-sm);
  font-size: 11.5px; direction: ltr; text-align: left; word-break: break-all;
}

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.toolbar .grow { flex: 1 1 200px; }

.tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a {
  padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); color: var(--ink-faint); box-shadow: var(--shadow-sm);
  transition: all .16s var(--ease);
}
.tabs a:hover { color: var(--ink); transform: translateY(-1px); }
.tabs a.active { background: var(--brand); color: #fff; }

/* ---------- افزودن سریع مدل ---------- */
.wizard {
  background: linear-gradient(135deg, var(--brand-soft), var(--surface-2));
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.wizard .steps { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.wizard .step { flex: 1 1 170px; position: relative; }
.wizard .step > label { display: flex; align-items: center; gap: 6px; color: var(--brand-deep); }
.wizard .step > label .n {
  width: 17px; height: 17px; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
  background: var(--brand-grad); color: #fff;
}
.wizard select, .wizard input { background: var(--surface); }
.preset {
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--brand); cursor: pointer;
  border: none; font-family: inherit; box-shadow: var(--shadow-sm);
  transition: all .16s var(--ease);
}
.preset:hover { background: var(--brand); color: #fff; transform: translateY(-1px); }

.drop {
  border: 2px dashed var(--surface-3); border-radius: var(--radius-lg);
  padding: 20px; text-align: center; color: var(--ink-faint); font-size: 12.5px;
  transition: border-color .2s var(--ease), background .2s var(--ease);
  cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.drop .big { font-size: 26px; opacity: .6; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .sep { display: none; }
  .main { padding: 14px 12px 36px; }
}
