
:root{
  /* X_STATS red-black theme */
  --bg:#050507;
  --card:#0b0b10;
  --card2:rgba(255,255,255,0.03);
  --stroke:rgba(255,80,80,0.16);
  --stroke2:rgba(255,80,80,0.10);
  --text:#f3f5fb;
  --muted:rgba(243,245,251,0.72);
  --muted2:rgba(243,245,251,0.55);
  --blue:#ff3b3b;
  --blue2:rgba(255,59,59,0.15);
  --danger:#ff3b3b;
}
*{ box-sizing:border-box; }
html,body{ height:100%; }

/*
  Background rendering note:
  Safari/WebKit can sometimes show horizontal seams when large gradients are
  painted as GPU tiles. To avoid this, we render the background on a single
  fixed pseudo-element layer.
*/
html{ background: var(--bg); }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: transparent;
  color:var(--text);
  position: relative;
}

body::before{
  content:"";
  position: fixed;
  inset: -12vh -12vw; /* extend beyond viewport to prevent edge artifacts */
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1100px 700px at 50% 0%, rgba(255,59,59,.18) 0%, rgba(255,59,59,.10) 35%, rgba(255,59,59,.03) 65%, rgba(255,59,59,0) 100%),
    radial-gradient(900px 600px at 70% 90%, rgba(255,59,59,.14) 0%, rgba(255,59,59,.07) 40%, rgba(255,59,59,.02) 70%, rgba(255,59,59,0) 100%),
    var(--bg);

  /* force single composited layer to reduce seam lines */
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

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

/* reveal-on-scroll (added by /static/js/animations.js) */
.reveal{
  opacity: 0;
  transform: translateY(10px);
  filter: blur(2px);
  transition:
    opacity .35s ease,
    transform .35s ease,
    filter .35s ease;
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform, filter;
}
.reveal.reveal-in{
  opacity: 1;
  transform: none;
  filter: none;
}
a{ color:inherit; text-decoration:none; }
.container{ max-width: 1020px; margin: 22px auto; padding: 0 16px; }

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 16px;
  border:1px solid var(--stroke);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  box-shadow:
    0 18px 55px rgba(0,0,0,0.35),
    0 0 0 1px rgba(255,59,59,0.10),
    0 0 28px rgba(255,59,59,0.08);
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:800;
  letter-spacing: .2px;
}
.brand-logo{
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(255,59,59,0.35);
  box-shadow:
    0 14px 40px rgba(0,0,0,0.45),
    0 0 0 3px rgba(255,59,59,0.10);
}
.brand:hover .brand-logo{
  box-shadow:
    0 16px 44px rgba(0,0,0,0.50),
    0 0 0 3px rgba(255,59,59,0.16),
    0 0 22px rgba(255,59,59,0.12);
}
.userpill{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.link{ color: rgba(255,120,120,0.95); font-weight:800; }
.card{
  margin-top:16px;
  border:1px solid var(--stroke);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.018));
  box-shadow: 0 18px 65px rgba(0,0,0,0.30);
  padding: 20px;
}

/* Subtle hover-lift for main blocks */
.card,
.rowbox,
.histCard,
.teamCard,
.kpiCard,
.chartCard,
.segTabs{
  transition:
    transform .16s ease,
    border-color .16s ease,
    background .16s ease,
    box-shadow .16s ease;
}

@media (hover:hover){
  .card:hover,
  .rowbox:hover,
  .histCard:hover,
  .teamCard:hover,
  .kpiCard:hover,
  .chartCard:hover,
  .segTabs:hover{
    transform: translateY(-1px);
    border-color: rgba(255,255,255,0.14);
    box-shadow:
      0 22px 85px rgba(0,0,0,0.34),
      inset 0 1px 0 rgba(255,255,255,0.06);
  }
}
h1{ margin:0 0 12px; font-size: 34px; letter-spacing: -0.3px; }
h2{ margin:0 0 10px; font-size: 18px; opacity:.95; }
.muted{ color: var(--muted2); font-size: 13px; }
hr.sep{ border:none; height:1px; background: rgba(255,255,255,0.07); margin: 16px 0; }

.grid3{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  align-items:end;
}
@media(max-width: 920px){ .grid3{ grid-template-columns: 1fr; } }

/* Section divider */
.divider{
  height: 1px;
  width: 100%;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  margin: 18px 0;
}

.divider.tight{ margin: 12px 0; }
.divider.loose{ margin: 24px 0; }

/* 4-column responsive grid (dashboard actions, history blocks, etc.) */
.grid4{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
@media(max-width: 1200px){ .grid4{ grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media(max-width: 920px){ .grid4{ grid-template-columns: 1fr; } }

/* 3-column responsive grid (dashboard without extra blocks) */
.grid3{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
@media(max-width: 1200px){ .grid3{ grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media(max-width: 920px){ .grid3{ grid-template-columns: 1fr; } }

label{ display:block; font-size: 13px; color: var(--muted); margin-bottom:6px; font-weight:600; }
input, select{
  width:100%;
  height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--stroke2);
  color: var(--text);
  outline:none;
  min-width: 0;
  max-width: 100%;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
input:focus, select:focus{ border-color: rgba(255,59,59,0.55); box-shadow: 0 0 0 3px rgba(255,59,59,0.15); }

/* Bigger money inputs (Income page) */
input.money-big{
  height: 52px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.money-help{ margin-top:6px; font-size: 12px; color: var(--muted); }

.btn{
  width:100%;
  height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255,59,59,0.55);
  background: rgba(255,59,59,0.16);
  color: var(--text);
  font-weight: 800;
  letter-spacing: .2px;
  cursor:pointer;
  transition: transform .06s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:hover{ background: rgba(255,59,59,0.22); }
.btn:active{ transform: translateY(1px) scale(0.995); }
.btn:active{ transform: translateY(1px) scale(0.99); }
.btn.danger{ border-color: rgba(255,59,59,0.55); background: rgba(255,59,59,0.14); }
.btn.danger:hover{ background: rgba(255,59,59,0.20); }

.banner{
  padding: 12px 14px;
  border-radius: 16px;
  border:1px solid rgba(255,59,59,0.35);
  background: rgba(255,59,59,0.12);
  color: rgba(255,255,255,0.92);
  margin-bottom: 14px;
}

.table{
  width:100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius: 16px;
  border:1px solid var(--stroke);
}
.table th, .table td{
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
}
.table th{ text-align:left; color: var(--muted); font-weight:700; }
.table tr:last-child td{ border-bottom:none; }

.rowbox{
  border:1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  border-radius: 18px;
  padding: 12px;
  overflow:hidden;
}
.rowgrid{
  display:grid;
  grid-template-columns: 1.7fr 0.8fr;
  gap: 12px;
  align-items:center;
  min-width:0;
}
.rowgrid > div{ min-width:0; }

.actions{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:14px;
  margin-top: 14px;
}
@media (max-width: 980px){
  .actions{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 560px){
  .actions{ grid-template-columns: 1fr; }
}

.action{
  position: relative;
  overflow: hidden;
  display:block;
  padding: 18px 18px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.045);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 10px 26px rgba(0,0,0,0.25);
  transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
  min-height: 104px;
}
.action h3{ margin:0; font-size:18px; letter-spacing: 0.2px; }
.action p{ margin:6px 0 0; color: var(--muted); line-height:1.25; }

.action::before{
  content:"";
  position:absolute;
  inset:-1px;
  background: radial-gradient(70% 120% at 0% 0%, rgba(var(--accent, 72, 156, 255), 0.18), transparent 60%);
  pointer-events:none;
}
.action:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 14px 32px rgba(0,0,0,0.30);
}
.action h3, .action p, .action .badge{ position:relative; z-index:1; }

/* dashboard card accents */
.stat-income{ --accent: 255, 95, 95; }
.stat-expense{ --accent: 255, 120, 80; }
.stat-balance{ --accent: 110, 240, 170; }
.nav-income{ --accent: 82, 170, 255; }
.nav-expense{ --accent: 255, 120, 80; }
.nav-salaries{ --accent: 150, 120, 255; }
.nav-users{ --accent: 110, 240, 170; }
.action h3{ margin:0 0 6px; font-size: 16px; }
.action p{ margin:0; color: var(--muted2); font-size: 13px; }

.badge{
  display:inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.07);
  color: var(--muted);
  font-size: 12px;
}

.pillbtn{
  display:inline-flex;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.07);
  color: rgba(180, 220, 255, 0.95);
  font-size: 12px;
  text-decoration:none;
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}

.pillbtn:hover{
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
}
.pillbtn:active{ transform: translateY(1px) scale(0.99); }

/* Team switch (superadmin) */
.team-switch{ display:flex; align-items:center; }
.team-select{
  width:auto;
  height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.07);
  color: rgba(180, 220, 255, 0.95);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1px;
  max-width: 220px;
}
.team-select:focus{ border-color: rgba(255,59,59,0.55); box-shadow: 0 0 0 3px rgba(255,59,59,0.15); }

/* ===== Teams (cards) ===== */
.teamCards{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  margin-top: 18px;
}

@media(max-width: 980px){
  .teamCards{ grid-template-columns: 1fr; }
}

.teamCard{
  position: relative;
  overflow: hidden;
  height: 100%;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
  border-radius: 22px;
  padding: 14px 14px 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.teamCard::before{
  content:"";
  position:absolute;
  inset:-1px;
  background: radial-gradient(70% 120% at 0% 0%, rgba(72,156,255,0.16), transparent 60%);
  pointer-events:none;
}
.teamCardActive{
  border-color: rgba(255,59,59,0.32);
  background: rgba(255,59,59,0.06);
}
.teamCardTop{
  position:relative;
  z-index:1;
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.teamCardTitle{
  min-width: 240px;
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}
.teamName{ font-weight: 950; font-size: 18px; letter-spacing: .2px; }
.teamBadges{ display:flex; gap: 8px; flex-wrap: wrap; }

.teamCardActions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.teamRename{
  display:flex;
  gap: 8px;
  align-items:center;
}
.teamRenameInput{
  width: 240px;
  height: 30px;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
}

.teamCardMeta{ position:relative; z-index:1; margin-top: 8px; }

.teamStats{
  position:relative;
  z-index:1;
  margin-top: 12px;
  display:grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
@media(max-width: 1100px){
  .teamStats{ grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media(max-width: 700px){
  .teamStats{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .teamRenameInput{ width: 100%; }
}

.teamStat{
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 10px 10px 9px;
}
.teamStatLabel{
  font-size: 12px;
  color: rgba(231,238,252,0.62);
  font-weight: 800;
  letter-spacing: .2px;
}
.teamStatValue{
  margin-top: 6px;
  font-size: 18px;
  font-weight: 950;
  letter-spacing: .2px;
}

/* Teams KPI layout (like Balance card) */
.teamCardKPI{
  padding: 18px 18px 16px;
  border-radius: 26px;
  background: radial-gradient(900px 420px at 20% 0%, rgba(255,59,59,0.20), rgba(255,255,255,0.03));
}
.teamNameBig{ font-size: 22px; }
.teamKpiRows{
  position: relative;
  z-index: 1;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.teamCardKPI .weekBalRow{
  padding: 12px 12px;
  border-radius: 18px;
}
.teamCardFooter{
  position: relative;
  z-index: 1;
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
@media(max-width: 820px){
  .teamNameBig{ font-size: 20px; }
  .teamCardFooter{ flex-direction: column; align-items: stretch; }
  .teamCardFooter .teamRename{ width: 100%; }
  .teamCardFooter .teamRenameInput{ width: 100%; }
}


/* Filters bar (expense page) */
.filters-bar{
  display:grid;
  grid-template-columns: 2fr 1.3fr 1fr auto;
  gap: 14px;
  align-items:end;
}
.filters-actions{
  display:flex;
  gap: 10px;
  align-items:end;
}
.filters-actions .btn{ width: 200px; }
.filters-actions .link{ white-space: nowrap; align-self:center; }

.filters-summary{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap:wrap;
  margin-top: 12px;
}

@media(max-width: 920px){
  .filters-bar{ grid-template-columns: 1fr; }
  .filters-actions{ justify-content: space-between; }
  .filters-actions .btn{ width: 100%; }
}

/* Teams page: period filter (date range + actions on the right) */
.teamsFiltersForm{ margin: 0; }
.teamsFiltersRow{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
}
.teamsFiltersActions{
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: flex-end;
}
.teamsFiltersActions .btn{ width: 220px; }
.teamsFiltersActions .link{ white-space: nowrap; align-self: center; }

@media(max-width: 920px){
  .teamsFiltersRow{ grid-template-columns: 1fr; }
  .teamsFiltersActions{ justify-content: space-between; }
  .teamsFiltersActions .btn{ width: 100%; }
}

/* ===== Stats tabs (segmented) ===== */
.segTabs{
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
  flex-wrap: wrap;
}
.segTab{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: .2px;
  color: rgba(231,238,252,0.88);
  border: 1px solid rgba(231,238,252,0.10);
  background: rgba(255,255,255,0.02);
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
.segTab:hover{
  background: rgba(255,255,255,0.06);
  border-color: rgba(231,238,252,0.16);
}
.segTab:active{ transform: translateY(1px) scale(0.99); }
.segTab.active{
  background: rgba(255,59,59,0.18);
  border-color: rgba(255,59,59,0.55);
  color: rgba(231,238,252,0.98);
}

.statsSummary{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.statsChip{
  display:inline-flex;
  gap: 8px;
  align-items:center;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .2px;
  color: rgba(231,238,252,0.90);
}
.statsChipGross{ border-color: rgba(140, 120, 255, 0.35); background: rgba(140, 120, 255, 0.08); }
.statsChipNet{ border-color: rgba(255,59,59,0.40); background: rgba(255,59,59,0.10); }
.statsChipExpense{ border-color: rgba(255,92,92,0.38); background: rgba(255,92,92,0.08); }
.statsChipWeek{ border-color: rgba(120,205,255,0.35); background: rgba(120,205,255,0.10); cursor:pointer; }
.statsChipWeek:hover{ background: rgba(120,205,255,0.14); }

.crm-modal-card.crm-modal-wide{
  width: min(760px, calc(100% - 32px));
}

.weekbal-table th, .weekbal-table td{ vertical-align: top; }

.weekbal-editbar{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap:wrap;
  margin-top:14px;
}
.weekbal-actions{ text-align: right; }

/* Week balance edit form inside modal: add comfortable spacing + prevent elements from "sticking" to each other */
.weekBalFormModal{ margin-top: 14px; }
.weekBalFormModal .weekBalGrid{ gap: 14px; margin-bottom: 24px; }
/* Push buttons noticeably ниже полей, чтобы они не "наезжали" визуально */
.weekBalFormModal .weekbal-editbar{
  /* ВАЖНО: дополнительный зазор между инпутами и кнопками (в модалке смотрится как "наезд") */
  margin-top: 18px !important;
  padding-top: 6px;
}
.weekBalFormModal #weekBalEditingLabel{
  flex: 0 0 100%;
  min-width: 0;
  margin-top: 2px;
}
.weekBalFormModal .weekbal-help{
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.35;
}

@media(max-width: 640px){
  .weekBalFormModal .weekbal-editbar .btn.btn-inline{ width: 100%; }
}

/* ===== KPI cards (Stats) ===== */
.kpiGrid{
  display:grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
@media(max-width: 1200px){ .kpiGrid{ grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media(max-width: 920px){ .kpiGrid{ grid-template-columns: 1fr; } }

.kpiCard{
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.035);
  border-radius: 18px;
  padding: 12px 12px 11px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  min-height: 88px;
}
.kpiCard::before{
  content:"";
  position:absolute;
  inset:-1px;
  background: radial-gradient(70% 120% at 0% 0%, rgba(var(--accent, 72, 156, 255), 0.20), transparent 60%);
  pointer-events:none;
}
.kpiLabel{ position:relative; z-index:1; font-size:12px; color: rgba(231,238,252,0.65); font-weight: 800; letter-spacing: .2px; }
.kpiValue{ position:relative; z-index:1; margin-top: 6px; font-size: 18px; font-weight: 950; letter-spacing: .2px; }
.kpiSub{ position:relative; z-index:1; margin-top: 6px; font-size: 12px; color: rgba(231,238,252,0.62); }

.kpiGross{ --accent: 140, 120, 255; border-color: rgba(140, 120, 255, 0.22); }
.kpiNet{ --accent: 255, 95, 95; border-color: rgba(255,59,59,0.22); }
.kpiExpense{ --accent: 255, 92, 92; border-color: rgba(255,92,92,0.22); }

.kpiDelta{ font-weight: 950; }
.kpiUp{ color: rgba(110, 240, 170, 0.95); }
.kpiDown{ color: rgba(255, 92, 92, 0.92); }


/* ===== History ===== */
.histGrid{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:14px;
  margin-top:12px;
}
@media (max-width: 1100px){
  .histGrid{ grid-template-columns: 1fr; }
}
.histCard{
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  background: rgba(255,255,255,.03);
  padding:12px;
  min-height: 140px;
}
.histHead{
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-weight:700;
  margin-bottom:8px;
}
.histHead .link{
  font-weight:600;
  font-size:12px;
  color: rgba(120,205,255,.95);
  text-decoration:none;
}
.histList{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.histItem{ margin:0; }
.histBtn{
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.12);
  color: inherit;
  cursor:pointer;
  text-align:left;
  transition: transform .06s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.histBtn:hover{
  border-color: rgba(120,205,255,.25);
  background: rgba(120,205,255,.06);
}
.histBtn:active{ transform: translateY(1px) scale(0.995); }
.histLeft{ min-width:0; }
.histTitle{
  font-size:12px;
  color: rgba(255,255,255,.82);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.histSub{
  margin-top:2px;
  font-size:12px;
  color: rgba(255,255,255,.55);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.histRight{
  text-align:right;
  flex: 0 0 auto;
}
.histAmt{
  font-weight:800;
  font-size:13px;
}
.histMeta{
  font-size:11px;
  color: rgba(255,255,255,.55);
}

/* Manual week balance card (dashboard / stats) */
.weekBalGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media(max-width: 420px){
  .weekBalGrid{ grid-template-columns: 1fr; }
}
.weekBalRead{ display:flex; flex-direction:column; gap: 8px; }
.weekBalRow{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(0,0,0,0.10);
}
.weekBalRow b{ font-size: 13px; }

/* make inline forms look nice */
form.inline{ display:inline; }
.btn.danger{
  border-color: rgba(255,120,120,.35);
  background: rgba(255,120,120,.08);
}
.btn.danger:hover{
  background: rgba(255,120,120,.16);
}
.btn.sm{
  padding:6px 10px;
  font-size:12px;
  border-radius:10px;
}



/* --- Salary history batch details toggle --- */
.histBtn{ flex-wrap: wrap; }
.histBtn.open{
  box-shadow: 0 0 0 1px rgba(120, 140, 255, 0.28), 0 16px 60px rgba(0,0,0,0.45);
}
.histDetails{
  width: 100%;
  flex: 0 0 100%;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(231,238,252,0.08);
  display: none;
}
.histBtn.open .histDetails{ display: block; }
.histDetailsHead{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.histDetailsBody{
  background: rgba(0,0,0,0.14);
  border: 1px solid rgba(231,238,252,0.06);
  border-radius: 14px;
  overflow: hidden;
}

/* --- Salary history filters: compact layout, buttons on the right --- */
.salaryHistFiltersGrid{
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}

.salaryHistForm{ margin: 0; }

.salaryHistRow{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
}

.salaryHistInputs{ min-width: 0; }

.salaryHistPeriod{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 280px;
}

.salaryHistActions{
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: flex-end;
}

.salaryHistActions .link{ justify-content: center; }

.salaryHistDivider{
  width: 1px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  align-self: stretch;
}

.salaryHistHint{ margin-top: 10px; }

@media (max-width: 980px){
  .salaryHistFiltersGrid{
    grid-template-columns: 1fr;
  }
  .salaryHistDivider{ display: none; }
  .salaryHistRow{ grid-template-columns: 1fr; }
  .salaryHistActions{
    flex-direction: row;
    flex-wrap: wrap;
  }
}



/* ===== Date inputs (calendar) ===== */
input[type="date"]{
  color-scheme: dark;
  padding-right: 44px;
}
input[type="date"]::-webkit-calendar-picker-indicator{
  opacity: .75;
  filter: invert(1);
  cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover{
  opacity: 1;
}
input[type="date"]::-webkit-datetime-edit{
  padding: 0;
}



/* ===== Dashboard chart ===== */
.chartCard{
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--stroke2);
  border-radius: 22px;
  background:
    radial-gradient(1200px 300px at 15% 0%, rgba(255,59,59,0.18) 0%, rgba(255,59,59,0.10) 40%, rgba(255,59,59,0.03) 65%, rgba(255,59,59,0) 100%),
    radial-gradient(900px 260px at 90% 30%, rgba(255,59,59,0.14) 0%, rgba(255,59,59,0.07) 45%, rgba(255,59,59,0.02) 70%, rgba(255,59,59,0) 100%),
    rgba(255,255,255,0.02);
}
.chartHead{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.chartTotals{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}
.chip{
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .2px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.03);
}
.chip-income{
  border-color: rgba(255,59,59,0.55);
  background: rgba(255,59,59,0.14);
}
.chip-expense{
  border-color: rgba(255,59,59,0.55);
  background: rgba(255,59,59,0.12);
}
.chartBox{
  margin-top: 14px;
  height: 270px;
  border-radius: 18px;
  border: 1px solid var(--stroke2);
  background: rgba(0,0,0,0.16);
  padding: 10px;
}
.chartBox canvas{
  width: 100% !important;
  height: 100% !important;
}

.chartBox.donutBox{ height: 340px; }

.donutLayout{
  height: 100%;
  display: flex;
  align-items: center;
  gap: 18px;
}
.donutCanvas{
  flex: 1 1 60%;
  min-width: 300px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.donutCanvas canvas{
  max-width: 520px;
}
.donutLegend{
  flex: 0 0 320px;
  max-width: 360px;
  height: 100%;
  overflow: auto;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.donutLegendRow{
  appearance: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.88);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease, transform .05s ease;
}
.donutLegendRow:hover{
  border-color: rgba(255,59,59,0.35);
  background: rgba(0,0,0,0.24);
}
.donutLegendRow:active{
  transform: translateY(1px);
}
.donutLegendRow.is-off{
  opacity: 0.45;
  filter: saturate(0.6);
}
.donutLegendRow .dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}
.donutLegendRow .lbl{
  flex: 1 1 auto;
  font-weight: 900;
  letter-spacing: .2px;
}
.donutLegendRow .val{
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  color: rgba(255,255,255,0.78);
}
.donutLegendRow .pct{
  margin-left: 8px;
  font-weight: 800;
  color: rgba(255,255,255,0.52);
}

@media (max-width: 980px){
  .chartBox.donutBox{ height: 560px; }
  .donutLayout{
    flex-direction: column;
    align-items: stretch;
  }
  .donutCanvas{
    min-width: 0;
  }
  .donutLegend{
    flex: 0 0 auto;
    max-width: none;
    height: auto;
  }
}


/* ===== Custom Date Range Picker (dark) ===== */
.js-date-range{
  cursor: pointer;
  user-select: none;
  padding-right: 46px;
  background-image:
    radial-gradient(16px 16px at calc(100% - 18px) 50%, rgba(120,205,255,0.20), transparent 60%);
}
.js-date-range:focus{
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.25);
  border-color: rgba(47, 107, 255, 0.55);
}

.js-date-single{
  cursor: pointer;
  user-select: none;
  padding-right: 46px;
  background-image:
    radial-gradient(16px 16px at calc(100% - 18px) 50%, rgba(120,205,255,0.20), transparent 60%);
}
.js-date-single:focus{
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.25);
  border-color: rgba(47, 107, 255, 0.55);
}

.drp-popover,
.sdp-popover{
  position: fixed;
  z-index: 9999;
  width: 320px;
  display: none;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(231,238,252,0.10);
  background:
    radial-gradient(900px 320px at 20% 0%, rgba(255,59,59,0.18), transparent 60%),
    rgba(12, 18, 28, 0.95);
  box-shadow: 0 30px 90px rgba(0,0,0,0.60);
  backdrop-filter: blur(14px);
}

.drp-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 8px;
  padding: 4px 4px 10px;
}
.drp-title{
  flex:1;
  text-align:center;
  font-weight: 900;
  letter-spacing: .2px;
  color: rgba(231,238,252,0.95);
}
.drp-nav{
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(231,238,252,0.10);
  background: rgba(255,255,255,0.04);
  color: rgba(231,238,252,0.95);
  cursor: pointer;
}
.drp-nav:hover{
  background: rgba(255,255,255,0.08);
  border-color: rgba(120,205,255,0.25);
}

.drp-week{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 0 2px 8px;
  text-align:center;
  font-size: 12px;
  font-weight: 800;
  color: rgba(231,238,252,0.55);
}

.drp-grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.drp-empty{
  height: 36px;
}

.drp-day{
  height: 36px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(231,238,252,0.92);
  font-weight: 900;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .05s ease;
}
.drp-day:hover{
  background: rgba(120,205,255,0.10);
  border-color: rgba(120,205,255,0.22);
}
.drp-day:active{ transform: translateY(1px); }

.drp-day.in-range{
  background: rgba(255,59,59,0.22);
  border-color: rgba(255,59,59,0.06);
  border-radius: 12px;
}

.drp-day.start,
.drp-day.end{
  background: rgba(255,59,59,0.70);
  border-color: rgba(255,59,59,0.80);
  color: rgba(255,255,255,0.98);
  border-radius: 999px;
}

.drp-hint{
  margin-top: 10px;
  font-size: 12px;
  color: rgba(231,238,252,0.55);
  text-align: center;
}


/* ===== CRM Modal Confirm ===== */

body.modal-open{ overflow:hidden; }

.crm-modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.crm-modal.hidden{ display:none; }

.crm-modal.is-open{
  opacity: 1;
  pointer-events: auto;
}

.crm-modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .18s ease;
}

.crm-modal.is-open .crm-modal-backdrop{ opacity: 1; }

.crm-modal-card{
  position:relative;
  width:min(420px, calc(100% - 32px));
  border-radius: 20px;
  padding: 18px 18px 16px;
  background: linear-gradient(180deg, rgba(16,24,40,0.92), rgba(10,16,28,0.92));
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  transform: translateY(10px) scale(0.985);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}

.crm-modal.is-open .crm-modal-card{
  transform: none;
  opacity: 1;
}

.crm-modal-title{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .2px;
  margin-bottom: 8px;
}

.crm-modal-text{
  color: rgba(255,255,255,0.78);
  font-size: 14px;
  line-height: 1.35;
}

.crm-modal-actions{
  margin-top: 16px;
  display:flex;
  gap: 10px;
  justify-content:flex-end;
}

.btn.btn-inline{
  width:auto;
  height: 40px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 900;
}

.btn.btn-inline.sm{
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 900;
}

.btn.ghost{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}
.btn.ghost:hover{ background: rgba(255,255,255,0.10); }

/* Entry date (add income/expense to a chosen day) */
.entryDateBar{
  display:flex;
  gap:12px;
  align-items:flex-end;
  justify-content:space-between;
  padding:12px;
  border-radius:16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.entryDateRow{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}
.entryDateInput{
  height: 40px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.20);
  color: rgba(255,255,255,0.92);
}
