:root {
  --accent: #2f5496;
  --accent-dark: #1f3a6e;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e1e5ec;
  --text: #1c2333;
  --text-dim: #6b7280;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --success: #1e8e5a;
  --success-bg: #e8f7ee;
  --warn: #b8860b;
  --warn-bg: #fdf3dc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); height: 100%; }
#app { min-height: 100vh; display: flex; flex-direction: column; }

.screens { flex: 1; display: flex; flex-direction: column; padding-bottom: 66px; }
.my-screen { flex: 1; }

.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); z-index: 200; padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-bar-btn {
  flex: 1; border: none; background: none; padding: 12px 4px; font-size: 12.5px; color: var(--text-dim);
  cursor: pointer;
}
.tab-bar-btn.active { color: var(--accent); font-weight: 700; }

.ts-period-form { display: flex; gap: 8px; align-items: center; margin: 8px 0 12px; flex-wrap: wrap; }
.ts-period-form input[type="date"] { padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; flex: 1; min-width: 130px; }
.ts-total { font-size: 14px; margin-bottom: 6px; }

.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-cancelled { background: #eef0f4; color: var(--text-dim); }

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* --- Login --- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, var(--accent-dark), var(--accent) 60%, #4a76c9);
}
.login-card { background: #fff; border-radius: 18px; padding: 32px 26px; width: 100%; max-width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { font-size: 22px; margin: 0 0 4px; text-align: center; }
.login-card p.sub { color: var(--text-dim); margin: 0 0 22px; font-size: 13.5px; text-align: center; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; background: #fff; color: var(--text);
}
.error-box { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; }
.hint { color: var(--text-dim); font-size: 12px; margin-top: 10px; text-align: center; }

.btn-big {
  width: 100%; padding: 15px; border-radius: 12px; border: none; font-size: 16px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff;
}
.btn-big:active { background: var(--accent-dark); }
.btn-big:disabled { opacity: .55; }

/* --- Top bar --- */
.topbar {
  background: var(--accent); color: #fff; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
}
.topbar .name { font-size: 14.5px; font-weight: 600; }
.topbar .role { font-size: 12px; opacity: .8; }
.topbar button { background: rgba(255,255,255,.15); border: none; color: #fff; padding: 7px 12px; border-radius: 8px; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.notif-btn { position: relative; font-size: 15px; padding: 7px 10px; }
.notif-btn #notif-dot {
  position: absolute; top: 4px; right: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: #ffb020; display: none; border: 1.5px solid var(--accent);
}

.offline-banner {
  background: var(--warn-bg); color: var(--warn); font-size: 13px; padding: 8px 16px; text-align: center; font-weight: 600;
}
.pending-banner {
  background: #eef2fb; color: var(--accent-dark); font-size: 12.5px; padding: 7px 16px; text-align: center;
}

/* --- Main status screen --- */
.status-screen { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 26px 20px 40px; }
.status-card { width: 100%; max-width: 380px; }

.object-picker { width: 100%; margin-bottom: 18px; }
.object-picker label { display:block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.object-picker select { width: 100%; padding: 13px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; background: #fff; }

.status-circle {
  width: 180px; height: 180px; border-radius: 50%; margin: 10px auto 22px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; background: var(--surface); border: 6px solid var(--border);
}
.status-circle.active { border-color: var(--success); background: var(--success-bg); }
.status-circle .big-label { font-size: 15px; font-weight: 700; }
.status-circle .sub-label { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }

.action-btn {
  width: 100%; max-width: 380px; padding: 22px; border-radius: 18px; border: none; font-size: 19px; font-weight: 700;
  cursor: pointer; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.action-btn.start { background: linear-gradient(160deg, #279a5f, #1e7a4a); }
.action-btn.end { background: linear-gradient(160deg, #d1483a, #b8382b); }
.action-btn:disabled { opacity: .6; }
.action-btn:active { transform: scale(.98); }

.geo-note { font-size: 12.5px; color: var(--text-dim); text-align: center; margin-top: 14px; max-width: 340px; }

.link-btn {
  display: block; margin: 10px auto 0; background: none; border: none; color: var(--accent);
  font-size: 13px; text-decoration: underline; cursor: pointer; padding: 4px;
}

/* --- Day status overlay (больничный/прогул/отгул) --- */
.day-status-overlay {
  position: fixed; inset: 0; background: rgba(20,25,40,.5); z-index: 310;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.day-status-card { background: #fff; border-radius: 16px; padding: 22px 20px; width: 100%; max-width: 360px; }
.day-status-card h3 { margin: 0 0 4px; font-size: 17px; }
.day-status-card textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; }
.ds-actions { display: flex; gap: 10px; margin-top: 6px; }

.notif-ov-item { padding: 10px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.notif-ov-item:last-child { border-bottom: none; }
.notif-ov-item.unread { background: #eef2fb; cursor: pointer; margin: 0 -4px; padding: 10px 8px; border-radius: 8px; }
.notif-ov-msg { font-size: 13.5px; line-height: 1.4; }
.notif-ov-time { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.ds-actions .btn-big { padding: 12px; font-size: 14.5px; }
.btn-secondary {
  flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  color: var(--text); font-size: 14.5px; cursor: pointer;
}
.ds-actions .btn-big { flex: 1; }

.history-section { width: 100%; max-width: 380px; margin-top: 30px; }
.history-section h3 { font-size: 14px; color: var(--text-dim); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .03em; }
.history-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  font-size: 13.5px; display: flex; justify-content: space-between; align-items: center;
}
.history-item .obj { font-weight: 600; }
.history-item .time { color: var(--text-dim); font-size: 12.5px; }
.history-item .hours { font-weight: 700; color: var(--accent-dark); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; margin-left: 6px; }
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-warn { background: var(--danger-bg); color: var(--danger); }

/* --- Camera modal --- */
.camera-overlay {
  position: fixed; inset: 0; background: #000; z-index: 300; display: flex; flex-direction: column;
  overflow: hidden;
}
.camera-overlay video {
  flex: 1 1 auto; width: 100%; min-height: 0; max-height: 100%; object-fit: cover; background: #111;
}
.camera-controls { flex: 0 0 auto; padding: 20px; display: flex; align-items: center; justify-content: center; gap: 30px; background: #000; }
.snap-btn {
  width: 72px; height: 72px; border-radius: 50%; background: #fff; border: 5px solid rgba(255,255,255,.4); cursor: pointer;
}
.snap-btn:disabled { opacity: .4; cursor: default; }
.cancel-camera { position: absolute; top: 16px; right: 16px; background: rgba(0,0,0,.5); color: #fff; border: none; border-radius: 50%; width: 38px; height: 38px; font-size: 18px; }
.camera-status { flex: 0 0 auto; color: #fff; text-align: center; padding: 14px; font-size: 14px; }

.toast {
  position: fixed; bottom: 20px; left: 16px; right: 16px; background: var(--text); color: #fff; padding: 13px 16px;
  border-radius: 10px; font-size: 14px; z-index: 400; text-align: center;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.spinner { display:inline-block; width:18px; height:18px; border:3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius:50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Карта ручного ввода геопозиции --- */
.map-picker-overlay {
  position: fixed; inset: 0; background: #fff; z-index: 320; display: flex; flex-direction: column;
}
.map-picker-header {
  background: var(--accent); color: #fff; padding: 14px 16px; display: flex; align-items: center;
  justify-content: space-between; font-weight: 600; flex: 0 0 auto;
}
.map-picker-cancel { background: rgba(255,255,255,.2); border: none; color: #fff; border-radius: 50%; width: 30px; height: 30px; font-size: 15px; }
.map-picker-map-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
.map-picker-map { position: absolute; inset: 0; }
.map-picker-pin {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%);
  font-size: 36px; line-height: 1; pointer-events: none; z-index: 500;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.4));
}
.map-picker-footer { flex: 0 0 auto; padding: 14px 16px; background: var(--surface); border-top: 1px solid var(--border); }

/* --- Приглашения в бригаду / подтверждение присутствия --- */
.brigade-alert {
  background: #eef2fb; border: 1px solid var(--accent); border-radius: 12px; padding: 14px; margin: 0 0 16px;
  max-width: 380px; width: 100%;
}
.brigade-alert.warn { background: var(--warn-bg); border-color: var(--warn); }
.brigade-alert h4 { margin: 0 0 6px; font-size: 14px; }
.brigade-alert p { margin: 0 0 10px; font-size: 13px; color: var(--text-dim); }
.brigade-invite-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.brigade-invite-item:last-child { border-bottom: none; }
.brigade-invite-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.btn-tiny { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 12.5px; cursor: pointer; }
.btn-tiny.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-tiny.danger { color: var(--danger); border-color: var(--danger-bg); }

.roster-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.roster-item:last-child { border-bottom: none; }
.roster-check { width: 20px; height: 20px; }
.candidate-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.candidate-row:last-child { border-bottom: none; }
