/* Micromart UI refresh — warm, clear and thumb-friendly across desktop and mobile. */
:root {
  color-scheme: light;
  --mm-orange: #f97316;
  --mm-orange-deep: #c2410c;
  --mm-ink: #172033;
  --mm-muted: #718096;
  --mm-line: #e9edf2;
  --mm-surface: #ffffff;
  --mm-canvas: #f7f8fa;
  --mm-shadow: 0 10px 30px -22px rgba(23, 32, 51, .24), 0 2px 5px rgba(23, 32, 51, .035);
}

html { scroll-behavior: smooth; }
body {
  color: var(--mm-ink);
  background:
    radial-gradient(900px 520px at 100% -10%, rgba(249, 115, 22, .075), transparent 62%),
    linear-gradient(180deg, #fbfbfc 0%, var(--mm-canvas) 34rem, #f6f7f9 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
::selection { color: #7c2d12; background: #ffedd5; }
:focus-visible { outline: 3px solid rgba(249, 115, 22, .38); outline-offset: 2px; }

/* Desktop workspace */
@media (min-width: 768px) {
  aside.mmside {
    background: rgba(255, 255, 255, .96);
    border-right-color: #edf0f3;
    box-shadow: 8px 0 30px -28px rgba(23, 32, 51, .28);
  }
  aside.mmside > div:first-child > div:first-child {
    border-bottom-color: #f0f1f3;
  }
  header.md\:flex {
    min-height: 68px;
    padding-inline: clamp(1.25rem, 2.4vw, 2.5rem);
    background: rgba(255, 255, 255, .88);
    border-bottom-color: rgba(233, 237, 242, .9);
    box-shadow: 0 6px 18px -18px rgba(23, 32, 51, .25);
  }
  main {
    max-width: 100%;
    padding: clamp(1.5rem, 3vw, 2.75rem) clamp(1.5rem, 3vw, 3.25rem) !important;
    gap: 1.5rem;
  }
  main > .noprint:first-child h2 { letter-spacing: -.035em; }
}

/* A clearer page title and calm, consistent surfaces */
main > .noprint:first-child:not(.relative) {
  padding-bottom: .2rem;
}
main > .page-heading > div:first-child {
  border-left: 3px solid #fb923c;
  padding-left: .85rem;
}
main > .noprint:first-child h2 {
  color: #172033;
  line-height: 1.15;
}
main > .noprint:first-child p {
  margin-top: .38rem;
  color: #788395;
  line-height: 1.55;
}
.card,
main .bg-white.rounded-2xl {
  border: 1px solid rgba(226, 232, 240, .82);
  box-shadow: var(--mm-shadow);
}
main .card,
main section.card,
main .bg-white.rounded-2xl {
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
main .card:hover,
main section.card:hover {
  border-color: rgba(253, 186, 116, .7);
  box-shadow: 0 14px 34px -24px rgba(194, 65, 12, .22), 0 3px 9px rgba(23, 32, 51, .045);
}
.hero {
  border-radius: 1.65rem;
  box-shadow: 0 24px 48px -30px rgba(194, 65, 12, .78);
}

/* Controls feel consistent and remain easy to use */
.btn {
  min-height: 40px;
  border-radius: .85rem;
  transition: transform .16s ease, background-color .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.btn-p {
  background: linear-gradient(135deg, #fb923c, #ea580c);
  box-shadow: 0 5px 12px -5px rgba(234, 88, 12, .52);
}
.btn-p:hover {
  background: linear-gradient(135deg, #f97316, #c2410c);
  box-shadow: 0 8px 17px -7px rgba(194, 65, 12, .58);
  transform: translateY(-1px);
}
.btn-g { background: #fff; }
.inp,
select.inp,
textarea.inp {
  background: #fbfcfd;
  border-color: #e4e8ee;
  color: #253044;
  border-radius: .85rem;
}
.inp:hover { border-color: #cfd6df; }
.inp:focus,
select.inp:focus,
textarea.inp:focus {
  background: #fff;
  border-color: #fb923c;
  box-shadow: 0 0 0 4px rgba(249, 115, 22, .12);
}

/* Tables: legible headers, quieter rules, intentional row feedback */
.tb th {
  color: #778397;
  background: #f8fafc;
  border-bottom-color: #e9edf2;
  letter-spacing: .07em;
  padding-block: .85rem;
}
.tb td { border-top-color: #edf0f4; }
.tb tbody tr:hover { background: #fff9f4; }

/* Desktop nav: stronger active state; mobile drawer stays lightweight */
aside.mmside nav > .relative > a[aria-current="page"],
aside.mmside .mmsub a[aria-current="page"] {
  background: linear-gradient(90deg, #fff4e9, #fffaf5);
  color: #c2410c;
  border-radius: .9rem;
}
aside.mmside nav > .relative > a { min-height: 46px; }
aside.mmside .mmgrp > summary { min-height: 42px; }

/* Mobile: edge-to-edge native-app rhythm with safe-area-aware controls */
@media (max-width: 767px) {
  body { background: #f7f8fa; background-attachment: scroll; }
  header.mmhead {
    min-height: 64px;
    padding-inline: 1rem;
    padding-bottom: .65rem !important;
    background: rgba(255, 255, 255, .94) !important;
    border-bottom: 1px solid rgba(230, 234, 239, .85);
    box-shadow: 0 5px 18px -16px rgba(23, 32, 51, .28);
  }
  header.mmhead > div:first-child > a > span:first-child {
    box-shadow: 0 5px 12px -6px rgba(234, 88, 12, .55);
  }
  main {
    padding: 1rem .85rem calc(6.7rem + env(safe-area-inset-bottom)) !important;
    gap: 1rem;
  }
  main > .noprint:first-child:not(.relative) { gap: .7rem; }
  main > .noprint:first-child h2 { font-size: 1.45rem; }
  .card,
  main .bg-white.rounded-2xl { border-radius: 1.15rem; }
  .btn { min-height: 44px; border-radius: .9rem; }
  #mmbottom {
    min-height: 68px;
    background: rgba(255, 255, 255, .96);
    border-color: #eceff3;
    box-shadow: 0 -8px 28px -18px rgba(23, 32, 51, .25);
  }
  #mmbottom a,
  #mmbottom button { min-height: 62px; }
  #mmbottom a[aria-current="page"]:not(:has(> span.-mt-6))::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 22px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: #f97316;
    transform: translateX(-50%);
  }
  #mmbottom a > span.-mt-6 { box-shadow: 0 7px 16px -7px rgba(194, 65, 12, .66); }
  .tb:not(.nostack) tr {
    background: #fff;
    border-color: #edf0f4 !important;
    box-shadow: 0 2px 5px rgba(23, 32, 51, .035);
  }
  .tb:not(.nostack) td[data-l]::before { color: #8792a2; letter-spacing: .045em; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}


/* Print uses a clean, standard light table. */
@media print {
  body { color: #111827 !important; background: #fff !important; }
  #report-sheet { width: 100%; border: 0 !important; padding: 0 !important; background: #fff !important; }
  #report-sheet .overflow-x-auto { overflow: visible !important; }
  #report-sheet .tb { display: table !important; width: 100%; border-collapse: collapse; }
  #report-sheet .tb thead { display: table-header-group !important; }
  #report-sheet .tb tbody { display: table-row-group !important; }
  #report-sheet .tb tr { display: table-row !important; break-inside: avoid; page-break-inside: avoid; }
  #report-sheet .tb th,
  #report-sheet .tb td { display: table-cell !important; color: #111827 !important; border: 1px solid #94a3b8 !important; }
  #report-sheet .tb th { background: #ffedd5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #report-sheet .tb td { background: #fff !important; }
}


/* Mobile touch behavior: suppress long-press selection and sticky hover states without disabling form editing. */
@media (max-width: 767px) {
  html, body { overscroll-behavior-y: contain; }
  header.mmhead > div:last-child { align-self: center; align-items: center; min-height: 40px; }
  header.mmhead > div:last-child > a[aria-label="Profile"] {
    display: inline-flex;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    align-self: center;
    align-items: center;
    justify-content: center;
    line-height: 1;
    vertical-align: middle;
  }
  .mm-pull-refresh {
    --pull-offset: 0px;
    display: flex !important;
    position: fixed;
    z-index: 80;
    top: calc(env(safe-area-inset-top) + 68px);
    left: 50%;
    align-items: center;
    gap: .6rem;
    min-height: 42px;
    padding: .45rem .9rem .45rem .55rem;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    color: #9a3412;
    background: #fff;
    box-shadow: 0 8px 22px -12px rgba(124, 45, 18, .42);
    font-size: .72rem;
    font-weight: 800;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, calc(-165% + var(--pull-offset)));
    transition: opacity .16s ease, transform .18s cubic-bezier(.2, .8, .2, 1);
    -webkit-user-select: none;
    user-select: none;
  }
  .mm-pull-refresh.visible { opacity: 1; }
  .mm-pull-icon {
    display: inline-flex;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #fb923c, #ea580c);
    transition: transform .15s ease;
  }
  .mm-pull-icon i { font-size: .78rem; }
  .mm-pull-refresh.refreshing .mm-pull-icon i { animation: mmPullSpin .72s linear infinite; }
  @keyframes mmPullSpin { to { transform: rotate(360deg); } }
}

@media (max-width: 767px) and (hover: none) and (pointer: coarse) {
  body, body * {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent;
  }
  input, textarea, select, [contenteditable="true"], .selectable {
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
  }
  [class*="hover:bg-"]:hover { background-color: inherit !important; }
  [class*="hover:text-"]:hover { color: inherit !important; }
  [class*="hover:border-"]:hover { border-color: inherit !important; }
  .btn:hover, a:hover, button:hover, [role="button"]:hover { transform: none !important; filter: none !important; }
  .btn-p:hover { background: linear-gradient(135deg, #fb923c, #ea580c) !important; }
  main .card:hover,
  main section.card:hover,
  main .grid > .bg-white.rounded-2xl:hover {
    transform: none !important;
    border-color: rgba(226, 232, 240, .82) !important;
    box-shadow: var(--mm-shadow) !important;
  }

}
@media (prefers-reduced-motion: reduce) {
  .mm-pull-refresh, .mm-pull-icon { transition: none !important; }
  .mm-pull-refresh.refreshing .mm-pull-icon i { animation: none !important; }
}

@media (max-width: 767px) and (hover: none) and (pointer: coarse) {
  .ib:hover, .dp:hover, .lg:hover, .fill button:hover,
  .rc-d:hover, .sb:hover, .ad-btn:hover, .att-btn:hover {
    transform: none !important;
    filter: none !important;
  }
  .ib:hover, .dp:hover, .lg:hover, .fill button:hover {
    background-color: inherit !important;
    border-color: inherit !important;
  }
  .tb tbody tr:hover { background: inherit !important; }
}


/* Attendance refresh: brighter orange-and-white controls, with the existing action animation preserved. */
:root { color-scheme: light; }
.ad-hero {
  color: #172033 !important;
  background: linear-gradient(135deg, #fff 0%, #fffaf5 54%, #fff1e5 100%) !important;
  border: 1px solid #fed7aa;
  box-shadow: 0 22px 48px -32px rgba(154, 52, 18, .36), 0 2px 8px rgba(15, 23, 42, .04) !important;
}
.ad-kicker { color: #c2410c !important; }
.ad-clock { color: #111827; font-variant-numeric: tabular-nums; }
.ad-date { color: #64748b !important; }
.ad-shift { color: #7c2d12 !important; background: #fff !important; border-color: #fed7aa !important; box-shadow: 0 2px 8px rgba(124, 45, 18, .06); }
.ad-shift i { color: #f97316 !important; }
.ad-shift.none { color: #64748b !important; }
.ad-state { color: #172033; background: rgba(255,255,255,.92) !important; border: 1px solid #ffedd5 !important; box-shadow: 0 4px 14px rgba(124,45,18,.05); }
.ad-ring { color: #c2410c; background: #fff7ed !important; border: 1px solid #fed7aa; }
.ad-ring.working { color: #fff !important; background: #10b981 !important; border-color: #10b981; box-shadow: 0 0 0 5px rgba(16,185,129,.12); }
.ad-ring.done { color: #fff !important; background: #f97316 !important; border-color: #f97316; }
.ad-ring.idle { color: #c2410c !important; }
.ad-lbl { color: #64748b !important; }
.ad-val { color: #111827 !important; }
.ad-val .arr { color: #94a3b8 !important; }
.ad-sub { color: #64748b !important; }
.ad-sub.working { color: #047857 !important; }
.ad-hero .att-btn { min-height: 96px; border-radius: 18px; box-shadow: 0 12px 24px -14px rgba(124,45,18,.5); }
.ad-hero .att-in { background: linear-gradient(135deg,#fb923c,#ea580c) !important; }
.ad-hero .att-out { background: linear-gradient(135deg,#475569,#1e293b) !important; }
.ad-hero .att-btn:disabled { color: #94a3b8 !important; background: #f1f5f9 !important; border: 1px solid #e2e8f0; box-shadow: none; }
.ad-who small.ad-work-time { color: #c2410c !important; font-weight: 800; }
.ad-who small.ad-work-time i { color: #f97316; }
.ad-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
@media (min-width: 768px) { .ad-stats { grid-template-columns: repeat(6,minmax(0,1fr)); } }
@media (max-width: 639px) {
  .ad-hero { padding: 1rem !important; border-radius: 22px !important; }
  .ad-top { align-items: flex-start; }
  .ad-clock { font-size: clamp(2.5rem, 13vw, 3.2rem) !important; }
  .ad-state { padding: .8rem; gap: .7rem; }
  .ad-btns { gap: .5rem; }
  .ad-hero .att-btn { min-height: 84px; font-size: .8rem; }
  .ad-hero .att-btn i { font-size: 1.45rem; }
}

/* Keep native date/time controls inside their cards on narrow mobile viewports. */
.rq,.rq-grid,.rq-grid > *,.rq-panel,.rq-two,.rq-f { min-width: 0; }
.rq-two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.rq-f input,.rq-f select,.rq-f textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-size: 16px;
}
.rq-when { min-width: 0; align-items: flex-start; white-space: normal; overflow-wrap: anywhere; }
.rq-when span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) { .rq-two { grid-template-columns: minmax(0,1fr); } }


/* ------------------------------------------------------------------ */
/* Pull to refresh: mobile / touch only. Never rendered on desktop.    */
/* ------------------------------------------------------------------ */
.mm-pull-refresh { display: none !important; }
@media (max-width: 767px) and (pointer: coarse) {
  .mm-pull-refresh { display: flex !important; }
}

/* ------------------------------------------------------------------ */
/* Modals: full-screen blurred backdrop. Backdrop clicks do nothing;   */
/* they close only with the X button, Cancel, Save or the Esc key.     */
/* ------------------------------------------------------------------ */
.mm-modal,
.mm-backdrop {
  background: rgba(15, 23, 42, .45);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  backdrop-filter: blur(10px) saturate(1.1);
}
.mm-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overscroll-behavior: contain;
}
.mm-modal-box {
  max-width: min(32rem, 100%);
  min-width: 0;
  box-sizing: border-box;
}
.mm-modal-box form,
.mm-modal-box label,
.mm-modal-box .grid > * { min-width: 0; max-width: 100%; }
.mm-modal-box .inp,
.mm-modal-box input,
.mm-modal-box select,
.mm-modal-box textarea { max-width: 100%; box-sizing: border-box; }

/* ------------------------------------------------------------------ */
/* max-width: 100% so nothing can push past its container               */
/* ------------------------------------------------------------------ */
img, svg, video, canvas, iframe, table, .card, .inp, input, select, textarea { max-width: 100%; }
main, main > * { min-width: 0; }

/* ------------------------------------------------------------------ */
/* Date / time pickers: tidy, contained and thumb-friendly on mobile    */
/* ------------------------------------------------------------------ */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 44px;
  line-height: 1.3;
  text-align: left;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  position: relative;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value {
  text-align: left;
  min-height: 1.3em;
  margin: 0;
  padding: 0;
}
input[type="date"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit,
input[type="datetime-local"]::-webkit-datetime-edit {
  padding: 0;
  min-width: 0;
  max-width: 100%;
}
input[type="date"]::-webkit-datetime-edit-fields-wrapper,
input[type="time"]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  margin: 0 0 0 .35rem;
  padding: 0;
  cursor: pointer;
  opacity: .55;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator { opacity: .9; }

@media (max-width: 767px) {
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    min-height: 46px;
    font-size: 16px; /* also stops iOS zooming in on focus */
    padding: .55rem .8rem;
    border-radius: .9rem;
  }
  /* Inputs inside labels / grids must be allowed to shrink */
  label, label > input, label > select { min-width: 0; max-width: 100%; }
  .grid > * { min-width: 0; }

  /* Filter bars (report, payroll, audit): two per row, full width, no overflow */
  form.flex.flex-wrap > label { flex: 1 1 calc(50% - .5rem); min-width: 0; }
  form.flex.flex-wrap > label > .inp { width: 100%; }
  form.flex.flex-wrap > .btn { flex: 1 1 100%; }

  /* Attendance roster row: status on its own line, In / Out side by side */
  .ad-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ad-fields label:first-child { grid-column: 1 / -1; }
  .ad-fields .inp { min-height: 44px; font-size: 16px; padding: .5rem .65rem; }

  /* Attendance date filter */
  .ad-f label, .ad-f .inp { min-width: 0; width: 100%; }

  /* Modal forms: two-up date/time rows stay inside the sheet */
  .mm-modal-box .grid.grid-cols-2,
  .mm-modal-box .grid.grid-cols-3 { gap: .6rem; }
}
@media (max-width: 380px) {
  .mm-modal-box .grid.grid-cols-2,
  .mm-modal-box .grid.grid-cols-3 { grid-template-columns: minmax(0, 1fr); }
}
