
/* === Consistent mobile layout & text scaling guard (Telegram WebApp) === */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body, #root { height: 100%; height: 100dvh; height: 100svh; overflow-x: hidden; background: var(--bg); }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; touch-action: manipulation; overscroll-behavior: contain; }
.wrap { width: 100%; max-width: 480px; margin: 0 auto; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); }
.calendar .day { min-width: 0; }
.day .head, .day .meta { font-size: clamp(10px, 2.3vw, 12px); line-height: 1.2; }
.btn { white-space: nowrap; }
:root { --safe-bottom: env(safe-area-inset-bottom, 0px); }

:root { --pad: 12px; --radius: 14px; --bg: #0e1621; --card: #17212b; --text: #e3e6eb; --muted:#9aa7b5; --accent:#5ea2ff; --danger:#ff6b6b; }
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
.wrap { max-width: 640px; margin: 0 auto; padding: var(--pad); }
.card { background: var(--card); border-radius: var(--radius); padding: var(--pad); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.row { display: flex; gap: var(--pad); align-items: center; }
.btn { background: var(--accent); color: #0b1220; border: none; border-radius: 12px; padding: 12px 14px; font-weight: 700; width: 100%; }
.muted{ color: var(--muted); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { background: #0f1b26; border-radius: 12px; min-height: 70px; padding: 6px; display:flex; flex-direction:column; }
.day .head { display:flex; justify-content:space-between; font-size:12px; color: var(--muted); }
.day .meta { margin-top:auto; font-size: 12px; }
.day.today { outline: 2px solid var(--accent); }
.day.weekend .head span:first-child { color: var(--danger); font-weight: 700; }
.sheet-wrap { position: fixed; inset: 0; display: grid; align-items: end;  z-index: 2000; }
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.sheet { position: relative; background: var(--card); border-top-left-radius: 20px; border-top-right-radius: 20px; padding: 16px; box-shadow: 0 -10px 30px rgba(0,0,0,.4); z-index: 1; }
.sheet input, .sheet textarea, .sheet select { width: 100%; background: #0f1b26; color: var(--text); padding: 10px; border: 1px solid #15202a; border-radius: 10px; }
.sheet label { display:block; font-size: 12px; margin: 8px 0 4px; color: var(--muted); }
.toolbar { display:flex; gap:8px; margin: 8px 0 12px; }
.grid-head { display:grid; grid-template-columns: repeat(7, 1fr); gap:6px; font-size:12px; color: var(--muted); margin-bottom:6px;}
.chip { font-size:11px; padding:4px 8px; border-radius: 999px; background:#0f1b26; border:1px solid #1c2a36; color:var(--muted); }
.spacer { height: 72px; }
.error-overlay { position: fixed; left: 12px; right: 12px; bottom: 88px; background:#2a0f12; color:#ffd1d1; border:1px solid #552; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.hdr { font-weight: 800; font-size: 20px; margin: 6px 0 12px; letter-spacing: .2px; }
.badge { font-size: 12px; color: var(--muted); }
.toggle { padding:8px 12px; border-radius: 10px; border:1px solid #1c2a36; background:#0f1b26; color:var(--text); }
.toggle.active { background:#1c2a36; }
/* --- totals bar --- */
.totals-bar{ position: sticky; top: 0; z-index: 10; }
.totals-row{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
.totals-row .vr{
  width:1px;
  height:20px;
  background: rgba(255,255,255,0.14);
}
.btn-sm{
  background:#2c7be5;
  color:#fff;
  border:none;
  border-radius:8px;
  padding:6px 10px;
  cursor:pointer;
}
.btn-sm:hover{opacity:0.92}
.totals-bar input[type="number"]{
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
}

.totals-bar{ z-index: 10; }
.modal, .modal-backdrop{ z-index: 1000; }


/* --- overlay & summary fixes --- */
html:has(.sheet-wrap.open) .totals-bar { display: none !important; }
.totals-bar { position: sticky; bottom: 0; z-index: 10; }
.modal, .modal-backdrop { z-index: 1060 !important; }


.btn-danger{ background: var(--danger) !important; color: #fff !important; border: none !important; }


/* --- iOS safe area + sticky toolbar --- */
:root { --safe-bottom: env(safe-area-inset-bottom, 0px); }
.sheet { padding-bottom: calc(var(--pad) + var(--safe-bottom)); }
.sheet .toolbar { 
  position: sticky; 
  bottom: 0; 
  background: var(--card);
  padding: 8px 0 calc(8px + var(--safe-bottom));
  margin-top: 8px;
}

/* Switch (iOS-like) */
.switch { position: relative; width: 44px; height: 26px; display:inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position:absolute; inset:0; background:#334152; border-radius: 999px; transition: .2s; }
.switch .slider:before { content:""; position:absolute; height:22px; width:22px; left:2px; top:2px; background:white; border-radius:50%; transition:.2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); }


/* Tiny 3-line meta block inside day tile */
.meta3 { font-size: 9px; line-height: 1.05; display:flex; flex-direction:column; gap: 2px;  white-space: nowrap; font-size: 8.5px; line-height: 1.0;
.meta3 .ln1, .meta3 .ln2, .meta3 .ln3 { min-height: 10px; }
.tag.ok { color: #22c55e; }         /* green */
.tag.bad { color: var(--danger); }  /* red */
.tag.off { color: var(--accent); }  /* accent for "выходной" */



/* Off-day strike-through */
.day.off { position: relative; }
.day.off::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  top: 50%;
  height: 2px;
  background: rgba(94,162,255,0.6);
  border-radius: 2px;
  pointer-events: none;
}
.day.off .meta3 { opacity: 0.7; }


/* German public holidays (red) */
.day.holiday .date { color: #ef4444; }
.day.holiday { outline: 1px dashed rgba(239,68,68,0.5); outline-offset: -2px; }


/* Stronger holiday highlight */
.day.holiday { box-shadow: inset 0 0 0 2px rgba(239,68,68,0.7); }
.day.holiday .ln1, .day.holiday .ln2, .day.holiday .ln3 { color: #ef4444; }



/* Holiday marking same as weekend */
.day.holiday .date { color: #ef4444; }
.day.holiday .ln1 { color: #ef4444; }
.day.holiday { box-shadow: inset 0 0 0 2px rgba(239,68,68,.7); }


.day.holiday .head span:first-child { color: var(--danger); font-weight: 700; }

.calendar .day.holiday .head span:first-child { color: var(--danger) !important; font-weight: 700; }
