body { font-size: 15px; }

#app { min-height: 100dvh; }

.crumb { display: inline-block; font-size: .8rem; color: var(--text-2); text-decoration: none; margin-block-end: 4px; }
.crumb::before { content: "‹ "; }
.crumb:hover { color: var(--accent); }

.set-section { margin-block-end: 26px; }
.set-section-head { display: flex; align-items: center; gap: 9px; margin-block-end: 12px; color: var(--text-2); }
.set-section-head svg { width: 18px; height: 18px; }
.set-section-head h2 { margin: 0; font-size: .92rem; font-weight: 650; }

.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.set-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: start;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  font: inherit;
  width: 100%;
  transition: transform .14s, box-shadow .14s, border-color .14s;
}

.set-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
}

.set-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  flex-shrink: 0;
}

.set-card-icon svg { width: 24px; height: 24px; }
.set-card-body { flex: 1; min-width: 0; }
.set-card-body b { display: block; font-weight: 700; font-size: 1rem; margin-block-end: 4px; }
.set-card-body p { margin: 0; color: var(--text-2); font-size: .84rem; line-height: 1.6; }

.set-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-block-start: 2px; }
.set-arrow { color: var(--text-2); font-size: 1.3rem; line-height: 1; transition: transform .14s, color .14s; }
.set-card:hover .set-arrow { color: var(--accent); transform: translateX(-3px); }

.layout { display: flex; min-height: 100dvh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; color: var(--text); }
.brand svg { width: 36px; height: 36px; flex-shrink: 0; }
.brand b { font-weight: 780; font-size: 1.08rem; }
.brand small { display: block; color: var(--text-2); font-weight: 400; font-size: .72rem; }

.conn { display: flex; align-items: center; gap: 8px; padding: 6px 12px 14px; font-size: .74rem; color: var(--text-2); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); transition: background .3s; }
.conn.live .dot { background: #3d9a5f; box-shadow: 0 0 0 0 rgba(61,154,95,.5); animation: livepulse 2s infinite; }
.conn.live { color: #3d9a5f; }

@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 rgba(61,154,95,.45); }
  70% { box-shadow: 0 0 0 7px rgba(61,154,95,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,154,95,0); }
}

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); text-decoration: none;
  font-weight: 450;
  transition: background .15s, color .15s;
}

.nav a svg { width: 18px; height: 18px; opacity: .8; }
.nav a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); }
.nav a.active { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); font-weight: 600; }

.sidebar-foot { margin-block-start: auto; display: flex; flex-direction: column; gap: 8px; }

.userchip { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, var(--text) 4%, transparent); font-size: .85rem; }
.userchip .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }

.foot-row { display: flex; gap: 8px; align-items: stretch; }
.foot-row .btn { flex: 1; justify-content: center; height: 40px; padding: 0 14px; }
.foot-row .theme-btn { width: 40px; height: 40px; flex-shrink: 0; }
#logoutBtn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
#logoutBtn:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }

.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 4vw, 44px); animation: viewin .25s ease; }

@keyframes viewin { from { opacity: 0; transform: translateY(6px); } }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-block-end: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.35rem; font-weight: 760; }
.page-head p { margin: 2px 0 0; color: var(--text-2); font-size: .85rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-block-end: 18px; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}

.card:hover { transform: translateY(-1px); }
.card .num { font-size: 1.7rem; font-weight: 820; line-height: 1.3; font-variant-numeric: tabular-nums; transition: color .3s; }
.card .num.bump { color: var(--accent); }
.card .lbl { color: var(--text-2); font-size: .82rem; }

.meter { margin-block-start: 10px; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--text) 8%, transparent); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); width: 0; transition: width .6s cubic-bezier(.3,.9,.3,1); }
.meter.hot > i { background: var(--danger); }

.spark { width: 100%; height: 36px; margin-block-start: 8px; display: block; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }

.panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-title { padding: 14px 18px 0; font-weight: 700; font-size: .95rem; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: start; color: var(--text-2); font-weight: 550; font-size: .78rem; padding: 12px 18px; border-block-end: 1px solid var(--border); }
td { padding: 12px 18px; border-block-end: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-block-end: none; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: color-mix(in srgb, var(--text) 2.5%, transparent); }
tbody tr.flash-in { animation: rowin .8s ease; }

@keyframes rowin { from { background: color-mix(in srgb, var(--accent) 18%, transparent); } }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text);
  font-weight: 550; font-size: .86rem;
  cursor: pointer; text-decoration: none;
  transition: filter .15s, background .15s, transform .05s;
}

.btn:active { transform: scale(.98); }
.btn:hover { background: color-mix(in srgb, var(--text) 5%, var(--bg-2)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn.sm { padding: 5px 11px; font-size: .8rem; border-radius: 8px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn.sm svg { width: 14px; height: 14px; }
.btn .spin { width: 13px; height: 13px; border: 2px solid currentColor; border-inline-start-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.form { padding: 24px; display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: .84rem; font-weight: 550; color: var(--text-2); }

input[type=text], input[type=password], textarea, select {
  width: 100%; padding: 9px 13px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.mono { font-family: 'Vazirmatn', monospace; direction: ltr; text-align: left; }
textarea { resize: vertical; min-height: 130px; line-height: 1.9; }
.hint { font-size: .76rem; color: var(--text-2); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 99px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.chip.on { background: color-mix(in srgb, #3d9a5f 14%, transparent); color: #3d9a5f; }
.chip.on::before { animation: livepulse 2s infinite; }
.chip.off { background: color-mix(in srgb, var(--text-2) 13%, transparent); color: var(--text-2); }
.chip.warn { background: color-mix(in srgb, #c78a2d 15%, transparent); color: #c78a2d; }

.alert { padding: 12px 16px; border-radius: 10px; font-size: .85rem; border: 1px solid; }
.alert.err { background: color-mix(in srgb, var(--danger) 9%, var(--bg-2)); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
  display: grid; gap: 18px;
  animation: viewin .3s ease;
}

.login-card .logo { display: grid; place-items: center; gap: 10px; text-align: center; margin-block-end: 4px; }
.login-card .logo svg { width: 58px; height: 58px; }
.login-card h1 { margin: 0; font-size: 1.15rem; font-weight: 760; }
.login-card .sub { color: var(--text-2); font-size: .82rem; margin: 0; }
.login-theme { position: fixed; top: 16px; inset-inline-start: 16px; }

.theme-btn {
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  border-radius: 10px; width: 38px; height: 38px;
  cursor: pointer; display: grid; place-items: center; font-size: 1rem;
}

.empty { padding: 34px; text-align: center; color: var(--text-2); font-size: .88rem; }

.audit { list-style: none; margin: 0; padding: 6px 0; max-height: 420px; overflow-y: auto; }
.audit li { display: flex; gap: 10px; padding: 9px 18px; font-size: .82rem; border-block-end: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
.audit li:last-child { border: none; }
.audit .who { font-weight: 650; white-space: nowrap; }
.audit .when { margin-inline-start: auto; color: var(--text-2); font-size: .72rem; white-space: nowrap; }

#toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; display: grid; gap: 8px; z-index: 999; max-width: min(360px, calc(100vw - 36px)); }
.toast {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  font-size: .84rem;
  display: flex; gap: 9px; align-items: center;
  animation: toastin .25s ease;
}

.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast.ok::before { background: #3d9a5f; }
.toast.err::before { background: var(--danger); }
.toast.info::before { background: var(--accent); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }

@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

#modal-root:empty { display: none; }
.overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,.45);
  display: grid; place-items: center; padding: 18px;
  animation: fadein .2s ease;
}

@keyframes fadein { from { opacity: 0; } }

.modal {
  width: 100%; max-width: 480px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: modalin .22s cubic-bezier(.3,1.2,.4,1);
  max-height: 90dvh; overflow-y: auto;
}

.modal.wide { max-width: 620px; }

@keyframes modalin { from { opacity: 0; transform: scale(.96) translateY(10px); } }

.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px 0; }
.modal-head h2 { margin: 0; font-size: 1.05rem; font-weight: 720; }
.modal-x { border: none; background: none; color: var(--text-2); font-size: 1.3rem; cursor: pointer; line-height: 1; padding: 4px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 24px 22px; }

.confirm-body { padding: 14px 24px 20px; color: var(--text-2); font-size: .9rem; }

.kv { display: flex; align-items: baseline; gap: 8px; }
.kv b { font-variant-numeric: tabular-nums; }

.gw-tag { direction: ltr; unicode-bidi: isolate; display: inline-block; background: color-mix(in srgb, var(--text) 5%, transparent); border-radius: 7px; padding: 2px 9px; font-size: .78rem; }

.menu-toggle { display: none; }

.dash-welcome {
  text-align: center;
  padding: clamp(40px, 10vh, 90px) 20px;
  display: grid;
  place-items: center;
  gap: 6px;
}
.dash-welcome-logo svg { width: 64px; height: 64px; opacity: .9; margin-block-end: 8px; }
.dash-welcome h2 { margin: 0; font-size: 1.3rem; font-weight: 750; }
.dash-welcome p { margin: 0; color: var(--text-2); font-size: .9rem; max-width: 380px; }

.inv-item { display: flex; gap: 8px; align-items: center; margin-block-end: 8px; }
.inv-item .i-title { flex: 1; }
.inv-item input { padding: 8px 11px; }
.inv-item .i-del { flex-shrink: 0; padding: 6px 10px; }

.inv-total-box {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 10px;
  font-size: .95rem;
}
.inv-total-box b { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.inv-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--text) 3%, transparent);
  border-radius: 10px;
}
.inv-summary .kv { flex-direction: column; align-items: flex-start; gap: 2px; }
.inv-summary b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  .inv-item { flex-wrap: wrap; }
  .inv-item .i-title { flex-basis: 100%; }
  .inv-summary { grid-template-columns: 1fr; gap: 8px; }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 50;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 10px 14px;
    border-inline-end: none; border-block-end: 1px solid var(--border);
  }
  .sidebar-top { display: flex; align-items: center; justify-content: space-between; }
  .brand { padding: 2px 4px; }
  .brand small { display: none; }
  .menu-toggle {
    display: grid; place-items: center;
    width: 42px; height: 42px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg); color: var(--text); cursor: pointer;
  }
  .menu-toggle svg { width: 22px; height: 22px; }

  .conn { display: none; }
  .nav { display: none; flex-direction: column; gap: 4px; margin-block-start: 10px; }
  .sidebar-foot { display: none; margin: 10px 0 4px; flex-direction: column; align-items: stretch; gap: 8px; }

  .sidebar.open .nav,
  .sidebar.open .sidebar-foot { display: flex; }
  .sidebar.open .conn { display: flex; }

  .nav a { padding: 11px 14px; font-size: .95rem; }
  .nav a svg { display: inline-block; }
  .userchip { display: flex; }
  .foot-row { display: flex; gap: 8px; }
  .foot-row .btn, .foot-row .theme-btn { flex: 1; }

  .main { padding: 20px 14px; }
  th, td { padding: 10px 12px; }
  .grid-2 { grid-template-columns: 1fr; }
}
