/* Рабочий календарь v2 — mobile-first, safe-area, без тяжёлых эффектов */
:root {
  --bg: #0a0c10;
  --card: #12161f;
  --card2: #171c27;
  --line: #232a38;
  --text: #e8ecf4;
  --mut: #8b93a7;
  --acc: #6c8cff;
  --acc2: #8a5cff;
  --ok: #3ddc84;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
}

.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.bg-orbs i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .16; }
.bg-orbs i:nth-child(1) { width: 420px; height: 420px; background: #4b5fd6; top: -140px; left: -120px; }
.bg-orbs i:nth-child(2) { width: 360px; height: 360px; background: #7a3fd6; bottom: -140px; right: -100px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 4px;
  max-width: 720px; margin: 0 auto;
}
.brand { font-size: 18px; }
.icon-btn {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 17px; width: 42px; height: 42px; cursor: pointer;
  touch-action: manipulation;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 10px 14px; display: grid; gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}
.card-title { font-size: 15px; margin-bottom: 12px; }

.month-nav { display: flex; align-items: center; gap: 8px; padding: 8px; }
.month-title { flex: 1; text-align: center; font-weight: 700; font-size: 18px; text-transform: capitalize; }
.nav-btn {
  background: var(--card2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  width: 48px; height: 44px; font-size: 20px; cursor: pointer;
  touch-action: manipulation;
}
.nav-btn:active { transform: scale(.94); }
.nav-today { font-size: 15px; }

.cal-card { touch-action: pan-y; }
.dow-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 7px; margin-bottom: 7px; text-align: center;
  color: var(--mut); font-size: 12px; text-transform: uppercase;
}
.dow-row .weekend { color: #b18cff; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.day {
  position: relative;
  min-height: 50px; border-radius: 13px;
  background: var(--card2);
  border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 15.5px; cursor: pointer; user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background .12s ease, border-color .12s ease;
}
.day:active { transform: scale(.93); }
.day.future { color: var(--mut); background: rgba(23, 28, 39, .55); }
.day.weekend:not(.worked) { color: #c3b2f5; }
.day.weekend.future { color: #7f74a8; }
.day.today { border-color: var(--acc); }
.day.worked {
  background: linear-gradient(135deg, var(--acc), var(--acc2));
  color: #fff; font-weight: 700;
  box-shadow: 0 4px 14px rgba(108, 140, 255, .35);
}
.day .tick { position: absolute; top: 3px; right: 5px; font-size: 10px; }
.legend {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-top: 11px; color: var(--mut); font-size: 12px;
}
.legend .hint { margin-left: auto; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.lg-work { background: linear-gradient(135deg, var(--acc), var(--acc2)); }
.lg-today { background: transparent; border: 2px solid var(--acc); height: 8px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { text-align: center; padding: 14px 6px; }
.stat-num { font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.stat-num.money { color: #7ee2a8; }
.stat-cap { color: var(--mut); font-size: 12px; margin-top: 4px; }

.payout-list { display: grid; gap: 10px; }
.payout {
  display: flex; align-items: center; gap: 12px;
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px;
}
.payout .badge {
  min-width: 54px; text-align: center;
  background: rgba(108, 140, 255, .14);
  color: var(--acc); border-radius: 10px;
  padding: 6px 4px; font-weight: 700; font-size: 12.5px; line-height: 1.25;
}
.payout .badge small { display: block; color: var(--mut); font-weight: 500; font-size: 10.5px; }
.payout .p-info { flex: 1; min-width: 0; }
.payout .p-title { font-weight: 700; font-size: 14px; }
.payout .p-period { color: var(--mut); font-size: 12.5px; margin-top: 2px; }
.payout .p-sum { font-size: 17px; font-weight: 800; color: #7ee2a8; white-space: nowrap; }
.fine { color: var(--mut); font-size: 12px; margin-top: 10px; line-height: 1.5; }

.history { display: grid; gap: 10px; }
.h-month { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.h-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.h-name { font-weight: 700; text-transform: capitalize; }
.h-total { color: #7ee2a8; font-weight: 800; }
.h-rows { display: grid; gap: 6px; }
.h-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(10, 12, 16, .45); border-radius: 10px; padding: 8px 10px;
}
.h-row .h-title { font-size: 13px; font-weight: 600; flex-shrink: 0; }
.h-row .h-period { color: var(--mut); font-size: 12px; flex: 1; min-width: 0; }
.h-row .h-sum { font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.h-paid-btn {
  background: transparent; border: 1px solid var(--line); color: var(--mut);
  border-radius: 8px; font-size: 11.5px; padding: 6px 8px; cursor: pointer;
  touch-action: manipulation; flex-shrink: 0;
}
.h-paid-btn.on { border-color: rgba(61, 220, 132, .45); color: var(--ok); font-weight: 700; }
.history .empty { color: var(--mut); font-size: 13.5px; text-align: center; padding: 8px 0 2px; }

.btn {
  width: 100%; border: none; border-radius: 14px;
  min-height: 50px; padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer;
  margin-top: 10px; touch-action: manipulation;
}
.btn-primary { background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #fff; }
.btn-ghost { background: var(--card2); color: var(--mut); border: 1px solid var(--line); }
.btn-ghost.danger { color: var(--danger); border-color: rgba(255, 107, 107, .35); }
.btn:active { transform: scale(.98); }

/* модалка-шторка */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 7, 10, .72);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 560px;
  background: var(--card);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.sheet-handle { width: 44px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-size: 17px; }
.sheet-sec {
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px; margin-top: 10px;
}
.sheet-cap { color: var(--mut); font-size: 13px; margin-bottom: 8px; }
.rate-row { display: flex; gap: 8px; }
.rate-row input {
  flex: 1; min-width: 0; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 18px; font-weight: 700; padding: 12px;
}
.step-btn {
  width: 52px; border-radius: 12px; font-size: 22px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  cursor: pointer; touch-action: manipulation;
}
.step-btn:active { transform: scale(.94); }
.txt {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 16px; padding: 13px; margin-top: 8px;
  letter-spacing: 2px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1d2432; border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 11px 18px; font-size: 14px; z-index: 60;
  white-space: nowrap;
}

/* логин */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  width: min(360px, calc(100vw - 40px));
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 28px 22px; text-align: center;
}
.login-emoji { font-size: 40px; }
.login-card h1 { font-size: 20px; margin: 10px 0 4px; }
.login-sub { color: var(--mut); font-size: 14px; margin-bottom: 14px; }
.login-err {
  background: rgba(255, 107, 107, .12); color: var(--danger);
  border-radius: 10px; padding: 8px; font-size: 13px; margin-bottom: 10px;
}
.pin-input {
  width: 100%; text-align: center; font-size: 24px; letter-spacing: 8px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); padding: 12px; margin-bottom: 6px;
}

@media (max-width: 420px) {
  .wrap { padding: 8px 10px; gap: 12px; }
  .day { min-height: 44px; font-size: 14.5px; }
  .cal, .dow-row { gap: 5px; }
  .stats-row { gap: 8px; }
  .stat-num { font-size: 16.5px; }
  .legend .hint { display: none; }
}

/* ===== v3: баннер, план/факт ===== */
.banner {
  display: flex; align-items: center; gap: 14px;
  border-radius: 18px; padding: 15px 16px;
  border: 1px solid var(--line);
}
.banner .b-emoji { font-size: 30px; }
.banner .b-body { flex: 1; min-width: 0; }
.banner .b-title { font-weight: 800; font-size: 15.5px; }
.banner .b-sub { color: var(--mut); font-size: 13px; margin-top: 3px; }
.banner .b-sub b { color: #7ee2a8; }
.banner.today.advance { background: linear-gradient(135deg, rgba(108,140,255,.22), rgba(138,92,255,.22)); border-color: rgba(108,140,255,.5); }
.banner.today.salary { background: linear-gradient(135deg, rgba(61,220,132,.2), rgba(108,140,255,.18)); border-color: rgba(61,220,132,.5); }
.banner.soon { background: var(--card); }
.banner.soon.advance .b-title { color: var(--acc); }
.banner.soon.salary .b-title { color: var(--ok); }
.b-btn {
  background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #fff;
  border: none; border-radius: 12px; padding: 11px 14px;
  font-size: 13.5px; font-weight: 700; cursor: pointer; touch-action: manipulation;
}

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.cal-mode { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.mode-btn {
  border: none; background: transparent; color: var(--mut);
  font-size: 13px; font-weight: 700; padding: 8px 14px; border-radius: 9px;
  cursor: pointer; touch-action: manipulation;
}
.mode-btn.active { background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #fff; }
.cal-hint { color: var(--mut); font-size: 11.5px; text-align: right; }

.day.planned {
  background: rgba(255, 180, 84, .16);
  border: 2px dashed rgba(255, 180, 84, .65);
  color: #ffcf94;
}
.day.both { border-style: solid; }
.day.planned.future { color: #e8b06c; }
.legend .lg-plan { background: rgba(255,180,84,.25); border: 2px dashed rgba(255,180,84,.8); height: 8px; }
.p-note { font-style: normal; color: var(--mut); font-size: 11.5px; font-weight: 500; }
.btn.big { margin-top: 0; padding: 15px; font-size: 15.5px; }


/* v3.1: планы — заметный оранжевый (перебивает .future) */
.cal .day.planned,
.cal .day.planned.future {
  background: linear-gradient(135deg, rgba(255,180,84,.38), rgba(255,138,56,.30));
  border: 2px dashed #ffb454;
  color: #ffe3bd;
  font-weight: 700;
}
.cal .day.planned::after {
  content: "\1F5D3";
  position: absolute; bottom: 2px; right: 4px; font-size: 9px; opacity: .9;
}


/* v5: будущая смена + зелёный выходной */
.cal .day.rest {
  background: rgba(61, 220, 132, .10);
  border: 1.5px solid rgba(61, 220, 132, .32);
  color: #8fd9ae;
}
.cal .day.rest.weekend { background: rgba(61, 220, 132, .16); }
.cal .day.rest.today { border-color: var(--acc); }
.cal .day.upcoming {
  background: linear-gradient(135deg, rgba(108,140,255,.20), rgba(138,92,255,.16));
  border: 2px dashed var(--acc);
  color: #cdd9ff;
  font-weight: 700;
}
.cal .day.upcoming .tick { font-size: 11px; }
.lg-rest { background: rgba(61,220,132,.25); border: 1.5px solid rgba(61,220,132,.5); }
.lg-soon { background: rgba(108,140,255,.2); border: 2px dashed var(--acc); height: 8px; }
