/* September 2026 timesheets — one stylesheet for the whole page. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1d2430;
  --muted: #5f6b7a;
  --line: #d9dde3;
  --primary: #1f6f43;
  --primary-ink: #ffffff;
  --weekend: #eef3fa;
  --error: #b42318;
  --error-bg: #fdecea;
  --good: #1f6f43;
  --radius: 12px;
  --vvh: 100vh;
  --vvtop: 0px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.no-scroll { overflow: hidden; }

.view { max-width: 720px; margin: 0 auto; padding: 16px 12px 40px; }

h1 { font-size: 24px; line-height: 1.25; margin: 4px 0 4px; font-weight: 700; }
h2, h3 { margin: 0; }

.muted { color: var(--muted); }
.center { text-align: center; padding: 24px 0; }

/* ---------- controls ---------- */
input[type="text"], input[type="search"] {
  font: inherit;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #b9c0ca;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus { outline: 2px solid #2f6fdb; outline-offset: 1px; border-color: #2f6fdb; }
input::placeholder { color: #8a94a3; }
input.needs-value { border-color: var(--error); outline: 2px solid var(--error); outline-offset: 1px; }

.btn {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-ink);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn-small { min-height: 44px; padding: 8px 16px; }
.btn-secondary { background: #fff; color: var(--ink); border-color: #b9c0ca; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-big { width: 100%; min-height: 56px; font-size: 19px; }
.btn-back { background: transparent; color: var(--ink); border-color: #b9c0ca; padding: 8px 14px; min-height: 44px; flex: none; }

/* ---------- list page ---------- */
.list-head { padding: 4px 4px 12px; }
.done-count { margin: 0; font-size: 20px; font-weight: 600; color: var(--primary); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.field { display: block; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.field-msg { margin: -4px 0 12px; color: var(--error); font-size: 16px; }
.field-msg.is-good { color: var(--good); }

.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 16px;
}
.banner-error { background: var(--error-bg); color: var(--error); border: 1px solid #f5c2bd; }

.group { margin-bottom: 22px; }
.group-title { font-size: 20px; font-weight: 700; padding: 6px 4px 8px; }

/* one company / agency block inside a section: header row + its men */
.co { margin-bottom: 10px; }
.co-head {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.co.is-open .co-head { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.co-toggle {
  font: inherit; color: inherit; text-align: left;
  flex: 1 1 auto; min-width: 0; min-height: 56px; padding: 8px 14px;
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; border-radius: var(--radius);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.co-toggle:active { background: #f0f2f5; }
.co-chev {
  flex: none; width: 10px; height: 10px; margin: 0 4px 0 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.15s;
}
.co.is-open .co-chev { transform: rotate(45deg); margin-top: -4px; }
.co-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.co-name { font-weight: 700; overflow-wrap: anywhere; }
.co-count { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.co-add {
  font: inherit; font-size: 28px; font-weight: 600; line-height: 1;
  flex: none; width: 56px; min-height: 56px; margin: 0;
  background: transparent; color: var(--primary);
  border: 0; border-left: 1px solid var(--line); border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.co.is-open .co-add { border-bottom-right-radius: 0; }
.co-add:active { background: #e8f3ec; }
.co .rows { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }

.tag-new {
  display: inline-block; vertical-align: middle;
  font-size: 13px; font-weight: 700; line-height: 1; letter-spacing: 0.02em;
  padding: 4px 7px; margin-left: 6px; border-radius: 6px;
  background: #fff4d6; color: #7a4b00; border: 1px solid #f0d58a;
}
.new-bar .tag-new { margin-left: 0; }
.rows {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.worker {
  font: inherit; color: inherit; text-align: left;
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 64px; padding: 10px 14px;
  background: transparent; border: 0; border-top: 1px solid var(--line);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.rows > .worker:first-child { border-top: 0; }
.worker:active { background: #f0f2f5; }
.w-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.w-name { font-weight: 600; overflow-wrap: anywhere; }
.w-ar { font-size: 15px; color: var(--muted); text-align: left; }
.w-sub { font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.w-side { flex: none; display: flex; align-items: center; gap: 10px; }
.w-days { font-size: 16px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.worker.is-done .w-days { color: var(--good); }
.w-unsaved { font-size: 14px; font-weight: 600; color: var(--error); white-space: nowrap; }
.done-tick {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--good); color: #fff; font-size: 18px; font-weight: 700;
}
.done-tick.is-off { background: transparent; border: 2px solid var(--line); }

.list-foot { text-align: center; padding: 8px 0 12px; }

/* ---------- month sheet ---------- */
.sheet-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  margin: -16px -12px 0; padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}
.sheet-who { flex: 1 1 auto; min-width: 0; }
.sheet-name { font-weight: 700; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.sheet-name-ar { font-size: 15px; color: var(--muted); text-align: left; }
.save-state {
  font: inherit; font-size: 15px; flex: none;
  background: transparent; border: 0; padding: 6px 4px; min-height: 44px;
  color: var(--muted); white-space: nowrap; cursor: default;
}
.save-state.is-saved { color: var(--good); }
.save-state.is-failed {
  color: #fff; background: var(--error); border-radius: 10px; padding: 6px 12px; cursor: pointer; font-weight: 600;
}

.btn-icon { flex: none; width: 48px; min-height: 48px; padding: 0; font-size: 22px; }
.btn-danger { color: var(--error); border-color: #e3a8a2; }

.new-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 12px 0 0; padding: 8px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.new-bar-text { flex: 1 1 auto; color: var(--muted); font-size: 16px; }

.sheet-head + .banner, .new-bar + .banner { margin-top: 12px; }
.sheet-month { font-size: 22px; font-weight: 700; margin: 14px 4px 12px; }

.fill-label { font-weight: 600; margin-bottom: 8px; }
.fill-controls { display: grid; grid-template-columns: 1fr 88px auto; gap: 8px; align-items: stretch; }
.fill-row .field-msg { margin: 10px 0 0; }

.pick {
  font: inherit; font-size: 16px; color: var(--ink); text-align: left;
  min-height: 48px; width: 100%; min-width: 0; padding: 8px 32px 8px 12px;
  border: 1px solid #b9c0ca; border-radius: 10px; background: #fff;
  cursor: pointer; line-height: 1.25; overflow-wrap: anywhere;
  position: relative; -webkit-tap-highlight-color: transparent;
}
.pick::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}
.pick.is-none { color: #8a94a3; }
.pick.is-absent { color: var(--error); font-weight: 600; }
.pick.is-bad { color: var(--error); }

.hours { text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; padding-left: 6px; padding-right: 6px; }

.grid-head {
  display: grid; grid-template-columns: 84px 76px 1fr; gap: 8px;
  padding: 0 12px 6px; font-size: 15px; color: var(--muted); font-weight: 600;
}
#days {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.day {
  display: grid; grid-template-columns: 84px 76px 1fr; gap: 8px; align-items: center;
  padding: 8px 12px; border-top: 1px solid var(--line);
}
.day:first-child { border-top: 0; }
.day.is-weekend { background: var(--weekend); }
.day-label { display: flex; flex-direction: column; line-height: 1.15; }
.day-num { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.day-wd { font-size: 14px; color: var(--muted); }
.day .hours { min-height: 48px; }
.day.is-invalid .hours { border-color: var(--error); outline: 2px solid var(--error); outline-offset: 0; }
.row-msg { grid-column: 1 / -1; margin: 0; color: var(--error); font-size: 15px; }

.sheet-foot { padding: 20px 0 8px; }

/* ---------- project picker (full visible screen on a phone) ---------- */
.picker { position: fixed; left: 0; right: 0; top: var(--vvtop); height: var(--vvh); z-index: 20; display: flex; }
.picker-backdrop { position: absolute; inset: 0; background: rgba(15, 20, 30, 0.45); }
.picker-panel {
  position: relative; margin: auto; width: 100%; max-width: 560px; height: 100%;
  background: #fff; display: flex; flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(8px + env(safe-area-inset-bottom));
}
.picker-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.picker-title { font-size: 19px; font-weight: 700; }
.picker-list { list-style: none; margin: 10px 0 0; padding: 0; overflow-y: auto; flex: 1 1 auto; -webkit-overflow-scrolling: touch; }
.picker-item {
  font: inherit; color: inherit; text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 52px; padding: 10px 12px;
  background: transparent; border: 0; border-bottom: 1px solid var(--line);
  cursor: pointer; overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent;
}
.picker-item:active { background: #f0f2f5; }
.picker-item.is-special { color: var(--muted); }
.picker-item.is-selected { background: #e8f3ec; color: var(--ink); font-weight: 600; }
.picker-item .tick { color: var(--good); font-weight: 700; flex: none; }
.picker-empty { padding: 16px 12px; color: var(--muted); }

/* the same sheet shell holding a short form: sits at the bottom of the visible screen */
.picker-panel.is-form {
  height: auto; max-height: 100%; margin: auto 0 0; overflow-y: auto;
  border-radius: 14px 14px 0 0;
}
.nf-where { margin: 0 0 12px; color: var(--muted); font-size: 16px; overflow-wrap: anywhere; }
.is-form .field-msg { margin: 0 0 12px; }

@media (min-width: 700px) {
  .view { padding-top: 24px; }
  .sheet-head { margin-top: -24px; }
  .picker-panel { height: auto; max-height: calc(var(--vvh) * 0.85); border-radius: 14px; padding: 16px; }
  .picker-panel.is-form { margin: auto; border-radius: 14px; }
  .grid-head, .day { grid-template-columns: 110px 90px 1fr; }
  .worker:hover, .picker-item:hover, .co-toggle:hover { background: #f5f7f9; }
  .co-add:hover { background: #eef6f1; }
}
