/* Font Import — self-hosted Inter (see scripts/selfhost-fonts.js). Was a live
   @import from fonts.googleapis.com; now local so there's no third-party fetch
   (works offline on the factory LOCAL box) and no CSP font/style exemption. */
@import url('/assets/vendor/fonts/g-5710dd5f5b.css');

:root {
  /* JMS OCEAN logo palette */
  --primary: #024c81;
  --primary-dark: #072450;
  --primary-light: rgba(1, 168, 221, 0.16);
  --accent-teal: #00929e;
  --accent-cyan: #01a8dd;
  --accent-gold: #faac24;

  --bg-body: #eef7fa;
  --bg-card: #ffffff;
  --bg-sidebar: #072450;
  --bg-sidebar-hover: #0b4c80;

  --text-main: #17384c;
  --text-muted: #5d778a;

  --sidebar-text: #c9dfec;
  --sidebar-text-hover: #ffffff;

  --border: #d9e9f0;
  --border-dark: rgba(255, 255, 255, 0.08);

  --danger: #ef4444;
  --success: #10b981;
  --warning: #faac24;

  --shadow-sm: 0 10px 24px rgba(8, 38, 58, 0.06);
  --shadow-md: 0 18px 36px rgba(8, 38, 58, 0.12);
  --shadow-premium: 0 24px 50px rgba(8, 38, 58, 0.16);
  --scrollbar-size: 12px;
  --scrollbar-track: linear-gradient(180deg, rgba(2, 76, 129, 0.08), rgba(1, 168, 221, 0.04));
  --scrollbar-track-dark: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  --scrollbar-thumb: linear-gradient(180deg, rgba(1, 168, 221, 0.95) 0%, rgba(2, 76, 129, 0.94) 68%, rgba(250, 172, 36, 0.96) 100%);
  --scrollbar-thumb-hover: linear-gradient(180deg, rgba(0, 146, 158, 0.98) 0%, rgba(2, 76, 129, 1) 62%, rgba(250, 172, 36, 1) 100%);
  --scrollbar-thumb-dark: linear-gradient(180deg, rgba(1, 168, 221, 0.98) 0%, rgba(6, 50, 110, 0.96) 75%, rgba(250, 172, 36, 0.95) 100%);
  --motion-duration-fast: 180ms;
  --motion-duration-base: 320ms;
  --motion-duration-slow: 760ms;
  --motion-ease-premium: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-sheen: linear-gradient(115deg, transparent 24%, rgba(255, 255, 255, 0.68) 48%, transparent 72%);
  --layout-max-width: 100%;
  --layout-page-padding: clamp(14px, 1.8vw, 24px);
  --layout-section-gap: clamp(12px, 1.4vw, 20px);
}

* {
  box-sizing: border-box;
}

/* Custom scrollbars only on the app chrome; everything else uses the
   browser default so scrolling large tables stays cheap. */
.sidebar,
.nav-links,
.nav-sub,
.user-profile,
.main-content {
  scrollbar-width: thin;
  scrollbar-color: rgba(2, 76, 129, 0.6) transparent;
}

.sidebar::-webkit-scrollbar,
.nav-links::-webkit-scrollbar,
.nav-sub::-webkit-scrollbar,
.user-profile::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

.sidebar::-webkit-scrollbar-track,
.nav-links::-webkit-scrollbar-track,
.nav-sub::-webkit-scrollbar-track,
.user-profile::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.nav-links::-webkit-scrollbar-thumb,
.nav-sub::-webkit-scrollbar-thumb,
.user-profile::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
  background: rgba(2, 76, 129, 0.55);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.nav-links::-webkit-scrollbar-thumb:hover,
.nav-sub::-webkit-scrollbar-thumb:hover,
.user-profile::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
  background: rgba(1, 168, 221, 0.8);
}

.sidebar::-webkit-scrollbar-thumb,
.nav-links::-webkit-scrollbar-thumb,
.nav-sub::-webkit-scrollbar-thumb,
.user-profile::-webkit-scrollbar-thumb {
  background: rgba(1, 168, 221, 0.7);
}

.main-content,
.modal-content,
.dataTables_scrollBody,
.card,
.table-responsive {
  scrollbar-gutter: stable;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  background-image:
    radial-gradient(circle at top left, rgba(1, 168, 221, 0.14), transparent 34%),
    radial-gradient(circle at bottom right, rgba(250, 172, 36, 0.12), transparent 28%),
    linear-gradient(180deg, #f8fdff 0%, #eef7fa 48%, #edf4f8 100%);
  background-size: 120% 120%, 120% 120%, 100% 100%;
  color: var(--text-main);
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Sidebar (Dark Theme) */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #072450 0%, #024c81 58%, #0a6277 100%);
  border-right: 1px solid var(--border-dark);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: 50;
  color: var(--sidebar-text);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
  box-shadow: 18px 0 36px rgba(7, 36, 80, 0.14);
  /* Hide overflow during transition */
}

.sidebar.collapsed,
.sidebar.auto-collapsed {
  width: 70px;
}

.sidebar.collapsed .brand-logo span,
.sidebar.auto-collapsed .brand-logo span,
.sidebar.collapsed .nav-text,
.sidebar.auto-collapsed .nav-text,
.sidebar.collapsed .user-profile>div:nth-child(2),
.sidebar.auto-collapsed .user-profile>div:nth-child(2),
.sidebar.collapsed .sidebar-unit-card,
.sidebar.auto-collapsed .sidebar-unit-card,
.sidebar.collapsed .nav-sub,
.sidebar.auto-collapsed .nav-sub {
  display: none !important;
}

.sidebar.collapsed .brand,
.sidebar.auto-collapsed .brand {
  padding: 24px 0;
  justify-content: center;
}

.sidebar.collapsed .brand-logo,
.sidebar.auto-collapsed .brand-logo {
  margin: 0;
}

.sidebar.collapsed .nav-link-main,
.sidebar.auto-collapsed .nav-link-main {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.collapsed .nav-link-main i,
.sidebar.auto-collapsed .nav-link-main i {
  margin: 0;
  font-size: 1.3rem;
}

.sidebar.collapsed .user-profile,
.sidebar.auto-collapsed .user-profile {
  padding: 16px 0;
  justify-content: center;
}

.sidebar.collapsed .user-profile>div:first-child,
.sidebar.auto-collapsed .user-profile>div:first-child {
  margin: 0;
}

.sidebar.collapsed .user-profile button,
.sidebar.auto-collapsed .user-profile button {
  display: none;
}

.brand {
  padding: 24px;
  /* border-bottom: 1px solid var(--border-dark); */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Center Logo */
  margin-bottom: 10px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
}

.brand-logo img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(1, 168, 221, 0.16));
  padding: 4px;
  flex-shrink: 0;
  box-shadow: 0 10px 24px rgba(1, 168, 221, 0.16);
}

.brand-logo span {
  white-space: nowrap;
}

.nav-links {
  list-style: none;
  padding: 0 12px;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-link-main i {
  font-size: 1.1rem;
  color: var(--sidebar-text);
  opacity: 0.7;
  transition: color 0.2s;
}

.nav-link-main:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--sidebar-text-hover);
}

.nav-link-main:hover i {
  color: var(--sidebar-text-hover);
  opacity: 1;
}

.nav-item.active .nav-link-main {
  background: linear-gradient(135deg, var(--primary), var(--accent-teal));
  color: white;
  box-shadow: 0 10px 24px rgba(2, 76, 129, 0.28);
}

.nav-item.active .nav-link-main i {
  color: white;
  opacity: 1;
}

/* Sub-Menu */
.nav-sub {
  list-style: none;
  padding: 4px 0 4px 10px;
  margin: 0 0 0 20px;
  display: none;
  border-left: 1px solid var(--border-dark);
}

.nav-item.active .nav-sub {
  display: block;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sub-link {
  display: block;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: color 0.15s;
  border-radius: 4px;
}

.sub-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.user-profile {
  padding: 10px 14px;
  border-top: 1px solid var(--border-dark);
  background: rgba(4, 20, 39, 0.42);
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
}

.sidebar-unit-card {
  margin: 0 8px 6px;
  padding: 8px 8px 7px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(201, 223, 236, 0.08);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.sidebar-unit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.sidebar-unit-title {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.sidebar-unit-title i {
  color: var(--accent-cyan);
  font-size: 0.74rem;
}

.sidebar-unit-refresh {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  width: 21px;
  height: 21px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar-unit-refresh:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: rotate(14deg);
}

.sidebar-unit-button {
  width: 100%;
  border: 1px solid rgba(1, 168, 221, 0.12);
  border-radius: 8px;
  background: rgba(1, 10, 30, 0.46);
  color: #f8fdff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 9px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.sidebar-unit-button:hover {
  background: rgba(2, 76, 129, 0.34);
  border-color: rgba(1, 168, 221, 0.26);
  transform: translateY(-1px);
}

.sidebar-unit-name {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-unit-button i {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.74rem;
}

.sidebar-avatar-shell {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  padding: 2px;
  background: linear-gradient(135deg, rgba(1, 168, 221, 0.7), rgba(250, 172, 36, 0.55));
  flex-shrink: 0;
}

.sidebar-avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 9px;
  background: radial-gradient(circle at 30% 20%, #375a7c, #0d2238 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 800;
}

.sidebar-avatar-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #76f0ff;
  border: 2px solid #0b2846;
  box-shadow: 0 0 0 2px rgba(118, 240, 255, 0.15);
}

.sidebar-user-meta {
  min-width: 0;
  flex: 1;
}

.sidebar-user-name {
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-role-label {
  margin-top: 1px;
  color: #6ce6f5;
  font-size: 0.72rem;
  font-weight: 700;
}

.sidebar-user-unit {
  margin-top: 0;
  color: rgba(201, 223, 236, 0.72);
  font-size: 0.6rem;
  /* Show the full plant name instead of truncating it with "…" */
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.sidebar-user-actions {
  margin-left: auto;
  display: flex;
  gap: 3px;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--layout-page-padding);
  max-width: var(--layout-max-width);
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
}

body.viewport-compact .sidebar:not(.collapsed):not(.auto-collapsed) {
  width: 232px;
}

body.viewport-compact .brand {
  padding: 18px 18px 16px;
}

body.viewport-compact .brand-logo {
  gap: 10px;
  font-size: 1.35rem;
}

body.viewport-compact .brand-logo img {
  width: 38px;
  height: 38px;
}

body.viewport-compact .nav-links {
  padding: 0 10px;
}

body.viewport-compact .nav-link-main {
  gap: 10px;
  padding: 9px 10px;
  font-size: 0.9rem;
}

body.viewport-compact .sub-link {
  padding: 7px 10px;
}

body.viewport-compact .user-profile {
  padding: 9px 10px;
}

body.viewport-compact .main-content {
  padding: clamp(12px, 1.4vw, 18px);
  max-width: var(--layout-max-width);
}

body.viewport-compact .header {
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
}

body.viewport-compact .page-title {
  font-size: 1.55rem;
}

body.viewport-compact .card {
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 14px;
}

body.viewport-compact th,
body.viewport-compact td {
  padding: 11px 12px;
}

body.viewport-compact .btn {
  padding: 9px 16px;
  font-size: 0.86rem;
}

body.viewport-compact .form-control {
  padding: 9px 12px;
  font-size: 0.92rem;
}

body.viewport-compact .modal-content {
  width: min(92vw, 1120px);
  max-height: calc(100vh - 40px);
  padding: 26px;
}

body.viewport-compact .dataTables_wrapper .dt-layout-row,
body.viewport-compact .dataTables_wrapper .dataTables_length,
body.viewport-compact .dataTables_wrapper .dataTables_filter,
body.viewport-compact .dataTables_wrapper .dataTables_info,
body.viewport-compact .dataTables_wrapper .dataTables_paginate {
  min-width: 0;
}

body.viewport-compact .dataTables_wrapper .dt-layout-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
}

body.viewport-tight .main-content {
  padding: 12px;
}

body.viewport-tight .header {
  margin-bottom: 18px;
  padding-bottom: 14px;
}

body.viewport-tight .page-title {
  font-size: 1.4rem;
}

body.viewport-tight .card {
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 12px;
}

body.viewport-tight .btn {
  padding: 8px 14px;
  font-size: 0.82rem;
}

body.viewport-tight .form-control {
  padding: 8px 11px;
  font-size: 0.88rem;
}

body.viewport-tight th,
body.viewport-tight td {
  padding: 9px 10px;
}

body.viewport-tight .modal-content {
  width: min(96vw, 960px);
  max-height: calc(100vh - 28px);
  padding: 20px;
  border-radius: 14px;
}

body.viewport-short .main-content {
  padding-top: 16px;
  padding-bottom: 16px;
}

body.viewport-short .header {
  margin-bottom: 16px;
  padding-bottom: 12px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--layout-section-gap);
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.page-title {
  font-size: clamp(1.3rem, 1.2rem + 0.9vw, 1.7rem);
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text-main);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: clamp(14px, 1.5vw, 20px);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--layout-section-gap);
  transition:
    transform var(--motion-duration-base) var(--motion-ease-premium),
    box-shadow var(--motion-duration-base) var(--motion-ease-premium),
    border-color var(--motion-duration-fast) ease,
    background-color var(--motion-duration-fast) ease;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.card:hover {
  box-shadow: var(--shadow-premium);
  border-color: rgba(1, 168, 221, 0.22);
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  background-color: #f2f9fc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: #f5fbfd;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #ffffff;
  transition:
    transform var(--motion-duration-fast) ease,
    border-color var(--motion-duration-fast) ease,
    box-shadow var(--motion-duration-fast) ease,
    background-color var(--motion-duration-fast) ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  transform: translateY(-1px);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    transform var(--motion-duration-fast) var(--motion-ease-premium),
    box-shadow var(--motion-duration-fast) ease,
    border-color var(--motion-duration-fast) ease,
    background-color var(--motion-duration-fast) ease,
    color var(--motion-duration-fast) ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent-teal));
  color: white;
  box-shadow: 0 8px 18px rgba(2, 76, 129, 0.18);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  transform: translateY(-1px);
}

.btn-outline {
  background-color: white;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: #f3fafc;
  border-color: rgba(1, 168, 221, 0.35);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(8, 38, 58, 0.08);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(220, 38, 38, 0.22);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 32px;
  border-radius: 16px;
  width: 500px;
  max-width: 90%;
  max-height: 90vh;
  /* Prevent overflow on small screens */
  overflow-y: auto;
  /* Enable scroll if content is too long */
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  animation: premiumModalIn 0.32s var(--motion-ease-premium);
  position: relative;
  overflow-x: hidden;
}

.modal-content::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.58), transparent 28%);
  pointer-events: none;
}

@keyframes premiumModalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body.motion-ready .sidebar {
  animation: premiumShellSlideIn 720ms var(--motion-ease-premium) both;
}

body.motion-ready .main-content {
  animation: premiumPageRiseIn 820ms var(--motion-ease-premium) both;
}

body.motion-ready .header {
  animation: premiumPageRiseIn 900ms var(--motion-ease-premium) both;
  animation-delay: 90ms;
}

.motion-target {
  opacity: 0;
  transform: translateY(24px) scale(0.985);
  transition:
    opacity var(--motion-duration-slow) var(--motion-ease-premium),
    transform var(--motion-duration-slow) var(--motion-ease-premium),
    box-shadow var(--motion-duration-base) var(--motion-ease-premium),
    border-color var(--motion-duration-fast) ease,
    background-color var(--motion-duration-fast) ease;
  transition-delay: calc(var(--motion-order, 0) * 60ms);
  will-change: opacity, transform;
}

.motion-target.motion-visible {
  opacity: 1;
  transform: none;
}

.nav-link-main,
.sub-link,
.sidebar-unit-card,
.sidebar-unit-button,
.mobile-nav .nav-item,
.machine,
tbody tr {
  transition:
    transform var(--motion-duration-fast) var(--motion-ease-premium),
    box-shadow var(--motion-duration-fast) ease,
    border-color var(--motion-duration-fast) ease,
    background-color var(--motion-duration-fast) ease,
    color var(--motion-duration-fast) ease;
}

.sidebar-unit-card:hover {
  box-shadow: 0 16px 28px rgba(1, 10, 30, 0.18);
  border-color: rgba(108, 230, 245, 0.16);
}

tbody tr:hover {
  background-color: rgba(1, 168, 221, 0.06);
}

.mobile-nav .nav-item:hover {
  transform: translateY(-3px);
}

@keyframes premiumShellSlideIn {
  from {
    opacity: 0;
    transform: translateX(-22px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes premiumPageRiseIn {
  from {
    opacity: 0;
    transform: translateY(22px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cute Global Loader (Progress Bar Modern) */
#global-loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

#global-loader.visible {
  opacity: 1;
  pointer-events: all;
}

/* No Card - Floating Layout */
.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: floatUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.loader-icon-container {
  position: relative;
  margin-bottom: 24px;
}

.loader-icon {
  font-size: 3.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-cyan) 62%, var(--accent-gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: pulseGradient 3s ease infinite;
  filter: drop-shadow(0 8px 16px rgba(1, 168, 221, 0.22));
  z-index: 2;
  position: relative;
}

.loader-glow {
  position: absolute;
  inset: -10px;
  background: radial-gradient(circle, rgba(1, 168, 221, 0.42) 0%, transparent 70%);
  filter: blur(12px);
  z-index: 1;
  animation: breathe 3s ease-in-out infinite;
}

.loader-text {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.5px;
  color: #1e293b;
  margin-bottom: 4px;
  background: linear-gradient(90deg, #1e293b, #475569);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.loader-sub {
  font-size: 1rem;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 24px;
  opacity: 0.9;
}

/* Progress Bar */
.loader-progress-container {
  width: 240px;
  height: 6px;
  background: rgba(203, 213, 225, 0.4);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.loader-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--primary), var(--accent-cyan), var(--accent-gold));
  border-radius: 99px;
  animation: progressIndeterminate 1.5s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(1, 168, 221, 0.4);
}

@keyframes progressIndeterminate {
  0% {
    left: -40%;
    width: 40%;
  }

  50% {
    left: 30%;
    width: 60%;
  }

  100% {
    left: 100%;
    width: 10%;
  }
}

@keyframes floatUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulseGradient {
  0% {
    transform: scale(1);
    filter: brightness(100%);
  }

  50% {
    transform: scale(1.05);
    filter: brightness(120%);
  }

  100% {
    transform: scale(1);
    filter: brightness(100%);
  }
}

@keyframes breathe {
  0% {
    opacity: 0.5;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.2);
  }

  100% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* =========================================
   DESKTOP COMPACT DENSITY OVERRIDES
   ========================================= */
@media (min-width: 769px) {
  body {
    font-size: 14px;
  }

  .main-content,
  #contentArea,
  #pageContent {
    max-width: 100% !important;
    padding: clamp(10px, 1.2vw, 16px) !important;
  }

  .header {
    margin-bottom: 12px !important;
    padding-bottom: 10px !important;
  }

  .page-title {
    font-size: clamp(1.18rem, 1.02rem + 0.58vw, 1.48rem) !important;
  }

  .card {
    padding: clamp(10px, 1.15vw, 14px) !important;
    margin-bottom: 12px !important;
    border-radius: 10px !important;
  }

  th,
  td {
    padding: 8px 10px !important;
  }

  .form-group {
    margin-bottom: 10px !important;
  }

  .form-control {
    padding: 8px 10px !important;
    min-height: 38px;
  }

  .btn {
    padding: 7px 12px !important;
    font-size: 0.82rem !important;
    border-radius: 8px !important;
  }

  .dashboard-header,
  .welcome-hero,
  .stats-row,
  .analytics-grid,
  .kpi-grid,
  .tiles-grid,
  .summary-grid {
    gap: 10px !important;
  }

  .hero-copy,
  .hero-visuals,
  .hero-card,
  .settings-card,
  .dashboard-panel,
  .panel {
    border-radius: 12px !important;
  }

  .dataTables_wrapper .dt-layout-row {
    gap: 8px 10px !important;
  }

  .notif-item,
  .metric-box,
  .stat-card {
    padding: 10px 12px !important;
  }
}

/* =========================================
   MOBILE APP EXPERIENCE V4 (FINAL CONSOLIDATED)
   ========================================= */

@media (max-width: 768px) {

  /* 1. APP SHELL LAYOUT (Native Feel - Light) */
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    background-color: #f8fafc !important;
    -webkit-tap-highlight-color: transparent;
  }

  /* Normal document scrolling; leave room for the fixed bottom nav */
  body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
  }

  .main-content,
  #contentArea,
  #pageContent {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 16px !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* 2. Hide desktop-only chrome */
  .top-nav,
  .desktop-only {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
  }

  /* 3. BOTTOM NAVIGATION (Fixed & Solid & Light) */
  .mobile-nav {
    display: flex !important;
    justify-content: space-around !important;
    align-items: center !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 70px !important;
    background-color: #ffffff !important;
    border-top: 1px solid #e2e8f0 !important;
    z-index: 999999 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05) !important;
  }

  .nav-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    color: #64748b !important;
    text-decoration: none !important;
    font-size: 11px !important;
    height: 100% !important;
    background: transparent !important;
  }

  .nav-item i {
    font-size: 1.5rem !important;
    margin-bottom: 2px !important;
    color: #64748b !important;
  }

  .nav-item.active i,
  .nav-item.active {
    color: var(--primary) !important;
  }

  /* The full sidebar DRAWER (opened via hamburger) must stay a normal vertical
     list — not inherit the bottom-tab-bar column styling above. Keep each item a
     horizontal row so the label sits left and the submenu chevron aligns right. */
  .sidebar .nav-links {
    flex-direction: column !important;
    padding: 0 12px !important;
  }
  .sidebar .nav-item {
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    height: auto !important;
    font-size: 0.95rem !important;
    color: var(--sidebar-text) !important;
    margin-bottom: 4px !important;
  }
  .sidebar .nav-link-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }
  .sidebar .nav-link-main {
    flex: 1 1 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    min-width: 0 !important;
  }
  .sidebar .nav-item i {
    font-size: 1.1rem !important;
    margin-bottom: 0 !important;
    color: var(--sidebar-text) !important;
  }
  .sidebar .nav-link-main .nav-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sidebar .sub-toggle-btn {
    flex: 0 0 auto !important;
  }

  /* 4. CARDS & VISUALS */
  .card,
  .card-mobile {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    max-width: 100% !important;
  }

  h1,
  h2,
  h3,
  h4,
  .page-title {
    color: #1e293b !important;
    font-size: 1.5rem !important;
  }

  .text-muted {
    color: #64748b !important;
  }

  /* 5. FORMS */
  input,
  select {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    height: 45px !important;
    border-radius: 8px !important;
    font-size: 16px !important;
    /* No Zoom */
  }

  /* 6. MODALS (Full Screen) */
  .modal-content {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    background: #f8fafc !important;
    z-index: 9999999 !important;
  }
}

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

  .motion-target {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* The hamburger FAB and backdrop are injected by app.js on every page that has
   a .sidebar. They stay hidden at >=1025px and only appear as the off-canvas
   drawer chrome below 1024px. */
.mobile-sidebar-fab,
.mobile-sidebar-backdrop {
  display: none;
}

/* JS owns visibility via the [hidden] attribute — it always wins */
.mobile-sidebar-fab[hidden],
.mobile-sidebar-backdrop[hidden] {
  display: none !important;
}

@media (max-width: 1024px) {
  /* Sidebar becomes a fixed off-canvas drawer — unconditional, no per-page classes */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: min(84vw, 300px) !important;
    max-width: 300px !important;
    height: 100dvh !important;
    transform: translateX(-110%) !important;
    transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1) !important;
    z-index: 1000001 !important;
    box-shadow: 24px 0 44px rgba(3, 18, 36, 0.34) !important;
    overflow-y: auto !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  /* Collapsed desktop states must not shrink the drawer */
  .sidebar.collapsed,
  .sidebar.auto-collapsed {
    width: min(84vw, 300px) !important;
  }

  .sidebar .brand {
    padding-top: calc(20px + env(safe-area-inset-top)) !important;
  }

  /* Content clears the fixed FAB */
  .main-content,
  #contentArea,
  #pageContent {
    padding-top: max(72px, calc(70px + env(safe-area-inset-top))) !important;
  }

  /* Dimmed backdrop */
  .mobile-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(3, 18, 36, 0.52);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1000000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }

  body.mobile-sidebar-open .mobile-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Hamburger FAB — >=44x44, fixed top-left, respects the notch */
  .mobile-sidebar-fab {
    display: inline-flex;
    position: fixed;
    top: calc(14px + env(safe-area-inset-top));
    left: 14px;
    width: 52px;
    height: 52px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
    color: #fff;
    align-items: center;
    justify-content: center;
    box-shadow: 0 16px 30px rgba(2, 76, 129, 0.28);
    z-index: 1000002;
  }

  .mobile-sidebar-fab i {
    font-size: 1.35rem;
  }
}

/* =========================================
   MOBILE SIDEBAR DRAWER & TABLE ENHANCEMENTS
   ========================================= */

/* Sidebar Search Box */
.sidebar-search-box {
  padding: 8px 14px 12px;
  position: relative;
}

.sidebar-search-box .search-inner {
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-search-box i {
  position: absolute;
  left: 12px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.9rem;
  pointer-events: none;
}

.sidebar-search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.sidebar-search-box input:focus {
  border-color: var(--accent-cyan, #01a8dd);
  background: rgba(255, 255, 255, 0.14);
}

.sidebar-search-box input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

/* Submenu Accordion Toggle */
.nav-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.nav-link-row .nav-link-main {
  flex: 1;
}

.sub-toggle-btn {
  background: transparent;
  border: none;
  color: var(--sidebar-text, #c9dfec);
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s ease, color 0.2s;
}

.sub-toggle-btn:hover {
  color: #ffffff;
}

.sub-toggle-btn i {
  font-size: 0.8rem;
  transition: transform 0.22s ease;
}

.nav-item.open .sub-toggle-btn i,
.nav-item.active .sub-toggle-btn i {
  transform: rotate(180deg);
}

.nav-item .nav-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-left: 18px;
  margin: 0;
  list-style: none;
}

.nav-item.open .nav-sub,
.nav-item.active .nav-sub {
  max-height: 800px;
  margin-top: 4px;
  margin-bottom: 8px;
}

/* Sidebar Close Button (Mobile Only) */
.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

@media (max-width: 1024px) {
  .sidebar-close-btn {
    display: inline-flex !important;
  }
}

/* Responsive Table Wrapper */
.table-responsive-mobile {
  width: 100%;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  margin-bottom: 1rem;
  border-radius: 8px;
  box-shadow: inset -6px 0 8px -4px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
  table {
    min-width: 580px;
  }

  .table-card,
  .card:has(table) {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

