:root {
  --navy: #35245f;
  --navy-2: #4b3a8c;
  --navy-dark: #1e1440;
  --orange: #2f86c8;
  --orange-soft: #e6f1fa;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --text: #1b2036;
  --muted: #6b7290;
  --border: #e3e7f1;
  --green: #12a150;
  --green-soft: #e5f7ed;
  --red: #e0383e;
  --red-soft: #fdecec;
  --amber: #d98a00;
  --amber-soft: #fff6df;
  --blue-soft: #efeaf8;
  --shadow: 0 1px 2px rgba(30, 20, 64, .06), 0 4px 16px rgba(30, 20, 64, .06);
  --radius: 14px;
  --sidebar: 248px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 24px; }
.boot img { width: 220px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; margin: auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  background: radial-gradient(1200px 500px at 10% 0%, #4b3a8c 0%, transparent 60%), linear-gradient(150deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.login-hero::after { content: ''; position: absolute; right: 48px; bottom: 0; width: 0; height: 0; border-left: 120px solid transparent; border-right: 120px solid transparent; border-bottom: 160px solid rgba(226, 55, 43, .9); }
.login-hero h1 { font-size: 40px; line-height: 1.1; max-width: 460px; position: relative; z-index: 1; }
.login-hero p { opacity: .85; max-width: 440px; font-size: 15px; position: relative; z-index: 1; }
.login-hero ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; position: relative; z-index: 1; }
.login-hero li { display: flex; gap: 10px; align-items: center; opacity: .95; }
.login-hero li::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--orange); flex: none; }
.login-panel { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.login-card { width: 100%; max-width: 380px; }
.login-card img { width: 210px; margin-bottom: 28px; }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-card form { display: grid; gap: 14px; margin-top: 24px; }

/* layout */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 6px 10px 20px; }
.sidebar .brand img { width: 150px; display: block; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #3a4060; font-weight: 500; position: relative;
}
.nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--blue-soft); color: var(--navy); font-weight: 600; }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--orange); }
.nav .badge { margin-left: auto; }
.sidebar .me { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--surface-2); display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.orange { background: linear-gradient(135deg, var(--orange), #5aa6dd); }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: rgba(244, 246, 251, .85);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 500; border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 20px; }
.topbar .spacer { flex: 1; }
.topbar .clock { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.menu-btn { display: none; }
.content { padding: 8px 28px 40px; display: grid; gap: 20px; align-content: start; }

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; }
.kpi .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi .ico svg { width: 21px; height: 21px; }
.kpi .val { font-size: 24px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 500; }
.tone-navy { background: var(--blue-soft); color: var(--navy); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-red { background: var(--red-soft); color: var(--red); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-orange { background: var(--orange-soft); color: var(--orange); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--surface);
  padding: 9px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: .15s background, .15s transform;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.accent { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn.accent:hover { background: #3b95d8; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.icon-btn { width: 38px; height: 38px; padding: 0; }

.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: #464c6b; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); outline: none; transition: .15s border, .15s box-shadow;
}
.input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(75, 58, 140, .12); }
textarea.input { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.toolbar .field { min-width: 140px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: #cfd4e4; position: relative; transition: .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.navy { background: var(--blue-soft); color: var(--navy); }
.badge.orange { background: var(--orange); color: #fff; }
.badge.grey { background: #eef0f5; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfe; }
.person { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.person b { display: block; }
.addr { max-width: 280px; font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; cursor: zoom-in; border: 1px solid var(--border); background: var(--surface-2); }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }

.map { height: 340px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); z-index: 1; }
.map.sm { height: 220px; }
.map.lg { height: 460px; }
/* punch markers on maps */
.pm { position: relative; width: 0; height: 0; --pm: var(--green); }
.pm-out { --pm: var(--red); }
.pm-dot { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--pm); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pm-card {
  position: absolute; left: 0; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer;
  background: #fff; border: 2px solid var(--pm); border-radius: 10px; padding: 3px 9px 3px 3px; box-shadow: 0 2px 8px rgba(0,0,0,.2); font: 11px/1.2 Inter, sans-serif; color: var(--text);
}
.pm-in .pm-card { bottom: 11px; }
.pm-out .pm-card { top: 11px; }
.pm-card img, .pm-card .pm-av { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; flex: none; }
.pm-card .pm-av { display: grid; place-items: center; background: var(--pm); color: #fff; font-weight: 700; font-size: 11px; }
.pm-card b { display: block; font-size: 11.5px; }
.pm-card span { color: var(--pm); font-weight: 700; font-size: 10.5px; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

/* punch card */
.punch {
  background: radial-gradient(800px 300px at 100% 0%, rgba(47, 134, 200, .28), transparent 60%), linear-gradient(150deg, var(--navy), var(--navy-dark));
  color: #fff; border: none; display: grid; gap: 18px; position: relative; overflow: hidden;
}
.punch .time { font-size: 44px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.punch .date { opacity: .8; font-weight: 500; }
.punch .row { display: flex; gap: 12px; flex-wrap: wrap; }
.punch .stat { background: rgba(255,255,255,.1); border-radius: 12px; padding: 10px 14px; min-width: 110px; flex: 1; }
.punch .stat small { display: block; opacity: .75; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.punch .stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.punch-btn {
  border: none; border-radius: 16px; padding: 18px; font-size: 17px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--orange); color: #fff; box-shadow: 0 8px 24px rgba(47, 134, 200, .45); transition: .15s transform;
}
.punch-btn svg { width: 22px; height: 22px; }
.punch-btn.out { background: #fff; color: var(--navy); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.punch-btn:disabled { opacity: .6; cursor: not-allowed; box-shadow: none; }
.punch-btn:not(:disabled):hover { transform: translateY(-1px); }
.punch .loc { display: flex; gap: 8px; font-size: 12.5px; opacity: .85; align-items: flex-start; }
.punch .loc svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.punch .opt { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.punch .opt .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.photo-preview { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 2px solid rgba(255,255,255,.5); }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dh { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; padding-bottom: 2px; }
.cal .d { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; font-size: 12.5px; font-weight: 600; position: relative; background: var(--surface-2); color: var(--muted); }
.cal .d.present { background: var(--green-soft); color: var(--green); }
.cal .d.late { background: var(--amber-soft); color: var(--amber); }
.cal .d.absent { background: var(--red-soft); color: var(--red); }
.cal .d.off { background: #eef0f5; color: #a0a6bd; }
.cal .d.today { outline: 2px solid var(--orange); outline-offset: 1px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* live list */
.live-list { display: grid; gap: 4px; max-height: 420px; overflow-y: auto; }
.live-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; }
.live-item:hover { background: var(--surface-2); }
.live-item .info { flex: 1; min-width: 0; }
.live-item .info b { display: block; font-size: 13px; }
.live-item .info span { font-size: 12px; color: var(--muted); }

/* messages */
.chat { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 150px); min-height: 460px; padding: 0; overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; }
.chat-list .search { padding: 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.contact { display: flex; gap: 12px; padding: 12px 14px; cursor: pointer; align-items: center; border-bottom: 1px solid #f1f3f8; }
.contact:hover { background: var(--surface-2); }
.contact.active { background: var(--blue-soft); }
.contact .info { min-width: 0; flex: 1; }
.contact .info b { display: block; font-size: 13px; }
.contact .info span { font-size: 12px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.chat-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.bubble { max-width: 72%; padding: 9px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); white-space: pre-wrap; word-wrap: break-word; }
.bubble.mine { align-self: flex-end; background: var(--navy); color: #fff; border-color: var(--navy); border-bottom-right-radius: 4px; }
.bubble:not(.mine) { border-bottom-left-radius: 4px; }
.bubble .meta { font-size: 10.5px; opacity: .7; margin-top: 3px; }
.bubble .tag { font-size: 10px; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 2px; }
.chat-input { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input textarea { min-height: 44px; max-height: 120px; }

.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.tabs button { border: none; background: transparent; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--navy); color: #fff; }

/* feed */
.feed { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.feed-item { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.feed-item img { width: 100%; height: 170px; object-fit: cover; cursor: zoom-in; background: var(--surface-2); }
.feed-item .noimg { height: 90px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.feed-item .body { padding: 12px 14px; display: grid; gap: 6px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 50, .45); display: grid; place-items: center; z-index: 2000; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); gap: 10px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.lightbox img { max-height: 80vh; border-radius: 12px; display: block; margin: auto; }
@keyframes fade { from { opacity: 0; } }

#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 3000; }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 360px; animation: slide .2s; display: flex; gap: 10px; align-items: center; }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

.notice { padding: 12px 14px; border-radius: 12px; background: var(--amber-soft); color: #7a5200; display: flex; gap: 10px; align-items: center; }
.notice.info { background: var(--blue-soft); color: var(--navy); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.bottom-nav { display: none; }
.scrim { display: none; }

/* responsive */
@media (max-width: 1100px) {
  .g-2-1, .g-1-2, .g3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 1500; transform: translateX(-100%); transition: .25s transform; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15,20,50,.4); z-index: 1400; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .topbar .clock { display: none; }
  .content { padding: 4px 16px 96px; gap: 16px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 170px); }
  .chat.show-pane .chat-list { display: none; }
  .chat:not(.show-pane) .chat-pane { display: none; }
  .punch .time { font-size: 38px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi .ico { width: 36px; height: 36px; }
  .kpi .val { font-size: 20px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 900;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; display: grid; justify-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); font-weight: 600; padding: 4px 0; position: relative; }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--navy); }
  .bottom-nav .badge { position: absolute; top: 0; left: 55%; padding: 1px 6px; font-size: 10px; }
  #toasts { left: 16px; right: 16px; bottom: 84px; }
  .bubble { max-width: 85%; }
}

/* ---------- v2: multi-company, sites, live team ---------- */
:root { --purple: #7c3aed; --purple-soft: #f1eafe; }
.tone-purple { background: var(--purple-soft); color: var(--purple); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.sidebar .brand img { width: auto; max-width: 100%; max-height: 56px; object-fit: contain; }
.brand-logo { width: auto !important; max-width: 240px; max-height: 84px; object-fit: contain; display: block; margin-bottom: 26px; }
.avatar { position: relative; }
.avatar.lg2 { width: 46px; height: 46px; font-size: 15px; }
.avatar .online { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid #fff; }
a.live-item { color: inherit; }
a.notice { color: var(--navy); }
.map.xl { height: 520px; }
.site-tip { background: transparent; border: none; box-shadow: none; color: #1f5f93; font-weight: 700; font-size: 11px; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.site-tip::before { display: none; }
.pm-now { --pm: var(--navy); }
.pm-visit { --pm: var(--orange); }
.pm-now .pm-card, .pm-visit .pm-card { bottom: 11px; }

.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-item { display: grid; gap: 2px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface-2); transition: .15s; }
.quick-item:hover { border-color: var(--navy-2); background: var(--blue-soft); }
.quick-item svg { width: 22px; height: 22px; color: var(--orange); margin-bottom: 6px; }
.quick-item span { font-size: 12px; color: var(--muted); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 7px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.chip b { margin-left: 4px; color: var(--text); }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.active b { color: #fff; }

.team-list { display: grid; gap: 8px; max-height: 560px; overflow-y: auto; }
.team-card { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.team-card .info { flex: 1; min-width: 0; }
.team-card .acts { display: flex; gap: 6px; align-items: center; flex: none; }
.kpi-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi-ico svg { width: 20px; height: 20px; }

.timeline { display: grid; gap: 2px; margin-top: 14px; }
.tl-item { display: grid; grid-template-columns: 14px 74px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.tl-item:last-child { border-bottom: none; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; }
.tl-dot.tone-green { background: var(--green); } .tl-dot.tone-red { background: var(--red); } .tl-dot.tone-orange { background: var(--orange); } .tl-dot.tone-navy { background: var(--navy); }
.tl-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }

.cal .d.leave { background: var(--purple-soft); color: var(--purple); }
.cal .d.holiday { background: #eef0f5; color: #7b8199; }
.cal .d.na, .cal .d.future { background: transparent; color: #c3c7d6; }
.cal .d.sel { box-shadow: 0 0 0 2px var(--navy); }
.legend i.c-present { background: var(--green-soft); border: 1px solid var(--green); }
.legend i.c-late { background: var(--amber-soft); border: 1px solid var(--amber); }
.legend i.c-absent { background: var(--red-soft); border: 1px solid var(--red); }
.legend i.c-leave { background: var(--purple-soft); border: 1px solid var(--purple); }
.legend i.c-off { background: #eef0f5; }

.checks { display: flex; gap: 8px; flex-wrap: wrap; }
.check { display: inline-flex; gap: 6px; align-items: center; padding: 7px 11px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 500; }
.check input { accent-color: var(--navy); width: 16px; height: 16px; }
.logo-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-box img { max-width: 200px; max-height: 80px; object-fit: contain; border: 1px dashed var(--border); border-radius: 12px; padding: 10px; background: var(--surface-2); }
.plan-box { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: linear-gradient(135deg, var(--blue-soft), #fff); border: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.plan-box div { display: grid; gap: 2px; }
.plan-box svg { width: 28px; height: 28px; color: var(--navy); flex: none; }
.co-logo { width: 44px; height: 30px; object-fit: contain; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); padding: 2px; flex: none; }
.co-logo.lg { width: 96px; height: 56px; }
.btn.danger:hover { background: var(--red-soft); }

@media (max-width: 860px) {
  .map.xl { height: 380px; }
  .tl-item { grid-template-columns: 14px 64px 1fr; }
  .tl-item .thumb { grid-column: 3; }
  .team-card { flex-wrap: wrap; }
  .team-card .acts { width: 100%; justify-content: flex-end; }
  .punch-btn { padding: 22px; font-size: 19px; }
}

/* ---------- v2.2: professional maps ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; align-items: center; }
.seg button, .seg-date { border: none; background: transparent; padding: 6px 11px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.active, .seg-date.active { background: var(--navy); color: #fff; box-shadow: 0 1px 3px rgba(30, 20, 64, .3); }
.seg-date svg { width: 15px; height: 15px; }
.seg-date input { border: none; background: transparent; font: inherit; color: inherit; width: 122px; outline: none; cursor: pointer; }
.seg-date.active input { color: #fff; color-scheme: dark; }
.btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.mp { padding: 0; overflow: hidden; }
.mp-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 16px 18px 12px; }
.mp-title h3 { font-size: 15px; }
.mp-title { display: grid; gap: 1px; margin-right: 6px; }
.mp-stats { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.mp-stat { padding: 10px 14px; border-right: 1px solid var(--border); display: grid; gap: 1px; min-width: 0; }
.mp-stat:last-child { border-right: none; }
.mp-stat b { font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.mp-stat span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-stat.g b { color: var(--green); } .mp-stat.r b { color: var(--red); } .mp-stat.b b { color: #2563eb; } .mp-stat.a b { color: var(--amber); } .mp-stat.o b { color: var(--orange); }
.mp-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 540px; }
.mp-mapwrap { position: relative; min-width: 0; }
.mp-map { height: 100% !important; border: none; border-radius: 0; }
.mp-side { border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.mp-search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; background: var(--surface); }
.mp-search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.mp-search input { border: none; outline: none; padding: 9px 0; width: 100%; background: transparent; }
.mp-side .mp-search { margin: 12px; }
.mp-list { overflow-y: auto; flex: 1; padding: 0 8px 8px; }
.pl-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; grid-template-areas: "av main times" "av main dur"; gap: 2px 10px; align-items: center; padding: 9px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.pl-row:hover { background: var(--surface-2); }
.pl-row.active { background: var(--blue-soft); border-color: #d6cbef; }
.pl-row .avatar { grid-area: av; }
.pl-main { grid-area: main; min-width: 0; }
.pl-main b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-main span { font-size: 11.5px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-times { grid-area: times; display: flex; gap: 6px; justify-content: flex-end; }
.pl-times span { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; position: relative; white-space: nowrap; }
.t-in { background: var(--green-soft); color: var(--green); }
.t-out { background: var(--red-soft); color: var(--red); }
.t-out.none { background: #eef0f5; color: var(--muted); font-weight: 600; }
.late-dot { position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); border: 1.5px solid #fff; }
.pl-dur { grid-area: dur; text-align: right; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.avatar.sm { width: 32px; height: 32px; font-size: 11.5px; }
.avatar.xs { width: 26px; height: 26px; font-size: 10px; border: 2px solid #fff; }
.mp-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 4px; text-align: center; z-index: 500; pointer-events: none; }
.mp-empty svg { color: var(--muted); background: #fff; border-radius: 50%; padding: 8px; box-shadow: var(--shadow); width: 42px; height: 42px; }
.mp-empty b { background: rgba(255,255,255,.92); padding: 4px 12px; border-radius: 8px; margin-top: 6px; }
.mp-empty span { background: rgba(255,255,255,.92); padding: 2px 10px; border-radius: 8px; font-size: 12px; color: var(--muted); }
.mp-full { position: fixed; inset: 10px; z-index: 2500; display: flex; flex-direction: column; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.mp-full .mp-body { flex: 1; height: auto; }
body.no-scroll { overflow: hidden; }

.mpin { width: 42px; height: 50px; position: relative; --pm: var(--green); filter: drop-shadow(0 3px 5px rgba(0,0,0,.28)); }
.mpin-out { --pm: var(--red); } .mpin-done { --pm: var(--navy); } .mpin-live { --pm: var(--green); }
.mpin-face { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--pm); background: #fff; display: grid; place-items: center; overflow: hidden; font: 800 12px Inter, sans-serif; color: var(--pm); position: relative; z-index: 1; }
.mpin-face img { width: 100%; height: 100%; object-fit: cover; }
.mpin::after { content: ""; position: absolute; left: 50%; bottom: 1px; transform: translateX(-50%); border: 7px solid transparent; border-top: 10px solid var(--pm); border-bottom: none; }
.mpin-tag { position: absolute; top: -5px; right: -6px; background: var(--pm); color: #fff; font: 800 8.5px Inter, sans-serif; padding: 2px 5px; border-radius: 6px; border: 1.5px solid #fff; z-index: 2; letter-spacing: .04em; }
.mpin-live::before { content: ""; position: absolute; left: 0; top: 0; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--green); box-sizing: border-box; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }
.mclus { width: 48px; height: 48px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-content: center; text-align: center; border: 3px solid #fff; box-shadow: 0 0 0 5px rgba(53, 36, 95, .25), 0 3px 8px rgba(0,0,0,.3); font-family: Inter, sans-serif; }
.mclus b { font-size: 15px; line-height: 1; }
.mclus span { display: flex; gap: 3px; justify-content: center; margin-top: 2px; }
.mclus i { font-style: normal; font-size: 8.5px; font-weight: 800; padding: 0 3px; border-radius: 4px; }
.mclus i.g { background: var(--green); } .mclus i.r { background: var(--red); }
.leaflet-tooltip.mtip { background: #0f172a; color: #fff; border: none; border-radius: 7px; padding: 4px 8px; font: 600 11.5px Inter, sans-serif; box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.leaflet-tooltip.mtip::before { border-top-color: #0f172a; }
.leaflet-tooltip.mtip b { color: #fff; }

.pp-wrap .leaflet-popup-content-wrapper { border-radius: 14px; padding: 0; overflow: hidden; }
.pp-wrap .leaflet-popup-content { margin: 0; width: auto !important; }
.pp { font: 13px/1.45 Inter, sans-serif; min-width: 240px; }
.pp-head { padding: 12px 14px; color: #fff; display: grid; gap: 1px; }
.pp-head b { font-size: 14px; }
.pp-head small { opacity: .85; }
.pp-kind { font-size: 10px; font-weight: 800; letter-spacing: .1em; opacity: .9; }
.pp-in { background: linear-gradient(135deg, #12a150, #0e7a3d); }
.pp-out { background: linear-gradient(135deg, #e0383e, #b4232a); }
.pp-site { background: linear-gradient(135deg, #2f86c8, #1f6aa5); }
.pp-photo { width: 100%; height: 150px; object-fit: cover; display: block; cursor: zoom-in; }
.pp-grid { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; padding: 12px 14px 4px; }
.pp-grid span { color: var(--muted); font-size: 12px; }
.pp-grid b { text-align: right; font-size: 12.5px; }
.pp-grid em { font-style: normal; color: var(--orange); font-size: 11px; }
.pp-note { padding: 4px 14px; font-size: 12px; }
.pp-addr { padding: 6px 14px; font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--border); margin-top: 6px; }
.pp-actions { display: flex; gap: 8px; padding: 10px 14px 12px; }
.pp-actions a { flex: 1; text-align: center; padding: 7px; border-radius: 8px; background: var(--blue-soft); font-weight: 600; font-size: 12px; }

/* ---------- calendar: colour by punch completeness ---------- */
.cal { gap: 5px; }
.cal .dh { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }
.cal .d { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.1; aspect-ratio: auto; min-height: 50px; border: 1.5px solid transparent; transition: .12s transform; }
.cal .d span { font-size: 14px; font-weight: 800; }
.cal .d small { font-size: 9.5px; font-weight: 700; opacity: .9; white-space: nowrap; }
.cal .d.full { background: #16a34a; color: #fff; }
.cal .d.partial { background: #f59e0b; color: #fff; }
.cal .d.progress { background: #2563eb; color: #fff; }
.cal .d.absent { background: #fff1f1; color: #dc2626; border-color: #fca5a5; }
.cal .d.leave { background: #7c3aed; color: #fff; }
.cal .d.holiday, .cal .d.off { background: #eef0f5; color: #8a90a8; }
.cal .d.future, .cal .d.na { background: transparent; color: #c3c7d6; border-color: #eef0f5; }
.cal .d.is-late::after { content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px #2f86c8 inset; }
.cal .d.today { outline: 2px solid var(--orange); outline-offset: 2px; }
.cal .d.sel { box-shadow: 0 0 0 3px var(--navy); transform: scale(1.04); }
.cal .d[data-day]:hover { transform: translateY(-1px); }
.cal-legend { gap: 10px 14px; }
.cal-legend i { width: 12px; height: 12px; border-radius: 4px; }
.legend i.c-full { background: #16a34a; } .legend i.c-partial { background: #f59e0b; } .legend i.c-progress { background: #2563eb; }
.legend i.c-absent { background: #fff1f1; border: 1.5px solid #fca5a5; } .legend i.c-leave { background: #7c3aed; } .legend i.c-off { background: #eef0f5; }
.legend i.c-late { background: #fff; border: 2.5px solid #2f86c8; border-radius: 50%; }

/* ---------- work sites ---------- */
.rules-head { display: flex; gap: 12px; align-items: center; padding-bottom: 6px; }
.rules .setting-row.dim { opacity: .5; }
.site-list { display: grid; gap: 10px; max-height: 560px; overflow-y: auto; padding-right: 2px; }
.site-card { border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: grid; gap: 10px; cursor: pointer; transition: .15s; background: var(--surface); }
.site-card:hover { border-color: #d6cbef; box-shadow: var(--shadow); }
.site-card.active { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(53, 36, 95, .12); }
.site-card.off { opacity: .6; }
.site-top { display: flex; gap: 10px; align-items: center; }
.site-top .info { flex: 1; min-width: 0; }
.site-top .info b { display: block; }
.site-top .info span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--orange-soft); color: var(--orange); display: grid; place-items: center; flex: none; }
.site-ico svg { width: 20px; height: 20px; }
.site-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.site-chips span { display: inline-flex; gap: 5px; align-items: center; font-size: 11.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); padding: 3px 8px; border-radius: 999px; color: #464c6b; }
.site-chips svg { width: 13px; height: 13px; }
.site-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.site-foot .acts { display: flex; gap: 4px; }
.stack { display: flex; }
.stack .avatar { margin-left: -7px; }
.stack .avatar:first-child { margin-left: 0; }
.avatar.more { background: #e5e8f2; color: var(--muted); }
.empty-state { text-align: center; padding: 30px 16px; display: grid; justify-items: center; gap: 8px; }
.empty-state svg { color: var(--orange); }
.empty-state p { color: var(--muted); max-width: 320px; margin: 0; }
.assign-list { display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.assign-row { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.assign-row.on { border-color: var(--navy); background: var(--blue-soft); }
.assign-row input { width: 18px; height: 18px; accent-color: var(--navy); }
.assign-row .info { flex: 1; min-width: 0; }
.assign-row .info b { display: block; }
.assign-row .info span { font-size: 12px; color: var(--muted); }
.addr-search { display: flex; gap: 8px; flex-wrap: wrap; }
.addr-search .input { flex: 1; min-width: 200px; }
.addr-results { display: grid; gap: 4px; margin-top: 6px; }
.addr-hit { display: flex; gap: 8px; align-items: flex-start; text-align: left; border: 1px solid var(--border); background: var(--surface); padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 12.5px; }
.addr-hit:hover { background: var(--blue-soft); }
.addr-hit svg { width: 15px; height: 15px; color: var(--orange); flex: none; margin-top: 2px; }
.radius { display: flex; gap: 10px; align-items: center; }
.radius input[type=range] { flex: 1; accent-color: var(--orange); }
.radius .input { width: 100px; }

/* ---------- shell extras ---------- */
.sidebar .ver { font-size: 10.5px; color: var(--muted); text-align: center; padding: 8px 4px 0; }
.login-ver { text-align: center; font-size: 11px; color: var(--muted); margin-top: 18px; }
.update-bar { display: flex; gap: 10px; align-items: center; margin: 6px 28px 0; padding: 10px 14px; border-radius: 12px; background: var(--orange-soft); color: #174c78; font-weight: 600; }
.update-bar svg { width: 18px; height: 18px; flex: none; }
.update-bar span { flex: 1; }
.section-title { border-top: 1px solid var(--border); padding-top: 14px; font-weight: 700; }
.usage { height: 5px; background: #eef0f5; border-radius: 4px; margin-top: 5px; overflow: hidden; }
.usage div { height: 100%; background: var(--green); border-radius: 4px; }
.usage div.full { background: var(--red); }
.danger-card { border-color: #f6caca; }
.co-head { padding-bottom: 0; }
.co-tabs { margin: 16px -20px 0; padding: 0 20px; border-radius: 0; border: none; border-top: 1px solid var(--border); background: transparent; display: flex; overflow-x: auto; gap: 4px; flex-wrap: nowrap; width: calc(100% + 40px); }
.co-tabs button { border-radius: 0; padding: 12px 14px; border-bottom: 3px solid transparent; white-space: nowrap; }
.co-tabs button.active { background: transparent; color: var(--navy); border-bottom-color: var(--orange); }

/* ---------- platform owner ---------- */
.owner-boot { background: #1a1036; }
.owner-login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 15% 10%, rgba(47, 134, 200, .25), transparent 60%), radial-gradient(800px 600px at 90% 90%, rgba(226, 55, 43, .25), transparent 60%), #1a1036; }
.owner-card { width: 100%; max-width: 420px; background: rgba(255,255,255,.97); border-radius: 22px; padding: 34px 30px 22px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.owner-badge { width: 60px; height: 60px; border-radius: 18px; background: linear-gradient(135deg, var(--navy), #1a1036); color: var(--orange); display: grid; place-items: center; margin-bottom: 16px; }
.owner-badge svg { width: 30px; height: 30px; }
.owner-card h1 { font-size: 24px; }
.owner-card p { color: var(--muted); margin: 6px 0 0; }
.owner-card form { display: grid; gap: 14px; margin-top: 22px; }
.owner-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 20px; font-size: 11px; color: var(--muted); }
.owner-shell .sidebar { background: #1a1036; border-right-color: #1a1036; }
.owner-shell .sidebar .nav a { color: #d9d1f0; }
.owner-shell .sidebar .nav a:hover { background: rgba(255,255,255,.07); }
.owner-shell .sidebar .nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.owner-shell .nav-label { color: #9d8fc9; }
.owner-shell .sidebar .me { background: rgba(255,255,255,.07); color: #fff; }
.owner-shell .sidebar .me .muted, .owner-shell .sidebar .ver { color: #b3a8d9; }
.owner-shell .sidebar .me .btn { color: #fff; }
.owner-shell .sidebar .brand img { background: #fff; border-radius: 10px; padding: 6px 10px; }
.owner-hero { background: radial-gradient(700px 300px at 100% 0%, rgba(47, 134, 200, .3), transparent 60%), linear-gradient(135deg, #35245f, #1a1036); color: #fff; border: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.owner-hero h2 { font-size: 22px; margin: 4px 0; }
.hero-acts { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-acts .btn:not(.accent) { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }

@media (max-width: 1200px) {
  .mp-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .mp-stat:nth-child(4n) { border-right: none; }
  .mp-stat:nth-child(-n+4) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 860px) {
  .mp-body { grid-template-columns: 1fr; height: auto; }
  .mp-mapwrap { height: 380px; }
  .mp-side { border-left: none; border-top: 1px solid var(--border); max-height: 420px; }
  .mp-head .spacer { display: none; }
  .update-bar { margin: 6px 16px 0; }
  .cal .d { min-height: 44px; }
  .cal .d small { font-size: 8.5px; }
}

.avatar.danger { background: linear-gradient(135deg, #e0383e, #b4232a); }
.badge svg { vertical-align: -1px; }

/* ---------- Day board ---------- */
.db { padding: 0; overflow: hidden; }
.db-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 18px 12px; }
.db-head h3 { font-size: 16px; }
.db-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.db-legend span { display: inline-flex; align-items: center; gap: 5px; }
.db-legend i { display: inline-block; }
.lg-bar { width: 18px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #12a150, #16a34a); }
.lg-shift { width: 18px; height: 8px; border-radius: 4px; background: repeating-linear-gradient(45deg, #e8ebf5, #e8ebf5 3px, #f5f6fb 3px, #f5f6fb 6px); border: 1px solid #dfe3ef; }
.lg-late { width: 18px; height: 8px; border-radius: 4px; background: repeating-linear-gradient(45deg, #fde3c4, #fde3c4 3px, #fff3e5 3px, #fff3e5 6px); }
.lg-in, .lg-out { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--green); background: var(--green); }
.lg-out { background: var(--red); box-shadow: 0 0 0 1.5px var(--red); }
.db-stats { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.db-stat { padding: 10px 14px; border-right: 1px solid var(--border); display: grid; gap: 1px; min-width: 0; }
.db-stat:last-child { border-right: none; }
.db-stat b { font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.db-stat span { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-stat.g b { color: var(--green); } .db-stat.b b { color: #2563eb; } .db-stat.n b { color: var(--navy); } .db-stat.a b { color: var(--amber); }
.db-stat.o b { color: var(--orange); } .db-stat.r b { color: var(--red); } .db-stat.p b { color: var(--purple); }
.db-grid { padding: 4px 18px 6px; }
.db-axis, .db-row { display: grid; grid-template-columns: 230px 150px minmax(240px, 1fr) 190px; gap: 14px; align-items: center; }
.db-axis { height: 30px; position: sticky; top: 64px; background: var(--surface); z-index: 3; border-bottom: 1px solid var(--border); }
.db-ticks { position: relative; height: 100%; }
.db-ticks span { position: absolute; bottom: 6px; transform: translateX(-50%); font-size: 10.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.db-ticks .db-nowlbl { color: #fff; background: #2563eb; border-radius: 5px; padding: 0 5px; bottom: 5px; }
.db-row { padding: 10px 0; border-bottom: 1px solid #f0f2f8; cursor: default; border-radius: 10px; }
.db-row.has { cursor: pointer; }
.db-row.has:hover, .db-row.open { background: var(--surface-2); }
.db-who { display: flex; gap: 10px; align-items: center; min-width: 0; padding-left: 6px; }
.db-name { min-width: 0; }
.db-name b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-name span { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-status { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.db-track { position: relative; height: 40px; background: linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), #eef0f6 calc(100% - 1px)) ; background-size: calc(100% / 12) 100%; border-radius: 8px; }
.db-shift { position: absolute; top: 14px; height: 12px; border-radius: 6px; background: repeating-linear-gradient(45deg, #e8ebf5, #e8ebf5 3px, #f5f6fb 3px, #f5f6fb 6px); border: 1px solid #dfe3ef; }
.db-late { position: absolute; top: 14px; height: 12px; border-radius: 6px 0 0 6px; background: repeating-linear-gradient(45deg, #fde3c4, #fde3c4 3px, #fff3e5 3px, #fff3e5 6px); }
.db-bar { position: absolute; top: 12px; height: 16px; border-radius: 8px; box-shadow: 0 2px 6px rgba(18, 161, 80, .3); }
.db-bar.completed { background: linear-gradient(90deg, #35245f, #5a47a8); box-shadow: 0 2px 6px rgba(53, 36, 95, .3); }
.db-bar.working { background: linear-gradient(90deg, #12a150, #22c55e); background-size: 24px 16px; animation: none; }
.db-bar.noout { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.db-pin { position: absolute; top: 20px; width: 0; height: 0; }
.db-pin::before { content: ""; position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.db-pin.in::before { background: var(--green); }
.db-pin.out::before { background: var(--red); }
.db-pin.live::before { background: #2563eb; animation: pulse2 1.6s ease-in-out infinite; }
@keyframes pulse2 { 50% { box-shadow: 0 0 0 6px rgba(37, 99, 235, .25); } }
.db-pin em { position: absolute; top: -26px; transform: translateX(-50%); font-style: normal; font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.db-pin.in em { background: var(--green-soft); color: var(--green); }
.db-pin.out em { background: var(--red-soft); color: var(--red); top: 12px; }
.db-now { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #2563eb; opacity: .55; border-radius: 1px; }
.db-empty { position: absolute; inset: 12px 0; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: var(--muted); border: 1.5px dashed #e3e7f1; border-radius: 8px; }
.db-sum { display: grid; grid-template-columns: auto auto; gap: 4px; justify-content: start; }
.db-sum span { font-size: 11.5px; font-weight: 800; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.db-sum small { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.db-detail { padding: 6px 0 16px; border-bottom: 1px solid #f0f2f8; }
.db-detail-in { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.db-hint { padding: 8px 18px 14px; }
.pc { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 10px; align-content: start; background: var(--surface); border-top: 4px solid var(--border); }
.pc-in { border-top-color: var(--green); } .pc-out { border-top-color: var(--red); } .pc-day { border-top-color: var(--navy); } .pc-none { color: var(--muted); border-top-color: #e3e7f1; }
.pc-top { display: flex; gap: 12px; align-items: center; }
.pc-top img, .pc-nophoto { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; cursor: zoom-in; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); border: 1px solid var(--border); }
.pc-nophoto { cursor: default; }
.pc-nophoto svg { width: 22px; height: 22px; }
.pc-top > div { display: grid; gap: 3px; justify-items: start; }
.pc-kind { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: var(--muted); }
.pc-time { font-size: 20px; font-variant-numeric: tabular-nums; }
.pc-grid { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 12.5px; }
.pc-grid span { color: var(--muted); }
.pc-grid b { text-align: right; font-weight: 600; }
.pc-addr { display: flex; gap: 6px; font-size: 12px; color: var(--muted); }
.pc-addr svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--orange); }
.pc-link { font-size: 12px; font-weight: 600; }

@media (max-width: 1200px) {
  .db-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .db-stat:nth-child(5n) { border-right: none; }
  .db-stat:nth-child(-n+5) { border-bottom: 1px solid var(--border); }
  .db-axis, .db-row { grid-template-columns: 200px 130px minmax(200px, 1fr) 160px; }
}
@media (max-width: 860px) {
  .db-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .db-stat:nth-child(5n) { border-right: 1px solid var(--border); }
  .db-stat:nth-child(3n) { border-right: none; }
  .db-grid { padding: 4px 12px 6px; }
  .db-axis { grid-template-columns: 1fr; top: 56px; }
  .db-axis > div:not(.db-ticks) { display: none; }
  .db-row { grid-template-columns: 1fr auto; grid-template-areas: "who sum" "status status" "track track"; gap: 8px; }
  .db-who { grid-area: who; padding-left: 0; }
  .db-status { grid-area: status; flex-direction: row; }
  .db-track { grid-area: track; }
  .db-sum { grid-area: sum; justify-content: end; }
  .db-sum small { text-align: right; }
  .db-detail-in { grid-template-columns: 1fr; }
}

/* Keep every page inside the screen width (wide toolbars wrap instead of stretching the page). */
.content { grid-template-columns: minmax(0, 1fr); }
.content > * { min-width: 0; }

/* ---------- undo punch-out, devices page ---------- */
.undo-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.undo-row .btn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.undo-row span { font-size: 12px; opacity: .8; }
.rules-strip { display: flex; gap: 10px 22px; align-items: center; flex-wrap: wrap; padding: 14px 18px; }
.rules-strip > span { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; }
.rules-strip .btn { margin-left: auto; }
.dev { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.dev-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--blue-soft); color: var(--navy); display: grid; place-items: center; flex: none; }
.dev-ico svg { width: 19px; height: 19px; }
.dev b { display: block; font-size: 13px; }
.dev span { display: block; font-size: 11.5px; color: var(--muted); }
.ver-num { font-variant-numeric: tabular-nums; }

/* ---------- sign-in selfie, rule selects ---------- */
.selfie-card form, .selfie-card > .btn { margin-top: 10px; }
.selfie-box { margin: 18px 0 12px; width: 100%; aspect-ratio: 1; max-height: 300px; border: 2px dashed #d6cbef; border-radius: 20px; background: var(--blue-soft); display: grid; place-items: center; cursor: pointer; overflow: hidden; padding: 0; color: var(--navy); }
.selfie-box .sf-empty { display: grid; justify-items: center; gap: 8px; }
.selfie-box img { width: 100%; height: 100%; object-fit: cover; }
.sf-device { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.rule-sel { width: auto; min-width: 220px; max-width: 100%; }

/* ---------- Maxtap brand ---------- */
:root { --red-brand: #e2372b; }
.sidebar .brand img { max-height: 46px; }
.brand-logo { max-height: 70px; }
.login-hero { background: radial-gradient(900px 420px at 0% 0%, rgba(47, 134, 200, .35), transparent 60%), linear-gradient(150deg, #35245f 0%, #1e1440 100%); }
.login-hero li::before { background: var(--red-brand); }
.punch { background: radial-gradient(800px 300px at 100% 0%, rgba(47, 134, 200, .35), transparent 60%), linear-gradient(150deg, #35245f, #1e1440); }
.punch-btn { background: linear-gradient(135deg, #2f86c8, #1f6aa5); box-shadow: 0 8px 24px rgba(47, 134, 200, .45); }
.nav a.active::before { background: var(--red-brand); }
.owner-shell .sidebar .brand img { background: #fff; border-radius: 12px; padding: 8px 10px; }
.owner-badge { color: #fff; background: linear-gradient(135deg, #2f86c8, #35245f); }
.brand-logo { max-width: 320px !important; max-height: 84px; }
.login-hero::before { content: ""; position: absolute; right: 200px; bottom: 0; width: 0; height: 0; border-left: 70px solid transparent; border-right: 70px solid transparent; border-bottom: 95px solid rgba(47, 134, 200, .55); }
