:root {
  --mtc-ink: #111827;
  --mtc-muted: #6b7280;
  --mtc-line: #e5e7eb;
  --mtc-surface: #ffffff;
  --mtc-soft: #f7f8fa;
  --mtc-red: #be123c;
  --mtc-gold: #b7791f;
  --mtc-green: #047857;
}

.panel-block {
  padding: 14px 18px;
}

.panel-title {
  margin-bottom: 12px;
}

.panel-title h2 {
  font-size: 18px;
}

.metric-card {
  padding: 14px;
}

.metric-card strong {
  font-size: 24px;
}

.work-order-customer-picker .modal-header {
  background: #111827;
  color: #fff;
}

.work-order-customer-picker .btn-close {
  filter: invert(1);
}

.work-order-customer-list {
  display: grid;
  gap: 8px;
}

.work-order-customer-row {
  background: #fff;
  border: 1px solid var(--mtc-line, #e5e7eb);
  border-radius: 8px;
  cursor: pointer;
  display: block;
  padding: 11px 12px;
  text-align: left;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
  width: 100%;
}

.work-order-customer-row:hover {
  background: #f8fafc;
  border-color: #111827;
  transform: translateY(-1px);
}

.work-order-customer-row strong,
.work-order-customer-row span {
  display: block;
}

.work-order-customer-row strong {
  color: #111827;
  font-size: 14px;
  font-weight: 900;
}

.work-order-customer-row span {
  color: var(--mtc-muted, #6b7280);
  font-size: 12px;
  margin-top: 3px;
}

@media (min-width: 992px) {
  body.sidebar-hidden-manual {
    --lte-sidebar-width: 0px;
  }

  body.sidebar-hidden-manual .app-sidebar {
    display: none !important;
  }

  body.sidebar-hidden-manual .app-header,
  body.sidebar-hidden-manual .app-main {
    margin-left: 0 !important;
  }
}

/* Compact operational layout */
.panel-block {
  padding: 14px 18px;
}

.panel-title {
  margin-bottom: 12px;
}

.panel-title h2 {
  font-size: 18px;
}

.panel-title span,
.form-label,
.small,
small {
  font-size: 11px;
}

.btn {
  --bs-btn-padding-y: .42rem;
  --bs-btn-padding-x: .72rem;
  --bs-btn-font-size: .82rem;
}

.btn-sm {
  --bs-btn-padding-y: .28rem;
  --bs-btn-padding-x: .55rem;
  --bs-btn-font-size: .76rem;
}

.form-control,
.form-select {
  font-size: .82rem;
  min-height: 34px;
  padding-bottom: .36rem;
  padding-top: .36rem;
}

.table > :not(caption) > * > * {
  padding: .42rem .5rem;
}

.ie-stat-grid,
.cash-actionbar,
.bank-actionbar,
.cari-actionbar {
  gap: 8px;
  margin-bottom: 10px;
}

.ie-stat,
.cash-detail-grid div,
.bank-detail-grid div,
.opening-card {
  padding: 10px 12px;
}

.ie-stat strong {
  font-size: 16px;
}

.ie-actionbar .btn,
.cash-actionbar .btn,
.bank-actionbar .btn {
  min-height: 44px;
}

body {
  letter-spacing: 0;
}

html.mtc-android-app,
body.mtc-android-app {
  background: var(--mtc-soft);
  overscroll-behavior: none;
}

body.mtc-android-app .app-wrapper {
  min-height: 100dvh;
}

body.mtc-android-app .premium-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 10px 30px rgba(17, 24, 39, .08);
}

body.mtc-android-app .app-content,
body.mtc-android-app .app-content-header {
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}

body.mtc-android-app .panel-block {
  border-radius: 14px;
  box-shadow: 0 12px 26px rgba(17, 24, 39, .07);
}

@media (max-width: 768px) {
  body.mtc-android-app .app-content-header h1 {
    font-size: 20px;
    font-weight: 900;
  }

  body.mtc-android-app .table-responsive {
    border-radius: 12px;
  }

  body.mtc-android-app .btn {
    min-height: 42px;
  }
}

body,
button,
input:not([type="email"]):not([type="password"]),
textarea,
select,
.table,
.modal,
.panel-block {
  text-transform: uppercase;
}

.login-page-premium {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(135deg, #171717 0%, #2b1118 48%, #f3f4f6 48%, #ffffff 100%);
  display: grid;
  place-items: center;
  color: var(--mtc-ink);
}

.login-shell {
  width: min(94vw, 460px);
}

.login-panel {
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .22);
  border-radius: 8px;
  padding: 32px;
  position: relative;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.login-brand > span,
.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: #111827;
  color: #fff;
  font-weight: 800;
}

.login-brand h1 {
  font-size: 24px;
  margin: 0;
}

.login-brand p {
  color: var(--mtc-muted);
  margin: 0;
}

.remember-premium {
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid var(--mtc-line);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 12px 13px;
  text-transform: none;
}

.remember-premium input {
  accent-color: var(--mtc-red);
  flex: 0 0 auto;
  height: 18px;
  margin-top: 2px;
  width: 18px;
}

.remember-premium strong,
.remember-premium small {
  display: block;
}

.remember-premium strong {
  color: var(--mtc-ink);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.remember-premium small {
  color: var(--mtc-muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 2px;
}

.login-service-pop {
  animation: loginServicePopIn .45s ease both;
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(17, 24, 39, .1);
  border-radius: 14px;
  bottom: 22px;
  box-shadow: 0 22px 60px rgba(17, 24, 39, .22);
  color: #111827;
  max-width: 360px;
  padding: 14px;
  position: fixed;
  right: 22px;
  text-transform: none;
  width: calc(100% - 44px);
  z-index: 20;
}

.login-service-pop.is-hidden {
  display: none;
}

.login-service-pop-head {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.login-service-pop-mark {
  align-items: center;
  background: #111827;
  border-radius: 10px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 18px;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.login-service-pop-title {
  display: block;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: uppercase;
}

.login-service-pop-text {
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
  margin: 7px 0 12px;
}

.login-service-pop-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.login-service-pop-actions a {
  align-items: center;
  border-radius: 10px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  gap: 6px;
  justify-content: center;
  padding: 9px 10px;
  text-decoration: none;
}

.login-service-pop-whatsapp {
  background: #16a34a;
  color: #fff;
}

.login-service-pop-site {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #111827;
}

.login-service-pop-close {
  align-items: center;
  background: #f1f5f9;
  border: 0;
  border-radius: 999px;
  color: #111827;
  display: inline-flex;
  height: 28px;
  justify-content: center;
  width: 28px;
}

body.dark-mode .login-service-pop {
  background: rgba(15, 23, 42, .96);
  border-color: rgba(148, 163, 184, .28);
  color: #f8fafc;
}

body.dark-mode .login-service-pop-text {
  color: #cbd5e1;
}

body.dark-mode .login-service-pop-site,
body.dark-mode .login-service-pop-close {
  background: #1f2937;
  border-color: rgba(148, 163, 184, .28);
  color: #f8fafc;
}

@media (max-width: 640px) {
  .login-service-pop {
    bottom: 10px;
    padding: 12px;
    right: 10px;
    width: calc(100% - 20px);
  }

  .login-service-pop-text {
    margin-bottom: 9px;
  }
}

@keyframes loginServicePopIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.premium-input .input-group-text,
.premium-input .form-control {
  border-color: var(--mtc-line);
  min-height: 46px;
}

.btn-premium {
  background: var(--mtc-red);
  color: #fff;
  min-height: 46px;
  border-radius: 6px;
  font-weight: 700;
}

.btn-premium:hover {
  background: #9f1239;
  color: #fff;
}

.powered {
  display: block;
  margin-top: 22px;
  color: var(--mtc-gold);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.premium-sidebar {
  background: #111827;
}

.premium-sidebar .nav-link.active {
  background: var(--mtc-red);
}

.premium-topbar {
  min-height: 64px;
}

.topbar-page-title {
  align-items: center;
  color: #111827;
  display: flex;
  flex: 1 1 auto;
  font-size: 22px;
  font-weight: 900;
  justify-content: center;
  letter-spacing: 0;
  min-width: 120px;
  padding: 0 18px;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

body.title-mode-classic .topbar-page-title {
  display: none;
}

body.title-mode-compact .app-content-header {
  display: none;
}

.title-mode-toggle.active {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.app-content-header h1 {
  font-size: 24px;
  font-weight: 800;
}

.decision-tile,
.module-tile {
  display: flex;
  min-height: 176px;
  border-radius: 8px;
  padding: 26px;
  color: #fff;
  text-decoration: none;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 20px 45px rgba(17, 24, 39, .18);
}

.decision-tile i {
  font-size: 42px;
  margin-bottom: 18px;
}

.decision-tile span,
.module-tile strong {
  font-size: 28px;
  font-weight: 900;
}

.decision-tile small,
.module-tile span {
  color: rgba(255, 255, 255, .82);
}

.service-tile {
  background: linear-gradient(135deg, #111827, #be123c);
}

.accounting-tile {
  background: linear-gradient(135deg, #1f2937, #047857);
}

.module-tile {
  background: #1f2937;
  min-height: 150px;
}

.module-tile i {
  font-size: 30px;
  margin-bottom: auto;
  color: #fbbf24;
}

.metric-card,
.panel-block {
  background: var(--mtc-surface);
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(17, 24, 39, .06);
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--mtc-muted);
  text-transform: uppercase;
  font-size: 12px;
}

.metric-card strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

.panel-block {
  padding: 18px;
}

.inner-panel {
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 16px;
}

.panel-title {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-title h2 {
  font-size: 18px;
  font-weight: 900;
  margin: 0;
}

.panel-title span {
  color: var(--mtc-muted);
  font-size: 13px;
}

.action-ribbon {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 4px;
}

.btn-ribbon {
  border: 1px solid var(--mtc-line);
  background: #fff;
  min-width: 86px;
  height: 58px;
  border-radius: 6px;
  font-size: 11px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
}

.btn-ribbon i {
  font-size: 17px;
}

.shortcut-flash {
  outline: 3px solid var(--mtc-gold);
}

.filter-grid,
.detail-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.filter-grid.five,
.detail-strip {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.table {
  font-size: 13px;
}

.table thead th {
  background: #f9fafb;
  color: #374151;
  white-space: nowrap;
}

.table-sort-link {
  color: inherit;
  text-decoration: none;
  font-weight: 800;
}

.table-sort-link:hover {
  color: var(--mtc-red);
}

.service-filter-table thead th {
  vertical-align: top;
}

.service-sort-button {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  display: inline-flex;
  gap: 6px;
  padding: 0;
  text-align: left;
}

.service-sort-button i {
  color: var(--mtc-muted);
  font-size: 12px;
}

.service-sort-button.active-sort-asc i::before {
  content: "\F145";
}

.service-sort-button.active-sort-desc i::before {
  content: "\F124";
}

.service-filter-row th {
  background: #fff;
  padding-top: 8px;
}

.service-filter-row .form-control,
.service-filter-row .form-select {
  border-color: #d1d5db;
  min-width: 128px;
}

.service-list-search {
  background: #fbfcfd;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
  padding: 14px;
}

.service-list-search label {
  color: var(--mtc-muted);
  display: block;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.work-order-table .clickable-row {
  cursor: pointer;
  transition: background-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.work-order-table .clickable-row:hover,
.work-order-table .clickable-row:focus {
  background: #fff7ed;
  box-shadow: inset 4px 0 0 var(--mtc-red);
  outline: none;
  transform: translateX(2px);
}

.placeholder-row td {
  color: var(--mtc-muted);
  text-align: center;
}

.premium-tabs .nav-link {
  color: var(--mtc-ink);
}

.premium-tabs .nav-link.active {
  font-weight: 800;
}

.info-grid,
.permission-matrix,
.report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.info-grid div,
.permission-card,
.report-grid button {
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  padding: 14px;
  background: var(--mtc-soft);
}

.info-grid span {
  display: block;
  color: var(--mtc-muted);
  font-size: 12px;
}

.print-heading {
  display: none;
}

.edit-grid input,
.edit-grid select {
  margin-top: 6px;
}

.subhead {
  font-size: 16px;
  font-weight: 800;
  margin: 20px 0 10px;
}

.expertise-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.expertise-grid span {
  border: 1px solid var(--mtc-line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
}

.upload-zone {
  min-height: 220px;
  border: 1px dashed #9ca3af;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--mtc-muted);
}

.upload-zone i {
  font-size: 40px;
}

.upload-form {
  gap: 12px;
  padding: 18px;
  text-align: center;
}

.upload-form .form-control {
  max-width: 520px;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.document-item {
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  color: var(--mtc-ink);
  background: #fff;
  padding: 8px;
  text-decoration: none;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.document-item img {
  width: 100%;
  height: 124px;
  object-fit: cover;
  border-radius: 6px;
}

.document-preview-button,
.document-file-link {
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  gap: 8px;
  padding: 0;
  text-align: center;
  text-decoration: none;
  width: 100%;
}

.document-preview-button {
  cursor: zoom-in;
}

.document-item i {
  font-size: 54px;
  color: var(--mtc-red);
  text-align: center;
}

.document-item span {
  font-size: 12px;
  word-break: break-word;
}

.document-delete-form {
  position: absolute;
  right: 12px;
  top: 12px;
}

.document-delete-form .btn {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  width: 32px;
}

.document-delete-form .btn i {
  color: #fff;
  font-size: 14px;
}

.document-viewer-modal .modal-body {
  background: #111827;
}

.document-viewer-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.document-viewer-counter {
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  min-width: 48px;
  text-align: center;
}

.document-viewer-stage {
  align-items: center;
  background: #0b1020;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  max-height: 72vh;
  min-height: 420px;
  overflow: auto;
}

.document-viewer-stage img {
  max-height: 68vh;
  max-width: 100%;
  transform-origin: center center;
  transition: transform .16s ease;
}

@media (max-width: 768px), (max-height: 520px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-wrapper,
  .app-main,
  .app-content,
  .panel-block,
  .modal {
    max-width: 100vw;
  }

  .app-content {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .panel-block {
    padding: 10px !important;
  }

  .panel-title,
  .salary-hero,
  .settings-hero {
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 8px;
  }

  .filter-grid,
  .service-list-search,
  .salary-paybar,
  .salary-add,
  .cari-toolbar,
  .cash-toolbar,
  .bank-toolbar,
  .ie-toolbar,
  .report-filter-panel {
    grid-template-columns: 1fr !important;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    max-width: 100%;
    overflow-x: auto;
  }

  .table {
    font-size: 12px;
  }

  .table > :not(caption) > * > * {
    padding: .34rem .4rem;
  }

  .btn {
    white-space: normal;
  }

  .document-grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 8px;
  }

  .document-item {
    min-height: 112px;
    padding: 6px;
  }

  .document-item img {
    height: 94px;
  }

  .document-viewer-modal .modal-dialog,
  #documentViewerModal .modal-dialog {
    height: calc(100dvh - 16px);
    margin: 8px;
    max-width: calc(100vw - 16px);
  }

  .document-viewer-modal .modal-content,
  #documentViewerModal .modal-content {
    max-height: calc(100dvh - 16px);
  }

  .document-viewer-toolbar {
    gap: 6px;
  }

  .document-viewer-toolbar .btn {
    min-height: 34px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .document-viewer-stage {
    max-height: calc(100dvh - 150px);
    min-height: 220px;
  }

  .document-viewer-stage img {
    max-height: calc(100dvh - 170px);
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .premium-topbar,
  body.mtc-android-app .premium-topbar {
    position: static;
  }

  .app-content-header {
    padding-bottom: 4px;
    padding-top: 4px;
  }

  .document-viewer-stage {
    max-height: calc(100dvh - 118px);
    min-height: 180px;
  }
}

@media (max-width: 820px) {
  html,
  body {
    min-width: 0;
    overflow-x: hidden;
    width: 100%;
  }

  .app-wrapper,
  .app-main,
  .app-content-wrapper,
  .app-content,
  .app-content .container-fluid,
  .panel-block {
    max-width: 100vw !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  .app-main,
  .app-header {
    margin-left: 0 !important;
  }

  .premium-topbar .container-fluid {
    flex-wrap: wrap;
    gap: 8px;
  }

  .premium-topbar .brand-mark + div {
    max-width: calc(100vw - 150px);
  }

  .premium-topbar .brand-mark + div small {
    display: none;
  }

  .topbar-page-title {
    flex: 1 0 100%;
    font-size: 17px;
    justify-content: flex-start;
    order: 3;
    overflow: hidden;
    padding: 0;
    text-align: left;
    text-overflow: ellipsis;
  }

  .premium-topbar .ms-auto {
    gap: 6px !important;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .app-content-header {
    padding: 8px 8px 4px !important;
  }

  .app-content {
    padding: 8px !important;
  }

  .panel-block {
    border-radius: 10px !important;
    margin-bottom: 10px;
    overflow: visible;
    padding: 10px !important;
  }

  .panel-title {
    align-items: stretch !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .panel-title > *,
  .panel-title .btn,
  .panel-title a {
    max-width: 100%;
  }

  .cari-actionbar,
  .cash-actionbar,
  .bank-actionbar,
  .ie-actionbar,
  .stock-actionbar,
  .invoice-actionbar,
  .report-grid,
  .settings-actionbar {
    display: flex !important;
    gap: 8px !important;
    grid-template-columns: none !important;
    margin-left: -2px;
    margin-right: -2px;
    overflow-x: auto !important;
    padding: 2px 2px 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .cari-actionbar .btn,
  .cash-actionbar .btn,
  .bank-actionbar .btn,
  .ie-actionbar .btn,
  .stock-actionbar .btn,
  .invoice-actionbar .btn,
  .report-grid button {
    flex: 0 0 auto !important;
    min-height: 42px !important;
    min-width: 116px !important;
    scroll-snap-align: start;
    white-space: nowrap !important;
  }

  .cari-toolbar,
  .cash-toolbar,
  .bank-toolbar,
  .ie-toolbar,
  .stock-filters,
  .invoice-toolbar,
  .filter-grid,
  .service-list-search,
  .report-filter-panel,
  .detail-strip,
  .salary-paybar,
  .salary-add {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .form-control,
  .form-select,
  .btn {
    max-width: 100%;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
    display: block;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: visible;
    position: relative;
    width: 100%;
  }

  .table-responsive::after {
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(17,24,39,.12));
    bottom: 0;
    content: "";
    pointer-events: none;
    position: sticky;
    right: 0;
    top: 0;
    width: 14px;
  }

  .table-responsive > table,
  .table-responsive .table {
    margin-bottom: 0;
    min-width: max-content;
    width: max-content;
  }

  .table-responsive th,
  .table-responsive td {
    max-width: 220px;
    white-space: nowrap;
  }

  .table-responsive td input,
  .table-responsive td select,
  .table-responsive td textarea {
    min-width: 120px;
  }

  .modal-dialog {
    margin: 8px !important;
    max-width: calc(100vw - 16px) !important;
  }

  .modal-content {
    max-height: calc(100dvh - 16px);
  }

  .modal-body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .row {
    --bs-gutter-x: .6rem;
  }
}

@media (max-width: 820px) and (orientation: landscape) {
  .premium-topbar {
    position: static !important;
  }

  .panel-block {
    padding: 8px !important;
  }

  .app-content-header h1,
  .panel-title h2 {
    font-size: 16px !important;
  }

  .cari-actionbar .btn,
  .cash-actionbar .btn,
  .bank-actionbar .btn,
  .ie-actionbar .btn {
    min-height: 38px !important;
  }
}

.customer-search-wrap,
.technician-search-wrap {
  position: relative;
}

.customer-suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% - 18px);
  left: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(17, 24, 39, .16);
  overflow: hidden;
}

.customer-suggestion {
  width: 100%;
  border: 0;
  background: #fff;
  text-align: left;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.customer-suggestion:hover,
.customer-suggestion:focus {
  background: #fff7ed;
  outline: none;
}

.customer-suggestion span {
  color: var(--mtc-muted);
  font-size: 12px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: #fff;
  padding: 8px 14px;
}

.segmented button.active {
  background: #111827;
  color: #fff;
}

.permission-card h3 {
  font-size: 16px;
  font-weight: 900;
}

.permission-card label {
  display: block;
  margin: 8px 0;
}

.settings-console .tab-content {
  min-height: 420px;
}

.settings-editor,
.role-card,
.dealer-card,
.user-log-panel {
  background: #fbfcfd;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  padding: 14px;
}

.settings-editor h3,
.settings-table-head h3 {
  font-size: 16px;
  font-weight: 900;
  margin: 0 0 12px;
}

.settings-split,
.settings-table-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.settings-table-head .form-control {
  max-width: 360px;
}

.role-grid {
  display: grid;
  gap: 14px;
}

.role-card-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.role-card-head strong {
  display: block;
  font-size: 17px;
  font-weight: 900;
}

.role-card-head span {
  color: var(--mtc-muted);
  display: block;
  font-size: 12px;
}

.permission-groups {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.permission-group {
  background: #fff;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  padding: 10px;
}

.permission-group h4 {
  font-size: 13px;
  font-weight: 900;
  margin: 0 0 8px;
}

.permission-group label {
  align-items: flex-start;
  display: flex;
  font-size: 12px;
  gap: 7px;
  margin: 7px 0;
}

.settings-table {
  min-width: 1120px;
}

.settings-table .form-control,
.settings-table .form-select {
  min-width: 110px;
}

.dealer-grid {
  display: grid;
  gap: 12px;
}

.user-log-panel {
  max-height: 560px;
  overflow: auto;
}

.user-log-item {
  border-bottom: 1px solid var(--mtc-line);
  padding: 10px 0;
}

.user-log-item:last-child {
  border-bottom: 0;
}

.user-log-item strong {
  display: block;
}

.user-log-item span {
  color: var(--mtc-muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.report-grid button {
  text-align: left;
  font-weight: 800;
}

.report-card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 16px;
}

.report-card {
  background: #fff;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  color: var(--mtc-ink);
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 16px;
  text-decoration: none;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.report-card:hover,
.report-card.active {
  border-color: var(--mtc-red);
  box-shadow: 0 14px 30px rgba(17, 24, 39, .10);
  transform: translateY(-1px);
}

.report-card i {
  color: var(--mtc-red);
  font-size: 28px;
}

.report-card strong {
  font-size: 16px;
  font-weight: 900;
}

.report-card span {
  color: var(--mtc-muted);
  font-size: 12px;
}

.report-filter-panel {
  align-items: end;
  background: #fbfcfd;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  margin-bottom: 16px;
  padding: 14px;
}

.report-result {
  background: #fff;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  padding: 18px;
}

.report-paper-head {
  align-items: flex-start;
  border-bottom: 2px solid var(--mtc-ink);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 14px;
}

.report-paper-head h1 {
  font-size: 24px;
  font-weight: 900;
  margin: 0;
}

.report-paper-head p {
  color: var(--mtc-muted);
  margin: 4px 0 0;
}

.report-paper-head span {
  color: var(--mtc-muted);
  display: block;
  font-size: 11px;
  text-transform: uppercase;
}

.report-paper-head strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.report-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 14px;
}

.report-summary div {
  background: #f9fafb;
  border: 1px solid var(--mtc-line);
  border-radius: 8px;
  padding: 12px;
}

.report-summary span {
  color: var(--mtc-muted);
  display: block;
  font-size: 11px;
  text-transform: uppercase;
}

.report-summary strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
  margin-top: 4px;
}

.report-table {
  min-width: 920px;
}

.report-paper-foot {
  border-top: 1px solid var(--mtc-line);
  color: var(--mtc-muted);
  font-size: 12px;
  margin-top: 14px;
  padding-top: 10px;
  text-align: right;
}

@media (max-width: 992px) {
  .filter-grid,
  .filter-grid.five,
  .detail-strip,
  .info-grid,
  .permission-matrix,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .decision-tile,
  .module-tile {
    min-height: 136px;
  }

  .report-filter-panel {
    grid-template-columns: 1fr;
  }

  .service-list-search {
    grid-template-columns: 1fr;
  }

  .report-paper-head {
    display: block;
  }
}

@media print {
  body.printing-report * {
    visibility: hidden !important;
  }

  body.printing-report #reportPrintArea,
  body.printing-report #reportPrintArea * {
    visibility: visible !important;
  }

  body.printing-report #reportPrintArea {
    border: 0;
    box-shadow: none;
    left: 0;
    padding: 0;
    position: absolute;
    top: 0;
    width: 100%;
  }

  body.printing-report .report-table {
    min-width: 0;
  }

  body.printing-work-order * {
    visibility: hidden !important;
  }

  body.printing-work-order .print-area,
  body.printing-work-order .print-area * {
    visibility: visible !important;
  }

  body.printing-work-order .print-area {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    padding: 0;
    background: #fff;
  }

  body.printing-work-order .app-header,
  body.printing-work-order .app-sidebar,
  body.printing-work-order .app-content-header,
  body.printing-work-order .action-ribbon,
  body.printing-work-order .premium-tabs,
  body.printing-work-order .no-print,
  body.printing-work-order #expertise,
  body.printing-work-order #documents {
    display: none !important;
  }

  body.printing-work-order .tab-pane {
    display: block !important;
    opacity: 1 !important;
  }

  body.printing-work-order .panel-block,
  body.printing-work-order .metric-card {
    box-shadow: none !important;
    border: 0 !important;
  }

  body.printing-work-order .print-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #111827;
    margin-bottom: 16px;
    padding-bottom: 10px;
  }

  body.printing-work-order input,
  body.printing-work-order select,
body.printing-work-order textarea {
    border: 0 !important;
    padding-left: 0 !important;
    background: transparent !important;
    color: #111827 !important;
  }
}

/* Final compact overrides */
.panel-block {
  padding: 14px 18px;
}

.panel-title {
  margin-bottom: 12px;
}

.panel-title h2 {
  font-size: 18px;
}

.metric-card {
  padding: 14px;
}

.metric-card strong {
  font-size: 24px;
}
/* Night mode: only color overrides, no layout changes. */
body.dark-mode {
  --mtc-ink: #e5e7eb;
  --mtc-muted: #94a3b8;
  --mtc-line: #263244;
  --mtc-surface: #0f172a;
  --mtc-soft: #020617;
  color: #e5e7eb;
  color-scheme: dark;
}

body.dark-mode,
body.dark-mode.bg-body-tertiary,
body.dark-mode .app-wrapper,
body.dark-mode .app-main,
body.dark-mode .app-content,
body.dark-mode .app-content-header {
  background: #020617 !important;
  color: #e5e7eb;
}

body.dark-mode .premium-topbar,
body.dark-mode .navbar.bg-white,
body.dark-mode .panel-block,
body.dark-mode .metric-card,
body.dark-mode .modal-content,
body.dark-mode .dropdown-menu,
body.dark-mode .card,
body.dark-mode .bg-white,
body.dark-mode .cari-stat,
body.dark-mode .cari-side,
body.dark-mode .cari-toolbar,
body.dark-mode .cari-movement,
body.dark-mode .bank-stat,
body.dark-mode .bank-toolbar,
body.dark-mode .bank-detail,
body.dark-mode .cash-stat,
body.dark-mode .cash-toolbar,
body.dark-mode .cash-detail,
body.dark-mode .ie-stat,
body.dark-mode .ie-toolbar,
body.dark-mode .opening-card,
body.dark-mode .settings-role-sidebar,
body.dark-mode .settings-role-editor,
body.dark-mode .settings-table,
body.dark-mode .dealer-card,
body.dark-mode .user-log-panel,
body.dark-mode .report-card,
body.dark-mode .salary-add,
body.dark-mode .salary-paybar,
body.dark-mode .salary-history,
body.dark-mode .document-item,
body.dark-mode .work-order-customer-row,
body.dark-mode .permission-group-premium,
body.dark-mode .role-list-button {
  background: #0f172a !important;
  border-color: #263244 !important;
  color: #e5e7eb !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .28);
}

body.dark-mode .premium-sidebar {
  background: #030712;
}

body.dark-mode .brand-mark,
body.dark-mode .login-brand > span {
  background: #e5e7eb;
  color: #020617;
}

body.dark-mode .panel-title h2,
body.dark-mode .panel-title h3,
body.dark-mode .app-content-header h1,
body.dark-mode .topbar-page-title,
body.dark-mode .fw-semibold,
body.dark-mode strong,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode label,
body.dark-mode .form-label {
  color: #f8fafc;
}

body.dark-mode .text-secondary,
body.dark-mode small,
body.dark-mode .small,
body.dark-mode .panel-title span,
body.dark-mode .metric-card span,
body.dark-mode .cari-mini-grid span,
body.dark-mode .user-log-item span,
body.dark-mode .work-order-customer-row span {
  color: #94a3b8 !important;
}

body.dark-mode .table {
  --bs-table-bg: #0f172a;
  --bs-table-color: #e5e7eb;
  --bs-table-border-color: #263244;
  --bs-table-striped-bg: #111c2f;
  --bs-table-striped-color: #e5e7eb;
  --bs-table-hover-bg: #1e293b;
  --bs-table-hover-color: #f8fafc;
  color: #e5e7eb;
  border-color: #263244;
}

body.dark-mode .table > :not(caption) > * > * {
  background-color: var(--bs-table-bg);
  border-color: #263244;
  color: #e5e7eb;
}

body.dark-mode .table-hover tbody tr:hover > *,
body.dark-mode tr.selected-row > *,
body.dark-mode .cari-selected-row > *,
body.dark-mode .cash-selected-row > *,
body.dark-mode .bank-selected-row > *,
body.dark-mode .stock-selected-row > * {
  background-color: #1e293b !important;
  color: #f8fafc !important;
}

body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode .input-group-text,
body.dark-mode textarea,
body.dark-mode input,
body.dark-mode select {
  background-color: #111827 !important;
  border-color: #334155 !important;
  color: #e5e7eb !important;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus,
body.dark-mode textarea:focus,
body.dark-mode input:focus,
body.dark-mode select:focus {
  border-color: #64748b !important;
  box-shadow: 0 0 0 .2rem rgba(148, 163, 184, .18) !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #64748b !important;
}

body.dark-mode .btn-outline-dark,
body.dark-mode .btn-outline-secondary {
  background: transparent;
  border-color: #475569;
  color: #e5e7eb;
}

body.dark-mode .btn-outline-dark:hover,
body.dark-mode .btn-outline-secondary:hover,
body.dark-mode .dark-mode-toggle.active,
body.dark-mode .title-mode-toggle.active {
  background: #e5e7eb;
  border-color: #e5e7eb;
  color: #020617;
}

body.dark-mode .btn-dark {
  background: #e5e7eb;
  border-color: #e5e7eb;
  color: #020617;
}

body.dark-mode .btn-dark:hover {
  background: #cbd5e1;
  border-color: #cbd5e1;
  color: #020617;
}

body.dark-mode .badge.text-bg-dark {
  background: #334155 !important;
  color: #f8fafc !important;
}

body.dark-mode .alert-light,
body.dark-mode .alert-warning,
body.dark-mode .list-group-item,
body.dark-mode .nav-tabs,
body.dark-mode .premium-tabs .nav-link {
  background: #111827 !important;
  border-color: #263244 !important;
  color: #e5e7eb !important;
}

body.dark-mode .premium-tabs .nav-link.active,
body.dark-mode .nav-tabs .nav-link.active {
  background: #0f172a !important;
  border-color: #475569 #475569 #0f172a !important;
  color: #f8fafc !important;
}

body.dark-mode .modal-backdrop.show {
  opacity: .72;
}

body.dark-mode .btn-close {
  filter: invert(1) grayscale(100%);
}

body.dark-mode a:not(.btn):not(.nav-link):not(.brand-link) {
  color: #93c5fd;
}

body.dark-mode .customer-suggestion,
body.dark-mode .insurance-company-suggestion,
body.dark-mode [data-audit-suggest-box] button {
  background: #111827 !important;
  border-color: #263244 !important;
  color: #e5e7eb !important;
}

body.dark-mode .customer-suggestion:hover,
body.dark-mode .insurance-company-suggestion:hover,
body.dark-mode [data-audit-suggest-box] button:hover {
  background: #1e293b !important;
}

/* Full dark-mode sweep for module-local white surfaces. */
body.dark-mode .bg-light,
body.dark-mode .bg-body,
body.dark-mode .bg-body-tertiary,
body.dark-mode .table-light,
body.dark-mode .alert,
body.dark-mode .accordion-item,
body.dark-mode .accordion-button,
body.dark-mode .offcanvas,
body.dark-mode .toast,
body.dark-mode .popover,
body.dark-mode .tooltip-inner,
body.dark-mode .list-group,
body.dark-mode .list-group-item,
body.dark-mode .input-group,
body.dark-mode .upload-zone,
body.dark-mode .detail-strip,
body.dark-mode .info-grid > div,
body.dark-mode .service-info-card,
body.dark-mode .service-card,
body.dark-mode .service-list-panel,
body.dark-mode .service-movement-body,
body.dark-mode .cash-console,
body.dark-mode .cash-ledger,
body.dark-mode .cash-ledger-head,
body.dark-mode .cash-movement,
body.dark-mode .bank-console,
body.dark-mode .bank-ledger,
body.dark-mode .bank-ledger-head,
body.dark-mode .bank-movement,
body.dark-mode .cari-movement-list,
body.dark-mode .cari-mini-grid > div,
body.dark-mode .cari-movement-panel,
body.dark-mode .invoice-preview,
body.dark-mode .invoice-meta-grid,
body.dark-mode .invoice-bottom-grid,
body.dark-mode .report-filter-panel,
body.dark-mode .report-preview,
body.dark-mode .settings-hero,
body.dark-mode .permission-toolbar,
body.dark-mode .role-form-grid,
body.dark-mode .opening-hero,
body.dark-mode .salary-hero,
body.dark-mode .salary-card,
body.dark-mode .stock-movement-panel,
body.dark-mode .stock-ledger,
body.dark-mode .stock-toolbar {
  background-color: #0f172a !important;
  border-color: #263244 !important;
  color: #e5e7eb !important;
}

body.dark-mode .table thead th,
body.dark-mode .table tfoot th,
body.dark-mode .table tfoot td,
body.dark-mode .table-responsive,
body.dark-mode .modal-header,
body.dark-mode .modal-footer {
  background-color: #111827 !important;
  border-color: #263244 !important;
  color: #f8fafc !important;
}

body.dark-mode .modal-body,
body.dark-mode .dropdown-item,
body.dark-mode .accordion-button:not(.collapsed) {
  background-color: #0f172a !important;
  color: #e5e7eb !important;
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:focus,
body.dark-mode .page-link:hover,
body.dark-mode .page-link:focus {
  background-color: #1e293b !important;
  color: #f8fafc !important;
}

body.dark-mode .page-link,
body.dark-mode .pagination .page-item.disabled .page-link,
body.dark-mode .cash-pill,
body.dark-mode .bank-pill,
body.dark-mode .cari-badge,
body.dark-mode .badge:not(.text-bg-success):not(.text-bg-danger):not(.text-bg-warning):not(.text-bg-info) {
  background-color: #111827 !important;
  border-color: #334155 !important;
  color: #e5e7eb !important;
}

body.dark-mode .alert-success {
  background-color: #052e1a !important;
  border-color: #166534 !important;
  color: #bbf7d0 !important;
}

body.dark-mode .alert-danger,
body.dark-mode .alert-warning {
  background-color: #3b1d13 !important;
  border-color: #92400e !important;
  color: #fde68a !important;
}

body.dark-mode .alert-info {
  background-color: #082f49 !important;
  border-color: #075985 !important;
  color: #bae6fd !important;
}

body.dark-mode .form-check-input {
  background-color: #111827 !important;
  border-color: #64748b !important;
}

body.dark-mode .form-check-input:checked {
  background-color: #2563eb !important;
  border-color: #2563eb !important;
}

body.dark-mode .btn-outline-danger {
  background: transparent;
  border-color: #f87171;
  color: #fecaca;
}

body.dark-mode .btn-outline-danger:hover {
  background: #7f1d1d;
  border-color: #991b1b;
  color: #fff;
}

body.dark-mode .btn-outline-success {
  background: transparent;
  border-color: #22c55e;
  color: #bbf7d0;
}

body.dark-mode .btn-outline-success:hover {
  background: #14532d;
  border-color: #166534;
  color: #fff;
}

body.dark-mode .btn-outline-primary {
  background: transparent;
  border-color: #60a5fa;
  color: #bfdbfe;
}

body.dark-mode .btn-outline-primary:hover {
  background: #1d4ed8;
  border-color: #2563eb;
  color: #fff;
}

body.dark-mode .text-bg-info,
body.dark-mode .service-status-progress {
  background-color: #1e3a8a !important;
  color: #dbeafe !important;
}

body.dark-mode .text-bg-success,
body.dark-mode .service-status-open {
  background-color: #14532d !important;
  color: #dcfce7 !important;
}

body.dark-mode .text-bg-danger,
body.dark-mode .service-status-closed {
  background-color: #7f1d1d !important;
  color: #fee2e2 !important;
}

body.dark-mode .text-bg-warning,
body.dark-mode .service-status-waiting {
  background-color: #713f12 !important;
  color: #fef3c7 !important;
}

body.dark-mode .table-hover tbody tr:hover > *,
body.dark-mode .service-selected-row > *,
body.dark-mode .selected-row > *,
body.dark-mode tr.table-warning > * {
  background-color: #273449 !important;
  color: #f8fafc !important;
}

body.dark-mode hr,
body.dark-mode .border,
body.dark-mode .border-top,
body.dark-mode .border-bottom,
body.dark-mode .border-start,
body.dark-mode .border-end {
  border-color: #263244 !important;
}

/* Service detail has module-local light cards; override them explicitly. */
body.dark-mode .service-detail-hero,
body.dark-mode .tab-content,
body.dark-mode .tab-pane {
  background: transparent !important;
  color: #e5e7eb !important;
}

body.dark-mode .service-note-card,
body.dark-mode .service-vehicle-card,
body.dark-mode .service-edit-panel,
body.dark-mode .service-edit-pane,
body.dark-mode .service-edit-choice,
body.dark-mode .expertise-sheet,
body.dark-mode .expertise-sheet-head,
body.dark-mode .expertise-sheet-scroll,
body.dark-mode .expertise-add-zone,
body.dark-mode .expertise-sheet-total,
body.dark-mode .full-edit-alert {
  background: #0f172a !important;
  border-color: #263244 !important;
  color: #e5e7eb !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .24) !important;
}

body.dark-mode .service-note-card span,
body.dark-mode .service-edit-heading span,
body.dark-mode .service-edit-choice span {
  color: #94a3b8 !important;
}

body.dark-mode .service-section-title,
body.dark-mode .service-section-title-work,
body.dark-mode .service-section-title-customer,
body.dark-mode .service-section-title-vehicle,
body.dark-mode .service-section-title-insurance {
  background: linear-gradient(90deg, #111827, #0f172a) !important;
  border-bottom-color: #263244 !important;
  color: #f8fafc !important;
}

body.dark-mode .service-section-title-work { border-left-color: #94a3b8 !important; }
body.dark-mode .service-section-title-customer { border-left-color: #2dd4bf !important; }
body.dark-mode .service-section-title-vehicle { border-left-color: #60a5fa !important; }
body.dark-mode .service-section-title-insurance { border-left-color: #f59e0b !important; }

body.dark-mode .service-section-title i {
  color: #fb7185 !important;
}

body.dark-mode .service-edit-choice:hover,
body.dark-mode .service-edit-choice.active {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}

body.dark-mode .expertise-edit-row > *,
body.dark-mode .expertise-sheet th,
body.dark-mode .expertise-sheet td,
body.dark-mode .expertise-sheet-total > * {
  background: #111827 !important;
  border-color: #263244 !important;
  color: #e5e7eb !important;
}

body.dark-mode .expertise-add-button {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}

body.dark-mode .service-note-card .btn:disabled,
body.dark-mode .service-note-card .btn.disabled,
body.dark-mode button:disabled,
body.dark-mode .btn:disabled {
  background: #111827 !important;
  border-color: #334155 !important;
  color: #64748b !important;
  opacity: 1 !important;
}
