/* =========================================================
   Phone design (js/19-mobile.js) — phones and the Android / iPhone app
   ========================================================= */
.m-app {
  --m-red: #dc0414;
  --m-red-2: #a8030f;
  --m-ink: var(--ink);
  --m-card: var(--panel);
  --m-bg: var(--bg);
  --m-r: 18px;
  --m-tabs: calc(64px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--m-bg);
  color: var(--m-ink);
  padding-bottom: var(--m-tabs);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
.m-app a {
  color: inherit;
  text-decoration: none;
}
.m-app button {
  font: inherit;
  color: inherit;
}

/* ---- headers ---- */
.m-top,
.m-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--m-bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.m-head h1 {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-sub .m-head h1 {
  font-size: 18px;
}
.m-head-r {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.m-icon {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--m-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  cursor: pointer;
}
.m-icon:disabled {
  opacity: 0.5;
}
.m-dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--m-red);
  border: 2px solid var(--m-card);
}
.m-text {
  border: 0;
  background: none;
  color: var(--m-red) !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  padding: 8px 4px;
}
.m-me {
  display: flex;
  align-items: center;
  gap: 10px;
}
.m-me small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
.m-me b {
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.m-av {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #111;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.m-av.sm {
  width: 40px;
  height: 40px;
  font-size: 14px;
  background: color-mix(in srgb, var(--m-red) 12%, var(--m-card));
  color: var(--m-red);
}
.m-av.lg {
  width: 56px;
  height: 56px;
  font-size: 19px;
}

.m-body {
  padding: 4px 16px 24px;
}
.m-h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  margin: 22px 2px 10px;
}
.m-h2 a {
  font-size: 14px;
  font-weight: 600;
  color: var(--m-red) !important;
}

/* ---- hero: attendance ---- */
.m-hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: 18px 18px 18px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(150deg, #e30a1b 0%, #b0030f 100%);
  box-shadow: 0 10px 28px -12px rgba(200, 4, 20, 0.55);
}
.m-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.m-date {
  margin: 0;
  font-size: 14px;
  opacity: 0.85;
}
.m-clock {
  margin: 2px 0 0;
  font-size: 34px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.m-shift {
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  white-space: nowrap;
}
.m-hero-line {
  margin: 10px 0 0;
  font-size: 14.5px;
  opacity: 0.95;
}
.m-punch {
  margin-top: 14px;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  color: #c00312 !important;
  font-weight: 700 !important;
  font-size: 16px !important;
  cursor: pointer;
}
.m-punch.out {
  background: #111;
  color: #fff !important;
}
.m-punch:active,
.m-quick button:active,
.m-fab:active {
  transform: scale(0.98);
}

/* ---- stats ---- */
.m-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.m-stats.three {
  grid-template-columns: repeat(3, 1fr);
}
.m-stat {
  background: var(--m-card);
  border-radius: 16px;
  padding: 12px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.m-stat b {
  font-size: 21px;
  font-weight: 750;
}
.m-stat span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}

/* ---- quick actions ---- */
.m-quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.m-quick.two {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}
.m-quick button {
  border: 0;
  background: var(--m-card);
  border-radius: 16px;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  cursor: pointer;
}
.m-quick.two button {
  flex-direction: row;
  justify-content: center;
  font-size: 14px !important;
  padding: 12px;
}
.m-quick button span {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--m-red) 10%, var(--m-card));
  color: var(--m-red);
}
.m-quick.two button span {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

/* ---- lists and cards ---- */
.m-card {
  display: block;
  background: var(--m-card);
  border-radius: var(--m-r);
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.m-ann b {
  display: block;
  margin-bottom: 4px;
}
.m-ann p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.m-link,
.m-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.m-link small,
.m-profile small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 1px;
}
.m-profile b {
  font-size: 17px;
}
.m-link > span:nth-child(2),
.m-profile > span:nth-child(2) {
  flex: 1;
}
.m-profile {
  margin-top: 4px;
}
.m-wa-ic {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #e7f8ee;
  color: #128c4b;
}
.m-chev {
  flex: none;
  color: var(--muted);
  margin-left: auto;
}
.m-list {
  background: var(--m-card);
  border-radius: var(--m-r);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.m-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 0;
  background: none;
  text-align: left;
  min-height: 56px;
  cursor: pointer;
}
.m-list > * + * {
  border-top: 1px solid var(--line-2);
}
.m-row-t {
  flex: 1;
  min-width: 0;
}
.m-row-t b {
  display: block;
  font-weight: 600;
  font-size: 15px;
}
.m-row-t small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m-row.danger {
  color: var(--m-red) !important;
}
.m-num {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  background: var(--m-red);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.m-n-ic {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  color: var(--ink-2);
}
.m-notif.unread .m-row-t b::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--m-red);
  margin-left: 8px;
  vertical-align: middle;
}
.m-day {
  width: 44px;
  flex: none;
  text-align: center;
  line-height: 1.1;
}
.m-day b {
  display: block;
  font-size: 19px;
}
.m-day small {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
}
.m-empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  background: var(--m-card);
  border-radius: var(--m-r);
}
.m-note {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 6px 0 12px;
}

/* ---- leads ---- */
.m-sticky {
  position: sticky;
  top: calc(62px + env(safe-area-inset-top));
  z-index: 15;
  background: var(--m-bg);
  padding: 0 0 8px;
}
.m-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px;
  height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--m-card);
  color: var(--muted);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.m-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  min-width: 0;
  height: 100%;
  padding: 0;
  box-shadow: none !important;
}
.m-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px 2px;
  scrollbar-width: none;
}
.m-chips::-webkit-scrollbar {
  display: none;
}
.m-chips > * {
  flex: none;
  border: 1px solid var(--line);
  background: var(--m-card);
  border-radius: 99px;
  padding: 7px 13px;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  white-space: nowrap;
  cursor: pointer;
}
.m-chips > * span {
  color: var(--muted);
  font-weight: 500;
  margin-left: 2px;
}
.m-chips > .on {
  background: #111;
  border-color: #111;
  color: #fff !important;
}
.m-chips > .on span {
  color: rgba(255, 255, 255, 0.7);
}
.m-pages {
  padding-top: 2px;
  padding-bottom: 8px;
}
.m-lead {
  padding: 12px 14px 12px 16px;
}
.m-lead-main {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: none;
  text-align: left;
  padding: 0;
  cursor: pointer;
}
.m-lead-t {
  flex: 1;
  min-width: 0;
}
.m-lead-t b {
  display: block;
  font-weight: 650;
  font-size: 15.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m-lead-t small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m-lead-act {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0 52px;
}
.m-lead-act .st-sel {
  flex: 1;
  height: 36px;
  font-size: 13.5px;
  max-width: 170px;
}
.m-act {
  width: 40px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  margin-left: auto;
}
.m-act + .m-act {
  margin-left: 0;
}
.m-act.call {
  background: color-mix(in srgb, #2563eb 12%, var(--m-card));
  color: #2563eb !important;
}
.m-act.wa {
  background: color-mix(in srgb, #16a34a 13%, var(--m-card));
  color: #16a34a !important;
}
.m-fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--m-tabs) + 16px);
  z-index: 30;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 18px;
  background: var(--m-red);
  color: #fff !important;
  font-size: 30px !important;
  font-weight: 400 !important;
  line-height: 1;
  box-shadow: 0 10px 24px -8px rgba(220, 4, 20, 0.6);
  cursor: pointer;
}

/* ---- more ---- */
.m-apps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 6px;
  background: var(--m-card);
  border-radius: var(--m-r);
  padding: 16px 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.m-apps a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}
.m-tile {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  box-shadow: none;
}
.m-tile i,
.m-tabs i {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--m-red);
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--m-card);
}
.m-ver {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 22px 0 0;
}

/* ---- bottom tabs ---- */
.m-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: var(--m-tabs);
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--m-card) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.m-tabs a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted) !important;
}
.m-tabs a.on {
  color: var(--m-red) !important;
}
.m-tabs a.on::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--m-red);
}
.m-tabs i {
  top: 6px;
  right: calc(50% - 22px);
}

/* ---- normal CRM pages inside the phone frame ---- */
.m-desk {
  padding-top: 4px;
}
.m-desk .page-head {
  flex-wrap: wrap;
  gap: 8px;
}
.m-desk .page-head h2 {
  display: none;
}
.m-desk .page-head:not(:has(> :not(h2))) {
  display: none;
}
.m-desk .card {
  border-radius: 16px;
}
.m-desk .tbl,
.m-desk .card {
  max-width: 100%;
  overflow-x: auto;
}
.m-desk table {
  font-size: 13.5px;
}

/* ---- dialogs as bottom sheets ---- */
body:has(.m-app) dialog[open] {
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top));
  margin: auto 0 0;
  border-radius: 22px 22px 0 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
body:has(.m-app) dialog .fields {
  grid-template-columns: 1fr !important;
}
body:has(.m-app) dialog input,
body:has(.m-app) dialog select,
body:has(.m-app) dialog textarea {
  font-size: 16px; /* stops iPhone zooming into fields */
}
body:has(.m-app) dialog .actions {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  padding-top: 10px;
}
body:has(.m-app) #toasts {
  bottom: calc(var(--m-tabs, 64px) + 80px);
}

@media (min-width: 761px) {
  .m-app {
    max-width: 560px;
    margin: 0 auto;
  }
  .m-tabs {
    max-width: 560px;
    margin: 0 auto;
  }
}
