/* ============================================
   ROOT VARIABLES & GLOBAL STYLES
   ============================================ */
:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --info-color: #2563eb;
    
    --text-dark: #2d3748;
    --text-light: #718096;
    --text-muted: #a0aec0;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 70px;
    
    --transition-speed: 0.3s;
    --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Responsive font sizes using clamp for fluid typography */
    --fs-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --fs-sm: clamp(0.875rem, 0.825rem + 0.25vw, 1rem);
    --fs-base: clamp(0.938rem, 0.875rem + 0.3vw, 1.125rem);
    --fs-md: clamp(1rem, 0.925rem + 0.375vw, 1.25rem);
    --fs-lg: clamp(1.125rem, 1rem + 0.625vw, 1.5rem);
    --fs-xl: clamp(1.5rem, 1.25rem + 1.25vw, 2.25rem);
    --fs-2xl: clamp(1.875rem, 1.5rem + 1.875vw, 3rem);
    
    /* Responsive spacing */
    --spacing-xs: clamp(0.25rem, 0.2rem + 0.25vw, 0.375rem);
    --spacing-sm: clamp(0.5rem, 0.4rem + 0.5vw, 0.75rem);
    --spacing-md: clamp(0.75rem, 0.6rem + 0.75vw, 1.125rem);
    --spacing-lg: clamp(1rem, 0.8rem + 1vw, 1.5rem);
    --spacing-xl: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}

html {
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape */
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-secondary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Visible keyboard focus everywhere (mouse clicks unaffected) */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================
   SIDEBAR STYLES
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    transition: all var(--transition-speed) var(--transition-timing);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: var(--topbar-height);
}

.sidebar .logo {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar .logo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* Expanded: the wordmark (logo as the "A" + NCHOR). Collapsed: the logo mark alone. */
.sidebar:not(.collapsed) .logo {
    display: none;
}

.sidebar-wordmark {
    display: block;
    height: 34px;
    width: auto;
}

.sidebar-title {
    font-size: 24px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-speed) var(--transition-timing);
    letter-spacing: -0.5px;
}

.sidebar.collapsed .sidebar-title {
    opacity: 0;
    width: 0;
}

.sidebar-close {
    display: none;
    margin-left: auto;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: all 0.2s;
}

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

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 20px 12px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: auto;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

/* Menu Group Header */
.sidebar-menu li.menu-group-header {
    margin-top: 20px;
    margin-bottom: 8px;
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-menu li.menu-group-header span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-menu li.menu-group-header i {
    font-size: 10px;
}

/* Submenu Items */
.sidebar-menu li.submenu-item {
    margin-left: 12px;
    margin-bottom: 2px;
}

.sidebar-menu li.submenu-item a {
    padding-left: 24px;
}

.sidebar-menu li.submenu-item a::before {
    width: 2px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    font-weight: 500;
}

.sidebar-menu a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    transform: scaleY(0);
    transition: transform 0.2s;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateX(2px);
}

.sidebar-menu a:hover::before {
    transform: scaleY(1);
}

.sidebar-menu li.active a {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.sidebar-menu li.active a::before {
    transform: scaleY(1);
}

.sidebar-menu a i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-menu a span {
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-speed) var(--transition-timing);
}

/* A long label (e.g. "Relief of Accountability") must not push its badge past the
   link's clipped edge: the label truncates, the badge keeps its size. */
.sidebar-menu a span:not(.notification-badge) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-menu a .notification-badge {
    flex-shrink: 0;
}

/* Notification Badge */
.notification-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: linear-gradient(135deg, #f5576c, #f093fb);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    margin-left: auto;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.4);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(245, 87, 108, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 3px 12px rgba(245, 87, 108, 0.6);
    }
}

.sidebar.collapsed .notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    padding: 0 4px;
}

.sidebar.collapsed .sidebar-menu a span {
    opacity: 0;
    width: 0;
}

/* Collapsed sidebar - hide menu group headers and adjust submenu items */
.sidebar.collapsed .sidebar-menu li.menu-group-header {
    display: none;
}

.sidebar.collapsed .sidebar-menu li.submenu-item {
    margin-left: 0;
}

.sidebar.collapsed .sidebar-menu li.submenu-item a {
    padding-left: 16px;
}

.sidebar-menu a.logout-link {
    color: rgba(245, 87, 108, 0.9);
}

.sidebar-menu a.logout-link:hover {
    background: rgba(245, 87, 108, 0.1);
    color: #f87171; /* light red — readable on the dark sidebar */
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-user-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-footer-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: rgba(245, 87, 108, 0.9);
    text-decoration: none;
    flex-shrink: 0;
    transition: all var(--transition-speed) var(--transition-timing);
}

.sidebar-footer-logout:hover {
    background: rgba(245, 87, 108, 0.1);
    color: #f87171; /* light red — readable on the dark sidebar */
}

.sidebar-footer-logout i {
    font-size: 18px;
}

.sidebar-user-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-speed) var(--transition-timing);
}

.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .sidebar-user-meta {
    display: none;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
    padding: 14px 10px;
}

.sidebar.collapsed .sidebar-footer-logout {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
}

.sidebar.collapsed .sidebar-footer-logout:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary-color));
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   MAIN CONTENT LAYOUT
   ============================================ */
.dashboard {
    display: flex;
    flex-wrap: wrap;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.main-content {
    flex: 1;
    /* Flex items default to min-width:auto, so one wide child (table, long
       select) used to stretch the whole page sideways. 0 keeps the overflow
       inside the child's own scroller. */
    min-width: 0;
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    transition: margin-left var(--transition-speed) var(--transition-timing);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--topbar-height));
    padding: 0;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ============================================
   TOPBAR STYLES
   ============================================ */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px 0 0;
    box-shadow: var(--shadow-sm);
    z-index: 999;
    transition: left var(--transition-speed) var(--transition-timing);
}

.sidebar.collapsed ~ .topbar {
    left: var(--sidebar-collapsed-width);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-left: 24px;
}

.topbar-left h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

/* Page title responsive */
.page-title-full {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.page-title-mobile {
    display: none;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-dark);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--primary-color);
    color: #fff;
    transform: scale(1.05);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-info:hover {
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-sm);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #fff;
    font-size: 14px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-dark);
    line-height: 1.2;
}

.user-role {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.2;
}

/* ============================================
   CONTENT AREA
   ============================================ */
.content-area {
    flex: 1;
    padding: 24px;
}

/* ============================================
   CARD STYLES
   ============================================ */
.card {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.card-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-header h3 i {
    font-size: 22px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card-header > div {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Action button group styling */
.action-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.action-buttons .btn {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.action-buttons .btn-secondary {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    position: relative;
}

.action-buttons .btn-secondary i {
    color: #667eea;
}

.action-buttons .btn-primary {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.action-buttons .btn-primary::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.action-buttons .btn-primary:hover::after {
    opacity: 0.3;
}

.card-body {
    padding: 24px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-card-info h3 {
    margin-bottom: 10px;
    font-size: 32px;
    font-weight: 700;
}

.stat-card-info p {
    margin: 0;
    opacity: 0.9;
    font-size: 14px;
}

.stat-card-icon {
    font-size: 48px;
    opacity: 0.5;
}

.stat-card.purple {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-card.pink {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card.blue {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-card.green {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

/* ============================================
   TABLE STYLES
   ============================================ */
.table-responsive {
    /* overflow-x must win: a trailing `overflow: hidden` used to clip wide
       tables on tablets/laptops. overflow-y stays hidden for the rounded corners. */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
}

.table thead {
    background: var(--bg-secondary);
    color: var(--text-dark);
}

.table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    border: none;
    border-bottom: 2px solid var(--border-color);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-dark);
    font-size: 13px;
    vertical-align: middle;
}

.table tbody tr {
    transition: all 0.15s ease;
    background: white;
}

.table tbody tr:hover {
    background: #f8fafc;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

/* ============================================
   BADGE STYLES
   ============================================ */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-create {
    background: rgba(67, 233, 123, 0.15);
    color: var(--success-color);
}

.badge-update {
    background: rgba(79, 172, 254, 0.15);
    color: var(--info-color);
}

.badge-delete {
    background: rgba(245, 87, 108, 0.15);
    color: var(--danger-color);
}

.badge-login {
    background: rgba(102, 126, 234, 0.15);
    color: var(--primary-color);
}

.badge-success {
    background: rgba(67, 233, 123, 0.15);
    color: var(--success-color);
}

.badge-danger {
    background: rgba(245, 87, 108, 0.15);
    color: var(--danger-color);
}

.badge-info {
    background: rgba(79, 172, 254, 0.15);
    color: var(--info-color);
}

.badge-warning {
    background: rgba(255, 167, 38, 0.15);
    color: var(--warning-color);
}

/* ============================================
   CREATE-PAGE FIELD GRID (shared)
   Sections stay full width and stack; the inputs
   INSIDE a section sit two-up so short fields don't
   stretch across the whole page. .full-width spans
   both columns (textareas, tables).
   ============================================ */
.create-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
}

.create-details-grid .full-width {
    grid-column: 1 / -1;
}

@media (max-width: 700px) {
    .create-details-grid {
        grid-template-columns: 1fr;
    }
}

/* Compact inline hint — replaces bulky instruction banners */
.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-light);
}

.section-hint {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 0 0 12px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-light);
}

.section-hint i {
    color: var(--info-color);
    flex-shrink: 0;
}

/* ============================================
   STAT CARDS (shared KPI/status summary cards)
   Base structure only — per-module status accent
   variants (.pending/.approved/…) stay in each page.
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Only clickable cards (status filters etc.) get the pointer + lift */
.stat-card.clickable,
.stat-card[data-status] {
    cursor: pointer;
}

.stat-card.clickable:hover,
.stat-card[data-status]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 2px;
}

.stat-card-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .stat-card {
        padding: 16px;
    }
    .stat-card-value {
        font-size: 24px;
    }
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    position: relative;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn i {
    font-size: 15px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
    border: 2px solid transparent;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5568d3 0%, #653a8c 100%);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.btn-secondary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

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

.btn-success:hover:not(:disabled) {
    background: #15803d;
}

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

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

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

.btn-warning:hover:not(:disabled) {
    background: #b45309;
}

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

.btn-info:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* Standardized action button variants (applied by common.js) */
.btn.btn-action-add,
.btn.btn-action-search,
.btn.btn-action-edit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #ffffff !important;
    border: 2px solid transparent !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35) !important;
}

.btn.btn-action-add:hover:not(:disabled),
.btn.btn-action-search:hover:not(:disabled),
.btn.btn-action-edit:hover:not(:disabled) {
    background: linear-gradient(135deg, #5568d3 0%, #653a8c 100%) !important;
    color: #ffffff !important;
}

.btn.btn-action-clear,
.btn.btn-action-close {
    background: #ffffff !important;
    color: var(--text-dark) !important;
    border: 2px solid var(--border-color) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06) !important;
}

.btn.btn-action-clear:hover:not(:disabled),
.btn.btn-action-close:hover:not(:disabled) {
    background: var(--bg-secondary) !important;
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
}

.btn.btn-action-delete {
    background: var(--danger-color) !important;
    color: #ffffff !important;
    border: 2px solid transparent !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3) !important;
}

.btn.btn-action-delete:hover:not(:disabled) {
    background: #b91c1c !important;
    color: #ffffff !important;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.mr-1 { margin-right: 8px !important; }
.mr-2 { margin-right: 12px !important; }
.mr-3 { margin-right: 16px !important; }
.ml-1 { margin-left: 8px !important; }
.ml-2 { margin-left: 12px !important; }
.ml-3 { margin-left: 16px !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 12px !important; }
.mt-3 { margin-top: 16px !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 12px !important; }
.mb-3 { margin-bottom: 16px !important; }

.gap-1 { gap: 8px !important; }
.gap-2 { gap: 12px !important; }
.gap-3 { gap: 16px !important; }

.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }

/* Responsive utilities */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

/* Display utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }

/* Mobile-specific utilities */
@media (max-width: 768px) {
    .mobile-hide { display: none !important; }
    .mobile-show { display: block !important; }
    .mobile-text-center { text-align: center !important; }
    .mobile-full-width { width: 100% !important; }
    .mobile-no-padding { padding: 0 !important; }
    .mobile-stack { flex-direction: column !important; }
}

/* Desktop-specific utilities */
@media (min-width: 769px) {
    .desktop-hide { display: none !important; }
    .desktop-show { display: block !important; }
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 13px;
}

.form-text {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-light);
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-dark);
    font-family: inherit;
}

/* One control height everywhere so inputs, selects and Select2 line up */
input.form-control,
select.form-control {
    height: 45px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

.form-control:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar .form-control {
    flex: 1;
    min-width: 200px;
}

/* Render filter <select>s as styled controls (not OS-native widgets) so they
   respect z-index and don't paint above modals that use backdrop-filter. */
.filter-bar select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2012%208'%3E%3Cpath%20fill='%236b7280'%20d='M1.41%200L6%204.58%2010.59%200%2012%201.41%206%207.41%200%201.41z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
}

/* Form Row Grid */
.form-row {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.form-row.cols-2 {
    grid-template-columns: 1fr 1fr;
}

.form-row.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-row .form-group {
    margin-bottom: 0;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999; /* Increased z-index to ensure modal appears above all content */
    backdrop-filter: blur(4px);
    animation: modalFadeIn 0.3s ease-out;
    overflow: hidden;
    padding: 20px 10px; /* Add padding for mobile */
}

.modal.closing {
    animation: modalFadeOut 0.3s ease-in;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 95%;
    max-width: 680px;
    max-height: 90vh;
    overflow: visible;
    box-shadow: var(--shadow-xl);
    transition: all 0.3s ease;
    margin: auto; /* Center vertically */
    position: relative;
    z-index: 100000; /* Ensure modal content appears above overlay */
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

.modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-dark);
}

.modal-body {
    padding: 20px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg-secondary);
}

/* ============================================
   MODAL SCROLL INTEGRITY
   Wrapper elements (a <form>, or a .modal-tab-content pane shown as
   display:block by jQuery .show()) sit between the flex-column
   .modal-content and the .modal-body. That broke the flex scroll chain:
   the body never scrolled, long forms spilled past max-height (content is
   overflow:visible), and per-modal sticky footers then floated over the
   spilled content. Bound the wrapper itself so the body scrolls and the
   footer stays in flow at the wrapper's bottom — no sticky, no spill.
   ============================================ */

/* Single-form modals: .modal-content > form (stock, edit-category).
   .modal-content is already a flex column with a max-height, so the form
   is a real flex item here — flex:1 + min-height:0 is enough. */
.modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* Tabbed modals: .modal-content > .modal-tab-content > form (employee,
   asset). The tab pane renders as display:block, so the form is NOT a
   flex item of a flex parent — flex:1 can't bound it. Bound it directly
   with its own max-height (leaves room for the header above it). */
.modal-tab-content > form {
    display: flex;
    flex-direction: column;
    max-height: calc(90vh - 64px);
    overflow: hidden;
}

/* The scroller and the in-flow footer, for every wrapper shape. */
.modal-content > form > .modal-body,
.modal-tab-content > form > .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.modal-content > form > .modal-footer,
.modal-tab-content > form > .modal-footer {
    flex-shrink: 0;
}

/* Form-less tab pane (e.g. details view): bound the body directly,
   reserving header + footer height. */
.modal-tab-content > .modal-body {
    max-height: calc(90vh - 124px);
    overflow-y: auto;
}

/* ============================================
   ASSET DETAILS VIEW
   ============================================ */
.detail-section {
    margin-bottom: 30px;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.detail-section h4 i {
    font-size: 1.2em;
    color: var(--primary-color);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.detail-item:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.detail-item label {
    font-weight: 600;
    color: #6c757d;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0;
}

.detail-item strong {
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.95em;
    line-height: 1.4;
}

/* Full width detail items */
.detail-item[style*="grid-column: 1 / -1"] {
    grid-column: 1 / -1;
}

/* View mode specific styles */
.modal-content.view-mode .details-grid {
    animation: fadeIn 0.3s ease-in-out;
}

.modal-content.view-mode .detail-section {
    animation: slideInUp 0.3s ease-in-out;
    animation-fill-mode: both;
}

.modal-content.view-mode .detail-section:nth-child(1) {
    animation-delay: 0.1s;
}

.modal-content.view-mode .detail-section:nth-child(2) {
    animation-delay: 0.2s;
}

.modal-content.view-mode .detail-section:nth-child(3) {
    animation-delay: 0.3s;
}

.modal-content.view-mode .detail-section:nth-child(4) {
    animation-delay: 0.4s;
}

/* Badge styles for status */
.badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    color: #ffffff;
    background-color: #28a745;
}

.badge-info {
    color: #ffffff;
    background-color: #17a2b8;
}

.badge-warning {
    color: #212529;
    background-color: #ffc107;
}

.badge-secondary {
    color: #ffffff;
    background-color: #6c757d;
}

/* Loading state for view mode */
.details-loading {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.details-loading i {
    font-size: 2em;
    margin-bottom: 10px;
    animation: spin 1s linear infinite;
}

/* Category disabled note styling */
.category-disabled-note {
    font-size: 0.8em;
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 6px 10px;
    border-radius: 4px;
    margin-top: 5px;
    font-style: italic;
}

/* Form validation styling */
.form-group.field-error .form-control {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-group.field-success .form-control {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.field-error-message {
    color: #dc3545;
    font-size: 0.8em;
    margin-top: 5px;
    font-style: italic;
}

.form-group.field-error label {
    color: #dc3545;
}

.form-group.field-success label {
    color: #28a745;
}

/* Modal tab content animations */
.modal-tab-content {
    animation: fadeIn 0.3s ease-in-out;
    position: relative; /* containing block for .modal-loading-overlay */
}

/* Inline load state for View/Edit Employee: shown the instant the modal
   opens (before the AJAX resolves) so clicking never looks unresponsive,
   even on a slow request. Reuses .loading-overlay's positioning/backdrop. */
.modal-loading-overlay {
    border-radius: inherit;
    flex-direction: column;
    gap: 10px;
}

.modal-loading-overlay span {
    font-size: 13px;
    color: var(--text-light, #6b7280);
}

/* ============================================
   PAGINATION
   ============================================ */
#pagination {
    margin-top: 20px;
    text-align: center;
}

.pagination {
    display: inline-flex;
    gap: 5px;
}

#pagination .btn {
    min-width: 40px;
    justify-content: center;
}

/* ============================================
   LOGIN PAGE STYLES
   ============================================ */
/* ============================================
   LOGIN — split-screen, scoped tokens
   ============================================ */
.login-page {
    --lg-ink: #0f172a;
    --lg-slate: #1e293b;
    --lg-accent: #4f46e5;
    --lg-accent-soft: #6366f1;
    --lg-line: #e7e9f1;
    --lg-field: #f6f7fb;
    --lg-text: #1f2733;
    --lg-muted: #6b7385;

    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vw, 40px);
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
    color: var(--lg-text);
    background:
        radial-gradient(900px 600px at 12% 8%, #eef0f9 0%, transparent 55%),
        radial-gradient(800px 700px at 100% 100%, #e8ecf6 0%, transparent 50%),
        #eef1f6;
    -webkit-font-smoothing: antialiased;
}

.login-shell {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    width: 100%;
    max-width: 920px;
    background: var(--bg-primary);
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 24px;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.6) inset,
        0 30px 60px -24px rgba(15, 23, 42, 0.45),
        0 12px 24px -18px rgba(79, 70, 229, 0.35);
    animation: loginRise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

/* ---- Brand panel (dark, textured) ---- */
.login-brand {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 32px;
    padding: clamp(28px, 3.4vw, 48px);
    color: #eef1f8;
    background:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 1.4px) 0 0 / 22px 22px,
        linear-gradient(165deg, var(--lg-slate) 0%, var(--lg-ink) 100%);
}

.login-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(420px 300px at 78% 8%, rgba(99, 102, 241, 0.45), transparent 60%),
        radial-gradient(380px 320px at 6% 100%, rgba(56, 189, 248, 0.16), transparent 60%);
}

.login-brand__top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand__mark {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: #fff;
    border-radius: 13px;
    background: linear-gradient(150deg, var(--lg-accent-soft), var(--lg-accent));
    box-shadow:
        0 6px 16px -4px rgba(79, 70, 229, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.login-brand__name {
    display: flex;
    flex-direction: column;
    gap: 8px;
    line-height: 1.15;
}

.login-brand__wordmark {
    display: block;
    height: 44px;
    width: auto;
}

.login-brand__org {
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: 0.01em;
    color: rgba(238, 241, 248, 0.68);
}

.login-brand__expansion {
    margin: 0 0 16px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(238, 241, 248, 0.62);
}

.login-brand__expansion span {
    display: block;
}

.login-brand__expansion b {
    color: #EAA000;
    font-weight: 800;
}

.login-brand__title {
    margin: 0 0 16px;
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.login-brand__lede {
    margin: 0;
    max-width: 34ch;
    font-size: 14.5px;
    line-height: 1.65;
    color: rgba(238, 241, 248, 0.72);
}

.login-brand__meta {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.login-brand__meta li {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 13.5px;
    color: rgba(238, 241, 248, 0.82);
}

.login-brand__meta i {
    color: var(--lg-accent-soft);
    font-size: 14px;
    width: 18px;
    text-align: center;
}

/* ---- Form panel (light) ---- */
.login-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(30px, 3.4vw, 48px);
}

.login-panel__head {
    margin-bottom: 26px;
}

.login-panel__head h1 {
    margin: 0 0 6px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--lg-ink);
}

.login-panel__head p {
    margin: 0;
    font-size: 14.5px;
    color: var(--lg-muted);
}

.login-form .form-group {
    margin-bottom: 18px;
}

.login-form label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    color: var(--lg-text);
    font-size: 13px;
    letter-spacing: 0.005em;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper > i {
    position: absolute;
    left: 15px;
    color: var(--lg-muted);
    font-size: 14px;
    z-index: 1;
    transition: color 0.2s ease;
}

.input-wrapper input {
    width: 100%;
    padding: 13px 14px 13px 44px;
    font: inherit;
    font-size: 14.5px;
    color: var(--lg-text);
    border-radius: 12px;
    border: 1.5px solid var(--lg-line);
    background: var(--lg-field);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-wrapper input::placeholder {
    color: #aeb4c2;
}

.input-wrapper input:focus {
    border-color: var(--lg-accent-soft);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
    outline: none;
}

.input-wrapper input:focus + .password-toggle,
.input-wrapper input:focus ~ i,
.input-wrapper:focus-within > i {
    color: var(--lg-accent);
}

.input-wrapper .password-toggle {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--lg-muted);
    cursor: pointer;
    padding: 7px;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.input-wrapper .password-toggle:hover {
    color: var(--lg-accent);
    background: rgba(99, 102, 241, 0.1);
}

.input-wrapper .password-toggle:focus-visible {
    outline: 2px solid var(--lg-accent-soft);
    outline-offset: 1px;
}

.input-wrapper .password-toggle i {
    position: static;
    font-size: 15px;
}

/* Hide browser default password reveal buttons for input-wrapper */
.input-wrapper input[type="password"]::-webkit-credentials-auto-fill-button {
    display: none !important;
}

.input-wrapper input[type="password"]::-ms-reveal {
    display: none;
}

.input-wrapper input[type="password"] {
    appearance: none;
    -webkit-appearance: none;
}

.login-btn {
    width: 100%;
    margin-top: 6px;
    padding: 13px 18px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: 12px;
    background: var(--lg-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    box-shadow: 0 10px 22px -8px rgba(79, 70, 229, 0.6);
}

.login-btn i {
    font-size: 13px;
}

.login-btn:hover {
    background: #4338ca;
    box-shadow: 0 14px 26px -8px rgba(79, 70, 229, 0.7);
}

.login-btn:active {
    transform: translateY(1px) scale(0.992);
    box-shadow: 0 8px 16px -8px rgba(79, 70, 229, 0.6);
}

.login-btn:focus-visible {
    outline: 2px solid var(--lg-accent-soft);
    outline-offset: 3px;
}

.login-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* ---- Self-registration view ---- */
.input-wrapper select {
    width: 100%;
    padding: 13px 14px 13px 44px;
    font: inherit;
    font-size: 14.5px;
    color: var(--lg-text);
    border-radius: 12px;
    border: 1.5px solid var(--lg-line);
    background: var(--lg-field);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-wrapper select:focus {
    border-color: var(--lg-accent-soft);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
    outline: none;
}

.login-shell.is-registering {
    max-width: 1060px;
    grid-template-columns: 0.85fr 1.15fr;
}

/* Keep the register view within one laptop screen at 100% zoom */
.login-page.is-registering {
    padding-top: 16px;
    padding-bottom: 16px;
}

.login-shell.is-registering .login-panel {
    padding-top: 26px;
    padding-bottom: 24px;
}

.login-shell.is-registering .login-panel__head {
    margin-bottom: 14px;
}

.login-shell.is-registering .login-panel__head h1 {
    font-size: 22px;
    margin-bottom: 4px;
}

.login-shell.is-registering .login-panel__head p {
    font-size: 13.5px;
}

.login-shell.is-registering .login-footer {
    display: none;
}

.register-form .form-group,
.register-form .form-row .form-group {
    margin-bottom: 10px;
}

.register-form .login-btn {
    margin-top: 4px;
    padding-top: 11px;
    padding-bottom: 11px;
}

.register-form .login-switch {
    margin-top: 10px;
}

.register-form .form-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 12px;
    margin-bottom: 0;
}

.register-form label {
    margin-bottom: 4px;
    font-size: 12.5px;
}

.register-form .input-wrapper input,
.register-form .input-wrapper select {
    padding-top: 9px;
    padding-bottom: 9px;
    font-size: 14px;
}

.register-form .req {
    color: #dc2626;
}

/* Registration: one searchable multi-select for the school(s) */
.reg-school-picker .select2-container--default .select2-selection--multiple {
    min-height: 40px;
    padding: 2px 6px;
    border: 1.5px solid var(--lg-line);
    border-radius: 12px;
    background: var(--lg-field);
}

.reg-school-picker .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--lg-accent-soft);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

.reg-school-picker .select2-search--inline .select2-search__field {
    margin-top: 7px;
    font: inherit;
    font-size: 14px;
}

.reg-school-hint {
    display: block;
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--lg-muted);
}

.hp-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.login-switch {
    margin: 16px 0 0;
    text-align: center;
    font-size: 13.5px;
    color: var(--lg-muted);
}

.login-link {
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--lg-accent);
    background: none;
    border: none;
    cursor: pointer;
}

.login-link:hover {
    text-decoration: underline;
}

.login-link:focus-visible {
    outline: 2px solid var(--lg-accent-soft);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (max-width: 760px) {
    .login-shell.is-registering {
        grid-template-columns: 1fr;
        max-width: 440px;
    }
}

@media (max-width: 560px) {
    .register-form .form-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-shell { animation: none; }
}

/* ---- Login responsive (self-contained) ---- */
@media (max-width: 760px) {
    .login-shell {
        grid-template-columns: 1fr;
        max-width: 440px;
    }
    .login-brand {
        gap: 22px;
        padding: 28px 26px;
    }
    .login-brand__expansion { font-size: 10.5px; margin-bottom: 10px; }
    .login-brand__meta { display: none; }
    .login-brand__title { font-size: 23px; margin-bottom: 8px; }
    .login-brand__lede { font-size: 13.5px; max-width: none; }
    .login-panel { padding: 28px 26px; }
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper .form-control {
    padding-right: 45px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password:hover {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
}

/* Hide browser default password reveal buttons */
input[type="password"]::-webkit-credentials-auto-fill-button {
    display: none !important;
}

input[type="password"]::-ms-reveal {
    display: none;
}

/* Ensure password input doesn't have default styling that conflicts */
input[type="password"] {
    appearance: none;
    -webkit-appearance: none;
}

.remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.remember-forgot .checkbox-label {
    font-weight: 500;
    color: var(--text-light);
    font-size: 13px;
}

.forgot-password {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.forgot-password:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
}

.login-footer {
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid var(--lg-line);
}

.login-footer p {
    margin: 0;
    color: var(--lg-muted);
    font-size: 12px;
    line-height: 1.6;
}

.login-footer__ver {
    color: #aeb4c2;
    font-variant-numeric: tabular-nums;
}

/* Alert Styles */
.alert {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
}

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

.alert i {
    font-size: 18px;
}

.alert-danger {
    background: rgba(245, 87, 108, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(245, 87, 108, 0.3);
}

.alert-success {
    background: rgba(67, 233, 123, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(67, 233, 123, 0.3);
}

.alert-info {
    background: rgba(79, 172, 254, 0.1);
    color: var(--info-color);
    border: 1px solid rgba(79, 172, 254, 0.3);
}

.alert-warning {
    background: rgba(255, 167, 38, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(255, 167, 38, 0.3);
}

/* ============================================
   HOW-TO PANEL (in-page guidance for transaction pages)
   ============================================ */
.how-to-panel {
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-left: 4px solid var(--info-color);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

.how-to-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
}

.how-to-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
}

.how-to-panel-title i {
    color: var(--info-color);
    font-size: 17px;
}

.how-to-panel-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--info-color);
    font-size: 13px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}

.how-to-panel-toggle:hover {
    background: rgba(37, 99, 235, 0.1);
}

.how-to-panel-body {
    padding: 0 18px 16px 18px;
}

.how-to-panel.collapsed .how-to-panel-body {
    display: none;
}

.how-to-steps {
    margin: 0;
    padding-left: 20px;
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.7;
}

.how-to-steps li {
    margin-bottom: 4px;
}

.how-to-steps li:last-child {
    margin-bottom: 0;
}

.how-to-notes {
    list-style: none;
    margin: 10px 0 0 0;
    padding: 10px 12px;
    background: rgba(217, 119, 6, 0.08);
    border: 1px solid rgba(217, 119, 6, 0.25);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-dark);
}

.how-to-notes li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.how-to-notes li:last-child {
    margin-bottom: 0;
}

.how-to-notes i {
    color: var(--warning-color);
    margin-top: 2px;
}

@media (max-width: 576px) {
    .how-to-panel-title {
        font-size: 14px;
    }
    .how-to-toggle-text {
        display: none;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center {
    text-align: center;
    padding: 40px !important;
}

.text-muted {
    color: #999;
}

/* ============================================
   LOADING SPINNER COMPONENT (Reusable)
   ============================================ */

/* Basic inline spinner - just the icon */
.loading-spinner {
    display: inline-block;
    font-size: 20px;
    color: var(--primary-color, #667eea);
    animation: spin 1s linear infinite;
}

/* Loading container - centered spinner with text */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--primary-color, #667eea);
}

.loading-container i {
    display: block;
    font-size: 32px;
    margin: 0 auto 12px;
    animation: spin 1s linear infinite;
}

.loading-container p,
.loading-container .loading-message {
    margin: 0;
    font-size: 14px;
    color: var(--text-light, #6b7280);
    animation: none !important;
}

/* Table loading state - inline spinner and text */
.table-loading {
    text-align: center;
    padding: 30px 20px;
}

.table-loading .loading-spinner {
    display: inline-block;
    margin-right: 8px;
}

.table-loading .loading-message {
    display: inline;
    font-size: 14px;
    color: var(--text-light, #6b7280);
    animation: none !important;
}

/* Loading overlay - full screen or contained */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-overlay.fixed {
    position: fixed;
}

.loading-overlay .loading-spinner {
    font-size: 48px;
}

/* Loading message without spinner */
.loading-message {
    margin: 0;
    padding: 10px 0;
    color: var(--text-light, #6b7280);
    font-size: 14px;
    animation: none !important;
}

/* Spinner size variants */
.loading-spinner.sm {
    font-size: 16px;
}

.loading-spinner.md {
    font-size: 24px;
}

.loading-spinner.lg {
    font-size: 32px;
}

.loading-spinner.xl {
    font-size: 48px;
}

/* Spinner color variants */
.loading-spinner.primary {
    color: var(--primary-color, #667eea);
}

.loading-spinner.success {
    color: var(--success-color, #10b981);
}

.loading-spinner.danger {
    color: var(--danger-color, #ef4444);
}

.loading-spinner.warning {
    color: var(--warning-color, #f59e0b);
}

.loading-spinner.muted {
    color: var(--text-muted, #9ca3af);
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(4px);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        backdrop-filter: blur(4px);
    }
    to {
        opacity: 0;
        backdrop-filter: blur(0);
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    /* Keep stacking order predictable on mobile:
       sidebar (top) > overlay > topbar/content */
    .sidebar {
        z-index: 1002;
    }

    .sidebar-overlay {
        z-index: 1001;
    }

    /* Login responsive handled in the login block above */
    .remember-forgot {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }
    
    .sidebar.collapsed.active {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: flex;
    }
    
    .main-content {
        margin-left: 0;
        margin-top: var(--topbar-height);
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }
    
    .topbar {
        left: 0;
        padding: 0 12px 0 0;
    }
    
    .sidebar.collapsed ~ .topbar {
        left: 0;
    }
    
    .topbar {
        padding: 0 12px 0 0;
    }
    
    .topbar-left {
        padding-left: 12px;
        gap: 12px;
    }
    
    .topbar-left h1 {
        font-size: 20px;
    }
    
    /* Show mobile title, hide full title */
    .page-title-full {
        display: none;
    }
    
    .page-title-mobile {
        display: block;
        font-size: 18px;
    }
    
    /* Make school selector more compact on mobile */
    .school-selector {
        max-width: 200px;
    }
    
    .school-select-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .selected-school-name {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .school-id-badge {
        display: none;
    }
    
    .topbar-right {
        flex: 1;
        display: flex;
        justify-content: flex-end;
        gap: 8px;
    }
    
    .user-details {
        display: none;
    }
    
    .content-area {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .table {
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: 10px 12px;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-bar .form-control {
        min-width: 100%;
    }
    
    .form-row.cols-2,
    .form-row.cols-3 {
        grid-template-columns: 1fr;
    }
    
    /* Mobile Card View for Tables — only tables whose cells carry
       data-label (the label is what makes a stacked card readable).
       Unlabelled tables used to become label-less cards; they now keep
       their columns and scroll sideways inside themselves (see below).
       Browsers without :has() drop these rules and get the scroll view. */
    .table:has(td[data-label]) thead {
        display: none !important;
    }
    
    .table:has(td[data-label]),
    .table:has(td[data-label]) tbody,
    .table:has(td[data-label]) tr,
    .table:has(td[data-label]) td {
        display: block !important;
        width: 100% !important;
    }
    
    .table:has(td[data-label]) tbody {
        display: block;
        width: 100%;
    }
    
    .table:has(td[data-label]) tr {
        margin-bottom: 16px;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 12px;
        box-shadow: var(--shadow-sm);
        transition: all 0.2s;
        display: block;
    }
    
    .table:has(td[data-label]) tr:hover {
        box-shadow: var(--shadow-md);
        border-color: var(--primary-color);
    }
    
    .table:has(td[data-label]) td {
        text-align: right !important;
        padding: 10px 0 !important;
        border: none !important;
        position: relative;
        padding-left: 50% !important;
        min-height: 36px;
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        font-size: 13px;
    }
    
    .table:has(td[data-label]) td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 48%;
        padding-left: 12px;
        font-weight: 600;
        text-align: left;
        color: var(--text-dark);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .table:has(td[data-label]) td:last-child {
        text-align: center !important;
        padding-left: 0 !important;
        padding-top: 12px !important;
        border-top: 1px solid var(--border-color) !important;
        margin-top: 8px;
        display: flex !important;
        justify-content: center;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .table:has(td[data-label]) td:last-child:before {
        content: none;
    }
    
    .table:has(td[data-label]) td:last-child .btn {
        flex: 0 0 auto;
    }
    
    /* Badge adjustments for mobile */
    .table:has(td[data-label]) td .badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 6px 12px;
        font-size: 11px;
    }
    
    /* Loading state in mobile */
    .table:has(td[data-label]) .text-center {
        padding-left: 0 !important;
        display: block !important;
        text-align: center !important;
    }
    
    .table:has(td[data-label]) .text-center:before {
        content: none;
    }
    
    .table:has(td[data-label]) tbody tr.text-center {
        padding: 20px;
        text-align: center;
    }
    
    /* Hide table striping on mobile */
    .table-striped:has(td[data-label]) tbody tr:nth-of-type(odd) {
        background-color: var(--bg-primary);
    }
    
    /* Modal adjustments for mobile/tablet */
    .modal-content {
        width: 95%;
        max-width: 95%;
        border-radius: 10px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 18px;
    }
    
    .modal-header h3 {
        font-size: 17px;
    }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 768px) {
    .filter-bar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        width: 92%;
        max-width: 650px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 18px;
    }
}

/* Large screens - wider modals */
@media (min-width: 1600px) {
    .modal-content {
        max-width: 1100px;
        width: 85%;
    }
}

@media (min-width: 1400px) and (max-width: 1599px) {
    .modal-content {
        max-width: 1000px;
        width: 85%;
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    .modal-content {
        max-width: 900px;
        width: 85%;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .modal-content {
        max-width: 850px;
        width: 88%;
    }
}

@media (min-width: 769px) and (max-width: 991px) {
    .modal-content {
        max-width: 720px;
        width: 90%;
    }
}

@media (max-width: 480px) {
    /* Login page for small devices */
    .login-page {
        padding: 12px;
    }

    .btn-block {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    .topbar-left h1 {
        font-size: 18px;
    }
    
    .sidebar-toggle {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .user-info {
        padding: 6px 12px;
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
    
    .modal-content {
        width: 98%;
        max-width: 98%;
        max-height: 96vh;
        margin: 8px;
        border-radius: 8px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 14px;
    }
    
    .modal-header h3 {
        font-size: 15px;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Ensure SweetAlert2 appears above all modals */
.swal2-container {
    z-index: 99999 !important;
}

/* ============================================
   TRANSACTION ASSET SELECTION STYLES
   ============================================ */
.selected-asset-item {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.2s ease;
}

.selected-asset-item:hover {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.selected-asset-info {
    flex: 1;
}

.selected-asset-info h6 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

.selected-asset-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 8px;
}

.selected-asset-details span {
    font-size: 13px;
    color: #718096;
    display: flex;
    align-items: center;
    gap: 5px;
}

.selected-asset-details strong {
    color: #4a5568;
}

.quantity-input {
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    text-align: center;
    transition: border-color 0.2s ease;
}

.quantity-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.quantity-input:hover {
    border-color: #a0aec0;
}

.condition-select {
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.condition-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.condition-select:hover {
    border-color: #a0aec0;
}

.selected-asset-actions {
    display: flex;
    gap: 5px;
    margin-left: 10px;
}

.selected-asset-actions .btn {
    min-width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-muted {
    color: #a0aec0;
    font-size: 12px;
}

/* ============================================
   MOBILE-FIRST CARD STYLES FOR RESPONSIVE TABLES
   ============================================ */
/* Base mobile card view - hidden on desktop */
.mobile-view {
    display: none;
}

.desktop-view {
    display: block;
}

/* Generic mobile card for all tables */
.mobile-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.mobile-card:active {
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transform: scale(0.99);
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-card-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
    line-height: 1.4;
    flex: 1;
}

.mobile-card-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-light);
    margin-top: 4px;
}

.mobile-card-badge {
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
}

.mobile-card-body {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
}

.mobile-card-label {
    font-size: var(--fs-xs);
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    min-width: 100px;
}

.mobile-card-value {
    font-size: var(--fs-sm);
    color: var(--text-dark);
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

.mobile-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.mobile-card-actions .btn {
    flex: 1;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 10px 12px;
    min-height: 44px; /* Better touch target */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Mobile card variants */
.mobile-card.highlight {
    border-left: 4px solid var(--primary-color);
    background: linear-gradient(to right, rgba(102, 126, 234, 0.05), transparent);
}

.mobile-card.success {
    border-left: 4px solid var(--success-color);
}

.mobile-card.warning {
    border-left: 4px solid var(--warning-color);
}

.mobile-card.danger {
    border-left: 4px solid var(--danger-color);
}

.mobile-card.info {
    border-left: 4px solid var(--info-color);
}

/* Status badges for mobile cards */
.mobile-status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mobile-status-badge.pending {
    background: #fef3c7;
    color: #f59e0b;
}

.mobile-status-badge.approved {
    background: #dbeafe;
    color: #3b82f6;
}

.mobile-status-badge.completed {
    background: #d1fae5;
    color: #10b981;
}

.mobile-status-badge.rejected,
.mobile-status-badge.voided {
    background: #fee2e2;
    color: #ef4444;
}

/* ============================================
   ADDITIONAL MOBILE PHONE COMPATIBILITY
   ============================================ */

/* Very small phones (iPhone SE, Galaxy S4 mini, etc.) - Portrait */
@media (max-width: 375px) and (orientation: portrait) {
    body {
        font-size: 13px;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 98vh;
        margin: 0;
        border-radius: 0;
    }
    
    .modal-header h3 {
        font-size: 14px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 12px;
    }
    
    .btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .form-control {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .topbar-left h1 {
        font-size: 16px;
    }
    
    .stat-card h3 {
        font-size: 22px;
    }
    
    .stat-card p {
        font-size: 12px;
    }
}

/* Small phones (iPhone 6/7/8, Galaxy S5, etc.) - Portrait */
@media (min-width: 376px) and (max-width: 414px) and (orientation: portrait) {
    .modal-content {
        width: 98%;
        max-width: 98%;
        border-radius: 6px;
    }
    
    .form-control {
        font-size: 14px;
    }
}

/* Standard phones (iPhone X/11/12, Galaxy S10, etc.) - Portrait */
@media (min-width: 375px) and (max-width: 428px) and (orientation: portrait) {
    .content-area {
        padding: 14px;
    }
    
    .page-header {
        padding: 16px 0;
    }
    
    .page-header h2 {
        font-size: 20px;
    }
}

/* Landscape orientation for phones */
@media (max-width: 896px) and (orientation: landscape) {
    .modal-content {
        width: 90%;
        max-width: 700px;
        max-height: 92vh;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 12px 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
}

/* Large phones (iPhone Pro Max, Galaxy Note, etc.) - Portrait */
@media (min-width: 429px) and (max-width: 480px) and (orientation: portrait) {
    .modal-content {
        width: 96%;
        max-width: 96%;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
}

/* Prevent horizontal scroll on all mobile devices */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        font-size: var(--fs-base);
    }
    
    /* Show mobile view, hide desktop view */
    .mobile-view {
        display: block !important;
    }
    
    .desktop-view {
        display: none !important;
    }
    
    .modal {
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    /* Improve form inputs on mobile (kept low-specificity so page rules,
       e.g. icon-padded login fields, still win). */
    input,
    select,
    textarea,
    .form-control {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 14px;
    }

    /* ...except native toggles/pickers: appearance:none makes checkboxes and
       radios invisible in iOS Safari, and the padding bloats them. */
    input[type="checkbox"],
    input[type="radio"],
    input[type="range"],
    input[type="file"],
    input[type="color"] {
        -webkit-appearance: auto;
        -moz-appearance: auto;
        appearance: auto;
        padding: 0;
    }

    input[type="file"] {
        font-size: 14px;
    }

    /* Native selects keep a visible arrow once appearance is removed. */
    select.form-control:not([multiple]) {
        padding-right: 34px;
        background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2012%208'%3E%3Cpath%20fill='%236b7280'%20d='M1.41%200L6%204.58%2010.59%200%2012%201.41%206%207.41%200%201.41z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 10px;
    }
    
    /* Better touch targets */
    .btn,
    button,
    a.btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 18px;
        font-size: var(--fs-sm);
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 8px 14px;
        font-size: var(--fs-xs);
    }
    
    /* Optimize tables for touch */
    .table .btn {
        padding: 8px 12px;
        font-size: var(--fs-xs);
        min-height: 36px;
    }
    
    /* Improve modal scrolling */
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stack form rows on mobile */
    .form-row {
        display: block;
    }
    
    .form-row .form-group {
        width: 100%;
        margin-bottom: 16px;
    }
    
    /* Card header responsive */
    .card-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .card-header h3 {
        font-size: var(--fs-lg);
        width: 100%;
    }
    
    .card-header > div {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .card-header .btn {
        width: 100%;
        justify-content: center;
    }
    
    .card-body {
        padding: 16px;
    }
    
    /* Content area adjustments */
    .content-area {
        padding: var(--spacing-md);
    }
    
    /* Typography scaling */
    h1 {
        font-size: var(--fs-xl);
    }
    
    h2 {
        font-size: var(--fs-lg);
    }
    
    h3 {
        font-size: var(--fs-md);
    }
    
    h4, h5, h6 {
        font-size: var(--fs-base);
    }
    
    /* Stats grid mobile layout */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: var(--spacing-md);
    }
    
    .stat-card h3 {
        font-size: var(--fs-xl);
    }
    
    .stat-card p {
        font-size: var(--fs-sm);
    }
    
    /* Filter bar mobile layout */
    .filter-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-bar .form-control,
    .filter-bar select {
        width: 100%;
        min-width: 100%;
    }
    
    /* Table responsive adjustments */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: -1px;
    }
    
    .table {
        font-size: var(--fs-sm);
    }

    /* Unlabelled tables with no scroll wrapper scroll sideways inside
       themselves rather than widening or being clipped by the card.
       (The old blanket min-width:600px forced a scroll even on 2-column
       tables and fought the stacked-card view above.) */
    .table:not(.table-responsive > .table) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table th {
        white-space: nowrap;
    }

    .table th,
    .table td {
        padding: 10px 8px;
        font-size: var(--fs-xs);
    }
    
    /* Pagination mobile */
    #pagination {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .pagination-btn {
        min-width: 40px;
        height: 40px;
        padding: 8px;
        font-size: var(--fs-sm);
    }
}

/* Fix for notched phones (iPhone X and later) */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .topbar {
            padding-left: max(12px, env(safe-area-inset-left));
            padding-right: max(12px, env(safe-area-inset-right));
        }
        
        .sidebar {
            padding-left: env(safe-area-inset-left);
        }
        
        .main-content {
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
        
        .modal-content {
            margin-left: env(safe-area-inset-left);
            margin-right: env(safe-area-inset-right);
        }
    }
}

/* Tablet specific (iPad, Galaxy Tab, etc.) */
@media (min-width: 768px) and (max-width: 1024px) {
    .modal-content {
        width: 85%;
        max-width: 700px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row.cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* iPad Pro and large tablets */
@media (min-width: 1024px) and (max-width: 1366px) {
    .modal-content {
        max-width: 850px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Accessibility improvements for all devices */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modal-content {
        border: 2px solid #000;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* =================================================================
   Uniform Select2 theme (system-wide)
   One consistent look for every searchable dropdown: clean white
   control, indigo focus ring, indigo highlighted option, tidy search.
   `body` prefix raises specificity so this beats the Select2 base CSS
   regardless of stylesheet load order.
   ================================================================= */
body .select2-container--default .select2-selection--single {
    height: 45px;
    border: 1px solid #d6dbe5;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    align-items: center;
}
body .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: normal;
    padding-left: 0;
    color: #1f2937;
}
body .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #9aa5b4;
}
body .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 43px;
    top: 0;
    right: 8px;
}
body .select2-container--default.select2-container--focus .select2-selection--single,
body .select2-container--default.select2-container--open .select2-selection--single {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* Multiple-select control matches the single look */
body .select2-container--default .select2-selection--multiple {
    border: 1px solid #d6dbe5;
    border-radius: 8px;
    min-height: 45px;
}
body .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
body .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: #eef1fe;
    border: 1px solid #c7cffb;
    color: #3949ab;
    border-radius: 6px;
}

/* Dropdown panel */
body .select2-dropdown {
    border: 1px solid #d6dbe5;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

/* When a Select2 lives inside a modal, its dropdown is appended to the
   modal as a sibling of .modal-content (z-index:100000). Without a higher
   z-index the panel paints *behind* the modal and looks "covered". Raise
   the open panel above the modal so options are visible and clickable. */
body .select2-container {
    position: relative;
    z-index: 100;
}
body .select2-container--open {
    z-index: 100001 !important;
}
body .select2-container--open .select2-dropdown {
    z-index: 100002 !important;
    position: relative;
}
body .select2-container--open .select2-dropdown--below { margin-top: 4px; }
body .select2-container--open .select2-dropdown--above { margin-bottom: 4px; }

/* Search box inside the dropdown */
body .select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #d6dbe5;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
}
body .select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

/* Options: highlighted = indigo with white text (matches reference) */
body .select2-container--default .select2-results__option {
    padding: 9px 12px;
    font-size: 14px;
    color: #1f2937;
}
/* Selected (current value) option - subtle indigo tint */
body .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: #eef1fe;
    color: #3949ab;
}
/* Highlighted (hovered/active) option - strong indigo. Placed AFTER the selected
   rule so it wins when the current value is also the highlighted row. */
body .select2-container--default .select2-results__option--highlighted[aria-selected],
body .select2-container--default .select2-results__option--highlighted[aria-selected="true"] {
    background-color: #667eea;
    color: #fff;
}
/* Keep custom multi-line option templates readable when highlighted */
body .select2-container--default .select2-results__option--highlighted[aria-selected] .picker-option div,
body .select2-container--default .select2-results__option--highlighted[aria-selected] .asset-option div,
body .select2-container--default .select2-results__option--highlighted[aria-selected] .ref-doc-option div,
body .select2-container--default .select2-results__option--highlighted[aria-selected] .asset-picker-option div,
body .select2-container--default .select2-results__option--highlighted[aria-selected] .book-option div {
    color: #fff !important;
}

/* =================================================================
   Skeleton loading (shared) — used by AMS.serverTable (ams-datatable.js)
   to replace the default DataTables spinner with shimmer placeholders.
   ================================================================= */
.ams-skeleton {
    display: inline-block;
    height: 12px;
    width: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, #eef0f3 0%, #e2e6ea 50%, #eef0f3 100%);
    background-size: 200% 100%;
    animation: amsSkeletonShimmer 1.1s ease-in-out infinite;
}

.ams-skeleton-row td {
    vertical-align: middle;
}

.ams-skeleton-card {
    pointer-events: none;
}

@keyframes amsSkeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ams-skeleton {
        animation: none;
    }
}

/* Filter-dropdown skeleton gate: until the global Select2 upgrader converts a
   filter <select> (it adds .select2-hidden-accessible), show it as a shimmer
   bar and block clicks — prevents the native-select flash / premature clicks
   during page load. Scoped to filter containers; self-healing once upgraded. */
.filter-bar select.form-control:not(.select2-hidden-accessible):not(.no-select2):not([data-no-select2]),
.filters-row select.form-control:not(.select2-hidden-accessible):not(.no-select2):not([data-no-select2]),
.filter-row select.form-control:not(.select2-hidden-accessible):not(.no-select2):not([data-no-select2]),
.filters-grid select.form-control:not(.select2-hidden-accessible):not(.no-select2):not([data-no-select2]) {
    pointer-events: none;
    color: transparent;
    background-image: linear-gradient(90deg, #eef0f3 0%, #e2e6ea 50%, #eef0f3 100%);
    background-size: 200% 100%;
    animation: amsSkeletonShimmer 1.1s ease-in-out infinite;
    border-color: #e5e7eb;
}

@media (prefers-reduced-motion: reduce) {
    .filter-bar select.form-control:not(.select2-hidden-accessible):not(.no-select2):not([data-no-select2]),
    .filters-row select.form-control:not(.select2-hidden-accessible):not(.no-select2):not([data-no-select2]),
    .filter-row select.form-control:not(.select2-hidden-accessible):not(.no-select2):not([data-no-select2]),
    .filters-grid select.form-control:not(.select2-hidden-accessible):not(.no-select2):not([data-no-select2]) {
        animation: none;
    }
}

/* ---------- Action-button colour hierarchy (all transaction views) ----------
   Neutral outline  = reference tools (Print, Edit, View PDF)
   Colored outline  = backward / destructive (Void, Cancel, Return, Unvoid)
   Solid            = the single next step for this user (Approve, Release, Sign...)
   AMS.orderActions() (common.js) puts them in that order, next step on the right.
   Text colours are !important because several views force `.btn { color: white !important }`. */
.btn.btn-ghost { background: #fff; color: #4b5563 !important; border: 1px solid #e2e8f0; box-shadow: none; }
.btn.btn-ghost:hover { background: #f8fafc; color: #4f46e5 !important; border-color: #c7d2fe !important; }
.btn.btn-outline-danger { background: #fff; color: #dc2626 !important; border: 1px solid #fecaca; box-shadow: none; }
.btn.btn-outline-danger:hover { background: #fef2f2; }
.btn.btn-outline-warning { background: #fff; color: #b45309 !important; border: 1px solid #fde68a; box-shadow: none; }
.btn.btn-outline-warning:hover { background: #fffbeb; }

/* ---------- Transaction process flow (AMS.renderProcessFlow) ---------- */
.ams-flow { margin: 14px 0 6px; }
.ams-flow-now { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-radius: 8px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 14px; }
.ams-flow-now strong { color: #78350f; }
.ams-flow-now.is-done { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.ams-flow-now.is-cancelled { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.ams-flow-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.ams-flow-step { position: relative; display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-primary); min-width: 0; }
.ams-flow-marker { flex: 0 0 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; background: var(--bg-tertiary); color: var(--text-light); }
.ams-flow-body { min-width: 0; }
.ams-flow-label { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.ams-flow-num { display: inline-block; min-width: 16px; color: var(--text-muted); font-weight: 600; }
.ams-flow-state { display: block; font-size: 11px; font-weight: 500; color: var(--text-light); margin-top: 1px; }
.ams-flow-who { font-size: 12.5px; color: var(--text-dark); margin-top: 4px; overflow-wrap: anywhere; }
.ams-flow-pos { color: var(--text-light); font-weight: 400; }
.ams-flow-hint { color: var(--text-light); font-style: italic; }
.ams-flow-note { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.ams-flow-extra { margin-top: 6px; }
.ams-flow-step.is-done .ams-flow-marker { background: #dcfce7; color: var(--success-color); }
.ams-flow-step.is-current { border-color: #f59e0b; box-shadow: 0 0 0 2px #fde68a; }
.ams-flow-step.is-current .ams-flow-marker { background: #fef3c7; color: var(--warning-color); }
.ams-flow-step.is-current .ams-flow-state { color: #b45309; font-weight: 600; }
.ams-flow-step.is-waiting { opacity: .85; }
.ams-flow-step.is-skipped, .ams-flow-step.is-cancelled { background: var(--bg-secondary); opacity: .75; }
.ams-flow-step.is-skipped .ams-flow-label, .ams-flow-step.is-cancelled .ams-flow-label { text-decoration: line-through; text-decoration-color: var(--text-muted); }
.ams-flow-step.is-cancelled .ams-flow-marker { background: #fee2e2; color: var(--danger-color); }
@media (max-width: 640px) { .ams-flow-steps { grid-template-columns: 1fr; } }
.ams-flow .ams-flow-sig { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.ams-flow .ams-flow-sig.pnpki { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.ams-flow .ams-flow-sig.electronic { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.ams-flow .ams-flow-sig.signed { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.ams-flow .ams-flow-sig.pending { background: #fff; color: #94a3b8; border: 1px dashed #cbd5e1; }

/* =====================================================================
   RESPONSIVE + APPLE/SAFARI HARDENING (2026-10-30)
   Shared fixes for phones, tablets (incl. iPad Split View) and Safari.
   Kept together so the cross-device behaviour is reviewable in one place.
   ===================================================================== */

/* Form controls don't inherit the page font by default (WebKit fell back to
   a serif/system face on buttons). */
button,
input,
select,
textarea {
    font-family: inherit;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

/* Select2 hides the real <select> as a 1px box. Mobile padding rules used to
   inflate it to ~30px, which poked past the right edge of every filter bar. */
.select2-hidden-accessible {
    padding: 0 !important;
    border: 0 !important;
    margin: 0 !important;
}

/* Module filter rules set `select { width: 100% !important }`, which also
   resized the hidden original into an invisible full-width box that pushed
   the page sideways. The doubled class outranks those rules. */
body select.select2-hidden-accessible.select2-hidden-accessible {
    width: 1px !important;
    min-width: 0 !important;
    max-width: 1px !important;
    height: 1px !important;
    flex: none !important;
}

body .select2-container {
    max-width: 100%;
}

/* Long names/IDs wrap instead of pushing headers wider than the screen. */
.card-header h3,
.modal-header h3,
.page-header h2,
.mobile-card-title,
.mobile-card-value {
    overflow-wrap: anywhere;
    min-width: 0;
}

/* ---------------------------------------------------------------------
   App shell: off-canvas sidebar also for portrait tablets (iPad 768-1024
   wide) and landscape phones, where the fixed 260px sidebar left too
   little room. This @media query is the ONLY definition of "off-canvas
   mode": it sets --shell-offcanvas, which assets/js/common.js reads, so
   CSS and JS cannot drift apart.
   --------------------------------------------------------------------- */
:root {
    --shell-offcanvas: 0;
}

@media (max-width: 768px),
       (max-width: 1024px) and (orientation: portrait),
       (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
    :root {
        --shell-offcanvas: 1;
    }

    .sidebar {
        z-index: 1002;
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }

    .sidebar.active,
    .sidebar.collapsed.active {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }

    .sidebar-overlay {
        z-index: 1001;
    }

    .sidebar-close {
        display: flex;
    }

    .main-content,
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    .topbar,
    .sidebar.collapsed ~ .topbar {
        left: 0;
    }
}

/* Landscape phones: give the short screen back to content. */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --topbar-height: 56px;
    }

    .topbar-left h1 {
        font-size: 18px;
    }
}

/* ---------------------------------------------------------------------
   Safe areas (notch, Dynamic Island, home indicator). Pages opt in with
   viewport-fit=cover; env() is 0 everywhere else, so this is a no-op on
   other devices.
   --------------------------------------------------------------------- */
@supports (padding: max(0px)) {
    .topbar {
        height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        padding-right: max(24px, env(safe-area-inset-right, 0px));
    }

    .main-content {
        margin-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
    }

    .sidebar {
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-left: env(safe-area-inset-left, 0px);
    }

    .content-area {
        padding-bottom: max(24px, calc(16px + env(safe-area-inset-bottom, 0px)));
    }

    /* `body` prefix: several pages redeclare `.modal { padding }` after
       this file, which silently dropped the insets. */
    body .modal {
        padding:
            max(20px, env(safe-area-inset-top, 0px))
            max(10px, env(safe-area-inset-right, 0px))
            max(20px, env(safe-area-inset-bottom, 0px))
            max(10px, env(safe-area-inset-left, 0px));
    }

    /* Landscape: keep page content clear of the notch side. The sidebar is
       off-canvas here, so the inset applies to the whole content column. */
    @media (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
        .topbar {
            padding-left: env(safe-area-inset-left, 0px);
        }

        .main-content {
            padding-left: env(safe-area-inset-left, 0px);
            padding-right: env(safe-area-inset-right, 0px);
        }
    }

    @media (max-width: 768px) {
        .topbar {
            padding-right: max(12px, env(safe-area-inset-right, 0px));
        }

        body .modal {
            padding:
                max(10px, env(safe-area-inset-top, 0px))
                max(10px, env(safe-area-inset-right, 0px))
                max(10px, env(safe-area-inset-bottom, 0px))
                max(10px, env(safe-area-inset-left, 0px));
        }

        /* The older notch rule offset modals sideways via margins; the
           padding on .modal above now handles it. */
        .modal-content {
            margin-left: auto;
            margin-right: auto;
        }
    }
}

/* ---------------------------------------------------------------------
   Viewport height: iOS Safari's 100vh is the height with the toolbar
   hidden, so 90vh dialogs ran under the address bar / keyboard. dvh
   tracks the visible area; vh stays as the fallback above.
   --------------------------------------------------------------------- */
@supports (height: 100dvh) {
    .dashboard {
        min-height: 100dvh;
    }

    .main-content {
        min-height: calc(100dvh - var(--topbar-height));
    }

    /* min(…, 100%): never taller than the modal's padded box, which already
       excludes the notch/home-indicator insets. The selector outranks the
       per-page `.modal-content { max-height: 9xvh }` overrides. */
    body .modal > .modal-content {
        max-height: min(90dvh, 100%);
    }

    .modal-tab-content > form {
        max-height: calc(90dvh - 64px);
    }

    .modal-tab-content > .modal-body {
        max-height: calc(90dvh - 124px);
    }

    /* Small and short screens: use the whole padded box. */
    @media (max-width: 480px), (max-width: 896px) and (orientation: landscape) {
        body .modal > .modal-content {
            max-height: 100%;
        }
    }
}

/* Scrolling inside a dialog or the sidebar doesn't chain to the page. */
.modal,
.modal-body,
.sidebar-menu,
.select2-results__options {
    overscroll-behavior: contain;
}

/* ---------------------------------------------------------------------
   iOS / iPadOS: Safari zooms the page when a focused field's text is under
   16px. -webkit-touch-callout is only supported by iOS WebKit, so desktop
   Safari and other browsers keep the compact sizes. Pinch-zoom stays on.
   --------------------------------------------------------------------- */
@supports (-webkit-touch-callout: none) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
    select,
    textarea,
    .form-control,
    body .select2-container--default .select2-search--dropdown .select2-search__field,
    body .select2-container--default .select2-search--inline .select2-search__field,
    .swal2-input,
    .swal2-textarea,
    .swal2-select {
        font-size: 16px !important;
    }
}

/* Date/time fields: iOS centres the value and collapses empty fields. */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"] {
    min-height: 45px;
}

input::-webkit-date-and-time-value {
    text-align: left;
}

/* ---------------------------------------------------------------------
   Touch: no hover on phones/tablets, so hover-lift effects must not stick
   after a tap, and small icon buttons get a 44px hit area (Apple HIG).
   --------------------------------------------------------------------- */
a,
button,
.btn,
[role="button"],
label,
summary,
select,
input[type="checkbox"],
input[type="radio"] {
    touch-action: manipulation;
}

@media (hover: none) {
    .btn:hover,
    .btn-primary:hover:not(:disabled),
    .btn-secondary:hover:not(:disabled),
    .stat-card:hover,
    .stat-card.clickable:hover,
    .stat-card[data-status]:hover,
    .selected-asset-item:hover,
    .sidebar-toggle:hover,
    .report-card:hover {
        transform: none;
    }

    .card:hover {
        box-shadow: var(--shadow-sm);
    }
}

/* The close button is display:flex from the mobile rules but had no
   alignment, so the icon sat in its top-left corner. */
.sidebar-close {
    align-items: center;
    justify-content: center;
}

@media (pointer: coarse) {
    .sidebar-toggle,
    .sidebar-close,
    .modal-close {
        min-width: 44px;
        min-height: 44px;
    }

    body .select2-container--default .select2-results__option {
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .checkbox-label input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }
}

/* Icon-only buttons: the topbar enhancer sets data-icon-label (and
   aria-label) from each button's title or icon. Without hover there are no
   tooltips, so touch devices show the label as text. The aria-label stays
   the accessible name, so the generated text isn't announced twice.
   Dense spots (table rows, card actions) stack it under the icon in small
   wrapping text so labels don't widen the table. */
@media (hover: none) {
    [data-icon-label] {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-width: 44px;
        min-height: 44px;
    }

    .btn[data-icon-label] {
        width: auto;
    }

    /* position/background reset: .action-buttons .btn-primary::after is a glow */
    [data-icon-label]::after {
        content: attr(data-icon-label);
        position: static;
        background: none;
        opacity: 1;
        font-size: 12px;
        font-weight: 600;
        line-height: 1.2;
        white-space: normal;
    }

    td:has(> [data-icon-label]),
    td:has(> * > [data-icon-label]) {
        white-space: normal;
    }

    /* 3+ actions: two per row with a gap, not one tall touching column */
    td:has(> [data-icon-label] ~ [data-icon-label] ~ [data-icon-label]) {
        min-width: 152px;
    }

    body td [data-icon-label][data-icon-label],
    body .lr-actions [data-icon-label][data-icon-label] {
        flex: 0 0 auto;
        flex-direction: column;
        gap: 2px;
        width: 60px;
        height: auto;
        min-width: 60px;
        min-height: 56px;
        max-width: 60px;
        padding: 6px 4px;
        margin: 2px;
        vertical-align: top;
    }

    /* Phone rows are cards, so there is room for wider buttons; wider tablet tables have none. */
    @media (max-width: 768px) {
        body td [data-icon-label][data-icon-label],
        body .lr-actions [data-icon-label][data-icon-label] {
            width: 72px;
            min-width: 72px;
            max-width: 72px;
        }
    }

    /* Row actions differ by colour only: no gradient or shadow on one of them.
       !important because .btn-action-* set both with !important. */
    body td [data-icon-label][data-icon-label],
    body .lr-actions [data-icon-label][data-icon-label],
    body .employee-card-actions .btn {
        box-shadow: none !important;
    }

    body td [data-icon-label]:is(.btn-primary, .btn-action-add, .btn-action-search, .btn-action-edit),
    body .lr-actions [data-icon-label]:is(.btn-primary, .btn-action-add, .btn-action-search, .btn-action-edit),
    body .employee-card-actions .btn:is(.btn-primary, .btn-action-add, .btn-action-search, .btn-action-edit) {
        background: #5568d3 !important;
        color: #fff !important;
    }

    body td [data-icon-label][data-icon-label]::after,
    body .lr-actions [data-icon-label][data-icon-label]::after {
        font-size: 10px;
        line-height: 1.1;
        text-align: center;
        white-space: normal;
    }
}

/* Item tables on PR/PO/IAR forms: seven columns can't fit a phone, and squeezing them
   left number inputs about 6px wide. Each line becomes a small card; pages name the
   cells through --label on their own td rules because data-label would switch on the
   stacked-table rules above. */
@media (max-width: 768px) {
    .table-responsive:has(> .line-items) {
        max-height: none;
        overflow: visible;
        border: 0;
    }

    table.line-items,
    table.line-items tbody,
    table.line-items tfoot {
        display: block;
        width: 100%;
    }

    table.line-items thead {
        display: none;
    }

    table.line-items tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
        padding: 12px;
        margin-bottom: 10px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }

    table.line-items tbody td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
        text-align: left !important;
    }

    table.line-items tbody td:first-child {
        display: none;
    }

    table.line-items tbody td:nth-child(2),
    table.line-items tbody td[colspan] {
        display: block;
        grid-column: 1 / -1;
    }

    table.line-items tbody td::before {
        content: var(--label, none);
        display: block;
        margin-bottom: 4px;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.04em;
        color: var(--text-secondary, #64748b);
        text-transform: uppercase;
    }

    table.line-items tbody input {
        width: 100% !important;
        min-height: 44px;
        text-align: left;
    }

    table.line-items tfoot tr {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 12px;
    }

    table.line-items tfoot td {
        display: block;
        padding: 0;
        border: 0;
    }

    table.line-items tfoot td:empty {
        display: none;
    }
}

/* Phones: stat cards are a quick count, not the page. Two compact columns keep the records
   on the first screen. */
@media (max-width: 768px) {
    .stats-grid:has(.stat-card-header) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stats-grid:has(.stat-card-header) .stat-card {
        min-width: 0;
        padding: 12px;
    }

    .stats-grid:has(.stat-card-header) .stat-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .stats-grid:has(.stat-card-header) .stat-card-icon,
    .stats-grid:has(.stat-card-header) .stat-card-sub {
        display: none;
    }

    .stats-grid:has(.stat-card-header) .stat-card-header {
        margin-bottom: 0;
    }

    .stats-grid:has(.stat-card-header) .stat-card-value {
        font-size: 22px;
        line-height: 1.2;
    }

    .stats-grid:has(.stat-card-header) .stat-card-label {
        font-size: 11px;
        line-height: 1.3;
    }
}

@media (max-width: 768px) {
    /* A margin left over from the desktop row pushes stacked header buttons off-centre. */
    .card-header .btn {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Settings tables: each row becomes a card with the label above its value. Pages name
       the cells through --label on their own td rules, as .line-items does. */
    table.stack-table,
    table.stack-table tbody,
    table.stack-table tr,
    table.stack-table td {
        display: block;
        width: 100%;
    }

    table.stack-table thead {
        display: none;
    }

    table.stack-table tbody tr {
        padding: 12px;
        margin-bottom: 10px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }

    table.stack-table tbody td {
        padding: 6px 0;
        border: 0;
        text-align: left !important;
        overflow-wrap: break-word;
    }

    table.stack-table tbody td::before {
        content: var(--label, none);
        display: block;
        margin-bottom: 2px;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.04em;
        color: var(--text-secondary, #64748b);
        text-transform: uppercase;
    }
}

/* Stock-in item lists (Assets, Supplies, Learning Resources): a line becomes a card, so cost
   and quantity stay editable without sideways scrolling. Pages name the cells through
   --label, as .line-items does. */
@media (max-width: 768px) {
    div:has(> table.stock-lines) {
        flex: none !important;
        overflow: visible !important;
        border: 0 !important;
    }

    table.stock-lines,
    table.stock-lines tbody {
        display: block;
        width: 100%;
        min-width: 0 !important;
    }

    table.stock-lines thead {
        display: none;
    }

    table.stock-lines tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
        padding: 12px;
        margin-bottom: 10px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }

    table.stock-lines tbody td {
        display: block;
        min-width: 0;
        padding: 0 !important;
        border: 0 !important;
        text-align: left !important;
        overflow-wrap: break-word;
    }

    table.stock-lines tbody td:first-child,
    table.stock-lines tbody td[colspan] {
        grid-column: 1 / -1;
    }

    table.stock-lines tbody td[colspan] {
        padding: 16px 0 !important;
        text-align: center !important;
    }

    table.stock-lines tbody td:last-child:not([colspan]) {
        grid-column: -2 / -1;
        align-self: end;
        text-align: right !important;
    }

    table.stock-lines tbody td::before {
        content: var(--label, none);
        display: block;
        margin-bottom: 4px;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.04em;
        color: var(--text-secondary, #64748b);
        text-transform: uppercase;
    }

    table.stock-lines tbody input,
    table.stock-lines tbody select {
        width: 100% !important;
        min-width: 0;
        min-height: 44px;
        text-align: left !important;
    }

    table.stock-lines tbody td .btn {
        min-height: 44px !important;
    }

    table.stock-lines tbody td:last-child .btn {
        min-width: 44px;
    }

    table.stock-lines .receipt-spec {
        white-space: normal !important;
    }
}

/* Tablets: the sidebar leaves about 670px for a list, so Actions must not need sideways
   scrolling. Screen only, since a printed page falls in this width range too. */
@media screen and (min-width: 769px) and (max-width: 1199px) {
    body .table thead th,
    body .table tbody td,
    body table.dataTable > thead > tr > th,
    body table.dataTable > tbody > tr > td {
        padding-left: 6px;
        padding-right: 6px;
    }

    .col-tablet-hide {
        display: none;
    }
}

/* Tablets: a one-line filter row pushed Clear off-screen. Three columns with search on top.
   Some pages put the filters straight in .filter-bar. Select2's hidden select stays out. */
@media screen and (min-width: 769px) and (max-width: 1199px) {
    body .filter-bar:not(:has(> .filters-row, > .filter-row)),
    body .filters-row,
    body .filters-row.cols-admin,
    body .filters-row.cols-ao,
    body .filter-row,
    body .filter-row.cols-admin,
    body .filter-row.cols-ao {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 10px;
        width: 100% !important;
        min-width: 0 !important;
    }

    body .filter-bar:not(:has(> .filters-row, > .filter-row)) > :not(.select2-hidden-accessible),
    body .filters-row > :not(.select2-hidden-accessible),
    body .filter-row > :not(.select2-hidden-accessible) {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    body .filter-bar:not(:has(> .filters-row, > .filter-row)) > input[type="text"],
    body .filter-bar:not(:has(> .filters-row, > .filter-row)) > input[type="search"],
    body .filter-bar:not(:has(> .filters-row, > .filter-row)) > .filter-note,
    body .filters-row > input[type="text"],
    body .filters-row > input[type="search"],
    body .filter-row > input[type="text"],
    body .filter-row > input[type="search"] {
        grid-column: 1 / -1;
    }
}

/* Phones: titles ran into the Back button, and each form stacked it differently. */
@media (max-width: 768px) {
    body .page-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px;
    }

    body .page-header > .btn,
    body .page-header > a.btn {
        width: 100%;
        justify-content: center;
    }

    body input.form-control:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
        min-height: 44px;
    }

    body .swal2-popup input.swal2-input {
        min-height: 44px;
    }
}

/* Signature preview: one box for every sign dialog, the signing panels and Profile. */
.rc-sig-box {
    position: relative;
    height: 92px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #dbeafe;
    border-radius: 8px;
}

.rc-sig-box img {
    position: absolute;
    left: 50%;
    bottom: 26px;
    max-width: 70%;
    max-height: 56px;
    object-fit: contain;
    transform: translateX(-50%);
}

.rc-sig-line {
    position: absolute;
    left: 14%;
    right: 14%;
    bottom: 30px;
    border-bottom: 1px solid #1e293b;
}

.rc-sig-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    font-size: 11px;
    color: #475569;
    text-align: center;
}

/* Long names and headers wrap instead of pushing Actions off-screen. Below 769px rows are cards. */
@media screen and (min-width: 769px) {
    body .table thead th,
    body table.dataTable > thead > tr > th {
        white-space: normal;
    }

    body .table tbody td:not(:last-child) {
        white-space: normal !important;
        overflow-wrap: break-word;
    }
}

/* One button scale: 44px for page, form and dialog actions, 30px in table rows. Purpose sets
   the colour through the existing classes. On touch screens labelled row buttons keep their
   own size (see the data-icon-label rules). */
body .btn:not(.btn-sm) {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

@media (hover: hover) {
    body .btn.btn-sm,
    body td .btn:not(.btn-sm) {
        min-width: 34px;
        min-height: 30px;
        padding: 0 10px;
        border-radius: 6px;
        font-size: 12px;
        font-weight: 600;
        line-height: 1.2;
    }

    body .btn.btn-sm i,
    body td .btn:not(.btn-sm) i {
        font-size: 12px;
    }

    body td:has(> .btn + .btn) {
        white-space: nowrap;
    }
}

@media (hover: none) {
    body .btn.btn-sm:not([data-icon-label]),
    body td .btn:not(.btn-sm):not([data-icon-label]) {
        min-height: 30px;
        padding: 0 10px;
        border-radius: 6px;
        font-size: 12px;
        font-weight: 600;
        line-height: 1.2;
    }
}

body td .btn.btn {
    box-shadow: none !important;
}

/* Some pages flatten .btn-primary or use .btn-indigo for the next step. */
body .btn.btn-primary,
body .btn.btn-indigo {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Pages recolour .btn-secondary in their own styles; Back, Cancel and Clear stay white. */
body .btn.btn-secondary:not([class*="btn-action-edit"]):not([class*="btn-action-add"]):not([class*="btn-action-delete"]) {
    background: #fff !important;
    border: 1px solid var(--border-color);
    color: #2d3748 !important;
}

.profile-hero-btn {
    min-height: 44px;
}

/* Some pages restyle these two colours in their own sheets. */
body .btn.btn-success {
    background: var(--success-color);
}

body .btn.btn-info {
    background: var(--info-color);
}
