/* Karavan brand: the logo is gold on black, so the app keeps that look instead of following the Telegram theme. */
:root {
  --bg: #000000;
  --card: #151412;
  --line: rgba(201, 150, 60, .22);
  --text: #f2eadb;
  --hint: #9c927f;
  --gold: #c0892a;
  --gold-light: #dcaa4e;
  --on-gold: #140f05;
  --error: #ff7a6b;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  /* Telegram sets these insets in fullscreen / on notched phones so content isn't hidden under its buttons. */
  padding:
    calc(12px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px))
    16px
    calc(24px + var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
  min-height: var(--tg-viewport-stable-height, 100vh);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  background: radial-gradient(ellipse at 50% 0%, #22201c 0%, var(--bg) 70%) fixed;
  background-color: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
h2 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; color: var(--gold-light); }
.muted { color: var(--hint); margin: 4px 0 0; }

header { text-align: center; margin-bottom: 14px; }
.logo { display: block; margin: 0 auto; width: 110px; height: auto; transition: width .25s ease; mix-blend-mode: lighten; }
body.signed-out .logo { width: min(260px, 70vw); margin-top: 12px; }
body.signed-out header { margin-bottom: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
#login { max-width: 360px; margin: 0 auto; }
.tag.closed { color: var(--gold-light); border-color: var(--gold); margin-left: 6px; vertical-align: 1px; }
#monthAction { margin-top: 10px; }
.tag { font-size: 11px; font-weight: 500; color: var(--hint); border: 1px solid var(--hint); border-radius: 6px; padding: 0 5px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list small { color: var(--hint); display: block; }

button {
  background: var(--gold); color: var(--on-gold);
  border: 0; border-radius: 8px; padding: 6px 12px; font: inherit; font-weight: 600;
}
button:active { background: var(--gold-light); }
button.danger { background: transparent; color: var(--error); border: 1px solid var(--error); font-weight: 400; margin-left: auto; }
button.link { background: none; border: 0; padding: 0; color: var(--hint); font-weight: 400; text-decoration: underline; }
button.off { background: transparent; color: var(--hint); border: 1px solid var(--hint); font-weight: 400; }
button.wide { width: 100%; padding: 11px; }
button:disabled { opacity: .35; }

label { display: block; margin-bottom: 10px; color: var(--hint); font-size: 13px; }
input, select, output.field {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #0b0a09; color: var(--text); font: inherit;
  font-size: 16px; /* below 16px iOS zooms the page on focus */
  -webkit-appearance: none; appearance: none;
}
input::placeholder { color: #5a554c; }
/* While typing, leave room under the form so the keyboard never covers the Save button. */
body.typing { padding-bottom: 45vh; }
input:focus, select:focus { outline: none; border-color: var(--gold); }
select { min-height: 44px; background-image: linear-gradient(45deg, transparent 50%, var(--hint) 50%), linear-gradient(135deg, var(--hint) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
select:disabled, input:disabled { opacity: .5; }
output.field { color: var(--gold-light); font-weight: 600; min-height: 44px; }
.error { color: var(--error); margin: 0 0 10px; }


.small { font-size: 12px; }
.center { text-align: center; }
.gold { color: var(--gold-light); }

/* payroll summary */
.summary-top { display: flex; justify-content: space-between; align-items: baseline; }
.summary-top .muted { margin: 0; }
.big { margin: 6px 0 0; }
.big b { font-size: 30px; color: var(--gold-light); letter-spacing: -.5px; }
.big span { color: var(--hint); font-size: 15px; }
.bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); margin: 10px 0 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-light)); transition: width .3s ease; }

/* section tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tabs button { flex: 1; background: transparent; color: var(--hint); font-weight: 500; padding: 8px; }
.tabs button.active { background: var(--gold); color: var(--on-gold); }

/* log */
.monthbar { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 34px; margin-bottom: 8px; }
.monthbar b { color: var(--gold-light); font-size: 16px; }
button.icon { font-size: 20px; line-height: 1; padding: 4px 12px; }
.seg { display: flex; gap: 6px; flex-shrink: 0; }
.choice { background: transparent; color: var(--hint); border: 1px solid rgba(255,255,255,.15); font-weight: 500; padding: 6px 10px; }
.choice.yes.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.choice.no.on { background: rgba(255,122,107,.15); border-color: var(--error); color: var(--error); }

/* red/green day strip */
:root { --good: #4fbf73; }
/* The strip runs to the screen edges (cancelling the body's 16px gutter) so it reads as scrollable,
   while padding keeps day 1 lined up with the cards. ::after is the end gutter (iOS drops right padding). */
.days { position: relative; display: flex; gap: 6px; overflow-x: auto; padding: 2px 16px 8px; margin: 0 -16px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.days::after { content: ''; flex: 0 0 10px; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 auto; width: 42px; padding: 5px 0; border-radius: 10px;
  background: var(--card); color: var(--text); border: 2px solid var(--line);
  display: flex; flex-direction: column; align-items: center; font-weight: 500;
}
.day small { color: var(--hint); font-size: 10px; text-transform: uppercase; }
.day b { font-size: 15px; }
.day.done { border-color: var(--good); }
.day.missing { border-color: var(--error); }
.day.sel { background: var(--gold); color: var(--on-gold); }
.day.sel small { color: var(--on-gold); }
.bad { color: var(--error); margin: 0; font-weight: 500; }
.good { color: var(--good); margin: 0; font-weight: 500; }

/* staff */
#addStaff { margin-bottom: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
@media (max-width: 360px) { .row2 { grid-template-columns: 1fr; } .choice { padding: 6px 8px; } }
.actions { display: flex; gap: 8px; }
.hint { margin: -4px 0 12px; }
.hint b { color: var(--text); }
.list button.danger { margin-left: 0; flex-shrink: 0; padding: 6px 10px; }
.actions button { padding: 10px 16px; }
.choice { min-height: 36px; }
.list li > div:first-child { min-width: 0; }
.list li b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .right { text-align: right; flex-shrink: 0; padding-left: 10px; }
.list li.tappable { cursor: pointer; }
.list li.removed { opacity: .5; }
.list li.empty { color: var(--hint); justify-content: center; }
.list.card { padding: 4px 14px; }
#missingNote, #dayNote { margin: 0 0 4px; }
.daypay { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; margin-top: 10px; }
.daypay b { font-size: 20px; color: var(--gold-light); }
[hidden] { display: none !important; }
/* five tabs: icon over a short label so Russian/Uzbek names fit on a phone */
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 5px; font-size: 11px; min-width: 0; }
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h2.section { margin: 22px 0 10px; }
#addItem { margin-bottom: 12px; }
.list .note { color: var(--text); opacity: .75; font-style: italic; }

/* language switch (top right of the payroll card) */
.lang { display: flex; gap: 2px; background: #0b0a09; border: 1px solid var(--line); border-radius: 8px; padding: 2px; flex-shrink: 0; }
.lang button { background: transparent; color: var(--hint); font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 6px; }
.lang button.on { background: var(--gold); color: var(--on-gold); }
.summary-top { gap: 10px; align-items: center; }

/* buy: menu items as big tap targets; gold squares mark days with purchases */
.items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.items .item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: #0b0a09; color: var(--text); border: 1px solid var(--line); padding: 10px 12px; min-height: 56px; font-weight: 500;
}
.items .item b { color: var(--gold-light); font-size: 14px; }
.items .item:active { background: rgba(192, 137, 42, .18); }
#buyHint { margin: 2px 0 8px; }
#buyHint.bad { color: var(--error); }
.day.has { border-color: var(--gold); }
#buyTotals { margin: 0 0 8px; }

/* staff list row arrow and one person's month page */
.chev { color: var(--hint); font-size: 20px; line-height: 1; margin-left: -2px; }
.detail-top { display: flex; justify-content: space-between; margin-bottom: 12px; }
.detail-top button { padding: 8px 14px; }
h2.person { color: var(--text); font-size: 19px; margin-bottom: 0; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 12px; }
.cal small { text-align: center; color: var(--hint); font-size: 10px; text-transform: uppercase; }
.cal .cd { padding: 0; height: 36px; border-radius: 8px; background: rgba(255,255,255,.05); color: var(--hint); font-weight: 600; font-size: 14px; }
.cal .cd.came { background: var(--good); color: #06140b; }
.cal .cd.absent { background: var(--error); color: #1d0705; }
.cal .cd.future { opacity: .25; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--hint); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: rgba(255,255,255,.12); }
.legend i.came { background: var(--good); }
.legend i.absent { background: var(--error); }
.calc-row { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.calc-row:first-child { border-top: 0; }
.calc-row span { color: var(--hint); }
.calc-row small { grid-column: 1 / -1; text-align: right; color: var(--hint); font-size: 11px; }
.calc-row.total b { color: var(--gold-light); font-size: 20px; }
#sendPdf { margin-bottom: 8px; }

/* stats */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.kpi small { display: block; color: var(--hint); font-size: 11px; }
.kpi b { display: block; font-size: 18px; color: var(--gold-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi span { display: block; color: var(--hint); font-size: 11px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; margin: 10px 0 16px; }
.bars .col { position: relative; flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; background: none; padding: 0; border-radius: 0; opacity: .7; }
.bars .col.sel { opacity: 1; }
.bars .col:active { background: none; }
.bars .col i { display: block; width: 100%; }
.bars .col i:first-of-type { border-radius: 3px 3px 0 0; }
.bars .col.sel::after { content: ''; position: absolute; inset: 0 -1px; border-radius: 4px; background: rgba(255,255,255,.06); pointer-events: none; }
.bars .cost { background: var(--gold); }
.bars .came { background: var(--good); }
.bars .absent { background: var(--error); }
.bars .col small { position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--hint); }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(0, 34%) 1fr; gap: 2px 10px; align-items: center; font-size: 13px; }
.hbar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 4px; background: var(--gold); }
.hbar .track i.absent { background: var(--error); }
.hbar small { grid-column: 2; color: var(--hint); font-size: 11px; margin-top: -2px; }
.tabs { gap: 2px; padding: 3px; }
