/* Bảo trì vận hành — danh sách cảnh báo và sửa chữa */
body.maintenance-page { height: 100dvh; overflow: hidden; }
.maintenance-page .app-shell { height: 100dvh; min-height: 0; overflow: hidden; }
.maintenance-page .main { min-width: 0; min-height: 0; padding: 0; overflow: hidden; }

.mt-workspace {
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 45px auto minmax(0, 1fr) 44px;
  background: var(--surface);
}
.mt-tabs {
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.mt-tabs button {
  position: relative;
  min-width: 132px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
}
.mt-tabs button::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 2px;
  background: transparent;
}
.mt-tabs button.active { color: var(--accent); }
.mt-tabs button.active::after { background: var(--accent); }

.mt-toolbar {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.mt-toolbar-start,
.mt-toolbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mt-toolbar .btn {
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: .02em;
}
.mt-toolbar .btn svg { flex: 0 0 auto; }
.mt-toolbar .btn.danger { color: var(--error); border-color: color-mix(in srgb, var(--error) 38%, var(--line)); background: var(--error-soft); }
.mt-search { width: 150px; height: 36px; font-size: 12px; }
.mt-column-field,
.mt-date-field,
.mt-bulk-field { position: relative; }

.mt-column-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: 250px;
  max-height: 390px;
  padding: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.mt-column-pop[hidden] { display: none; }
.mt-column-pop label,
.mt-export-options label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
}
.mt-column-pop label:hover,
.mt-export-options label:hover { background: var(--info-soft); color: var(--accent); }
.mt-column-pop input,
.mt-export-options input { width: 15px; height: 15px; accent-color: var(--accent); }

.mt-date-range {
  min-width: 300px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.mt-date-range svg { color: var(--muted); }
.mt-date-range:hover,
.mt-date-range[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--info-soft); }

.mt-cal-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mt-cal-pop[hidden] { display: none; }
.mt-cal-presets {
  width: 126px;
  padding: 8px;
  border-right: 1px solid var(--line);
  background: var(--soft-2);
}
.mt-cal-presets button {
  width: 100%;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  font-size: 12px;
}
.mt-cal-presets button:hover,
.mt-cal-presets button.active { background: var(--info-soft); color: var(--accent); }
.mt-cal-main { width: 510px; padding: 10px 12px 12px; }
.mt-cal-head { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; gap: 8px; }
.mt-cal-head > button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
}
.mt-cal-head > div { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; text-align: center; font-size: 13px; font-weight: 700; }
.mt-cal-months { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 8px; }
.mt-cal-grid { display: grid; grid-template-columns: repeat(7, 30px); justify-content: center; }
.mt-cal-grid .dow { height: 24px; display: grid; place-items: center; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.mt-cal-day {
  position: relative;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.mt-cal-day span { position: relative; z-index: 1; width: 26px; height: 26px; margin: auto; display: grid; place-items: center; border-radius: 6px; }
.mt-cal-day.out { color: var(--muted); opacity: .4; }
.mt-cal-day:hover span { color: var(--accent); background: var(--info-soft); }
.mt-cal-day.in-range::before { content: ""; position: absolute; inset: 1px 0; background: var(--info-soft); }
.mt-cal-day.start::before { left: 50%; }
.mt-cal-day.end::before { right: 50%; }
.mt-cal-day.start.end::before { display: none; }
.mt-cal-day.start span,
.mt-cal-day.end span { color: var(--surface); background: var(--accent); font-weight: 700; }
.mt-cal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.mt-cal-foot > div { display: flex; gap: 8px; }
.mt-cal-foot .btn { min-height: 30px; padding: 0 12px; font-size: 11px; }

.mt-grain {
  display: inline-grid;
  grid-template-columns: repeat(3, 48px);
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.mt-grain button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}
.mt-grain button:last-child { border-right: 0; }
.mt-grain button.active { color: var(--accent); background: var(--info-soft); font-weight: 700; }
.mt-period-nav { display: inline-flex; gap: 4px; }
.mt-period-nav .btn { width: 36px; min-width: 36px; padding: 0; justify-content: center; }

.mt-bulk-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: 214px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.mt-bulk-menu[hidden] { display: none; }
.mt-bulk-menu button {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  text-align: left;
  font-size: 12px;
}
.mt-bulk-menu button:hover { background: var(--info-soft); }

.mt-table-shell {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  scrollbar-color: var(--border) var(--soft-2);
}
.mt-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12px;
}
.mt-table th,
.mt-table td {
  min-width: 145px;
  height: 46px;
  padding: 8px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  white-space: nowrap;
  text-align: left;
  vertical-align: middle;
}
.mt-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 42px;
  background: var(--soft-2);
  color: var(--fg);
  font-weight: 600;
  letter-spacing: .01em;
}
.mt-table th:first-child,
.mt-table td:first-child { min-width: 42px; width: 42px; text-align: center; }
.mt-table th[data-col="deviceName"],
.mt-table td[data-col="deviceName"] { min-width: 190px; }
.mt-table th[data-col="actions"],
.mt-table td[data-col="actions"] { min-width: 270px; }
.mt-table th[data-col="workOrders"],
.mt-table td[data-col="workOrders"] { min-width: 180px; }
.mt-table th[data-col="repairContent"],
.mt-table td[data-col="repairContent"] { min-width: 220px; }
.mt-table tbody tr:hover td { background: var(--info-soft); }
.mt-table input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }
.mt-table a,
.mt-table button.link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
}
.mt-table td.actions { display: flex; align-items: center; gap: 14px; }
.mt-table td.actions button:hover,
.mt-table a:hover { text-decoration: underline; }
.mt-table .badge { min-height: 22px; }
.mt-table .mono { font-variant-numeric: tabular-nums; }
.mt-table [hidden] { display: none !important; }
.mt-empty { position: absolute; inset: 42px 0 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; pointer-events: none; }
.mt-empty[hidden] { display: none; }

.mt-table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}
.mt-table-foot > div { display: flex; align-items: center; gap: 12px; }
.mt-table-foot select { min-width: 92px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-soft); padding: 0 8px; }
.mt-pages { display: flex; align-items: center; gap: 5px; }
.mt-pages button,
.mt-pages input {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-soft);
  text-align: center;
}
.mt-pages button.active { color: var(--surface); border-color: var(--accent); background: var(--accent); }
.mt-pages button:disabled { opacity: .45; cursor: default; }

.mt-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--fg) 34%, transparent);
}
.mt-modal-backdrop.is-open { display: grid; }
.mt-modal {
  width: min(620px, 100%);
  max-height: calc(100dvh - 48px);
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr) 64px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 16px 48px color-mix(in srgb, var(--fg) 18%, transparent);
  overflow: hidden;
}
.mt-modal header,
.mt-modal footer { display: flex; align-items: center; padding: 0 22px; }
.mt-modal header { justify-content: space-between; border-bottom: 1px solid var(--line); }
.mt-modal header h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.mt-modal header .icon-btn { font-size: 22px; color: var(--muted); }
.mt-modal-body { padding: 18px 22px; overflow: auto; display: grid; gap: 14px; }
.mt-modal-body > label { display: grid; grid-template-columns: 138px minmax(0, 1fr); align-items: center; gap: 12px; font-size: 13px; }
.mt-modal-body > label > span,
.mt-modal-body legend { color: var(--fg); font-weight: 600; }
.mt-modal-body textarea { min-height: 72px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); resize: vertical; font: inherit; }
.mt-modal-body fieldset { margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.mt-export-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 8px; margin-top: 6px; }
.mt-modal footer { justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.mt-modal footer > div { display: flex; gap: 8px; }
.mt-modal footer .btn { min-width: 96px; }

.mt-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 130;
  max-width: 360px;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--success) 34%, var(--line));
  border-radius: var(--radius);
  background: var(--success-soft);
  color: var(--fg);
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .18s ease;
}
.mt-toast.is-on { opacity: 1; transform: translateY(0); }

@media (max-width: 1280px) {
  .mt-toolbar { align-items: flex-start; }
  .mt-toolbar-start { flex-wrap: wrap; }
  .mt-date-range { min-width: 270px; }
}
@media (max-width: 1024px) {
  .mt-toolbar { flex-wrap: wrap; gap: 8px; }
  .mt-toolbar-start,
  .mt-toolbar-end { flex-wrap: wrap; }
  .mt-date-range { min-width: 0; flex: 1 1 240px; }
  .mt-cal-pop { left: 0; max-width: min(560px, calc(100vw - 24px)); overflow: auto; }
  .mt-table-shell { overflow-x: auto; }
}
@media (max-width: 820px) {
  .maintenance-page { height: auto; overflow: auto; }
  .maintenance-page .app-shell { height: auto; min-height: 100dvh; }
  .maintenance-page .main { overflow: visible; }
  .mt-workspace { min-height: calc(100dvh - var(--top)); grid-template-rows: 45px auto minmax(480px, 1fr) auto; }
  .mt-toolbar { flex-direction: column; align-items: stretch; }
  .mt-toolbar-start,
  .mt-toolbar-end { flex-wrap: wrap; }
  .mt-cal-pop { left: -100px; max-width: calc(100vw - 24px); overflow: auto; }
  .mt-table-foot { align-items: flex-start; flex-direction: column; }
  .mt-pages { flex-wrap: wrap; }
}
