:root {
  --bg: #f4f9ff;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --line: #d9e8f7;
  --line-strong: #b8d5ee;
  --text: #102a43;
  --muted: #6b86a0;
  --blue: #3b82f6;
  --blue-dark: #1d4f9a;
  --blue-soft: #eaf4ff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --gray: #64748b;
  --sidebar: 280px;
  --radius: 20px;
  --shadow: 0 12px 34px rgba(42, 92, 142, .10);
}

* {
  box-sizing: border-box
}

html,
body {
  min-height: 100%
}

body {
  margin: 0;
  background: linear-gradient(180deg, #edf7ff 0, #f8fbff 190px, var(--bg) 190px);
  font-family: Arial, 'Noto Sans Thai', sans-serif;
  color: var(--text);
  line-height: 1.45;
}

a {
  text-decoration: none
}

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%
}

.sidebar {
  width: var(--sidebar);
  position: fixed;
  inset: 0 auto 0 0;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 30px rgba(42, 92, 142, .08);
  z-index: 1045;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.content-wrap {
  margin-left: var(--sidebar);
  width: calc(100% - var(--sidebar));
  min-height: 100vh;
}

.app-main {
  max-width: 1600px;
  padding-left: 24px;
  padding-right: 24px
}

.sidebar-brand {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text)
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue-dark), #72b6ff);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(59, 130, 246, .24);
}

.brand-title {
  display: block;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1
}

.brand-sub {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  margin-top: 4px
}

.sidebar-close {
  border: 0;
  background: #edf6ff;
  color: var(--blue-dark);
  width: 38px;
  height: 38px;
  border-radius: 13px;
  font-size: 26px;
  line-height: 1;
}

.sidebar-user {
  margin: 16px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(42, 92, 142, .06);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #5aa7ff, #1d4f9a);
  flex: 0 0 auto;
}

.user-name {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.user-role {
  font-size: .78rem;
  color: var(--blue-dark);
  background: var(--blue-soft);
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  margin-top: 3px
}

.sidebar-menu {
  padding: 8px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px
}

.side-section {
  font-size: .74rem;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 900;
  padding: 16px 12px 4px;
  letter-spacing: .08em
}

.side-link {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #24455f;
  border-radius: 16px;
  font-weight: 800;
  border: 1px solid transparent;
}

.side-link:hover {
  background: #f0f7ff;
  color: var(--blue-dark)
}

.side-link.active {
  background: linear-gradient(135deg, #eaf4ff, #f9fcff);
  border-color: #a7cdf8;
  color: var(--blue-dark);
  box-shadow: 0 8px 18px rgba(59, 130, 246, .12);
}

.side-ico {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #eef6ff;
  color: var(--blue-dark);
  flex: 0 0 auto;
}

.side-link.active .side-ico {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: #fff
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--line)
}

.logout-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  border-radius: 16px;
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
  font-weight: 900;
}

.logout-btn:hover {
  background: #ffe4e6;
  color: #9f1239
}

.mobile-topbar {
  display: none
}

.mobile-backdrop {
  display: none
}

.card,
.stat,
.soft-card,
.check-item,
.machine-card {
  border: 1px solid rgba(184, 213, 238, .78) !important;
  border-radius: var(--radius) !important;
  background: linear-gradient(180deg, #fff, #fbfdff);
  box-shadow: var(--shadow);
}

.card {
  border: 1px solid rgba(184, 213, 238, .78) !important
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px
}

.page-title {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -.04em;
  margin: 0;
  color: #0f2942
}

.page-subtitle {
  color: var(--muted);
  font-size: .95rem;
  margin-top: 4px
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap
}

.stat {
  padding: 20px
}

.stat .small-label {
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 10px
}

.stat .num {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.04em
}

.stat.primary {
  background: linear-gradient(180deg, #fff, #eff7ff)
}

.stat.success {
  background: linear-gradient(180deg, #fff, #f0fdf4)
}

.stat.warning {
  background: linear-gradient(180deg, #fff, #fffbeb)
}

.stat.danger {
  background: linear-gradient(180deg, #fff, #fef2f2)
}

.btn-brand {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: #fff !important;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(59, 130, 246, .22)
}

.btn-brand:hover {
  background: linear-gradient(135deg, #174484, #2f74f0);
  color: #fff
}

.btn-soft {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 11px 16px;
  font-weight: 900
}

.btn-soft:hover {
  background: var(--blue-soft);
  border-color: #b7d7f7;
  color: var(--blue-dark)
}

.btn-outline-secondary,
.btn-secondary {
  border-radius: 14px
}

.form-control,
.form-select {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.form-control:focus,
.form-select:focus {
  border-color: #8dbbff;
  box-shadow: 0 0 0 .2rem rgba(59, 130, 246, .15)
}

.form-label {
  font-weight: 800;
  color: #35526b;
  margin-bottom: 8px
}

.table-responsive,
.scroll-x {
  border-radius: 18px
}

.table {
  --bs-table-bg: transparent
}

.table thead th {
  color: #5a728b;
  font-weight: 900;
  border-bottom-color: var(--line)
}

.table td,
.table th {
  padding: .8rem .85rem;
  vertical-align: middle;
  border-color: var(--line)
}

.table-hover tbody tr:hover>* {
  background: #f7fbff
}

.muted {
  color: var(--muted)
}

.small-label {
  font-size: .86rem;
  color: var(--muted)
}

.section-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 900;
  font-size: 12px
}

.machine-card {
  padding: 18px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px
}

.machine-code {
  font-size: 1.55rem;
  font-weight: 900;
  color: #13314c;
  line-height: 1
}

.machine-name {
  font-size: 1.02rem;
  font-weight: 800
}

.machine-section {
  color: var(--muted);
  font-size: .92rem
}

.machine-card .btn {
  margin-top: auto
}

.check-machine-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start
}

.machine-detail-title {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -.04em;
  margin-bottom: 4px
}

.machine-detail-name {
  font-size: 1.08rem;
  color: #284b63
}

.date-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end
}

.status-box {
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line)
}

.status-box.success {
  background: #effdf4;
  border-color: #b7e6c7;
  color: #166534
}

.status-box.info {
  background: #eef7ff;
  border-color: #cfe0fb;
  color: #1d4f91
}

.status-box.holiday {
  background: #f4f6f8;
  border-color: #d7dde7;
  color: #475569
}

.check-item {
  padding: 16px;
  margin-bottom: 14px
}

.check-item-title {
  font-size: 1.02rem;
  font-weight: 900;
  color: #16324a;
  margin-bottom: 10px
}

.item-sub {
  font-size: .88rem;
  color: var(--muted)
}

.radio-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

.radio-pill input {
  display: none
}

.radio-pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 14px;
  min-width: 122px;
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}

.radio-pill input:checked+span {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 16px rgba(22, 50, 74, .12)
}

.radio-pill.normal input:checked+span {
  background: linear-gradient(135deg, #16a34a, #22c55e)
}

.radio-pill.abnormal input:checked+span {
  background: linear-gradient(135deg, #dc2626, #ef4444)
}

.radio-pill.correction input:checked+span {
  background: linear-gradient(135deg, #d97706, #f59e0b)
}

.numeric-required {
  font-size: 1.15rem;
  font-weight: 900;
  text-align: center
}

.unit-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 900
}

.check-submit-wrap {
  position: sticky;
  bottom: 10px;
  z-index: 8;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(246, 250, 255, 0), rgba(246, 250, 255, .92) 30%, rgba(246, 250, 255, .98))
}

.check-submit-wrap .btn {
  min-height: 54px;
  border-radius: 18px;
  font-size: 1.05rem
}

.progress-box {
  padding: 14px 16px;
  border-radius: 16px;
  background: #eef7ff;
  border: 1px solid #cde0f8;
  color: #184a8c;
  font-weight: 900
}

.alert {
  border-radius: 18px;
  border: 1px solid transparent
}

.alert-success {
  background: #eefdf3;
  border-color: #b5e6c7;
  color: #166534
}

.alert-info {
  background: #eef7ff;
  border-color: #cde0f8;
  color: #184a8c
}

.alert-secondary {
  background: #f4f6f8;
  border-color: #dae0e7;
  color: #475569
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px
}

.mini-info {
  padding: 12px 14px;
  border-radius: 16px;
  background: #f8fbff;
  border: 1px solid var(--line)
}

.table-excel {
  border-collapse: collapse;
  background: #fff;
  font-size: 12px;
  width: max-content;
  min-width: 100%
}

.table-excel th,
.table-excel td {
  border: 1px solid #b8cbe0;
  padding: 4px;
  text-align: center;
  vertical-align: middle
}

.table-excel .left {
  text-align: left;
  min-width: 300px;
  background: #fbfdff
}

.table-excel .title {
  font-weight: 900;
  background: #eff6ff
}

.cell-day {
  min-width: 46px;
  height: 30px;
  font-weight: 900
}

.ok {
  background: #dcfce7;
  color: #166534
}

.ng {
  background: #fee2e2;
  color: #b91c1c
}

.fix {
  background: #fef3c7;
  color: #92400e
}

.hol {
  background: #eef2f6;
  color: #475569
}

.empty {
  background: #fff;
  color: #aaa
}

.val {
  background: #eef6ff;
  color: #0f172a
}

.sticky-left {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2
}

.sheet-tab {
  display: inline-block;
  padding: 9px 13px;
  border-radius: 12px;
  background: #fff;
  margin: 3px;
  text-decoration: none;
  color: #111827;
  border: 1px solid var(--line)
}

.sheet-tab.active {
  background: var(--blue-soft);
  color: var(--blue-dark);
  border-color: #9ec5f8
}

.unit {
  font-size: 11px;
  color: #475569
}

.report-card {
  overflow: hidden
}

.report-head {
  font-size: 14px
}

.table-excel .name-cell {
  min-width: 118px;
  max-width: 138px;
  font-size: 10px;
  line-height: 1.15;
  white-space: normal;
  word-break: break-word;
  font-weight: 900
}

.table-excel .time-cell {
  min-width: 72px;
  font-size: 11px;
  font-weight: 900
}

.table-excel .cell-day.val {
  font-size: 11px;
  font-weight: 900
}

.badge.val {
  background: #dbeafe;
  color: #1e3a8a
}

.legend-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900
}

.legend-pill.ok {
  background: #dcfce7;
  color: #166534
}

.legend-pill.ng {
  background: #fee2e2;
  color: #b91c1c
}

.legend-pill.fix {
  background: #fef3c7;
  color: #92400e
}

.legend-pill.hol {
  background: #eef2f6;
  color: #475569
}

.legend-pill.val {
  background: #eaf4ff;
  color: #194b87
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    transition: .22s ease;
    width: min(320px, 86vw)
  }

  body.sidebar-open .sidebar {
    transform: translateX(0)
  }

  .mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 35, 55, .48);
    z-index: 1040
  }

  body.sidebar-open .mobile-backdrop {
    display: block
  }

  .content-wrap {
    margin-left: 0;
    width: 100%
  }

  .mobile-topbar {
    height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, .93);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 0 14px;
    box-shadow: 0 6px 18px rgba(42, 92, 142, .08);
  }

  .menu-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 12px rgba(42, 92, 142, .08)
  }

  .menu-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--blue-dark);
    border-radius: 999px;
    margin: 2px 0
  }

  .mobile-title {
    font-weight: 900;
    font-size: 1.05rem
  }

  .mobile-sub {
    font-size: .78rem;
    color: var(--muted)
  }

  .app-main {
    padding-left: 12px;
    padding-right: 12px
  }

  .page-title {
    font-size: 1.45rem
  }

  .check-machine-header {
    grid-template-columns: 1fr
  }

  .machine-detail-title {
    font-size: 1.45rem
  }
}

@media (max-width: 767.98px) {

  .card,
  .stat,
  .soft-card,
  .check-item,
  .machine-card {
    border-radius: 18px !important
  }

  .page-title {
    font-size: 1.32rem
  }

  .stat {
    padding: 16px
  }

  .stat .num {
    font-size: 2rem
  }

  .quick-grid {
    grid-template-columns: 1fr
  }

  .machine-card {
    padding: 16px
  }

  .machine-code {
    font-size: 1.45rem
  }

  .check-item {
    padding: 14px
  }

  .radio-row {
    display: grid;
    grid-template-columns: 1fr
  }

  .radio-pill span {
    width: 100%;
    min-width: 0
  }

  .table-excel .left {
    min-width: 210px
  }

  .cell-day {
    min-width: 40px
  }

  .table-excel .name-cell {
    min-width: 92px;
    max-width: 110px;
    font-size: 9px
  }

  .table-excel .time-cell {
    min-width: 62px;
    font-size: 10px
  }

  .btn-brand,
  .btn-soft {
    width: 100%
  }

  .date-switch {
    display: grid;
    grid-template-columns: 1fr auto
  }
}

@media print {

  .no-print,
  .sidebar,
  .mobile-topbar,
  .check-submit-wrap {
    display: none !important
  }

  .content-wrap {
    margin-left: 0;
    width: 100%
  }

  body {
    background: #fff
  }

  .card,
  .stat {
    box-shadow: none !important;
    border-radius: 0
  }

  .table-excel {
    font-size: 9px
  }

  .table-excel .left {
    min-width: 210px
  }

  .cell-day {
    min-width: 28px
  }

  .table-excel .name-cell,
  .table-excel .time-cell {
    min-width: 55px;
    font-size: 8px
  }

  .scroll-x {
    overflow: visible
  }
}


/* Compact full-month report view */
.report-filter-card {
  padding: 12px 14px !important
}

.report-page .report-card {
  padding: 10px !important
}

.report-page .report-head {
  font-size: 13px
}

.report-page .report-head h4 {
  font-size: 1.15rem !important;
  margin: 2px 0 8px
}

.report-page .scroll-x {
  overflow: auto
}

.report-page .table-excel.report-table {
  font-size: 10px;
  min-width: 0;
  width: 100%;
  table-layout: fixed
}

.report-page .table-excel.report-table th,
.report-page .table-excel.report-table td {
  padding: 3px 2px
}

.report-page .table-excel.report-table th:first-child,
.report-page .table-excel.report-table td:first-child {
  width: 26px;
  min-width: 26px
}

.report-page .table-excel.report-table .left {
  min-width: 235px;
  width: 235px;
  font-size: 10px;
  line-height: 1.15
}

.report-page .table-excel.report-table .cell-day {
  min-width: 30px;
  width: 30px;
  height: 24px;
  font-size: 10px
}

.report-page .table-excel.report-table .name-cell {
  min-width: 30px;
  width: 30px;
  max-width: 30px;
  font-size: 8px;
  line-height: 1.02;
  word-break: break-word
}

.report-page .table-excel.report-table .time-cell {
  min-width: 30px;
  width: 30px;
  font-size: 8px;
  line-height: 1.02
}

.report-page .table-excel.report-table .unit {
  font-size: 8px
}

.report-page .legend-row,
.report-page .legend-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap
}

.report-page .legend-row .badge,
.report-page .legend-pills .badge {
  font-size: 11px;
  padding: 4px 7px
}

@media (min-width: 1500px) {
  .report-page .table-excel.report-table .left {
    min-width: 255px;
    width: 255px
  }

  .report-page .table-excel.report-table .cell-day {
    min-width: 31px;
    width: 31px
  }
}

@media (max-width: 1399.98px) {
  .report-page .table-excel.report-table {
    font-size: 9px
  }

  .report-page .table-excel.report-table .left {
    min-width: 220px;
    width: 220px;
    font-size: 9px
  }

  .report-page .table-excel.report-table .cell-day {
    min-width: 28px;
    width: 28px;
    font-size: 9px
  }

  .report-page .table-excel.report-table .name-cell,
  .report-page .table-excel.report-table .time-cell {
    min-width: 28px;
    width: 28px;
    font-size: 7px
  }
}

@media (max-width: 991.98px) {
  .report-page .table-excel.report-table {
    width: max-content;
    min-width: 100%
  }

  .report-page .table-excel.report-table .left {
    min-width: 210px;
    width: 210px
  }

  .report-page .table-excel.report-table .cell-day {
    min-width: 40px;
    width: 40px
  }

  .report-page .table-excel.report-table .name-cell {
    min-width: 58px;
    width: 58px;
    font-size: 8px
  }

  .report-page .table-excel.report-table .time-cell {
    min-width: 44px;
    width: 44px;
    font-size: 8px
  }
}


/* Machine checked status cards */
.checked-card {
  border-color: #9fe0b7 !important;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%) !important;
}

.pending-card {
  border-color: #c7dcf3 !important;
}

.holiday-card {
  border-color: #d8dde6 !important;
  background: linear-gradient(180deg, #ffffff 0%, #f5f7fa 100%) !important;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  padding: 7px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: .78rem;
  white-space: nowrap;
}

.status-badge.checked {
  background: #dcfce7;
  color: #166534;
}

.status-badge.pending {
  background: #fff7ed;
  color: #c2410c;
}

.status-badge.holiday {
  background: #eef2f6;
  color: #475569;
}

.checked-info,
.pending-info {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.45;
}

.checked-info {
  background: rgba(220, 252, 231, .72);
  color: #14532d;
  border: 1px solid #bbf7d0;
}

.pending-info {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  font-weight: 800;
}

.holiday-info {
  background: #f1f5f9;
  color: #475569;
  border-color: #d8e0ea;
}

.machine-card.checked-card .machine-code {
  color: #166534;
}

.machine-card.pending-card .machine-code {
  color: #0f2942;
}

.machine-card .btn-success {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 900;
  background: linear-gradient(135deg, #15803d, #22c55e);
  box-shadow: 0 10px 24px rgba(34, 197, 94, .20);
}

@media(max-width:767.98px) {
  .status-badge {
    min-width: 76px;
    font-size: .72rem;
    padding: 6px 9px
  }

  .checked-info,
  .pending-info {
    font-size: .86rem
  }
}


/* Compact mobile select page */
.machine-select-page .compact-page-head {
  margin-bottom: 10px
}

.machine-select-page .page-title {
  font-size: 1.35rem
}

.machine-select-page .page-subtitle {
  font-size: .88rem;
  line-height: 1.3
}

.machine-select-page .compact-filter-card {
  padding: 14px 14px 12px !important
}

.machine-select-page .compact-filter-form .form-label {
  margin-bottom: 6px;
  font-size: .92rem
}

.machine-select-page .compact-filter-form .form-control,
.machine-select-page .compact-filter-form .form-select {
  min-height: 44px;
  font-size: 1rem
}

.machine-select-page .compact-btn {
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 14px
}

.machine-select-page .compact-stat {
  padding: 12px 14px;
  border-radius: 16px !important
}

.machine-select-page .compact-stat .small-label {
  font-size: .82rem;
  margin-bottom: 6px;
  line-height: 1.2
}

.machine-select-page .compact-stat .num {
  font-size: 1.05rem
}

.machine-select-page .compact-machine-grid {
  gap: .75rem 0
}

.machine-select-page .compact-machine-card {
  padding: 14px 16px;
  border-radius: 18px !important;
  gap: 6px
}

.machine-select-page .compact-machine-card .machine-code {
  font-size: 1rem;
  line-height: 1.05;
  margin-bottom: 2px
}

.machine-select-page .compact-machine-card .machine-name {
  font-size: .8rem;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: .01em
}

.machine-select-page .compact-machine-card .machine-section {
  font-size: .72rem;
  line-height: 1.1
}

.machine-select-page .status-badge {
  min-width: 68px;
  padding: 5px 8px;
  font-size: .68rem
}

.machine-select-page .compact-info-box {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  font-size: .82rem;
  line-height: 1.3
}

.machine-select-page .compact-machine-btn {
  margin-top: 10px !important;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: .95rem
}

.machine-select-page .machine-card .btn-success {
  padding: 10px 12px
}

@media (min-width:768px) {
  .machine-select-page .compact-filter-card {
    padding: 16px 18px !important
  }

  .machine-select-page .compact-machine-grid .col-12 {
    width: 50%
  }

  .machine-select-page .compact-stats-row .col-6 {
    width: 25%
  }
}

@media (max-width:767.98px) {
  .machine-select-page .page-title {
    font-size: 1.18rem
  }

  .machine-select-page .page-subtitle {
    font-size: .82rem
  }

  .machine-select-page .compact-filter-card {
    padding: 12px !important
  }

  .machine-select-page .compact-stat {
    padding: 10px 12px
  }

  .machine-select-page .compact-stat .num {
    font-size: .95rem
  }

  .machine-select-page .compact-machine-card {
    padding: 12px 14px
  }

  .machine-select-page .compact-machine-card .machine-code {
    font-size: .95rem
  }

  .machine-select-page .compact-machine-card .machine-name {
    font-size: .76rem
  }

  .machine-select-page .compact-machine-card .machine-section {
    font-size: .68rem
  }

  .machine-select-page .status-badge {
    min-width: 62px;
    font-size: .64rem;
    padding: 4px 7px
  }

  .machine-select-page .compact-info-box {
    font-size: .77rem;
    padding: 8px 10px
  }

  .machine-select-page .compact-machine-btn {
    font-size: .9rem;
    min-height: 40px
  }
}


/* Smaller top area + 2-column machine cards */
.machine-select-page.compact-v2 .page-title {
  font-size: 1.05rem;
  margin-bottom: 2px
}

.machine-select-page.compact-v2 .page-subtitle {
  font-size: .76rem;
  line-height: 1.2
}

.slim-top-wrap {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 4px 12px rgba(42, 92, 142, .05);
}

.slim-filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px
}

.slim-field .form-label {
  font-size: .82rem;
  margin-bottom: 4px
}

.slim-field .form-control,
.slim-field .form-select {
  min-height: 40px;
  font-size: .95rem;
  border-radius: 12px
}

.slim-show-btn {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: .95rem
}

.compact-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px
}

.compact-mini-stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 9px 10px;
  box-shadow: 0 4px 12px rgba(42, 92, 142, .04);
}

.compact-mini-stat.primary {
  background: linear-gradient(180deg, #fff, #eff7ff)
}

.compact-mini-stat.success {
  background: linear-gradient(180deg, #fff, #f0fdf4)
}

.compact-mini-stat.warning {
  background: linear-gradient(180deg, #fff, #fffbeb)
}

.compact-mini-stat.danger {
  background: linear-gradient(180deg, #fff, #fef2f2)
}

.compact-mini-stat .small-label {
  font-size: .74rem;
  line-height: 1.15;
  margin-bottom: 4px
}

.compact-mini-stat .num {
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1
}

.compact-machine-grid-v2 {
  margin-left: -4px;
  margin-right: -4px
}

.compact-machine-grid-v2>[class*="col-"] {
  padding-left: 4px;
  padding-right: 4px
}

.compact-machine-card-v2 {
  padding: 10px 10px 9px !important;
  border-radius: 16px !important;
  gap: 0
}

.compact-machine-card-v2 .machine-code {
  font-size: .76rem;
  line-height: 1.05;
  margin-bottom: 2px
}

.compact-machine-card-v2 .machine-name {
  font-size: .62rem;
  line-height: 1.08;
  font-weight: 900;
  text-transform: uppercase
}

.compact-machine-card-v2 .machine-section {
  font-size: .56rem;
  line-height: 1.05;
  margin-top: 1px
}

.compact-machine-card-v2 .status-badge {
  min-width: 54px;
  padding: 3px 6px;
  font-size: .55rem;
  border-radius: 999px
}

.compact-info-inline {
  margin-top: 6px;
  border-radius: 10px;
  padding: 7px 8px;
  font-size: .63rem;
  line-height: 1.2;
  min-height: 54px
}

.checked-inline {
  background: rgba(220, 252, 231, .72);
  color: #14532d;
  border: 1px solid #bbf7d0
}

.pending-inline {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center
}

.holiday-inline {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #d8e0ea;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center
}

.compact-info-inline .name-line {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.compact-info-inline .time-line {
  margin-top: 2px
}

.compact-info-inline .abn-line {
  margin-top: 2px;
  color: #dc2626;
  font-weight: 900
}

.compact-machine-btn-v2 {
  margin-top: 7px !important;
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 11px;
  font-size: .72rem;
  font-weight: 900
}

.compact-machine-card-v2 .btn-success {
  padding: 7px 8px;
  box-shadow: 0 8px 16px rgba(34, 197, 94, .16)
}

@media (min-width:768px) {
  .slim-filter-grid {
    grid-template-columns: 1fr 1fr auto;
    align-items: end
  }

  .slim-show-btn {
    min-width: 110px
  }
}

@media (max-width:767.98px) {
  .machine-select-page.compact-v2 .page-head {
    margin-bottom: 8px
  }

  .machine-select-page.compact-v2 .page-title {
    font-size: 1rem
  }

  .machine-select-page.compact-v2 .page-subtitle {
    font-size: .72rem
  }

  .slim-top-wrap {
    padding: 8px
  }

  .compact-mini-stat .num {
    font-size: 1.35rem
  }
}


/* Inline group/date filter for mobile */
.machine-select-page.compact-v2 .slim-filter-grid {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
}

.machine-select-page.compact-v2 .slim-filter-grid .slim-field {
  min-width: 0;
}

.machine-select-page.compact-v2 .slim-filter-grid .slim-show-btn {
  grid-column: 1 / -1;
}

.machine-select-page.compact-v2 .slim-field .form-label {
  font-size: .76rem;
  margin-bottom: 3px;
}

.machine-select-page.compact-v2 .slim-field .form-control,
.machine-select-page.compact-v2 .slim-field .form-select {
  min-height: 38px;
  font-size: .88rem;
  padding: 7px 10px;
  border-radius: 11px;
}

.machine-select-page.compact-v2 .slim-show-btn {
  min-height: 38px;
  font-size: .9rem;
  padding: 8px 10px;
}

@media (max-width: 360px) {
  .machine-select-page.compact-v2 .slim-filter-grid {
    gap: 6px;
  }

  .machine-select-page.compact-v2 .slim-field .form-control,
  .machine-select-page.compact-v2 .slim-field .form-select {
    font-size: .82rem;
    padding-left: 8px;
    padding-right: 8px;
  }
}


/* 4 stats in a single row on mobile */
.machine-select-page.compact-v2 .compact-stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.machine-select-page.compact-v2 .compact-mini-stat {
  padding: 8px 6px;
  border-radius: 12px;
}

.machine-select-page.compact-v2 .compact-mini-stat .small-label {
  font-size: .62rem;
  line-height: 1.08;
  margin-bottom: 4px;
}

.machine-select-page.compact-v2 .compact-mini-stat .num {
  font-size: 1.12rem;
  line-height: 1;
}

@media (max-width:767.98px) {
  .machine-select-page.compact-v2 .compact-stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .machine-select-page.compact-v2 .compact-mini-stat {
    padding: 7px 5px;
  }

  .machine-select-page.compact-v2 .compact-mini-stat .small-label {
    font-size: .56rem;
    line-height: 1.02;
    letter-spacing: -.01em;
  }

  .machine-select-page.compact-v2 .compact-mini-stat .num {
    font-size: 1.02rem;
  }
}

@media (max-width:390px) {
  .machine-select-page.compact-v2 .compact-mini-stat .small-label {
    font-size: .52rem;
  }

  .machine-select-page.compact-v2 .compact-mini-stat .num {
    font-size: .95rem;
  }
}


/* Company logo */
.brand-logo-wrap {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(42, 92, 142, .10);
  flex: 0 0 auto;
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}

.mobile-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 3px;
}

.login-logo-box{
  width:130px;
  height:130px;
  border-radius:32px;
  display:grid;
  place-items:center;
  margin:0 auto 18px;
  background:#fff;
  border:1px solid var(--line);
  box-shadow:0 12px 28px rgba(42,92,142,.10);
}

.login-logo-box img{
  width:105px;
  height:105px;
  object-fit:contain;
  transform:scale(2.65);
}

.login-card {
  overflow: hidden
}

@media(max-width:767.98px) {
  .brand-logo-wrap {
    width: 42px;
    height: 42px;
    border-radius: 14px
  }

  .brand-logo {
    width: 30px;
    height: 30px
  }

  .mobile-logo {
    width: 30px;
    height: 30px
  }

  .login-logo-box{
  width:140px;
  height:140px;
  border-radius:34px;
  margin:0 auto 18px;
}

.login-logo-box img{
  width:100px;
  height:100px;
  transform:scale(2.8);
}
}


/* Real Excel-like monthly inspection form */
.real-form-page {
  font-family: "Times New Roman", Arial, 'Noto Sans Thai', sans-serif;
  color: #000
}

.real-sheet {
  background: #fff;
  border: 2px solid #1b26c9;
  padding: 0;
  margin: 0 auto;
  min-width: 1260px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .06);
  overflow: visible
}

.real-top-grid {
  display: grid;
  grid-template-columns: 270px 1fr 305px;
  border-bottom: 1px solid #000
}

.real-machine-box>div {
  min-height: 34px;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  padding: 5px 6px;
  font-size: 13px;
  line-height: 1.12
}

.real-machine-box>div:last-child {
  border-bottom: 0
}

.real-title-box {
  border-right: 1px solid #000;
  text-align: center;
  min-height: 245px;
  position: relative;
  padding-top: 10px
}

.real-title-box h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  line-height: 1.05
}

.blue-sub {
  color: #00f;
  font-size: 10px;
  line-height: 1;
  font-weight: 400
}

.machine-photo-row {
  display: flex;
  gap: 44px;
  justify-content: center;
  align-items: center;
  margin-top: 28px;
  min-height: 150px;
  flex-wrap: wrap
}

.machine-photo {
  position: relative;
  width: 165px;
  height: 136px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible
}

.machine-photo img {
  max-width: 165px;
  max-height: 136px;
  object-fit: contain;
  border: 0
}

.machine-photo span {
  position: absolute;
  top: 22px;
  right: 18px;
  background: #fff;
  border: 1px solid #000;
  color: #00f;
  min-width: 28px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  padding: 2px 7px
}

.machine-photo-placeholder {
  border: 1px dashed #94a3b8;
  color: #64748b;
  border-radius: 8px;
  padding: 16px;
  font-family: Arial, 'Noto Sans Thai', sans-serif;
  font-size: 14px;
  background: #f8fafc
}

.real-resp-box {
  text-align: center;
  font-size: 13px
}

.resp-title,
.result-title {
  height: 34px;
  border-bottom: 1px solid #000;
  padding-top: 5px
}

.resp-two {
  display: grid;
  grid-template-columns: 1fr 1fr
}

.resp-two>div {
  height: 48px;
  border-bottom: 1px solid #000;
  border-right: 1px solid #000;
  padding-top: 8px
}

.resp-two>div:last-child {
  border-right: 0
}

.date-row>div {
  text-align: left;
  padding-left: 8px;
  padding-top: 18px
}

.result-icons {
  display: grid;
  grid-template-columns: repeat(4, 1fr)
}

.result-icons>div {
  height: 62px;
  border-right: 1px solid #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center
}

.result-icons>div:last-child {
  border-right: 0
}

.result-icons b {
  font-size: 30px;
  font-weight: 400;
  line-height: 1
}

.result-icons span {
  font-size: 11px;
  line-height: 1.05
}

.result-icons em {
  font-style: normal;
  color: #00f;
  font-size: 10px
}

.result-month {
  font-size: 13px;
  line-height: 1.05;
  padding: 6px 4px 3px;
  border-bottom: 1px solid #000
}

.real-table-wrap {
  overflow: visible
}

.real-report-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px
}

.real-report-table th,
.real-report-table td {
  border: 1px solid #000;
  text-align: center;
  vertical-align: middle;
  padding: 2px 3px;
  height: 25px;
  line-height: 1.05
}

.real-report-table thead th {
  font-weight: 700;
  background: #fff
}

.real-report-table .no-col {
  width: 34px
}

.real-report-table .pos-col {
  width: 235px;
  text-align: left
}

.real-report-table .day-col {
  width: 26px
}

.real-report-table .side-head {
  width: 88px
}

.real-report-table .moment-col {
  width: 44px
}

.real-report-table .freq-col {
  width: 48px
}

.real-report-table .method-col {
  width: 56px
}

.real-report-table .std-col {
  width: 218px
}

.real-report-table .holiday-head {
  background: #ff0
}

.pos-text {
  text-align: left !important;
  font-size: 12px
}

.std-text {
  text-align: center;
  font-size: 12px
}

.unit {
  font-size: 10px
}

.day-cell {
  font-size: 18px;
  font-family: Arial, 'Noto Sans Thai', sans-serif;
  font-weight: 700
}

.day-cell.val {
  font-size: 11px
}

.day-cell.holiday-cell {
  font-size: 16px
}

.tick-col {
  font-size: 20px;
  font-family: Arial, 'Noto Sans Thai', sans-serif;
  font-weight: 700
}

.eye {
  font-size: 19px
}

.blank-row td {
  height: 34px
}

.checked-row td {
  height: 42px
}

.checked-label {
  text-align: right !important;
  font-style: italic;
  padding-right: 8px !important
}

.checker-name {
  font-family: Arial, 'Noto Sans Thai', sans-serif;
  font-size: 8px;
  line-height: 1.03;
  word-break: break-word;
  white-space: normal
}

.checker-time {
  font-family: Arial, 'Noto Sans Thai', sans-serif;
  font-size: 8px;
  font-weight: 700
}

.abnormal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px
}

.abnormal-table th,
.abnormal-table td {
  border: 1px solid #000;
  text-align: center;
  vertical-align: middle;
  height: 30px;
  padding: 2px 3px;
  line-height: 1.05
}

.abnormal-table th:nth-child(1) {
  width: 34px
}

.abnormal-table th:nth-child(2) {
  width: 295px
}

.abnormal-table th:nth-child(3) {
  width: 305px
}

.abnormal-table th:nth-child(4) {
  width: 275px
}

.abnormal-table th:nth-child(5) {
  width: 110px
}

.abnormal-table th:nth-child(6) {
  width: 110px
}

.abnormal-table th:nth-child(7) {
  width: 125px
}

.abnormal-table th:nth-child(8) {
  width: auto
}

.machine-image-admin-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #fff
}

.machine-image-admin-card img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0
}

@media(max-width:991.98px) {
  .real-sheet {
    min-width: 1260px
  }

  .real-form-page {
    overflow-x: auto
  }

  .real-top-grid {
    grid-template-columns: 270px 685px 305px
  }

  .machine-photo-row {
    gap: 30px
  }

  .machine-photo {
    width: 145px
  }

  .machine-photo img {
    max-width: 145px
  }
}

@media print {
  .app-main {
    padding: 0 !important;
    max-width: none !important
  }

  .real-form-page {
    overflow: visible !important
  }

  .real-sheet {
    min-width: 0;
    width: 100%;
    border: 2px solid #1b26c9;
    box-shadow: none;
    transform-origin: top left
  }

  .real-top-grid {
    grid-template-columns: 18.5% 61% 20.5%
  }

  .real-machine-box>div {
    font-size: 8px;
    min-height: 25px;
    padding: 3px
  }

  .real-title-box {
    min-height: 126px;
    padding-top: 5px
  }

  .real-title-box h4 {
    font-size: 10px
  }

  .blue-sub {
    font-size: 6px
  }

  .machine-photo-row {
    gap: 22px;
    margin-top: 18px;
    min-height: 78px
  }

  .machine-photo {
    width: 92px;
    height: 72px
  }

  .machine-photo img {
    max-width: 92px;
    max-height: 72px
  }

  .machine-photo span {
    font-size: 10px;
    min-width: 18px;
    min-height: 15px;
    top: 10px;
    right: 8px;
    padding: 1px 4px
  }

  .real-resp-box {
    font-size: 8px
  }

  .resp-title,
  .result-title {
    height: 22px;
    padding-top: 3px
  }

  .resp-two>div {
    height: 31px;
    padding-top: 4px
  }

  .date-row>div {
    padding-top: 13px;
    padding-left: 5px
  }

  .result-icons>div {
    height: 40px
  }

  .result-icons b {
    font-size: 18px
  }

  .result-icons span {
    font-size: 7px
  }

  .result-icons em {
    font-size: 6px
  }

  .result-month {
    font-size: 8px;
    padding: 3px
  }

  .real-report-table {
    font-size: 7px
  }

  .real-report-table th,
  .real-report-table td {
    height: 18px;
    padding: 1px
  }

  .real-report-table .no-col {
    width: 24px
  }

  .real-report-table .pos-col {
    width: 175px
  }

  .real-report-table .day-col {
    width: 18px
  }

  .real-report-table .side-head {
    width: 58px
  }

  .real-report-table .moment-col {
    width: 29px
  }

  .real-report-table .freq-col {
    width: 31px
  }

  .real-report-table .method-col {
    width: 38px
  }

  .real-report-table .std-col {
    width: 150px
  }

  .pos-text,
  .std-text {
    font-size: 7px
  }

  .day-cell {
    font-size: 11px
  }

  .day-cell.val {
    font-size: 7px
  }

  .tick-col {
    font-size: 12px
  }

  .eye {
    font-size: 11px
  }

  .blank-row td {
    height: 21px
  }

  .checked-row td {
    height: 24px
  }

  .checker-name,
  .checker-time {
    font-size: 5px
  }

  .abnormal-table {
    font-size: 7px
  }

  .abnormal-table th,
  .abnormal-table td {
    height: 22px
  }

  .abnormal-table th:nth-child(1) {
    width: 24px
  }

  .abnormal-table th:nth-child(2) {
    width: 210px
  }

  .abnormal-table th:nth-child(3) {
    width: 210px
  }

  .abnormal-table th:nth-child(4) {
    width: 195px
  }

  .abnormal-table th:nth-child(5),
  .abnormal-table th:nth-child(6) {
    width: 70px
  }

  .abnormal-table th:nth-child(7) {
    width: 80px
  }
}