/* ALMS Design System - Extracted from Alms UI.html reference */
/* ============================================================ */

/* ── Design Tokens ── */
:root {
  /* Color palette */
  --blue-50:  #eaf3fc;
  --blue-100: #cfe4f8;
  --blue-400: #4a9ce2;
  --blue-500: #3a94e4;
  --blue-600: #2f7bc0;

  --teal-700: #2c6d80;
  --teal-800: #204f5d;

  --navy-900: #20252f;
  --slate-800: #303c43;

  --orange-500: #f49800;
  --orange-600: #d98600;

  --red-500: #d64545;
  --red-050: #fbe9e9;

  --amber-500: #e9a90a;
  --amber-050: #fdf3d9;

  --green-600: #3f8f4f;
  --green-050: #e3f1e4;

  --gray-050: #f4f5f6;
  --gray-100: #e9ecef;
  --gray-200: #dee2e6;
  --gray-300: #ced4da;
  --gray-400: #adb5bd;
  --gray-500: #868e96;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;

  --white: #ffffff;

  /* Semantic aliases */
  --surface-page: var(--gray-200);
  --surface-card: var(--white);
  --surface-sidebar: var(--white);
  --surface-sidebar-photo: var(--slate-800);
  --surface-header-band: var(--teal-700);
  --surface-table-head: var(--gray-300);
  --surface-row-alt: var(--gray-050);

  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --text-inverse: var(--white);
  --text-link: var(--blue-500);

  --border-default: var(--gray-300);
  --border-strong: var(--gray-400);

  --brand-primary: var(--blue-500);
  --brand-primary-hover: var(--blue-600);
  --brand-accent: var(--orange-500);
  --brand-accent-hover: var(--orange-600);

  --status-overdue-fg: var(--red-500);
  --status-overdue-bg: var(--red-050);
  --status-soon-fg: var(--amber-500);
  --status-soon-bg: var(--amber-050);
  --status-approved-fg: var(--green-600);
  --status-approved-bg: var(--green-050);
  --status-inprogress-fg: var(--blue-600);
  --status-inprogress-bg: var(--blue-50);

  /* Typography */
  --font-sans: "Roboto", "Kanit", "Segoe UI", Arial, sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-bold: 700;

  /* Spacing & Radius */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-card: 0 1px 2px rgba(0,0,0,0.08), 0 1px 1px rgba(0,0,0,0.04);
  --shadow-popover: 0 4px 12px rgba(0,0,0,0.15);

  /* ── Legacy variable bridge ── */
  --ui-bg: var(--surface-page);
  --ui-bg-deep: var(--gray-300);
  --ui-bg-soft: var(--white);
  --ui-surface: var(--surface-card);
  --ui-surface-strong: var(--white);
  --ui-text: var(--text-primary);
  --ui-text-invert: var(--text-inverse);
  --ui-muted: var(--text-secondary);
  --ui-primary: var(--brand-primary);
  --ui-primary-dark: var(--brand-primary-hover);
  --ui-accent: var(--brand-accent);
  --ui-accent-dark: var(--brand-accent-hover);
  --ui-line: var(--border-default);
  --ui-line-light: var(--gray-200);
  --ui-radius: var(--radius-lg);
  --ui-radius-sm: var(--radius-md);
  --ui-shadow: var(--shadow-card);
  --ui-shadow-soft: var(--shadow-card);
}

/* ── Reset & Base ── */
* { box-sizing: border-box; }
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
[hidden] { display: none !important; }
html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--surface-page);
}

a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--brand-primary-hover); text-decoration: underline; }
img, svg { max-width: 100%; }
body::before { display: none; }

/* ── Layout ── */
.container-fluid,
.main-container,
.container,
.main {
  width: 100%;
  max-width: none;
  padding-left: 24px;
  padding-right: 24px;
  color: var(--text-primary);
}

.main-container {
  margin: 0 0 0 260px;
  width: calc(100% - 260px);
  max-width: none;
  padding: 22px 26px 60px;
  box-sizing: border-box;
}

body.sidebar-collapsed .main-container,
body.sidebar-collapsed .container,
body.sidebar-collapsed .main,
html.sidebar-collapsed .main-container,
html.sidebar-collapsed .container,
html.sidebar-collapsed .main {
  width: calc(100% - 72px) !important;
  margin-left: 72px !important;
}

body.sidebar-hidden .main-container,
html.sidebar-hidden .main-container,
body.modal-open .main-container,
html.modal-open .main-container {
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: auto !important;
}

@media (max-width: 1024px) {
  .app-sidebar {
    width: 200px;
  }

  .main-container {
    width: calc(100% - 200px);
    margin-left: 200px;
  }
}

@media (max-width: 760px) {
  .app-sidebar {
    width: min(236px, calc(100vw - 20px));
    display: block;
    transform: translateX(-100%);
    will-change: transform;
  }

  .main-container {
    width: 100% !important;
    margin-left: 0 !important;
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ── Sidebar ── */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  height: 100vh;
  z-index: 30;
  overflow-y: auto;
  padding: 0;
  border: none;
  border-right: 1px solid rgba(0,0,0,0.08);
  border-radius: 0;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  backdrop-filter: blur(10px);
  transition: transform .3s ease, opacity .3s ease, visibility .3s ease;
}

/* Collapsed sidebar (compact icons only) */
body.sidebar-collapsed .app-sidebar,
html.sidebar-collapsed .app-sidebar {
  width: 72px !important;
}
body.sidebar-collapsed .sidebar-brand-text,
html.sidebar-collapsed .sidebar-brand-text {
  display: none !important;
}
body.sidebar-collapsed .sidebar-menu-link span:not(.sidebar-menu-icon),
html.sidebar-collapsed .sidebar-menu-link span:not(.sidebar-menu-icon) {
  display: none !important;
}
body.sidebar-collapsed .sidebar-menu-link,
html.sidebar-collapsed .sidebar-menu-link {
  justify-content: center;
}
body.sidebar-collapsed .sidebar-user-email,
html.sidebar-collapsed .sidebar-user-email { display:none !important; }

/* Hidden sidebar overlay for mobile */
body.sidebar-hidden .app-sidebar,
html.sidebar-hidden .app-sidebar {
  transform: translateX(-100%) !important;
  box-shadow: none;
}
body.sidebar-hidden .main-container,
html.sidebar-hidden .main-container { margin-left: 0 !important; }

body.alms-page .app-sidebar,
html.alms-page .app-sidebar {
  display: none !important;
}
body.alms-page .main-container,
html.alms-page .main-container {
  width: 100% !important;
  margin-left: 0 !important;
  max-width: none !important;
}

.sidebar-card {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.sidebar-card-header {
  position: relative;
  padding: 24px 20px;
  color: var(--text-inverse);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
  border-radius: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  text-decoration: none;
  transition: all 0.3s ease;
}

.sidebar-brand:hover {
  transform: translateX(4px);
}

.sidebar-brand-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--text-inverse);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
}

.sidebar-brand:hover .sidebar-brand-icon {
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
  transform: scale(1.05);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-brand-text strong {
  display: block;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

.sidebar-brand-text span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.sidebar-user-section {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.sidebar-user-section:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.sidebar-user-label {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-user-name {
  margin: 0;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.3;
}

/* ── Sidebar Navigation ── */
.sidebar-card-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 16px 24px;
}

.sidebar-menu-label {
  padding: 8px 16px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 12px;
  margin-bottom: 4px;
}

.sidebar-menu-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 16px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  transition: all 0.3s ease;
  margin-bottom: 2px;
}

.sidebar-menu-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  text-decoration: none;
}

.sidebar-menu-link.active {
  color: #ffffff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  font-weight: 600;
  transform: translateX(4px);
}

.sidebar-menu-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: none;
  color: inherit;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.sidebar-menu-link:hover .sidebar-menu-icon,
.sidebar-menu-link.active .sidebar-menu-icon {
  opacity: 1;
  color: #ffffff;
}

.sidebar-menu-link.active .sidebar-menu-icon {
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.3));
}
.sidebar-footer {
  margin: 0;
  padding: 20px 16px 24px;
  color: rgba(255, 255, 255, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.sidebar-footer-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer-text {
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.sidebar-footer-user {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 500;
}

/* ── Topbar ── */
.topbar {
  margin: 0 0 18px 0 !important;
  padding: 16px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-primary);
  border: none;
  border-bottom: 1px solid var(--border-default);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transition: none;
}
body.sidebar-collapsed .topbar,
html.sidebar-collapsed .topbar { margin-left: 0 !important; }
body.sidebar-hidden .topbar,
html.sidebar-hidden .topbar,
body.modal-open .topbar,
html.modal-open .topbar { margin-left: 0 !important; margin-right: 0 !important; }
.main > .topbar {
  margin: 0 0 18px 0 !important;
}

.topbar h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: var(--weight-bold);
}
.topbar-subtitle,
.small,
.small-muted {
  color: var(--text-muted) !important;
  font-size: var(--text-sm);
}
.topbar-actions,
.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* ── Top Nav ── */
.top-nav {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: auto !important;
  min-height: 56px !important;
  transform: none;
  color: var(--text-inverse);
  border: none;
  border-radius: 0;
  background: var(--surface-header-band) !important;
  box-shadow: none;
  backdrop-filter: none;
}
.top-nav-inner {
  max-width: none !important;
  padding: 10px 16px !important;
}
.nav-left .brand svg {
  width: 100px;
  height: 40px;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}
.nav-left .brand svg rect { fill: #ffffff; }
.nav-left .brand svg text { fill: var(--teal-800); }
.nav-center {
  gap: 4px !important;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}
.nav-link {
  color: rgba(255, 255, 255, 0.8) !important;
  border-radius: var(--radius-md) !important;
  padding: 8px 14px !important;
  font-size: var(--text-sm);
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}
.nav-link.active {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.2) !important;
  box-shadow: none;
  font-weight: var(--weight-medium);
}
.nav-right .user-bubble {
  color: var(--text-inverse) !important;
  background: rgba(255,255,255,0.15) !important;
  border: none;
}

.sidebar-toggle {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--text-primary) !important;
  background: var(--white) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: none !important;
  cursor: pointer;
}

/* ── Buttons ── */
.btn,
.btn-primary,
.btn-secondary,
.btn-login,
.btn-action,
.btn-ghost,
button[type="submit"],
input[type="submit"] {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.3;
  text-decoration: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-login:hover,
.btn-action:hover,
.btn-ghost:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
  transform: none;
  background: var(--gray-050);
  box-shadow: none;
}
.btn-primary,
.btn-login,
.btn-action,
button[type="submit"],
input[type="submit"] {
  color: var(--text-inverse) !important;
  border-color: var(--brand-primary) !important;
  background: var(--brand-primary) !important;
}
.btn-primary:hover,
.btn-login:hover,
.btn-action:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
  background: var(--brand-primary-hover) !important;
  border-color: var(--brand-primary-hover) !important;
}
.btn-secondary,
.btn-ghost {
  color: var(--text-primary) !important;
  background: var(--white) !important;
  border-color: var(--border-default) !important;
}
.btn-secondary:hover,
.btn-ghost:hover {
  background: var(--gray-050) !important;
}

/* ── Cards & Panels ── */
.panel,
.panel-card,
.card,
.search-card,
.result-card,
.record-card,
.stat-card,
.filter-panel,
.info-card,
.login-container,
.summary-cards > *,
.card-summary,
.table-wrapper,
.table-panel,
.modal-content {
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--surface-card) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-card) !important;
}

.panel h1, .panel h2, .panel h3,
.panel-card h1, .panel-card h2, .panel-card h3,
.card h1, .card h2, .card h3,
.record-card h1, .record-card h2, .record-card h3,
.login-container h1,
.records-title,
.page-title h1,
.page-header h1 {
  color: var(--text-primary);
}
.panel h1, .panel h2, .panel h3,
.panel-card h1, .panel-card h2, .panel-card h3,
.card h1, .card h2, .card h3,
.record-card h1, .record-card h2, .record-card h3,
.login-container h1,
.records-title {
  color: var(--text-primary) !important;
}
.page-title p,
.page-header p,
.sub {
  color: var(--text-muted) !important;
}

.stat-card .label,
.detail-label,
.filter-panel label,
.record-label,
.form-group label,
.panel-subtitle,
.muted {
  color: var(--text-muted) !important;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.stat-card .value,
.detail-value,
.record-barcode,
.info-value,
.card-summary .v {
  color: var(--text-primary) !important;
  font-weight: var(--weight-bold);
}

/* ── Forms ── */
input,
select,
textarea,
.form-input,
.form-select,
.form-textarea {
  color: var(--text-primary) !important;
  background: var(--white) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-md) !important;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  padding: 7px 10px;
}
input:focus,
select:focus,
textarea:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none !important;
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 3px rgba(58, 148, 228, 0.15) !important;
}
input::placeholder,
textarea::placeholder { color: var(--text-muted) !important; }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: var(--text-sm);
}
thead th,
.table-panel thead th {
  text-align: left;
  padding: 10px 14px;
  font-weight: var(--weight-medium);
  color: var(--text-primary) !important;
  background: var(--surface-table-head) !important;
  border: 0 !important;
  border-bottom: 1px solid var(--border-strong) !important;
}
tbody td,
.table-panel tbody td {
  padding: 10px 14px;
  color: var(--text-primary) !important;
  border-top: none !important;
  border-bottom: 1px solid var(--border-default) !important;
}
tbody tr:nth-child(even),
.table-panel tbody tr:nth-child(even) {
  background: var(--surface-row-alt) !important;
}
tbody tr:hover,
.table-panel tbody tr:hover {
  background: var(--blue-50) !important;
}

/* ── Badges ── */
.badge,
.status-pill,
.filter-tag,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  color: var(--text-primary) !important;
  border: none !important;
  border-radius: var(--radius-pill) !important;
  background: var(--gray-100) !important;
  font-size: 11px;
  font-weight: 600;
}

/* ── Alerts ── */
.alert,
.alert-box,
.empty,
.loading,
.error,
.hint-box {
  border-radius: var(--radius-md) !important;
  box-shadow: none !important;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  body:not(.sidebar-collapsed) .app-sidebar,
  html:not(.sidebar-collapsed) .app-sidebar {
    transform: translateX(0);
  }
  .topbar,
  body.sidebar-collapsed .topbar,
  html.sidebar-collapsed .topbar {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .main-container,
  .container,
  .main {
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}

body.modal-open .app-sidebar,
html.modal-open .app-sidebar,
body.sidebar-hidden .app-sidebar,
html.sidebar-hidden .app-sidebar {
  transform: translateX(-100%) !important;
  pointer-events: none !important;
  opacity: 0.98;
}

/* Overlay used on mobile when sidebar is open */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 20010;
  display: none;
  -webkit-tap-highlight-color: transparent;
}
/* Show overlay only on small screens when the sidebar is visible (i.e. NOT hidden) */
@media (max-width: 900px) {
  body:not(.sidebar-hidden) .sidebar-overlay,
  html:not(.sidebar-hidden) .sidebar-overlay {
    display: block;
  }

  /* Ensure sidebar floats above overlay on mobile */
  .app-sidebar { z-index: 20020; }

  /* When not hidden, slide the sidebar into view on mobile */
  body:not(.sidebar-hidden) .app-sidebar,
  html:not(.sidebar-hidden) .app-sidebar {
    transform: translateX(0) !important;
    pointer-events: auto !important;
  }
}

.sidebar-toggle { z-index: 20000; position: relative; }
/* Fixed hamburger in top-left for easy access */
.sidebar-toggle { position: fixed !important; left: 12px; top: 12px; z-index: 20050 !important; }

/* Hide hamburger on desktop widths (keep for mobile) */
@media (min-width: 901px) {
  .sidebar-toggle,
  [data-toggle-sidebar],
  #sidebarToggle {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    border-radius: 0;
  }
  .topbar-actions,
  .form-inline {
    width: 100%;
    margin-left: 0;
  }
  .topbar-actions .btn,
  .form-inline .btn {
    flex: 1 1 130px;
  }
  .app-sidebar {
    top: 0;
    left: 0;
    bottom: 0;
    width: min(236px, calc(100vw - 20px));
  }
}

/* Table and records responsive improvements */
.table-responsive { width:100%; overflow:auto; -webkit-overflow-scrolling: touch; }
.table-panel { padding: 12px; }
.table-panel table { border-radius: 8px; overflow: hidden; }
.record-card { transition: box-shadow .18s ease, transform .12s ease; }
.record-card:hover { transform: translateY(-4px); box-shadow: 0 10px 30px rgba(0,0,0,0.08); }

/* Responsive: stack table rows into card-like blocks on very small screens */
@media (max-width: 560px) {
  .table-panel thead { display: none; }
  .table-panel tbody td { display: block; width: 100%; }
  .table-panel tbody tr { display: block; margin-bottom: 12px; border-radius: 10px; overflow: hidden; }
}

/* Modal lock and stacking fixes */
body.modal-open, html.modal-open {
  overflow: hidden !important;
}
.modal {
  z-index: 11000;
}
.modal .modal-dialog {
  z-index: 11010;
}
