:root {
  --bg: var(--tg-theme-bg-color, #f5f6f8);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #18212f);
  --muted: var(--tg-theme-hint-color, #84909f);
  --line: rgba(100, 116, 139, .16);
  --primary: var(--tg-theme-button-color, #246bfd);
  --primary-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary: var(--tg-theme-secondary-bg-color, #eef1f5);
  --green: #16885b;
  --green-bg: #e4f6ed;
  --yellow: #a56a08;
  --yellow-bg: #fff2d7;
  --blue: #245fc2;
  --blue-bg: #e7efff;
  --red: #bd3945;
  --shadow: 0 10px 30px rgba(20, 30, 50, .12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100dvh; max-width: 760px; margin: 0 auto; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
.topbar { height: 62px; padding: 0 16px; display: flex; align-items: center; gap: 11px; position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: #1d3561; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: -.5px; }
.brand-copy { flex: 1; min-width: 0; }
.brand-title { font-weight: 800; font-size: 15px; letter-spacing: -.2px; }
.brand-subtitle { font-size: 11px; color: var(--muted); margin-top: 1px; }
.main-content { padding: 17px 15px 18px; }
.view { display: none; animation: fade .16s ease-out; }
.view.active { display: block; }
@keyframes fade { from { opacity: .5; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 17px; }
.eyebrow { font-size: 9px; font-weight: 800; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 4px; }
h1 { font-size: 27px; line-height: 1.1; letter-spacing: -.8px; margin: 0; font-weight: 800; }
h2 { font-size: 18px; margin: 0; letter-spacing: -.35px; }
.button { border: 0; border-radius: 12px; min-height: 43px; padding: 0 15px; font-weight: 700; font-size: 13px; }
.button-primary { background: var(--primary); color: var(--primary-text); }
.button-light { background: var(--secondary); color: var(--text); }
.button-danger { background: #fff0f0; color: var(--red); }
.button-small { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 12px; }
.button:disabled { opacity: .5; cursor: default; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 12px; background: var(--secondary); color: var(--text); font-size: 25px; line-height: 1; display: grid; place-items: center; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.calendar-month { font-size: 16px; font-weight: 800; text-transform: capitalize; }
.segmented { display: flex; padding: 3px; gap: 3px; background: var(--secondary); border-radius: 12px; }
.segment { flex: 1; border: 0; border-radius: 9px; min-height: 34px; padding: 0 7px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.segment.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.calendar-mode { margin-bottom: 12px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.weekday { text-align: center; color: var(--muted); font-size: 10px; font-weight: 700; padding: 5px 0; }
.calendar-day { border: 1px solid transparent; border-radius: 10px; min-height: 48px; background: var(--surface); color: var(--text); padding: 6px 2px 4px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.calendar-day.muted-day { opacity: .34; }
.calendar-day.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.calendar-day.today .day-number { background: var(--primary); color: var(--primary-text); }
.day-number { width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.day-dots { display: flex; min-height: 5px; gap: 2px; align-items: center; }
.day-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--blue); }
.day-dot.completed { background: var(--green); }
.calendar-week-list { display: grid; gap: 6px; }
.week-day-row { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; color: var(--text); }
.week-day-row.selected { border-color: var(--primary); }
.week-day-number { width: 38px; flex: 0 0 38px; font-weight: 800; font-size: 17px; text-align: center; }
.week-day-number small { display: block; font-size: 9px; color: var(--muted); font-weight: 600; }
.week-day-meta { flex: 1; font-size: 12px; color: var(--muted); }
.selected-day-heading { display: flex; align-items: center; justify-content: space-between; margin: 22px 1px 10px; }
.count-pill { background: var(--secondary); color: var(--text); min-width: 27px; height: 27px; padding: 0 8px; border-radius: 20px; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.job-list, .district-list { display: grid; gap: 9px; }
.job-card { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 13px; box-shadow: 0 2px 8px rgba(20,30,50,.025); }
.job-card-main { display: flex; align-items: flex-start; gap: 9px; }
.job-card-content { min-width: 0; flex: 1; }
.job-number { font-size: 10px; font-weight: 800; color: var(--muted); letter-spacing: .5px; }
.job-name { font-size: 15px; font-weight: 800; margin: 2px 0 4px; overflow-wrap: anywhere; }
.job-sub { color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.job-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.meta-chip { padding: 5px 8px; border-radius: 8px; background: var(--secondary); color: var(--muted); font-size: 10px; font-weight: 700; }
.status-badge { display: inline-flex; align-items: center; border-radius: 8px; padding: 6px 8px; font-size: 10px; line-height: 1; font-weight: 800; white-space: nowrap; }
.status-waiting { background: var(--yellow-bg); color: var(--yellow); }
.status-scheduled { background: var(--blue-bg); color: var(--blue); }
.status-completed { background: var(--green-bg); color: var(--green); }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); margin-top: 11px; padding-top: 9px; }
.card-updated { color: var(--muted); font-size: 10px; }
.card-open { border: 0; background: none; color: var(--primary); padding: 5px 0 5px 8px; font-size: 11px; font-weight: 800; }
.helper-text { color: var(--muted); font-size: 12px; line-height: 1.5; margin: -5px 0 13px; }
.status-filter { margin-bottom: 14px; overflow-x: auto; }
.status-filter .segment { flex: 0 0 auto; }
.district-card { border: 1px solid var(--line); border-radius: 15px; background: var(--surface); padding: 14px; text-align: left; color: var(--text); width: 100%; }
.district-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 15px; }
.district-stats { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.district-stat { font-size: 10px; color: var(--muted); background: var(--secondary); padding: 5px 7px; border-radius: 8px; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 6px 6px 6px 12px; }
.search-icon { color: var(--muted); font-size: 24px; line-height: 1; }
.search-box input { border: 0; outline: 0; background: transparent; color: var(--text); min-width: 0; flex: 1; font-size: 14px; }
.empty-state { text-align: center; border: 1px dashed var(--line); color: var(--muted); border-radius: 14px; padding: 24px 15px; font-size: 12px; line-height: 1.5; }
.floating-add { position: fixed; right: max(18px, calc((100vw - 760px)/2 + 18px)); bottom: calc(91px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border: 0; border-radius: 18px; background: var(--primary); color: var(--primary-text); font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(36,107,253,.3); z-index: 15; }
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 760px; height: calc(70px + env(safe-area-inset-bottom)); padding: 6px 8px calc(7px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); background: color-mix(in srgb, var(--surface) 95%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(16px); z-index: 20; }
.nav-item { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 700; }
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 22px; line-height: 1.1; }
.modal-root:empty { display: none; }
.modal-root { position: fixed; inset: 0; z-index: 50; background: rgba(12, 20, 34, .48); display: flex; align-items: flex-end; justify-content: center; padding-top: 20px; }
.modal-sheet { width: 100%; max-width: 620px; max-height: min(92dvh, 900px); overflow: auto; background: var(--bg); color: var(--text); border-radius: 22px 22px 0 0; padding: 9px 17px calc(22px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); animation: slideup .18s ease-out; }
@keyframes slideup { from { transform: translateY(25px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-grabber { width: 38px; height: 4px; background: var(--muted); opacity: .35; border-radius: 5px; margin: 0 auto 14px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; }
.modal-title { font-size: 19px; font-weight: 850; letter-spacing: -.4px; }
.modal-close { border: 0; background: var(--secondary); color: var(--text); width: 34px; height: 34px; border-radius: 11px; font-size: 20px; }
.form-grid { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 11px; font-weight: 800; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; min-height: 45px; padding: 10px 12px; outline: 0; background: var(--surface); color: var(--text); font-size: 14px; }
.field textarea { min-height: 82px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field-hint { font-size: 10px; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; margin-top: 17px; }
.modal-actions .button { flex: 1; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.detail-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.detail-label { color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.detail-value { font-size: 13px; font-weight: 750; overflow-wrap: anywhere; }
.detail-wide { grid-column: 1 / -1; }
.detail-section-title { font-size: 13px; font-weight: 850; margin: 17px 0 8px; }
.comment-item { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 10px; margin-bottom: 7px; }
.comment-body { font-size: 12px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-meta { font-size: 10px; color: var(--muted); margin-top: 6px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; }
.detail-actions .button { width: 100%; }
.toast-root { position: fixed; z-index: 100; left: 14px; right: 14px; bottom: calc(84px + env(safe-area-inset-bottom)); display: grid; justify-items: center; pointer-events: none; }
.toast { background: #1c2738; color: #fff; border-radius: 12px; padding: 11px 15px; font-size: 12px; box-shadow: var(--shadow); max-width: 100%; }
.toast.error { background: #9e2934; }
.loading { color: var(--muted); text-align: center; padding: 24px; font-size: 12px; }
@media (min-width: 600px) { .main-content { padding-left: 22px; padding-right: 22px; } .calendar-day { min-height: 62px; } .modal-root { align-items: center; } .modal-sheet { border-radius: 22px; } }
