@import url("/static/fonts/fonts.css");

:root {
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --ok-soft: #ecfdf5;
  --ok-border: #a7f3d0;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --sans: "IBM Plex Sans Hebrew", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.14);
  --sidebar-w: 268px;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--ink);
  font: 400 0.95rem/1.6 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.htmx-progress {
  position: fixed; top: 0; right: 0; left: 0; height: 3px;
  background: linear-gradient(90deg, #3b82f6, #2563eb, #60a5fa);
  transform: scaleX(0); transform-origin: right; transition: transform 0.25s ease;
  z-index: 9999; pointer-events: none;
}
.htmx-request .htmx-progress, .htmx-progress.htmx-request { transform: scaleX(0.85); }

.app-shell { display: flex; min-height: 100vh; }
.mobile-bar { display: none; }

.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: #fff;
  display: flex; flex-direction: column; position: fixed; top: 0; right: 0; bottom: 0;
  z-index: 50; border-left: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-head {
  padding: 1.35rem 1.25rem; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand { display: flex; align-items: center; gap: 0.75rem; color: #fff; text-decoration: none !important; }
.brand-mark {
  width: 46px; height: 40px; object-fit: contain; display: block; flex-shrink: 0;
  background: transparent;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-text small { font-size: 0.72rem; color: var(--sidebar-muted); font-weight: 500; }

.menu-close {
  display: none; background: transparent; border: none; color: var(--sidebar-text);
  padding: 0.4rem; border-radius: var(--radius-sm); cursor: pointer;
}

.sidebar-nav { flex: 1; padding: 1.25rem 0.85rem; display: flex; flex-direction: column; gap: 0.25rem; overflow-y: auto; }
.nav-section-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--sidebar-muted); padding: 0 0.75rem 0.5rem;
}
.nav-item {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md); color: var(--sidebar-text); font-weight: 500; font-size: 0.93rem;
  text-decoration: none !important; transition: background 0.15s ease, color 0.15s ease;
}
.nav-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--sidebar-muted); transition: all 0.15s ease; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item[aria-current="page"] {
  background: rgba(37, 99, 235, 0.18); color: #fff; font-weight: 600; box-shadow: inset -3px 0 0 #3b82f6;
}
.nav-item[aria-current="page"] .nav-dot { background: #60a5fa; transform: scale(1.3); }

.sidebar-foot { padding: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.08); background: rgba(2, 6, 23, 0.35); }
.user-card { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.75rem; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 999px; background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15); color: #93c5fd; font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-email { font-size: 0.83rem; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.74rem; color: #94a3b8; }

.btn-logout {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.5rem 0.75rem; background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: var(--radius-sm);
  color: #e2e8f0; font: 500 0.84rem/1 var(--sans); cursor: pointer; transition: background 0.15s ease;
}
.btn-logout:hover { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.35); color: #fecaca; }

.workspace { flex: 1; margin-right: var(--sidebar-w); min-width: 0; }
.workspace-inner { max-width: 1240px; margin: 0 auto; padding: 2rem 2.25rem 4rem; }

.page-title { margin: 0 0 0.4rem; font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.lede { margin: 0 0 1.75rem; color: var(--ink-soft); font-size: 0.96rem; max-width: 68ch; }
h2 { margin: 0 0 0.9rem; font-size: 1.1rem; font-weight: 600; color: var(--ink); }

.split { display: grid; grid-template-columns: minmax(310px, 380px) minmax(0, 1fr); gap: 1.75rem; align-items: start; }
.slip { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.35rem; box-shadow: var(--shadow-sm); }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.86rem; font-weight: 600; color: var(--ink); margin-bottom: 0.35rem; }
.hint { font-weight: 400; font-size: 0.82rem; color: var(--ink-muted); }

input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%; min-height: 40px; padding: 0.5rem 0.75rem; background: var(--bg-surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--ink);
  font: 400 0.93rem/1.4 var(--sans); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14); }

.role-select {
  width: auto; min-width: 130px; min-height: 34px; padding: 0.3rem 0.6rem; font-size: 0.86rem;
  background-color: var(--bg-subtle); border-color: var(--border); font-weight: 500;
}

button[type="submit"], .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: 0.55rem 1.15rem; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); font: 600 0.9rem/1 var(--sans); cursor: pointer;
  box-shadow: var(--shadow-xs); transition: background 0.15s ease, transform 0.08s ease;
}
button[type="submit"]:hover { background: var(--accent-hover); }
button[type="submit"]:active { transform: translateY(1px); }

button.quiet {
  background: transparent; border: 1px solid var(--border-strong); color: var(--ink-soft);
  padding: 0.35rem 0.7rem; border-radius: var(--radius-sm); font: 500 0.82rem/1 var(--sans); cursor: pointer;
}
button.quiet:hover { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

.ledger {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
}
.ledger thead th {
  background: var(--bg-subtle); color: var(--ink-soft); font-size: 0.8rem; font-weight: 600;
  text-align: right; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ledger tbody td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
.ledger tbody tr:last-child td { border-bottom: none; }
.ledger tbody tr:hover td { background: #f8fafc; }

.code {
  display: inline-block; font-family: var(--mono); font-size: 0.8rem; background: var(--bg-subtle);
  border: 1px solid var(--border); padding: 0.15rem 0.45rem; border-radius: 5px; color: var(--ink);
}
.audit .delta { font-family: var(--mono); font-size: 0.78rem; max-width: 220px; overflow-x: auto; color: var(--ink-soft); }

.entity-picker {
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.65rem;
  background: var(--bg-canvas); max-height: 210px; overflow-y: auto;
}
.entity-picker label { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.45rem; border-radius: var(--radius-sm); font-weight: 400; cursor: pointer; }
.entity-picker label:hover { background: var(--bg-surface); }
.picker-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.6rem; }

.sheet-wrap { width: 100%; overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.sheet { width: 100%; border-collapse: collapse; }
.sheet th, .sheet td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); text-align: center; }
.sheet th:first-child { text-align: right; min-width: 240px; }
.sheet thead th { background: var(--bg-subtle); font-size: 0.84rem; font-weight: 600; color: var(--ink-soft); }
.sheet tbody th small { display: block; font-family: var(--mono); font-weight: 400; font-size: 0.74rem; color: var(--ink-muted); }

.legend {
  margin-top: 1.25rem; padding: 1rem 1.25rem; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--ink-soft);
}
.legend span:first-child { font-weight: 600; color: var(--ink); }

.notice { padding: 0.85rem 1rem; margin-bottom: 1.25rem; background: var(--ok-soft); border: 1px solid var(--ok-border); color: #065f46; border-radius: var(--radius-md); font-size: 0.9rem; }
.error-text { padding: 0.75rem 0.95rem; margin-bottom: 1rem; background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger); border-radius: var(--radius-md); font-size: 0.88rem; font-weight: 500; }
.empty { padding: 2rem 1.5rem; text-align: center; background: var(--bg-surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--ink-muted); font-size: 0.92rem; }

.entity-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.entity-list li { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 0.5rem; }
.entity-list .name { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.entity-list .meta { color: var(--ink-soft); font-size: 0.85rem; }

.solo { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: radial-gradient(circle at top right, #eff6ff 0%, #f8fafc 55%); }
.solo-card { width: 100%; max-width: 410px; padding: 2.25rem 2rem; box-shadow: var(--shadow-lg); }
.solo-card .brand-line {
  margin: 0 0 0.5rem; font-weight: 800; font-size: 1.25rem; color: var(--accent);
  display: flex; align-items: center; gap: 0.65rem;
}
.solo-logo { width: 48px; height: 42px; object-fit: contain; display: block; flex-shrink: 0; }
.solo-card button[type="submit"] { width: 100%; margin-top: 0.5rem; }

#toast:not(:empty) {
  position: fixed; bottom: 1.25rem; left: 1.25rem; z-index: 100; background: var(--sidebar-bg); color: #fff;
  padding: 0.75rem 1.15rem; border-radius: var(--radius-md); font-size: 0.88rem; font-weight: 500;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, 0.12);
}

@media (max-width: 1024px) {
  .split { grid-template-columns: 1fr; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40;
    height: 60px; padding: 0 1rem; background: var(--sidebar-bg); color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .menu-toggle {
    background: transparent; border: 1px solid rgba(255, 255, 255, 0.14); color: #fff;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  }
  .mobile-brand { display: inline-flex; align-items: center; gap: 0.55rem; color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none !important; }
  .mobile-brand .brand-mark { width: 36px; height: 32px; }
  .mobile-role-badge { font-size: 0.75rem; background: rgba(59, 130, 246, 0.22); color: #93c5fd; padding: 0.25rem 0.6rem; border-radius: 999px; font-weight: 600; }
  .menu-close { display: inline-flex; }
  .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(2px); z-index: 45; }
  .app-shell { flex-direction: column; }
  .workspace { margin-right: 0; }
  .workspace-inner { padding: 1.35rem 1rem 3rem; }
  input[type="text"], input[type="email"], input[type="password"], select, button[type="submit"] { font-size: 1rem; min-height: 44px; }
  .ledger { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #toast:not(:empty) { left: 1rem; right: 1rem; bottom: 1rem; text-align: center; }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

body.login-shell { margin: 0; min-height: 100dvh; display: grid; grid-template-columns: 1.05fr 1fr; background: #f1f5f9; }
.login-brand { background: linear-gradient(155deg, #091124 0%, #0f172a 55%, #172554 100%); color: #f8fafc; padding: 3.5rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-brand-top { display: flex; align-items: center; gap: 1rem; }
.login-brand-logo { width: 52px; height: 52px; object-fit: contain; flex-shrink: 0; }
.login-brand-title { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.02em; color: #ffffff; line-height: 1.1; }
.login-brand-sub { font-size: 0.85rem; color: #93c5fd; font-weight: 500; }
.login-hero { max-width: 440px; margin: 2rem 0; }
.login-hero h2 { font-size: 1.85rem; font-weight: 700; line-height: 1.3; margin: 0 0 1rem; color: #ffffff; }
.login-hero p { color: #cbd5e1; font-size: 0.98rem; line-height: 1.65; margin: 0 0 1.75rem; }
.login-pillars { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.85rem; }
.login-pillars li { display: flex; align-items: center; gap: 0.65rem; font-size: 0.9rem; color: #e2e8f0; }
.login-dot { width: 8px; height: 8px; border-radius: 99px; background: #38bdf8; flex-shrink: 0; }
.login-footer { font-size: 0.8rem; color: #64748b; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.login-card { width: 100%; max-width: 410px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 2.25rem 1.75rem; box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 10px -4px rgba(15, 23, 42, 0.04); }
.login-card-head { margin-bottom: 1.5rem; }
.login-card-head h1 { font-size: 1.5rem; font-weight: 700; color: #0f172a; margin: 0 0 0.35rem; }
.login-card-head p { font-size: 0.88rem; color: #64748b; margin: 0; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; box-shadow: none; border: 0; padding: 0; background: transparent; }
.login-card input { font-size: 16px; }
.login-card button[type="submit"] { width: 100%; margin-top: 0.5rem; padding: 0.78rem 1rem; font-weight: 600; font-size: 0.95rem; }
@media (max-width: 860px) {
  body.login-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { padding: 1.35rem 1.25rem; }
  .login-brand-logo { width: 40px; height: 40px; }
  .login-brand-title { font-size: 1.35rem; }
  .login-hero, .login-footer { display: none; }
  .login-panel { align-items: flex-start; padding-top: 1.75rem; }
  .login-card { padding: 1.75rem 1.35rem; }
}

.brand-lockup { display: inline-flex; align-items: center; gap: 0.9rem; text-align: left; }
.brand-lockup-icon { width: 58px; height: 58px; object-fit: contain; flex-shrink: 0; }
.brand-lockup-text { display: flex; flex-direction: column; justify-content: center; }
.brand-lockup-name { font-size: 2.15rem; font-weight: 800; letter-spacing: -0.03em; color: #ffffff; line-height: 1; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.brand-lockup-sub { font-size: 0.88rem; font-weight: 500; color: #cbd5e1; letter-spacing: 0.01em; margin-top: 0.28rem; }
@media (max-width: 860px) {
  .brand-lockup-icon { width: 42px; height: 42px; }
  .brand-lockup-name { font-size: 1.55rem; }
  .brand-lockup-sub { font-size: 0.78rem; margin-top: 0.15rem; }
}

/* === Login Symmetry & Centering Polish === */
.login-card-head { text-align: center; }
.login-brand { align-items: center; text-align: center; }
.login-brand .brand-lockup { justify-content: center; }
.login-hero { text-align: center; }
.login-pillars { align-items: center; }
@media (max-width: 860px) {
  .login-brand { padding: 1.5rem 1.25rem; }
}


/* === Global Responsive Typography & Layout Scaling (Large Desktop / 4K) === */
@media (min-width: 1280px) {
  html { font-size: 17.5px; }
}
@media (min-width: 1680px) {
  html { font-size: 20px; }
  .login-card { max-width: 480px; padding: 2.75rem 2.25rem; }
  .login-hero { max-width: 560px; }
  .brand-lockup-icon { width: 68px; height: 68px; }
}
@media (min-width: 2200px) {
  html { font-size: 22px; }
  .login-card { max-width: 520px; }
  .login-hero { max-width: 620px; }
}


/* === Strict Global Mobile & Box-Model Containment === */
*, *::before, *::after {
  box-sizing: border-box;
}
html, body {
  max-width: 100%;
  overflow-x: hidden;
}
main, section, .slip, .field {
  min-width: 0;
  max-width: 100%;
}
input, select, textarea, button {
  max-width: 100%;
}
.slip input,
.slip select,
.slip textarea {
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}
.code {
  white-space: normal !important;
  word-break: break-word;
  max-width: 100%;
}
.page-title {
  overflow-wrap: break-word;
  word-wrap: break-word;
}
@media (max-width: 768px) {
  .split {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1.25rem !important;
  }
  .slip {
    padding: 1.1rem 1rem !important;
  }
  .page-title {
    font-size: 1.45rem !important;
    line-height: 1.3 !important;
  }
  table.ledger {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}


/* === Sanpir Branded Modal Dialog === */
.sanpir-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 17, 36, 0.58);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  animation: sanpirFadeIn 0.16s ease-out;
}
.sanpir-modal-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-top: 4px solid #f59e0b;
  border-radius: 16px;
  padding: 1.75rem 1.5rem 1.4rem;
  box-shadow: 0 20px 35px -10px rgba(15, 23, 42, 0.25);
  text-align: center;
  direction: rtl;
}
.sanpir-modal-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.9rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #d97706;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
}
.sanpir-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.45rem;
}
.sanpir-modal-body {
  font-size: 0.95rem;
  color: #475569;
  line-height: 1.55;
  margin: 0 0 1.4rem;
}
.sanpir-modal-badge {
  display: inline-block;
  margin-top: 0.45rem;
  padding: 0.2rem 0.65rem;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-weight: 600;
  color: #0f172a;
  direction: ltr;
}
.sanpir-modal-actions {
  display: flex;
  justify-content: center;
}
.sanpir-modal-btn {
  min-width: 130px;
  padding: 0.65rem 1.4rem;
  background: #1d4ed8;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.sanpir-modal-btn:hover {
  background: #1e40af;
}
@keyframes sanpirFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* === Manage Page Header Action & Form Modal === */
.page-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-header-bar .page-title {
  margin-bottom: 0.25rem;
}
.btn-new-entity {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.72rem 1.35rem;
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.22);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
.btn-new-entity:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.3);
}
.sanpir-form-modal-card {
  width: 100%;
  max-width: 500px;
  max-height: 90dvh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-top: 4px solid #1d4ed8;
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 24px 40px -12px rgba(15, 23, 42, 0.28);
  text-align: right;
  direction: rtl;
}
.sanpir-form-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #e2e8f0;
}
.sanpir-form-modal-head h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}
.sanpir-modal-close-x {
  background: #f1f5f9;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 1.15rem;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sanpir-modal-close-x:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.sanpir-form-modal-card form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  box-shadow: none;
  border: 0;
  padding: 0;
  background: transparent;
}
.sanpir-form-modal-card input {
  width: 100% !important;
  font-size: 16px;
}
.sanpir-modal-footer-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}
.btn-modal-cancel {
  padding: 0.65rem 1.15rem;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
@media (max-width: 640px) {
  .page-header-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-new-entity {
    justify-content: center;
    width: 100%;
  }
}

table tbody tr { transition: background-color 0.14s ease; }
table tbody tr:hover { background-color: #f8fafc; }
.entity-row-actions { display: inline-flex; align-items: center; gap: 0.45rem; opacity: 0.35; transition: opacity 0.15s ease; }
table tbody tr:hover .entity-row-actions, table tbody tr:focus-within .entity-row-actions { opacity: 1; }
@media (hover: none) { .entity-row-actions { opacity: 1; } }
.btn-row-edit, .btn-row-del { padding: 0.32rem 0.68rem; border-radius: 7px; font-size: 0.82rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.btn-row-edit { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.btn-row-edit:hover { background: #dbeafe; }
.btn-row-del { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.btn-row-del:hover { background: #fee2e2; }
.btn-modal-danger { min-width: 120px; padding: 0.65rem 1.3rem; background: #dc2626; color: #ffffff; border: none; border-radius: 10px; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.btn-modal-danger:hover { background: #b91c1c; }
.btn-modal-primary { min-width: 120px; padding: 0.65rem 1.3rem; background: #1d4ed8; color: #ffffff; border: none; border-radius: 10px; font-size: 0.95rem; font-weight: 600; cursor: pointer; }


/* === Manage Page Stacked Accordions === */
.sanpir-accordion-stack {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  width: 100%;
}
details.sanpir-accordion {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  width: 100%;
}
details.sanpir-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 1.1rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  background: #f8fafc;
  user-select: none;
  transition: background-color 0.15s ease;
}
details.sanpir-accordion > summary::-webkit-details-marker {
  display: none;
}
details.sanpir-accordion > summary:hover {
  background: #f1f5f9;
}
details.sanpir-accordion[open] > summary {
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}
.sanpir-acc-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}
.sanpir-acc-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.82rem;
  font-weight: 600;
}
.sanpir-acc-chevron {
  font-size: 0.9rem;
  color: #64748b;
  transition: transform 0.2s ease;
}
details.sanpir-accordion[open] .sanpir-acc-chevron {
  transform: rotate(180deg);
}
.sanpir-acc-body {
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
}
.sanpir-acc-body table {
  width: 100%;
  margin: 0;
  box-shadow: none;
}
.sanpir-acc-body td:first-child {
  white-space: nowrap !important;
}
