/* ============================================================
   IMS — Modern Professional UI
   ============================================================ */

:root {
    /* Sidebar */
    --sb-w: 260px;
    --sb-mini: 64px;
    --sb-bg: #111827;
    --sb-border: rgba(255, 255, 255, 0.07);
    --sb-text: #9ca3af;
    --sb-hover: rgba(255, 255, 255, 0.06);
    --sb-active-bg: rgba(99, 102, 241, 0.15);
    --sb-active-text: #a5b4fc;
    --sb-active-bar: #6366f1;
    --sb-group: #4b5563;

    /* Brand / Accent */
    --accent: #6366f1;
    --accent-dark: #4f46e5;
    --accent-soft: #eef2ff;
    --accent-text: #4338ca;

    /* Surface */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;

    /* Text */
    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Borders */
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Semantic */
    --success: #10b981;
    --success-soft: #ecfdf5;
    --success-text: #065f46;
    --danger: #ef4444;
    --danger-soft: #fef2f2;
    --danger-text: #991b1b;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;
    --warning-text: #92400e;
    --info: #3b82f6;
    --info-soft: #eff6ff;
    --info-text: #1e40af;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.1);

    /* Shape */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.625rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --t: 0.22s var(--ease);

    /* Layout */
    --topbar-h: 62px;
    --font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Layout Shell
   ============================================================ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: var(--sb-w);
    min-height: 100vh;
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--t);
    overflow: hidden;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
}
.sb-pre-collapse #sidebar,
.sidebar.collapsed { width: var(--sb-mini); }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
}
.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 800;
    font-size: 0.8rem;
    color: #fff;
    letter-spacing: -0.03em;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--t), transform var(--t);
}
.sidebar-brand-text strong {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.sidebar-brand-text small {
    font-size: 0.65rem;
    color: var(--sb-group);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.sidebar.collapsed .sidebar-brand-text,
.sb-pre-collapse #sidebar .sidebar-brand-text {
    opacity: 0;
    transform: translateX(-8px);
    pointer-events: none;
    width: 0;
    overflow: hidden;
    flex: 0 0 0;
}
.sidebar.collapsed .sidebar-brand,
.sb-pre-collapse #sidebar .sidebar-brand {
    justify-content: center;
    padding: 0;
    gap: 0;
}

/* Scrollable nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Groups */
.nav-group { margin-bottom: 0.125rem; }
.nav-group-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sb-group);
    padding: 0.85rem 1.2rem 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--t), max-height var(--t), padding var(--t);
    max-height: 40px;
}
.sidebar.collapsed .nav-group-label,
.sb-pre-collapse #sidebar .nav-group-label {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Nav item */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.52rem 0.9rem;
    margin: 0.06rem 0.5rem;
    border-radius: var(--radius);
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.855rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: background var(--t), color var(--t);
    position: relative;
}
.nav-item:hover {
    background: var(--sb-hover);
    color: #e2e8f0;
}
.nav-item.active {
    background: var(--sb-active-bg);
    color: var(--sb-active-text);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 25%;
    height: 50%;
    width: 3px;
    background: var(--sb-active-bar);
    border-radius: 0 3px 3px 0;
}

/* Icon */
.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.65;
    transition: opacity var(--t);
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Label */
.nav-label {
    flex: 1;
    transition: opacity var(--t), transform var(--t);
}
.sidebar.collapsed .nav-label,
.sb-pre-collapse #sidebar .nav-label {
    opacity: 0;
    transform: translateX(-6px);
    pointer-events: none;
}

/* Tooltip when collapsed */
.sidebar.collapsed .nav-item:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sb-mini) - 0.4rem);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 200;
    pointer-events: none;
}

/* Sidebar footer - toggle button */
.sidebar-footer {
    border-top: 1px solid var(--sb-border);
    padding: 0.6rem 0.5rem;
    flex-shrink: 0;
}
.sidebar-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0.5rem;
    background: none;
    border: none;
    border-radius: var(--radius);
    color: var(--sb-group);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background var(--t), color var(--t);
    white-space: nowrap;
    overflow: hidden;
    font-family: var(--font);
}
.sidebar-toggle:hover {
    background: var(--sb-hover);
    color: #e2e8f0;
}
.sidebar-toggle svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    transition: transform var(--t);
}
.sidebar.collapsed .sidebar-toggle svg,
.sb-pre-collapse #sidebar .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar-toggle-label {
    transition: opacity var(--t), transform var(--t);
}
.sidebar.collapsed .sidebar-toggle-label,
.sb-pre-collapse #sidebar .sidebar-toggle-label {
    opacity: 0;
    transform: translateX(-6px);
    pointer-events: none;
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
    backdrop-filter: blur(1px);
}

/* ============================================================
   Content area
   ============================================================ */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-xs);
    flex-shrink: 0;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.topbar-mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    transition: background var(--t), color var(--t);
    line-height: 0;
}
.topbar-mobile-toggle:hover {
    background: var(--surface-2);
    color: var(--text);
}
.topbar-mobile-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.topbar-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.topbar-user-menu {
    position: relative;
}
.topbar-user-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    padding: 0.28rem 0.6rem 0.28rem 0.28rem;
    transition: background var(--t), border-color var(--t), box-shadow var(--t);
    font-family: var(--font);
}
.topbar-user-trigger:hover {
    background: var(--accent-soft);
    border-color: #c7d2fe;
}
.topbar-user-trigger[aria-expanded="true"] {
    background: var(--accent-soft);
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.topbar-chevron {
    width: 13px;
    height: 13px;
    color: var(--text-muted);
    transition: transform var(--t);
    flex-shrink: 0;
}
.topbar-user-trigger[aria-expanded="true"] .topbar-chevron {
    transform: rotate(180deg);
    color: var(--accent);
}
/* Dropdown panel */
.topbar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    overflow: hidden;
    transform-origin: top right;
    animation: dropdown-in .15s var(--ease);
}
@keyframes dropdown-in {
    from { opacity: 0; transform: scale(.96) translateY(-4px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}
/* Header strip — accent gradient */
.topbar-dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    background: linear-gradient(110deg, #1e1b4b 0%, #312e81 60%, #4338ca 100%);
}
.user-avatar--lg {
    width: 44px;
    height: 44px;
    font-size: 0.88rem;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.25);
}
.topbar-dropdown-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
}
.topbar-dropdown-email {
    font-size: 0.74rem;
    color: #a5b4fc;
    margin-top: 0.15rem;
    word-break: break-all;
}
.topbar-dropdown-body {
    padding: 0.35rem 0;
}
.topbar-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.2rem 0;
}
.topbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.6rem 1.1rem;
    font-size: 0.845rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    text-align: left;
    transition: background var(--t), color var(--t);
    border-radius: 0;
}
.topbar-dropdown-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color var(--t);
}
.topbar-dropdown-item:hover {
    background: var(--accent-soft);
    color: var(--accent-text);
}
.topbar-dropdown-item:hover svg {
    color: var(--accent);
}
.topbar-dropdown-item--danger {
    color: var(--danger);
}
.topbar-dropdown-item--danger svg {
    color: var(--danger);
}
.topbar-dropdown-item--danger:hover {
    background: var(--danger-soft);
    color: var(--danger-text);
}
.topbar-dropdown-item--danger:hover svg {
    color: var(--danger);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}
.user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.72rem;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.topbar-divider {
    width: 1px;
    height: 18px;
    background: var(--border);
}
.topbar-link {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius);
    transition: background var(--t), color var(--t);
    font-weight: 500;
}
.topbar-link:hover {
    background: var(--surface-2);
    color: var(--text);
}
.topbar-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.32rem 0.7rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background var(--t), color var(--t), border-color var(--t);
    font-family: var(--font);
}
.topbar-logout:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #fca5a5;
}

/* ============================================================
   Main content
   ============================================================ */
.main {
    flex: 1;
    padding: 1.5rem;
}

/* ============================================================
   Profile page (prf-*)
   ============================================================ */
.prf-page {
    max-width: 900px;
}
.prf-hero {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.prf-hero-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.prf-hero-name {
    margin: 0 0 .35rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}
.prf-hero-meta {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: .3rem;
}
.prf-hero-sub {
    font-size: .78rem;
    color: var(--text-muted);
}
.prf-badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    padding: .15rem .55rem;
    border-radius: 20px;
    line-height: 1.5;
}
.prf-badge--role {
    background: #ede9fe;
    color: #6d28d9;
}
.prf-badge--active {
    background: #dcfce7;
    color: #15803d;
}
.prf-badge--inactive {
    background: #fee2e2;
    color: #b91c1c;
}
.prf-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.25rem;
    align-items: start;
}
@media (max-width: 680px) {
    .prf-layout { grid-template-columns: 1fr; }
}
.prf-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.prf-card-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
}
.prf-card-title svg {
    width: 16px;
    height: 16px;
    color: #6366f1;
    flex-shrink: 0;
}
.prf-form {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.prf-field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.prf-label {
    font-size: .8rem;
    font-weight: 600;
    color: #374151;
}
.prf-required {
    color: var(--danger);
}
.prf-input {
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: var(--font);
    color: var(--text);
    background: #fff;
    transition: border-color var(--t), box-shadow var(--t);
}
.prf-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.prf-input--readonly {
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: default;
}
.prf-hint {
    font-size: .73rem;
    color: var(--text-muted);
}
.prf-save-btn {
    align-self: flex-start;
    margin-top: .25rem;
}
.prf-card-divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}
.prf-change-pw-link {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .845rem;
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
}
.prf-change-pw-link svg {
    width: 15px;
    height: 15px;
}
.prf-change-pw-link:hover {
    text-decoration: underline;
}
.prf-dl {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.prf-dl-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .75rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .845rem;
}
.prf-dl-row:last-child {
    border-bottom: none;
}
.prf-dl-row dt {
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}
.prf-dl-row dd {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

/* ============================================================
   Settings page (stg-*)
   ============================================================ */
.stg-page { max-width: 860px; }

/* Tab bar */
.stg-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.75rem;
}
.stg-tab {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem 1.25rem;
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color var(--t), border-color var(--t);
    white-space: nowrap;
}
.stg-tab:hover { color: var(--accent); }
.stg-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.stg-tab svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Section cards */
.stg-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.stg-card-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.stg-card-head svg {
    width: 16px;
    height: 16px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.stg-card-head h4 {
    margin: 0;
    font-size: .875rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}
.stg-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Logo upload row */
.stg-logo-row {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    flex-wrap: wrap;
}
.stg-logo-preview {
    width: 110px;
    height: 70px;
    border: 1.5px dashed var(--border);
    border-radius: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    overflow: hidden;
    flex-shrink: 0;
}
.stg-logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.stg-logo-actions {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    flex: 1;
    min-width: 160px;
}
.stg-logo-hint {
    font-size: .75rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}
.stg-remove-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .75rem;
    font-size: .78rem;
    font-weight: 600;
    border: 1.5px solid #fca5a5;
    border-radius: .375rem;
    background: #fef2f2;
    color: #dc2626;
    cursor: pointer;
    transition: background var(--t), border-color var(--t);
    font-family: var(--font);
}
.stg-remove-btn:hover { background: #fee2e2; border-color: #f87171; }

/* 2-col field row */
.stg-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 540px) { .stg-row { grid-template-columns: 1fr; } }

/* Save bar */
.stg-save-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: .25rem;
}

/* ============================================================
   Shared searchable-select widget  (ims-ssel)
   Used on item dropdowns in GI / SA / PR / PO / GRN
   ============================================================ */
.ims-ssel { position: relative; display: block; width: 100%; }
.ims-ssel-display {
    display: flex; align-items: center; justify-content: space-between;
    padding: .32rem .5rem; font-size: .83rem;
    border: 1.5px solid #e2e8f0; border-radius: .45rem;
    background: #fff; cursor: pointer; min-height: 34px;
    user-select: none; color: #0f172a;
    transition: border-color .15s; box-sizing: border-box; width: 100%;
}
.ims-ssel-display:focus,
.ims-ssel.open .ims-ssel-display {
    outline: none; border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.ims-ssel-placeholder { color: #94a3b8; }
.ims-ssel-arrow {
    flex-shrink: 0; margin-left: .4rem; color: #94a3b8;
    font-size: .65rem; transition: transform .15s;
}
.ims-ssel.open .ims-ssel-arrow { transform: rotate(180deg); }
.ims-ssel-panel {
    display: none; position: fixed;
    background: #fff; border: 1.5px solid #e2e8f0;
    border-radius: .45rem; box-shadow: 0 8px 24px rgba(0,0,0,.1);
    z-index: 3000; overflow: hidden;
}
.ims-ssel.open .ims-ssel-panel { display: block; }
.ims-ssel-search-wrap {
    padding: .4rem .45rem; border-bottom: 1px solid #f1f5f9; background: #fafbff;
}
.ims-ssel-search-inp {
    width: 100%; padding: .3rem .45rem; font-size: .78rem;
    border: 1.5px solid #e2e8f0; border-radius: .35rem;
    outline: none; box-sizing: border-box; background: #fff; color: #0f172a;
}
.ims-ssel-search-inp:focus { border-color: #6366f1; }
.ims-ssel-list {
    list-style: none; margin: 0; padding: .25rem 0;
    max-height: 200px; overflow-y: auto;
}
.ims-ssel-list li {
    padding: .38rem .65rem; font-size: .82rem; cursor: pointer;
    color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ims-ssel-list li:hover { background: #f1f5f9; }
.ims-ssel-list li[data-selected] { background: #eef2ff; color: #4f46e5; font-weight: 600; }
.ims-ssel-list .ims-ssel-empty {
    color: #94a3b8; font-size: .78rem; cursor: default; padding: .5rem .65rem;
}

/* ============================================================
   Dashboard (db-*)
   ============================================================ */

/* Page header */
.db-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.db-page-title {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}
.db-page-title-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
    flex-shrink: 0;
}
.db-page-title-icon svg {
    width: 22px;
    height: 22px;
    stroke: #fff;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.db-page-h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    margin: 0 0 0.1rem;
}
.db-page-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

/* ── Filter button & dropdown ────────────────────────────────── */
.db-filter-wrap {
    position: relative;
}
.db-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 0.6rem;
    font-size: 0.8375rem;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font);
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: border-color var(--t), box-shadow var(--t);
    white-space: nowrap;
}
.db-filter-btn:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.db-filter-caret { transition: transform 0.2s; }
.db-filter-dropdown.is-open + .db-filter-btn .db-filter-caret,
.db-filter-btn.is-open .db-filter-caret { transform: rotate(180deg); }

.db-filter-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    z-index: 300;
    animation: db-fade-drop 0.15s ease;
}
.db-filter-dropdown.is-open { display: block; }
@keyframes db-fade-drop {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.db-filter-section {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    padding: 0.35rem 0.5rem 0.25rem;
}
.db-filter-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.8375rem;
    font-weight: 500;
    color: var(--text);
    background: none;
    border: none;
    border-radius: 0.45rem;
    cursor: pointer;
    font-family: var(--font);
    transition: background var(--t), color var(--t);
}
.db-filter-item:hover { background: var(--surface-2); }
.db-filter-item.is-active {
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
}
.db-filter-divider {
    height: 1px;
    background: var(--border);
    margin: 0.35rem 0;
}
.db-filter-custom {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.25rem 0.25rem 0.25rem;
}
.db-filter-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: 0.45rem;
    font-size: 0.8125rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface-2);
    outline: none;
    cursor: pointer;
    box-sizing: border-box;
}
.db-filter-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.db-filter-apply { width: 100%; }

/* ── Stat card grid ─────────────────────────────────────────── */
.db-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    transition: opacity 0.25s;
}
.db-stat-grid.db-loading { opacity: 0.4; pointer-events: none; }

.db-stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-xs);
    transition: transform var(--t), box-shadow var(--t);
    position: relative;
    overflow: hidden;
}
.db-stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.db-stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.db-stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 0.875rem;
    flex-shrink: 0;
}
.db-stat-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.db-stat-body { flex: 1; min-width: 0; }
.db-stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.db-stat-value {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.1;
    word-break: break-all;
}
.db-stat-sub {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

/* Colour variants */
.db-stat-indigo::after { background: linear-gradient(90deg,#6366f1,#818cf8); }
.db-stat-indigo .db-stat-icon { background: #eef2ff; }
.db-stat-indigo .db-stat-icon svg { stroke: #6366f1; }

.db-stat-emerald::after { background: linear-gradient(90deg,#10b981,#34d399); }
.db-stat-emerald .db-stat-icon { background: #ecfdf5; }
.db-stat-emerald .db-stat-icon svg { stroke: #10b981; }

.db-stat-amber::after { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.db-stat-amber .db-stat-icon { background: #fffbeb; }
.db-stat-amber .db-stat-icon svg { stroke: #d97706; }

.db-stat-violet::after { background: linear-gradient(90deg,#8b5cf6,#a78bfa); }
.db-stat-violet .db-stat-icon { background: #f5f3ff; }
.db-stat-violet .db-stat-icon svg { stroke: #7c3aed; }

.db-stat-rose::after { background: linear-gradient(90deg,#ef4444,#f87171); }
.db-stat-rose .db-stat-icon { background: #fef2f2; }
.db-stat-rose .db-stat-icon svg { stroke: #dc2626; }

.db-stat-sky::after { background: linear-gradient(90deg,#0ea5e9,#38bdf8); }
.db-stat-sky .db-stat-icon { background: #f0f9ff; }
.db-stat-sky .db-stat-icon svg { stroke: #0284c7; }

.db-stat-teal::after { background: linear-gradient(90deg,#14b8a6,#2dd4bf); }
.db-stat-teal .db-stat-icon { background: #f0fdfa; }
.db-stat-teal .db-stat-icon svg { stroke: #0d9488; }

.db-stat-orange::after { background: linear-gradient(90deg,#f97316,#fb923c); }
.db-stat-orange .db-stat-icon { background: #fff7ed; }
.db-stat-orange .db-stat-icon svg { stroke: #ea580c; }

/* ── Charts ─────────────────────────────────────────────────── */
.db-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
.db-chart-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.db-chart-panel-full { grid-column: 1 / -1; }

.db-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}
.db-chart-head-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}
.db-dept-select {
    padding: 0.32rem 2rem 0.32rem 0.65rem;
    border: 1.5px solid var(--border);
    border-radius: 0.45rem;
    font-size: 0.8rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E") right 0.5rem center no-repeat;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    cursor: pointer;
    max-width: 220px;
    transition: border-color var(--t), box-shadow var(--t);
}
.db-dept-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.db-chart-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.2rem;
}
.db-chart-sub {
    font-size: 0.775rem;
    color: var(--text-muted);
    margin: 0;
}
.db-chart-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}
.db-chart-badge-emerald { background: #ecfdf5; color: #065f46; }
.db-chart-badge-violet  { background: #f5f3ff; color: #4c1d95; }
.db-chart-badge-amber   { background: #fffbeb; color: #92400e; }
.db-chart-badge-rose    { background: #fef2f2; color: #991b1b; }

.db-chart-canvas-wrap {
    position: relative;
    height: 240px;
}
.db-chart-canvas-wrap canvas { display: block; width: 100% !important; height: 100% !important; }

/* ── Low stock helpers ─────────────────────────────────────── */
.db-code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    padding: 0.1rem 0.45rem;
    font-size: 0.775rem;
    font-family: monospace;
    color: var(--accent-text);
}
.db-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    color: var(--text-muted);
    text-align: center;
}
.db-empty-state svg { stroke: #10b981; opacity: 0.7; }

/* Toolbar above low-stock table */
.db-ls-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0 0 0.875rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.db-ls-filter-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.db-ls-filter-select {
    padding: 0.38rem 2rem 0.38rem 0.65rem;
    border: 1.5px solid var(--border);
    border-radius: 0.45rem;
    font-size: 0.8125rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E") right 0.5rem center no-repeat;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    cursor: pointer;
    transition: border-color var(--t), box-shadow var(--t);
}
.db-ls-filter-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.db-ls-count {
    margin-left: auto;
    font-size: 0.775rem;
    color: var(--text-light);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 0.2rem 0.65rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Store pill inside table */
.db-store-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--info-soft);
    color: var(--info-text);
    border-radius: 99px;
    padding: 0.22rem 0.65rem;
    font-size: 0.775rem;
    font-weight: 600;
    white-space: nowrap;
}
.db-store-pill svg { stroke: var(--info-text); flex-shrink: 0; }
.db-store-code {
    background: rgba(59,130,246,0.15);
    border-radius: 0.3rem;
    padding: 0 0.35rem;
    font-size: 0.7rem;
    font-family: monospace;
    letter-spacing: 0.02em;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 960px) {
    .db-charts-row { grid-template-columns: 1fr; }
    .db-stat-grid  { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .db-stat-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .db-stat-value { font-size: 1.1rem; }
    .db-page-head { flex-direction: column; align-items: flex-start; }
    .db-filter-dropdown { right: auto; left: 0; }
}
@media (max-width: 420px) {
    .db-stat-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Stat Cards
   ============================================================ */
.cards-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--t), transform var(--t);
    position: relative;
    overflow: hidden;
}
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.card h3 {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}
.card p {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    letter-spacing: -0.02em;
}

/* ============================================================
   Panel
   ============================================================ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    padding: 1.25rem;
}

/* Scrollable wrapper — auto-injected by table-filters.js around every .table */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.table-scroll::-webkit-scrollbar {
    height: 5px;
}
.table-scroll::-webkit-scrollbar-track {
    background: var(--surface-2);
}
.table-scroll::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}
.table-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
.panel h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 0;
    margin-bottom: 1rem;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: -1.25rem -1.25rem 1.25rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.panel-head h3 { margin: 0; }

/* ============================================================
   Report nav cards  (reports/index.php)
   ============================================================ */
.report-section { margin-bottom: 1.75rem; }
.report-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.625rem;
}
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.875rem;
}
.report-card {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    color: inherit;
    transition: box-shadow var(--t), transform var(--t), border-color var(--t);
    position: relative;
    overflow: hidden;
}
.report-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--accent), #8b5cf6);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    opacity: 0;
    transition: opacity var(--t);
}
.report-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    border-color: var(--accent);
}
.report-card:hover::before { opacity: 1; }
.report-card-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}
.report-card-icon svg {
    width: 18px; height: 18px;
    stroke: var(--accent-text);
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.report-card-body { flex: 1; min-width: 0; }
.report-card-body strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.report-card-body span {
    font-size: 0.775rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.report-card-arrow {
    flex-shrink: 0;
    align-self: center;
    color: var(--text-light);
    transition: color var(--t), transform var(--t);
}
.report-card:hover .report-card-arrow {
    color: var(--accent);
    transform: translateX(3px);
}
@media (max-width: 600px) {
    .report-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Auth card
   ============================================================ */
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    width: min(440px, 92vw);
    margin: 3rem auto;
}
.auth-card h2 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

/* ============================================================
   Table
   ============================================================ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 600px; /* always wide enough to warrant scrolling */
}
.table thead { background: var(--surface-2); }
.table th {
    padding: 0.7rem 1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
    white-space: nowrap;
}
/* Allow certain cells to wrap (e.g. description, notes, address) */
.table td.wrap,
.table td.al-td-changes { white-space: normal; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
/* Action cells: keep buttons on one row */
.table td .btn-actions,
.table td > div[style*="display:flex"] {
    flex-wrap: nowrap !important;
    white-space: nowrap;
}

/* ============================================================
   Buttons
   ============================================================ */
.button,
button[type="submit"],
button.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--t), box-shadow var(--t), transform var(--t);
    line-height: 1.4;
    white-space: nowrap;
}
.button:hover,
button[type="submit"]:hover,
button.btn:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}
.button:active,
button[type="submit"]:active,
button.btn:active { transform: translateY(0); }

.button.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.button.btn-outline {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
}
.button.btn-outline:hover {
    background: var(--surface-2);
    color: var(--text);
    box-shadow: none;
}
.button.btn-danger { background: var(--danger); color: #fff; }
.button.btn-danger:hover { background: #dc2626; color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,0.3); }

/* ============================================================
   Forms
   ============================================================ */
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.375rem;
}
input,
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--t), box-shadow var(--t);
    outline: none;
    line-height: 1.4;
}
input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
input::placeholder,
textarea::placeholder { color: var(--text-light); }
select[multiple] { min-height: 9rem; padding: 0.4rem; }
textarea { resize: vertical; min-height: 90px; }

.stack { display: grid; gap: 0.875rem; }
.grid-form { display: grid; grid-template-columns: 1fr; gap: 0.875rem; }
.grid-form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.875rem; }

/* ============================================================
   Two-column content layout
   ============================================================ */
.grid-two {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    border: 1px solid transparent;
}
.alert.success { background: var(--success-soft); border-color: #a7f3d0; color: var(--success-text); }
.alert.error   { background: var(--danger-soft);  border-color: #fecaca; color: var(--danger-text); }
.alert.warning { background: var(--warning-soft); border-color: #fde68a; color: var(--warning-text); }
.alert.info    { background: var(--info-soft);    border-color: #bfdbfe; color: var(--info-text); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-info    { background: var(--info-soft);    color: var(--info-text); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ============================================================
   Line items
   ============================================================ */
.line-items {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface-2);
}
.line-items-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.line-items-head h4 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.line-items-body { padding: 0.75rem; }

.line-row {
    display: grid;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
}
.line-po-row  { grid-template-columns: 2fr 0.9fr 1fr 0.8fr 0.8fr 0.8fr auto; }
.line-grn-row { grid-template-columns: 1.6fr 0.8fr 0.8fr 0.8fr 0.8fr 0.9fr; }

.inline-price-form {
    display: grid;
    gap: 0.35rem;
    grid-template-columns: 1fr 1fr 1.2fr auto;
    align-items: end;
}

/* ============================================================
   Actions row
   ============================================================ */
.actions-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* ============================================================
   Utility
   ============================================================ */
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 0.5rem; }
.gap-3        { gap: 0.75rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        transition: transform var(--t), width var(--t);
        width: var(--sb-w) !important;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .topbar-mobile-toggle {
        display: flex;
    }
    .grid-two {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-form-2 { grid-template-columns: 1fr; }
    .main { padding: 1rem; }
    .line-po-row { grid-template-columns: 1fr; }
}

/* ============================================================
   Auth pages — Split panel layout
   ============================================================ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: #0f172a;
}

/* ----- Split wrapper ----- */
.auth-split {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ----- LEFT: branded dark panel ----- */
.auth-left {
    flex: 0 0 48%;
    background: linear-gradient(145deg, #1e1b4b 0%, #312e81 40%, #1e1b4b 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.auth-left-inner {
    position: relative;
    z-index: 2;
    max-width: 400px;
}

/* Logo mark */
.auth-logo-mark {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.auth-logo-mark svg {
    width: 30px;
    height: 30px;
    stroke: #fff;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-brand-name {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #a5b4fc;
    margin-bottom: 0.6rem;
}

.auth-brand-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.auth-brand-sub {
    font-size: 0.9rem;
    color: #a5b4fc;
    line-height: 1.7;
    margin-bottom: 2rem;
}

/* Feature list */
.auth-feature-list {
    list-style: none;
    display: grid;
    gap: 0.75rem;
}
.auth-feature-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: #c7d2fe;
    font-weight: 500;
}
.auth-feature-icon {
    width: 22px;
    height: 22px;
    background: rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.auth-feature-icon svg {
    width: 12px;
    height: 12px;
    stroke: #a5b4fc;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Decorative dot-grid overlay */
.auth-left-grid {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(8, 1fr);
    pointer-events: none;
    opacity: 0.18;
}
.auth-left-grid span {
    border-right: 1px solid rgba(255, 255, 255, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

/* Glow blobs */
.auth-left::before,
.auth-left::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    pointer-events: none;
}
.auth-left::before {
    width: 350px; height: 350px;
    background: rgba(139, 92, 246, 0.35);
    top: -100px; right: -80px;
}
.auth-left::after {
    width: 280px; height: 280px;
    background: rgba(99, 102, 241, 0.3);
    bottom: -60px; left: -60px;
}

/* ----- RIGHT: form panel ----- */
.auth-right {
    flex: 1;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
}

.auth-form-wrap {
    width: 100%;
    max-width: 380px;
}

.auth-form-header {
    margin-bottom: 2rem;
}
.auth-form-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.025em;
    margin-bottom: 0.3rem;
}
.auth-form-header p {
    font-size: 0.875rem;
    color: #64748b;
}

/* Error alert */
.auth-alert-error {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    color: #991b1b;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}
.auth-alert-error svg {
    width: 17px; height: 17px;
    stroke: #ef4444;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Form */
.auth-form {
    display: grid;
    gap: 1.25rem;
}

.auth-field {
    display: grid;
    gap: 0.4rem;
}
.auth-field label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1e293b;
    width: auto;
    padding: 0;
    border: none;
    background: none;
}
.auth-field-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.auth-forgot {
    font-size: 0.775rem;
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
    transition: color 0.18s;
}
.auth-forgot:hover { color: #4f46e5; text-decoration: underline; }

/* Input with icon */
.auth-input-wrap {
    position: relative;
}
.auth-input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
}
.auth-input-icon svg {
    width: 16px; height: 16px;
    stroke: #94a3b8;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.auth-input-wrap input {
    width: 100%;
    padding: 0.65rem 0.85rem 0.65rem 2.5rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-family: var(--font);
    color: #0f172a;
    background: #f8fafc;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
    outline: none;
}
.auth-input-wrap input:focus {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}
.auth-input-wrap input::placeholder { color: #cbd5e1; }

/* Submit button */
.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1rem;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: opacity 0.18s, transform 0.18s, box-shadow 0.18s;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
    margin-top: 0.5rem;
}
.auth-btn:hover {
    opacity: 0.93;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}
.auth-btn:active { transform: translateY(0); opacity: 1; }
.auth-btn svg {
    width: 18px; height: 18px;
    stroke: currentColor; fill: none;
    stroke-width: 2.2;
    stroke-linecap: round; stroke-linejoin: round;
}

/* Responsive: stack on mobile */
@media (max-width: 860px) {
    .auth-split { flex-direction: column; }
    .auth-left { flex: none; min-height: 260px; padding: 2rem 1.5rem; }
    .auth-brand-title { font-size: 1.3rem; }
    .auth-feature-list { display: none; }
    .auth-right { padding: 2rem 1.5rem; }
}


/* ============================================================
   Login Page — Glass morphism theme (lp-*)
   ============================================================ */

/* Animated gradient background */
.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99,102,241,0.35) 0%, transparent 55%),
        radial-gradient(ellipse 60% 70% at 80% 85%, rgba(139,92,246,0.3) 0%, transparent 55%),
        radial-gradient(ellipse 50% 50% at 60% 30%, rgba(59,130,246,0.2) 0%, transparent 50%),
        linear-gradient(135deg, #0a0e1a 0%, #0d1224 40%, #0f0f23 100%) !important;
    background-attachment: fixed !important;
}
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    position: relative;
}

/* Floating orb decorations */
.auth-page::before,
.auth-page::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
}
.auth-page::before {
    width: 500px; height: 500px;
    background: rgba(99,102,241,0.18);
    top: -120px; left: -100px;
    animation: lp-orb1 12s ease-in-out infinite alternate;
}
.auth-page::after {
    width: 400px; height: 400px;
    background: rgba(139,92,246,0.18);
    bottom: -80px; right: -80px;
    animation: lp-orb2 14s ease-in-out infinite alternate;
}
@keyframes lp-orb1 {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(60px, 40px) scale(1.15); }
}
@keyframes lp-orb2 {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(-50px, -30px) scale(1.1); }
}

/* Glass card */
.lp-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 1.5rem;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.06),
        0 32px 80px rgba(0,0,0,0.6),
        0 8px 32px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(255,255,255,0.12);
    padding: 2.75rem 2.5rem 2.25rem;
    animation: lp-fade-in 0.4s cubic-bezier(0.22,1,0.36,1);
}
@keyframes lp-fade-in {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Subtle top accent line */
.lp-card::before {
    content: '';
    position: absolute;
    top: 0; left: 10%; right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(99,102,241,0.8), rgba(139,92,246,0.8), transparent);
    border-radius: 0 0 4px 4px;
}

/* Head */
.lp-head {
    text-align: center;
    margin-bottom: 2rem;
}
/* Real company logo image */
.lp-logo-img {
    display: block;
    margin-bottom: 1.25rem;
}
/* Fallback icon box */
.lp-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(99,102,241,0.9) 0%, rgba(139,92,246,0.9) 100%);
    border-radius: 1.1rem;
    margin-bottom: 1.1rem;
    box-shadow: 0 8px 28px rgba(99,102,241,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.15);
}
.lp-logo svg {
    width: 30px; height: 30px;
    stroke: #fff; fill: none;
    stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
}
.lp-title {
    font-size: 1.65rem;
    font-weight: 800;
    color: #f1f5f9;
    letter-spacing: -0.03em;
    margin: 0 0 0.4rem;
    text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.lp-sub {
    font-size: 0.85rem;
    color: rgba(148,163,184,0.85);
    margin: 0;
    line-height: 1.5;
    letter-spacing: 0.01em;
}

/* Error banner */
.lp-error {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.35);
    border-radius: 0.7rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.8375rem;
    color: #fca5a5;
    line-height: 1.5;
    backdrop-filter: blur(8px);
}
.lp-error svg {
    flex-shrink: 0;
    width: 16px; height: 16px;
    stroke: #f87171; fill: none;
    stroke-width: 2.2;
    stroke-linecap: round; stroke-linejoin: round;
    margin-top: 1px;
}

/* Form */
.lp-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.lp-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.lp-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(203,213,225,0.9);
    letter-spacing: 0.02em;
}
.lp-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.lp-forgot {
    font-size: 0.8rem;
    color: #a5b4fc;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.lp-forgot:hover { color: #c7d2fe; text-decoration: underline; }

/* Input wrapper */
.lp-inp-wrap {
    position: relative;
}
.lp-inp-ico {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    stroke: rgba(148,163,184,0.7); fill: none;
    stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    pointer-events: none;
    transition: stroke 0.18s;
}
.lp-inp-wrap:focus-within .lp-inp-ico {
    stroke: #a5b4fc;
}
.lp-inp {
    width: 100%;
    padding: 0.75rem 0.9rem 0.75rem 2.6rem;
    background: rgba(255,255,255,0.07);
    border: 1.5px solid rgba(255,255,255,0.12);
    border-radius: 0.7rem;
    font-size: 0.9rem;
    font-family: var(--font);
    color: #f1f5f9;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    backdrop-filter: blur(8px);
}
.lp-inp:focus {
    border-color: rgba(99,102,241,0.7);
    background: rgba(255,255,255,0.11);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2), 0 0 16px rgba(99,102,241,0.1);
}
.lp-inp::placeholder { color: rgba(100,116,139,0.7); }

/* Submit button */
.lp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1rem;
    margin-top: 0.5rem;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.2);
    border-radius: 0.7rem;
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99,102,241,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
    transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s;
}
.lp-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(99,102,241,0.6), inset 0 1px 0 rgba(255,255,255,0.15);
}
.lp-btn:active { transform: translateY(0); box-shadow: 0 2px 12px rgba(99,102,241,0.4); }
.lp-btn svg {
    width: 16px; height: 16px;
    stroke: currentColor; fill: none;
    stroke-width: 2.5;
    stroke-linecap: round; stroke-linejoin: round;
}

/* Footer copyright */
.lp-footer {
    text-align: center;
    margin-top: 1.75rem;
    font-size: 0.75rem;
    color: rgba(100,116,139,0.75);
}
.lp-footer a { color: #a5b4fc; }
.lp-footer a:hover { color: #c7d2fe; }

/* Responsive */
@media (max-width: 480px) {
    .lp-card { padding: 2.25rem 1.5rem 2rem; border-radius: 1.25rem; }
    .lp-title { font-size: 1.4rem; }
}

/* ============================================================
   Reusable Modal  (.ims-modal-overlay / .ims-modal)
   ============================================================ */
.ims-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(3px);
    display: flex;          /* toggled by JS */
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    animation: modal-fade-in 0.2s ease;
}
@keyframes modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
body.modal-open { overflow: hidden; }

.ims-modal {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 24px 64px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    animation: modal-slide-up 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modal-slide-up {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.ims-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.ims-modal-head h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}
.ims-modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    transition: background 0.15s, color 0.15s;
}
.ims-modal-close:hover { background: #f1f5f9; color: #0f172a; }

/* Body */
.ims-modal-body {
    padding: 1.5rem;
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-width: 0;
}

/* Modal form grid */
.modal-grid-form { display: flex; flex-direction: column; gap: 1rem; }
.mf-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
}
@media (max-width: 520px) { .mf-row { grid-template-columns: 1fr; } }
.mf-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.mf-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    letter-spacing: 0.01em;
}
.mf-label .req { color: #ef4444; margin-left: 2px; }
.mf-input {
    padding: 0.55rem 0.75rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: var(--font);
    color: #0f172a;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
    width: 100%;
    box-sizing: border-box;
}
.mf-input:focus {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.mf-input::placeholder { color: #cbd5e1; }

/* Modal actions */
.mf-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
    margin-top: 0.5rem;
}
.btn-primary {
    padding: 0.5rem 1.1rem;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(99,102,241,0.4);
    transition: opacity 0.15s, transform 0.15s;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
    padding: 0.5rem 1.1rem;
    background: #f1f5f9;
    color: #475569;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover { background: #e2e8f0; color: #1e293b; }
.btn-modal-danger {
    padding: 0.5rem 1.1rem;
    background: #f1f5f9;
    color: #dc2626;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-modal-danger:hover { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

/* ============================================================
   Table action buttons  (.btn-sm, .btn-edit, .btn-danger)
   ============================================================ */
.actions-cell { white-space: nowrap; }

.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.1rem;
    border-radius: 0.4rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
    text-decoration: none;
}

.btn-edit {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}
.btn-edit:hover {
    background: #dbeafe;
    border-color: #3b82f6;
    box-shadow: 0 1px 4px rgba(59,130,246,0.2);
}

.btn-view {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}
.btn-view:hover {
    background: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
    box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}

.btn-edit {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}
.btn-edit:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn-revoke {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fed7aa;
}
.btn-revoke:hover {
    background: #c2410c;
    color: #ffffff;
    border-color: #c2410c;
    box-shadow: 0 4px 12px rgba(194,65,12,0.3);
}

.btn-danger {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}
.btn-danger:hover {
    background: #fee2e2;
    border-color: #f87171;
    box-shadow: 0 1px 4px rgba(220,38,38,0.18);
}

/* ============================================================
   Page Tabs  (.tabs-bar / .tab-btn)
   ============================================================ */
.tabs-bar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 1.5rem;
    padding-bottom: 0;
    flex-wrap: wrap;
}
.tab-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -2px;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-radius: 0;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    box-shadow: none;
}
.tab-btn:hover  { color: #6366f1; background: none; transform: none; }
.tab-btn.active { color: #6366f1; border-bottom-color: #6366f1; }
.tabs-action { margin-left: auto; }

/* ============================================================
   Table column filters  (table-filters.js)
   ============================================================ */

/* ============================================================
   Table column filters  (table-filters.js)
   ============================================================ */

/* ── Filter row ─────────────────────────────────────────────── */
.tbl-filter-row {
    background: var(--surface);
    border-bottom: 2px solid var(--accent);
}
.tbl-filter-row .tbl-filter-cell {
    padding: .4rem .6rem .5rem;
    vertical-align: middle;
}

/* ── Shared input base ──────────────────────────────────────── */
.tbl-col-input {
    display: block;
    width: 100%;
    padding: .3rem .55rem .3rem 1.9rem;
    font-size: .78rem;
    font-family: var(--font);
    font-weight: 400;
    color: var(--text);
    background: var(--surface-2)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")
        no-repeat 9px center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    outline: none;
    box-shadow: var(--shadow-xs);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.tbl-col-input::placeholder {
    color: var(--text-light);
    font-size: .74rem;
}
.tbl-col-input:hover:not(:focus) {
    border-color: var(--border-strong);
    background-color: var(--surface);
}
.tbl-col-input:focus {
    border-color: var(--accent);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px rgba(99,102,241,.13);
}

/* ── Date input — swap to calendar icon ─────────────────────── */
.tbl-date-input {
    cursor: pointer;
    padding-right: 1.6rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

/* ── Image presence dropdown ────────────────────────────────── */
.tbl-img-select {
    padding-left: .55rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 1.7rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.tbl-img-select:focus {
    border-color: var(--accent);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px rgba(99,102,241,.13);
}

/* ── Clear-button dedicated column ─────────────────────────── */
.tbl-clear-col-hdr,
.tbl-clear-col {
    width: 1px;          /* shrink-wrap to content */
    white-space: nowrap;
    padding: 0 .5rem !important;
}
.tbl-clear-col {
    vertical-align: middle;
    text-align: center;
}

/* ── Clear-all button ───────────────────────────────────────── */
.tbl-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .28rem .7rem;
    font-size: .73rem;
    font-family: var(--font);
    font-weight: 600;
    letter-spacing: .01em;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    line-height: 1.5;
}
.tbl-clear-btn svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
    transition: transform .3s ease;
}
.tbl-clear-btn:hover {
    background: var(--danger-soft);
    border-color: #fca5a5;
    color: var(--danger);
    box-shadow: var(--shadow-sm);
}
.tbl-clear-btn:hover svg {
    transform: rotate(-180deg);
    stroke: var(--danger);
}

/* ── Flatpickr calendar theme ───────────────────────────────── */
.flatpickr-calendar {
    font-family: var(--font);
    font-size: .82rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    z-index: 1400 !important; /* above all modals (rpt-overlay z-index:1200) */
}
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--accent);
    border-color: var(--accent);
}
.flatpickr-day.inRange {
    background: var(--accent-soft);
    box-shadow: -5px 0 0 var(--accent-soft), 5px 0 0 var(--accent-soft);
    color: var(--accent-text);
}
.flatpickr-day:hover {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
    color: var(--accent-text);
}

/* ============================================================
   Audit Logs Page  (audit_logs/index.php)
   ============================================================ */

/* ── Page header ── */
.al-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.al-page-header-left {
    display: flex;
    align-items: center;
    gap: .9rem;
}
.al-page-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.al-page-icon svg { width: 22px; height: 22px; }
.al-page-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}
.al-page-sub {
    margin: .15rem 0 0;
    font-size: .8rem;
    color: var(--text-muted);
}

/* ── Filter panel ── */
.al-filter-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.2rem 1.1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-xs);
}
.al-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: .75rem;
    align-items: end;
}
.al-filter-field { display: flex; flex-direction: column; gap: .28rem; }
.al-filter-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}
.al-select-wrap,
.al-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.al-field-icon {
    position: absolute;
    left: 9px;
    width: 14px;
    height: 14px;
    color: var(--text-light);
    pointer-events: none;
    flex-shrink: 0;
}
.al-filter-input {
    width: 100%;
    padding: .42rem .65rem .42rem 2rem;
    font-size: .815rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    box-sizing: border-box;
    box-shadow: var(--shadow-xs);
    transition: border-color .15s, box-shadow .15s, background .15s;
    appearance: none;
}
.al-filter-input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(99,102,241,.13);
}
.al-filter-input:hover:not(:focus) {
    border-color: var(--border-strong);
}
/* Arrow for selects */
.al-select-wrap::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-light);
    pointer-events: none;
}
.al-filter-actions {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    padding-bottom: 1px;
}
.al-btn-apply {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .42rem 1rem;
    font-size: .82rem;
    font-family: var(--font);
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background .15s, box-shadow .15s;
    white-space: nowrap;
}
.al-btn-apply svg { width: 13px; height: 13px; }
.al-btn-apply:hover { background: var(--accent-dark); box-shadow: var(--shadow); }
.al-btn-clear {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .42rem .85rem;
    font-size: .82rem;
    font-family: var(--font);
    font-weight: 600;
    background: var(--surface);
    color: var(--text-muted);
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.al-btn-clear svg { width: 12px; height: 12px; }
.al-btn-clear:hover { background: var(--danger-soft); border-color: #fca5a5; color: var(--danger); }

/* ── Active filter chips ── */
.al-chips {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .9rem;
}
.al-chips-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.al-chip {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .18rem .55rem;
    background: var(--accent-soft);
    color: var(--accent-text);
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    font-size: .73rem;
    font-weight: 500;
}

/* ── Table wrapper ── */
.al-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.al-table { margin: 0; }
.al-table thead { background: var(--surface-2); }
.al-table th {
    font-size: .68rem;
    padding: .65rem 1rem;
    white-space: nowrap;
}
.al-table td { padding: .65rem 1rem; vertical-align: top; }
.al-row:hover { background: #fafbff; }

/* ── Timestamp cell ── */
.al-td-time { white-space: nowrap; }
.al-date { display: block; font-size: .82rem; font-weight: 600; color: var(--text); }
.al-time { display: block; font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }

/* ── User cell ── */
.al-td-user { white-space: nowrap; display: flex; align-items: center; gap: .5rem; padding-top: .7rem; }
.al-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .02em;
    flex-shrink: 0;
}
.al-username { font-size: .82rem; color: var(--text); font-weight: 500; }

/* ── Module pill ── */
.al-module-pill {
    display: inline-block;
    padding: .2rem .55rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .73rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Action badges ── */
.al-badge {
    display: inline-block;
    padding: .22rem .6rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
.al-badge-create   { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.al-badge-update   { background: var(--info-soft); color: var(--info-text); border: 1px solid #bfdbfe; }
.al-badge-delete   { background: var(--danger-soft); color: var(--danger-text); border: 1px solid #fecaca; }
.al-badge-approve  { background: #f5f3ff; color: #5b21b6; border: 1px solid #ddd6fe; }
.al-badge-received { background: #ecfeff; color: #155e75; border: 1px solid #a5f3fc; }
.al-badge-revoke   { background: var(--warning-soft); color: var(--warning-text); border: 1px solid #fde68a; }
.al-badge-issue    { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.al-badge-settled  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.al-badge-default  { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Table column sorting ───────────────────────────────────── */
.tbl-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.tbl-sortable:hover { color: var(--accent); }
.tbl-sort-ico {
    display: inline-block;
    margin-left: .28em;
    opacity: .28;
    font-size: .78em;
    vertical-align: middle;
    line-height: 1;
    transition: opacity .14s, color .14s;
    pointer-events: none;
}
.tbl-sort-ico::before { content: '⇅'; }
.tbl-sortable:hover .tbl-sort-ico { opacity: .6; }
.tbl-sort-asc  .tbl-sort-ico { opacity: 1; color: var(--accent); }
.tbl-sort-asc  .tbl-sort-ico::before { content: '↑'; }
.tbl-sort-desc .tbl-sort-ico { opacity: 1; color: var(--accent); }
.tbl-sort-desc .tbl-sort-ico::before { content: '↓'; }

/* ── Export / Print toolbar ─────────────────────────────────── */
.tbl-export-bar {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 0 .55rem;
    flex-wrap: wrap;
}
.tbl-export-bar .tile-view-toggle {
    margin-left: auto;
}
.tbl-export-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-right: .1rem;
    white-space: nowrap;
}
.tbl-export-btn {
    display: inline-flex;
    align-items: center;
    gap: .28rem;
    padding: .28rem .65rem;
    border-radius: var(--radius-sm);
    font-size: .73rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    transition: background .14s, color .14s, border-color .14s;
    white-space: nowrap;
    line-height: 1.45;
}
.tbl-export-btn svg {
    flex-shrink: 0;
    transition: color .14s;
}
.tbl-export-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}
.tbl-export-print:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
.tbl-export-xls:hover {
    border-color: #16a34a;
    color: #16a34a;
    background: #f0fdf4;
}
.tbl-export-pdf:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}
@media print {
    .tbl-export-bar,
    .tabs-bar,
    .topbar,
    .sidebar,
    .panel-head .button,
    .panel-head .btn,
    .tbl-filter-row,
    .tbl-clear-btn,
    .tbl-clear-col-hdr { display: none !important; }
}

/* ── Record / IP ── */
.al-td-record { text-align: center; }
.al-record-id {
    font-size: .75rem;
    font-family: 'Courier New', monospace;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .1rem .35rem;
    color: var(--text-muted);
}
.al-ip {
    font-size: .75rem;
    font-family: 'Courier New', monospace;
    color: var(--text-muted);
}
.al-muted { color: var(--text-light); font-size: .8rem; }

/* ── Changes / diff ── */
.al-td-changes { min-width: 140px; }
.al-diff-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .22rem .6rem;
    font-size: .73rem;
    font-family: var(--font);
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.al-diff-btn svg { width: 12px; height: 12px; }
.al-diff-btn:hover,
.al-diff-btn--open {
    background: var(--accent-soft);
    border-color: #c7d2fe;
    color: var(--accent-text);
}
.al-diff-panel {
    margin-top: .5rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.al-diff-block {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}
.al-diff-block-label {
    padding: .22rem .6rem;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.al-diff-old .al-diff-block-label { background: var(--danger-soft); color: var(--danger-text); border-bottom: 1px solid #fecaca; }
.al-diff-new .al-diff-block-label { background: #ecfdf5; color: #065f46; border-bottom: 1px solid #a7f3d0; }
.al-diff-pre {
    margin: 0;
    padding: .55rem .7rem;
    font-size: .7rem;
    font-family: 'Courier New', monospace;
    color: var(--text);
    background: var(--surface-2);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}

/* Date-range picker input */
.al-daterange-input {
    cursor: pointer;
    padding-right: 1.8rem;
}
.al-daterange-clr {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-light);
    font-size: .85rem;
    font-weight: 700;
    line-height: 1;
    transition: background .15s, color .15s;
    user-select: none;
}
.al-daterange-clr:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ── Empty state ── */
.al-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 2rem;
    color: var(--text-muted);
    gap: .6rem;
    text-align: center;
}
.al-empty svg { width: 40px; height: 40px; color: var(--text-light); }
.al-empty p { margin: 0; font-size: .9rem; }
.al-empty a { color: var(--accent); font-weight: 600; font-size: .85rem; text-decoration: none; }
.al-empty a:hover { text-decoration: underline; }


/* ============================================================
   RESPONSIVE — TABLET & TOUCH  (≤ 1024px)
   ============================================================ */

/* ── CSS custom property overrides for tablet ── */
@media (max-width: 1024px) {
    :root {
        --topbar-h: 58px;
    }

    /* Main padding tightened slightly */
    .main { padding: 1rem; }

    /* Topbar: show hamburger, hide user name on small space */
    .topbar { padding: 0 1rem; }
    .topbar-mobile-toggle { display: flex; }
    .user-name { display: none; }

    /* Grid layouts collapse to single column */
    .grid-two { grid-template-columns: 1fr; }
    .grid-form-2 { grid-template-columns: 1fr; }

    /* Panel head — stack title + button vertically on very tight space */
    .panel-head { flex-wrap: wrap; gap: .5rem; }

    /* Cards grid: 2 columns on tablet */
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── TABLET TOUCH MODE  (768px – 1024px) ── */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Larger touch targets for all buttons */
    .btn-sm {
        padding: .6rem 1.1rem;
        font-size: .875rem;
        min-height: 42px;
    }
    .button,
    button.btn,
    .btn-primary,
    .btn-secondary,
    .btn-modal-danger {
        min-height: 44px;
        padding: .65rem 1.25rem;
        font-size: .9rem;
    }
    .tab-btn {
        padding: .7rem 1.35rem;
        font-size: .9rem;
    }

    /* Form inputs: larger for touch */
    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    .mf-input,
    .lp-inp,
    .al-filter-input,
    .tbl-col-input {
        min-height: 44px;
        font-size: .9rem;
        padding: .65rem .85rem;
    }
    .tbl-col-input { padding: .42rem .55rem .42rem 1.9rem; font-size: .82rem; min-height: 36px; }

    /* Dashboard stat cards: 2-col */
    .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }

    /* Reports tile grid: wider min */
    .report-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* ── MOBILE  (< 768px) ── */
@media (max-width: 767px) {
    :root { --topbar-h: 54px; }

    .main { padding: .75rem; }
    .topbar { padding: 0 .875rem; }
    .user-name { display: none; }
    .topbar-divider { display: none; }
    .topbar-link { display: none; }

    /* Single column cards */
    .cards-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
    .card p { font-size: 1.6rem; }

    /* Reports single col */
    .report-grid { grid-template-columns: 1fr; }

    /* Modal: fit on tablet */
    .ims-modal { max-width: 98vw !important; max-height: calc(100vh - 2rem); border-radius: .75rem; }
    .ims-modal-body { padding: 1rem; }
    .ims-modal-head { padding: .875rem 1rem; }
    .mf-actions { padding-top: .875rem; }

    /* Buttons: full touch size */
    .btn-sm { min-height: 40px; padding: .55rem .9rem; }
    .btn-primary,
    .btn-secondary { min-height: 44px; padding: .6rem 1rem; }

    /* Form inputs touch */
    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    .mf-input {
        min-height: 44px;
        font-size: .925rem;
    }

    /* Tabs bar: scrollable */
    .tabs-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
    .tab-btn { flex-shrink: 0; }

    /* Panel head: stack */
    .panel-head { flex-direction: row; flex-wrap: wrap; gap: .5rem; }
}

/* ── Very small mobile  (< 480px) ── */
@media (max-width: 479px) {
    .cards-grid { grid-template-columns: 1fr; }
}


/* ============================================================
   TILE CARD VIEW  (injected by responsive.js at ≤ 1024px)
   ============================================================ */

/* Toggle button */
.tile-view-toggle {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .75rem;
    font-size: .78rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-muted);
    transition: background var(--t), border-color var(--t), color var(--t);
    white-space: nowrap;
    flex-shrink: 0;
}
.tile-view-toggle:hover,
.tile-view-toggle.is-tile {
    background: var(--accent-soft);
    border-color: #c7d2fe;
    color: var(--accent-text);
}
.tile-view-toggle svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Cards grid container */
.tile-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
    padding: .25rem 0;
    animation: tile-fade-in .22s ease;
}
@keyframes tile-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Individual tile card */
.tile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.15rem;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: box-shadow var(--t), transform var(--t), border-color var(--t);
    position: relative;
    overflow: hidden;
    cursor: default;
}
.tile-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.tile-card:hover {
    box-shadow: var(--shadow);
    border-color: #c7d2fe;
    transform: translateY(-2px);
}

/* Card title row (first meaningful field) */
.tile-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .75rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--border);
}
.tile-card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.tile-head-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .2rem;
    flex-shrink: 0;
    margin-left: .4rem;
}
.tile-card-code {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: 'Consolas', 'Courier New', monospace;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: .3rem;
    padding: .1rem .4rem;
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    text-align: right;
}

/* Field rows */
.tile-fields {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    flex: 1;
    min-height: 0;
}
.tile-field-row {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: .82rem;
    line-height: 1.4;
}
.tile-field-label {
    flex: 0 0 36%;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    padding-top: .15rem;
    word-break: break-word;
    line-height: 1.3;
}
.tile-field-val {
    flex: 1;
    color: var(--text);
    word-break: break-word;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    font-size: .82rem;
    line-height: 1.4;
}
.tile-val-empty {
    color: var(--text-muted);
    font-style: italic;
}

/* Tile card image banner (for tables with an Image column) */
.tile-card-img {
    margin: -1.1rem -1.15rem .9rem;
    width: calc(100% + 2.3rem);
    height: 130px;
    overflow: hidden;
    position: relative;
    background: #f0f4f8;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    flex-shrink: 0;
}
.tile-card-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: .5rem;
    box-sizing: border-box;
}
.tile-card-img.tile-card-no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 2.2rem;
}

/* Actions strip */
.tile-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding-top: .7rem;
    margin-top: .6rem;
    border-top: 1px solid var(--border);
}
/* Make action buttons fill space on tile card */
.tile-card-actions .btn-sm {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 72px;
    min-height: 40px;
}

/* Empty-state tile */
.tile-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: .9rem;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}

/* Sticky panel-head gets toggle button injected inside .panel-head-actions */
.panel-head-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

/* Fallback toolbar for panels without a panel-head (e.g. tab-panels) */
.panel-tile-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: .45rem 0 .6rem;
    margin-bottom: .25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .75rem;
}

/* On mobile tile cards: single column */
@media (max-width: 480px) {
    .tile-cards-grid {
        grid-template-columns: 1fr;
    }
    .tile-card-actions .btn-sm {
        flex: 1 1 80px;
    }
}

/* Print: always table, hide tiles */
@media print {
    .tile-cards-grid { display: none !important; }
    .tile-view-toggle { display: none !important; }
    .table-scroll { display: block !important; overflow: visible !important; }
}


/* ============================================================
   TOUCH ENHANCEMENTS  (pointer: coarse = touch device)
   ============================================================ */
@media (pointer: coarse) {
    /* Minimum 44×44 touch targets */
    .btn-sm,
    .button,
    button.btn,
    .btn-primary,
    .btn-secondary,
    .btn-modal-danger,
    .tab-btn,
    .tbl-export-btn,
    .tbl-clear-btn,
    .tile-view-toggle {
        min-height: 44px;
    }
    .btn-sm { padding: .6rem 1rem; }

    /* Inputs: larger for fat fingers */
    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    .mf-input,
    .lp-inp {
        min-height: 46px;
        font-size: .9375rem;
    }

    /* Sidebar nav items: taller */
    .nav-item { padding: .65rem .9rem; }

    /* Table rows: slightly taller */
    .table td { padding: .9rem 1rem; }

    /* Remove hover-only transforms (can be jarring on touch) */
    .card:hover { transform: none; }
    .report-card:hover { transform: none; }
    .tile-card:hover { transform: none; }
}


/* ============================================================
   BOTTOM NAV BAR  (mobile < 768px only — quick jump nav)
   ============================================================ */
.bottom-nav {
    display: none;
}
@media (max-width: 767px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 16px rgba(15,23,42,.08);
        height: 58px;
        align-items: stretch;
        padding: 0;
        overflow: hidden;
    }
    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        text-decoration: none;
        color: var(--text-muted);
        font-size: .6rem;
        font-weight: 600;
        letter-spacing: .01em;
        text-transform: uppercase;
        transition: color var(--t), background var(--t);
        padding: .4rem .25rem;
        border-radius: 0;
        background: none;
        border: none;
        cursor: pointer;
        font-family: var(--font);
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav-item svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        fill: none;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
        flex-shrink: 0;
    }
    .bottom-nav-item.active,
    .bottom-nav-item:active {
        color: var(--accent);
        background: var(--accent-soft);
    }
    /* Push main content up so it isn't hidden behind bottom nav */
    .main { padding-bottom: 70px; }
    .topbar-logout { font-size: .77rem; padding: .28rem .55rem; }
}


/* ============================================================
   PERMISSION MATRIX — tablet responsive
   ============================================================ */
@media (max-width: 1024px) {
    .perm-matrix-tbl { font-size: .72rem; }
    .perm-matrix-tbl th,
    .perm-matrix-tbl td { padding: .4rem .35rem; }
}

/* ============================================================
   TOPBAR — small phone adjustments
   ============================================================ */
@media (max-width: 480px) {
    /* Hide user name text, keep only avatar */
    .user-name { display: none; }
    /* Hide profile link — access via sidebar */
    .topbar-link { display: none; }
    /* Hide divider */
    .topbar-divider { display: none; }
    /* Shrink topbar padding */
    .topbar { padding: 0 0.75rem; }
    /* Prevent title from being cut off */
    .topbar-title {
        font-size: 0.875rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: calc(100vw - 140px);
    }
}

/* ============================================================
   MODALS — mobile-friendly sizing & centered layout
   ============================================================ */
@media (max-width: 640px) {
    .ims-modal-overlay {
        padding: .75rem .5rem;
        align-items: center;    /* centered, not bottom-sheet */
    }
    /* !important overrides any inline max-width/width set on .ims-modal */
    .ims-modal {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: .75rem !important;
        max-height: calc(100vh - 1.5rem) !important;
    }
    .ims-modal-head {
        padding: .875rem 1rem;
        gap: .5rem;
        flex-shrink: 0;
    }
    .ims-modal-head h3,
    .ims-modal-head h4 {
        font-size: .9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }
    .ims-modal-body {
        padding: .875rem 1rem;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* override any inline max-height set on .ims-modal-body */
        max-height: calc(100vh - 8rem) !important;
    }

    /* All .mf-row inside a modal collapse to 1 column,
       even those with inline grid-template-columns overrides */
    .ims-modal .mf-row {
        grid-template-columns: 1fr !important;
    }

    /* Table wrappers inside modal body: "overflow:hidden" prevents
       horizontal scrolling — flip to auto so tables scroll */
    .ims-modal-body div[style*="overflow:hidden"] {
        overflow: auto !important;
    }

    /* Inline detail-info grids (2/3-col label/value pairs in view modals)
       collapse to 2 col on mobile — down to 1 col on tiny phones only */
    .ims-modal-body div[style*="grid-template-columns:1fr 1fr"],
    .ims-modal-body div[style*="grid-template-columns: 1fr 1fr"],
    .ims-modal-body div[style*="grid-template-columns:repeat(2,1fr)"],
    .ims-modal-body div[style*="grid-template-columns:repeat(3,1fr)"],
    .ims-modal-body div[style*="grid-template-columns: repeat(3,1fr)"],
    .ims-modal-body div[style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* ── Line-item rows (.line-row): reflow as flex card ── */
    /* Each .line-row in create/edit modals morphs from a multi-column
       grid into a wrap-friendly flex card so items don't overflow. */
    .ims-modal-body .line-row {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: .35rem .4rem !important;
        padding: .55rem .65rem !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: .5rem !important;
        background: #f8fafc !important;
        margin-bottom: .45rem !important;
    }
    /* Thumbnail: fixed square, doesn't grow */
    .ims-modal-body .line-row .gi-item-thumb,
    .ims-modal-body .line-row .sa-item-thumb,
    .ims-modal-body .line-row .pr-item-thumb {
        flex: 0 0 auto !important;
    }
    /* Item select / PR item name text: takes up full width of its line */
    .ims-modal-body .line-row .gi-item-sel,
    .ims-modal-body .line-row .sa-item-sel,
    .ims-modal-body .line-row .pr-item-sel,
    .ims-modal-body .line-row .gi-pr-item-name {
        flex: 1 1 calc(100% - 50px) !important;
        min-width: 0 !important;
    }
    /* On-hand / req-qty / avail-qty badges: fixed, non-growing */
    .ims-modal-body .line-row .gi-stock-cell,
    .ims-modal-body .line-row .gi-pr-req-qty,
    .ims-modal-body .line-row .gi-pr-avail-qty {
        flex: 0 0 auto !important;
        min-width: 44px !important;
        font-size: .75rem !important;
    }
    /* Qty input: small but usable */
    .ims-modal-body .line-row .gi-line-qty,
    .ims-modal-body .line-row .gi-pr-issue-qty,
    .ims-modal-body .line-row input[name="quantity[]"],
    .ims-modal-body .line-row input[name="requested_qty[]"],
    .ims-modal-body .line-row input[name="issued_qty[]"] {
        flex: 1 1 70px !important;
        max-width: 100px !important;
        min-width: 0 !important;
    }
    /* Adjust-type select (Stock Adjustment): compact */
    .ims-modal-body .line-row select[name="adjust_type[]"] {
        flex: 0 0 90px !important;
        min-width: 0 !important;
    }
    /* Notes input: takes remaining space */
    .ims-modal-body .line-row input[name="line_notes[]"] {
        flex: 1 1 100px !important;
        min-width: 0 !important;
    }
    /* Remove button: always at end */
    .ims-modal-body .line-row [data-remove-line] {
        flex: 0 0 auto !important;
        margin-left: auto !important;
        white-space: nowrap !important;
    }
    /* Edit-GI line (no thumbnail): select full-width */
    .ims-modal-body .line-row select[name="item_id[]"]:not(.gi-item-sel):not(.sa-item-sel):not(.pr-item-sel) {
        flex: 1 1 100% !important;
        min-width: 0 !important;
    }

    /* Hide column-header label bars for line-item sections on mobile —
       they're aligned to grid columns that no longer exist */
    #gi-free-lines-header,
    #gi-pr-lines-header {
        display: none !important;
    }

    /* Action buttons: wrap on 640px */
    .ims-modal .mf-actions {
        flex-wrap: wrap;
        gap: .5rem;
    }
    .ims-modal .mf-actions .btn-primary,
    .ims-modal .mf-actions .btn-secondary,
    .ims-modal .mf-actions .button {
        flex: 1 1 auto;
        min-width: 120px;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 400px) {
    .ims-modal .mf-actions {
        flex-direction: column-reverse;
    }
    .ims-modal .mf-actions .btn-primary,
    .ims-modal .mf-actions .btn-secondary,
    .ims-modal .mf-actions .button {
        width: 100%;
        flex: none;
    }
    /* Collapse all info grids to 1 column on tiny phones */
    .ims-modal-body div[style*="grid-template-columns:1fr 1fr"],
    .ims-modal-body div[style*="grid-template-columns: 1fr 1fr"],
    .ims-modal-body div[style*="grid-template-columns:repeat(2,1fr)"],
    .ims-modal-body div[style*="grid-template-columns:repeat(3,1fr)"],
    .ims-modal-body div[style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================================
   PANEL HEAD — wrap on small screens
   ============================================================ */
@media (max-width: 640px) {
    .panel-head {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .panel-head h3 { font-size: 0.875rem; }
    .panel-head-actions { flex-wrap: wrap; }
}

/* ============================================================
   LINE ITEM ROWS — collapse grn-row on mobile
   ============================================================ */
@media (max-width: 640px) {
    .line-grn-row { grid-template-columns: 1fr; }
    .inline-price-form { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   AUTH SPLIT — override .auth-page centering when split layout
   ============================================================ */
.auth-page:has(.auth-split) {
    padding: 0;
    align-items: stretch;
}

/* Company logo in auth left panel */
.auth-logo-wrap {
    margin-bottom: 1.5rem;
}
.auth-company-logo {
    max-height: 80px;
    max-width: 220px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

/* Auth form footer copyright */
.auth-form-footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.775rem;
    color: #94a3b8;
}


/* ═══════════════════════════════════════════════════════════════
   IMS TOAST NOTIFICATION SYSTEM
   #ims-toasts container + .imt  individual toast cards
   ═══════════════════════════════════════════════════════════════ */

#ims-toasts {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99900;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 370px;
    max-width: calc(100vw - 48px);
    pointer-events: none;
}

/* ── Base card ── */
.imt {
    pointer-events: all;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 18px 14px;
    background: #ffffff;
    border-radius: 10px;
    border-left: 4px solid transparent;
    box-shadow:
        0 4px 6px -1px rgba(15, 23, 42, .10),
        0 12px 40px -4px rgba(15, 23, 42, .15),
        0 0 0 1px rgba(15, 23, 42, .05);
    overflow: hidden;
    /* Enter: off-screen right → origin */
    transform: translateX(calc(100% + 32px));
    opacity: 0;
    transition: transform .36s cubic-bezier(.34, 1.42, .64, 1), opacity .28s ease;
    will-change: transform, opacity;
}

/* Enter state */
.imt.imt--in {
    transform: translateX(0);
    opacity: 1;
}

/* Exit state */
.imt.imt--out {
    transform: translateX(calc(100% + 32px));
    opacity: 0;
    transition: transform .3s ease-in, opacity .25s ease;
}

/* ── Type left-border colors ── */
.imt--success { border-left-color: var(--success, #10b981); }
.imt--error   { border-left-color: var(--danger,  #ef4444); }
.imt--warning { border-left-color: var(--warning, #f59e0b); }
.imt--info    { border-left-color: var(--info,    #3b82f6); }

/* ── Icon ── */
.imt__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}
.imt--success .imt__icon { color: var(--success, #10b981); }
.imt--error   .imt__icon { color: var(--danger,  #ef4444); }
.imt--warning .imt__icon { color: var(--warning, #f59e0b); }
.imt--info    .imt__icon { color: var(--info,    #3b82f6); }

/* ── Text area ── */
.imt__body  { flex: 1; min-width: 0; }

.imt__title {
    font-size: .875rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 2px;
    line-height: 1.3;
}

.imt__msg {
    font-size: .8rem;
    color: #475569;
    margin: 0;
    line-height: 1.5;
    word-break: break-word;
}

/* When no title exists, make message slightly larger */
.imt__body > .imt__msg:first-child {
    font-size: .875rem;
    color: #1e293b;
}

/* ── Close button ── */
.imt__close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin: -1px -2px 0 4px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.imt__close:hover { background: #f1f5f9; color: #475569; }

/* ── Progress bar (auto-dismiss timer) ── */
.imt__bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    transform-origin: left center;
    animation: imt-shrink linear forwards;
    animation-play-state: paused;
}
.imt--success .imt__bar { background: var(--success, #10b981); opacity: .7; }
.imt--error   .imt__bar { background: var(--danger,  #ef4444); opacity: .7; }
.imt--warning .imt__bar { background: var(--warning, #f59e0b); opacity: .7; }
.imt--info    .imt__bar { background: var(--info,    #3b82f6); opacity: .7; }

@keyframes imt-shrink {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ── Mobile adjustments ── */
@media (max-width: 480px) {
    #ims-toasts {
        top: 60px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }
}

/* ============================================================
   SETTINGS TABS — horizontal scroll on small screens
   ============================================================ */
@media (max-width: 767px) {
    .stg-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 2px;
        scrollbar-width: none;
    }
    .stg-tabs::-webkit-scrollbar { display: none; }
    .stg-tab { flex-shrink: 0; }
}

/* ============================================================
   PROFILE HERO — stack on small phones
   ============================================================ */
@media (max-width: 480px) {
    .prf-hero {
        flex-direction: column;
        text-align: center;
    }
    .prf-hero-meta { justify-content: center; }
}
