/* ============================================================================
   ChemShield GHS Hazardous Label Generator & SDS Management System
   Main Stylesheet + Exact Avery 5164 (8.5" x 11", 6-up) Print Engine
   ============================================================================ */

:root {
    --bg-body: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-light: #94a3b8;
    --border-color: #cbd5e1;
    --border-subtle: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --ghs-red: #d91b1b;
    --ghs-red-bg: #fef2f2;
    --ghs-warning: #d97706;
    --ghs-warning-bg: #fffbeb;
    --raw-material: #0284c7;
    --raw-material-bg: #e0f2fe;
    --finished-good: #059669;
    --finished-good-bg: #d1fae5;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.18);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.45;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ============================================================================
   LOGIN VIEW
   ============================================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(circle at 20% 20%, #1e293b 0%, #0f172a 65%, #020617 100%);
}

.login-container {
    width: 100%;
    max-width: 960px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55);
}

@media (max-width: 820px) {
    .login-container {
        grid-template-columns: 1fr;
    }
}

.login-hero {
    background: linear-gradient(155deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 4px solid var(--ghs-red);
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.brand-diamond {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.brand-subtitle {
    font-size: 0.78rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.login-feature-list {
    list-style: none;
    margin: 1.25rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.login-feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.login-feature-badge {
    background: rgba(217, 27, 27, 0.25);
    border: 1px solid #ef4444;
    color: #fca5a5;
    font-weight: 700;
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
}

.demo-accounts-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
}

.demo-accounts-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin-bottom: 0.65rem;
    font-weight: 700;
}

.demo-role-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.demo-role-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #f8fafc;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.demo-role-btn:hover {
    background: rgba(37, 99, 235, 0.28);
    border-color: #60a5fa;
}

.demo-role-btn strong {
    font-size: 0.85rem;
    display: block;
}

.demo-role-btn span {
    font-size: 0.74rem;
    color: #94a3b8;
}

.demo-role-pill {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
}

.pill-admin { background: #dc2626; color: #fff; }
.pill-editor { background: #2563eb; color: #fff; }
.pill-user { background: #059669; color: #fff; }

.login-form-pane {
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-form-pane h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.login-form-pane p.sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ============================================================================
   MAIN APP LAYOUT (SIDEBAR + TOPBAR + WORKSPACE)
   ============================================================================ */
.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
}

.app-sidebar {
    background: var(--bg-sidebar);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.25rem;
    border-right: 1px solid #1e293b;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 1.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: #cbd5e1;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #ffffff;
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}

.sidebar-avery-card {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-md);
    padding: 0.95rem;
    margin-top: 1.5rem;
}

.sidebar-avery-card h4 {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin-bottom: 0.4rem;
}

.mini-sheet-indicator {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin: 0.6rem 0;
}

.mini-slot {
    padding: 0.3rem;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 3px;
    background: #0f172a;
    color: #64748b;
    border: 1px solid #334155;
    cursor: pointer;
}

.mini-slot.used {
    background: #1e293b;
    color: #475569;
    text-decoration: line-through;
}

.mini-slot.next-avail {
    background: #dc2626;
    color: #ffffff;
    border-color: #f87171;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.5);
}

/* Main Content Area */
.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.topbar-left h1 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
}

.topbar-left p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.user-profile-chip {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
}

.user-profile-meta {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-profile-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.user-profile-dept {
    font-size: 0.73rem;
    color: var(--text-muted);
}

.app-content {
    padding: 1.5rem 1.75rem;
    flex: 1;
}

/* ============================================================================
   BUTTONS, INPUTS, BADGES & CARDS
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    font-size: 0.86rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-sm {
    padding: 0.36rem 0.68rem;
    font-size: 0.78rem;
}

.btn-lg {
    padding: 0.72rem 1.35rem;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-danger {
    background: var(--ghs-red);
    color: #ffffff;
}
.btn-danger:hover {
    background: #b91c1c;
}

.btn-secondary {
    background: #ffffff;
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-success {
    background: #059669;
    color: #ffffff;
}
.btn-success:hover {
    background: #047857;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.58rem 0.75rem;
    font-size: 0.88rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--text-main);
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

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

/* KPI Stats Row */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.stat-card-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 0.2rem;
}

.stat-card-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Filter Toolbar */
.toolbar-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem 1.15rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
}

.category-tabs {
    display: inline-flex;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    gap: 0.25rem;
}

.cat-tab {
    border: none;
    background: transparent;
    padding: 0.45rem 0.9rem;
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--text-muted);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cat-tab.active {
    background: #ffffff;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.filter-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    justify-content: flex-end;
}

/* Product Table & Cards */
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.86rem;
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: #f8fafc;
}

/* Category & Signal Word Badges */
.badge-category {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-raw {
    background: var(--raw-material-bg);
    color: var(--raw-material);
    border: 1px solid #bae6fd;
}

.badge-finished {
    background: var(--finished-good-bg);
    color: var(--finished-good);
    border: 1px solid #a7f3d0;
}

.badge-signal {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.signal-DANGER {
    background: #dc2626;
    color: #ffffff;
}

.signal-WARNING {
    background: #f59e0b;
    color: #111827;
}

.signal-NONE {
    background: #e2e8f0;
    color: #475569;
}

.picto-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.picto-icon-sm {
    width: 30px;
    height: 30px;
    display: inline-block;
}

.ghs-diamond-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================================================
   AVERY 5164 LABEL STUDIO & INTERACTIVE POSITION PICKER
   ============================================================================ */
.studio-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1180px) {
    .studio-layout {
        grid-template-columns: 1fr;
    }
}

.studio-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.studio-panel h3 {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.studio-panel p.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Interactive 2x3 Avery 5164 Position Picker Grid */
.avery-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 0.85rem;
    margin-bottom: 1rem;
}

.picker-slot-btn {
    position: relative;
    height: 82px;
    border-radius: var(--radius-sm);
    border: 2px solid #cbd5e1;
    background: #ffffff;
    padding: 0.5rem 0.6rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.15s ease;
}

.picker-slot-btn:hover {
    border-color: var(--primary);
}

.picker-slot-btn.slot-used-skip {
    background: repeating-linear-gradient(
        -45deg,
        #f1f5f9,
        #f1f5f9 8px,
        #e2e8f0 8px,
        #e2e8f0 16px
    );
    border-color: #cbd5e1;
    color: #64748b;
}

.picker-slot-btn.slot-active-print {
    background: #eff6ff;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.picker-slot-btn.slot-is-next-start {
    border-color: var(--ghs-red);
    box-shadow: 0 0 0 2px rgba(217, 27, 27, 0.25);
}

.picker-slot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.picker-slot-num {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--text-main);
}

.picker-slot-coord {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 600;
}

.picker-slot-status {
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-printing {
    color: var(--primary);
}

.status-skipped {
    color: #64748b;
}

.next-avail-ribbon {
    position: absolute;
    top: -9px;
    left: 8px;
    background: var(--ghs-red);
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/*Scaled Screen Preview of the 8.5" x 11" Avery 5164 Sheet */
.sheet-preview-stage {
    background: #334155;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: auto;
}

.sheet-preview-toolbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #f8fafc;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.sheet-scale-wrapper {
    /* Scale 8.5in x 11in sheet smoothly on screen */
    transform-origin: top center;
    background: #ffffff;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
}

/* ============================================================================
   EXACT AVERY 5164 SHEET & GHS LABEL GEOMETRY (SHARED SCREEN PREVIEW & PRINT)
   Avery 5164 Specifications:
   - Sheet: 8.5in wide x 11.0in high
   - Top/Bottom Margin: 0.5in
   - Left/Right Margin: 0.15625in (5/32")
   - 2 Columns of 4.0in width, Horizontal Gutter: 0.1875in (3/16")
   - 3 Rows of 3.3333in (3-1/3") height, Vertical Gap: 0in
   ============================================================================ */
.avery-5164-sheet {
    width: 8.5in;
    height: 11in;
    background: #ffffff;
    box-sizing: border-box;
    padding-top: 0.5in;
    padding-bottom: 0.5in;
    padding-left: 0.15625in;
    padding-right: 0.15625in;
    display: grid;
    grid-template-columns: 4in 4in;
    column-gap: 0.1875in;
    grid-template-rows: repeat(3, 3.3333in);
    row-gap: 0in;
    position: relative;
}

.avery-5164-slot {
    width: 4in;
    height: 3.3333in;
    box-sizing: border-box;
    padding: 0.09in 0.11in;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Screen preview dashed die-cut outline */
.avery-5164-sheet.preview-guides .avery-5164-slot {
    border: 1px dashed #94a3b8;
    border-radius: 6px;
}

.avery-5164-sheet.show-cut-borders .avery-5164-slot.slot-populated {
    border: 1px dashed #cbd5e1;
}

.slot-empty-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.8rem;
    text-align: center;
    border-radius: 4px;
    background: rgba(241, 245, 249, 0.55);
    cursor: pointer;
    user-select: none;
}

.slot-empty-placeholder:hover {
    background: rgba(226, 232, 240, 0.8);
    color: #475569;
}

/* Inside a Populated 4" x 3.333" GHS Hazardous Label */
.ghs-label-card {
    width: 100%;
    height: 100%;
    border: 2px solid #111827;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #ffffff;
    color: #000000;
    font-family: 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
    overflow: hidden;
    box-sizing: border-box;
}

.ghs-label-top {
    background: #111827;
    color: #ffffff;
    padding: 4px 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    border-bottom: 2px solid #111827;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.ghs-label-prod-title {
    font-size: 10.5pt;
    font-weight: 900;
    line-height: 1.12;
    letter-spacing: -0.01em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ghs-label-code-meta {
    text-align: right;
    font-size: 6.8pt;
    line-height: 1.15;
    flex-shrink: 0;
    font-weight: 700;
    color: #e2e8f0;
}

.ghs-label-body {
    display: grid;
    grid-template-columns: 1.12in 1fr;
    gap: 6px;
    padding: 5px 7px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.ghs-label-left-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    border-right: 1.5px solid #cbd5e1;
    padding-right: 5px;
}

.ghs-signal-banner {
    width: 100%;
    text-align: center;
    font-weight: 900;
    font-size: 9.5pt;
    letter-spacing: 0.06em;
    padding: 2px 4px;
    border-radius: 2px;
    text-transform: uppercase;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.ghs-signal-banner.sig-DANGER {
    background: #d91b1b;
    color: #ffffff;
    border: 1px solid #991b1b;
}

.ghs-signal-banner.sig-WARNING {
    background: #f59e0b;
    color: #000000;
    border: 1px solid #b45309;
}

.ghs-signal-banner.sig-NONE {
    background: #e2e8f0;
    color: #334155;
    font-size: 7.5pt;
}

.ghs-label-pictos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
}

.ghs-label-pictos .label-picto-box {
    width: 0.48in;
    height: 0.48in;
}

.ghs-label-pictos.picto-count-1 .label-picto-box {
    width: 0.72in;
    height: 0.72in;
}

.ghs-label-pictos.picto-count-2 .label-picto-box {
    width: 0.52in;
    height: 0.52in;
}

/* Mini NFPA 704 Diamond on Label Left Column */
.ghs-mini-nfpa-wrap {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 6pt;
    font-weight: 700;
    color: #334155;
}

.nfpa-mini-grid {
    width: 24px;
    height: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    transform: rotate(45deg);
    border: 1px solid #111;
    margin: 4px;
    flex-shrink: 0;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.nfpa-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5.5pt;
    font-weight: 900;
    border: 0.5px solid #111;
}
.nfpa-cell span {
    transform: rotate(-45deg);
}
.nfpa-r { background: #ef4444; color: #fff; }
.nfpa-b { background: #3b82f6; color: #fff; }
.nfpa-y { background: #fde047; color: #000; }
.nfpa-w { background: #ffffff; color: #000; }

.ghs-label-right-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
    overflow: hidden;
    font-size: 6.6pt;
    line-height: 1.22;
}

/* Density adjustments for products with long statements */
.ghs-label-card.density-compact .ghs-label-right-col {
    font-size: 5.9pt;
    line-height: 1.16;
}

.ghs-label-card.density-ultra .ghs-label-right-col {
    font-size: 5.3pt;
    line-height: 1.12;
}

.ghs-stmt-section-title {
    font-weight: 900;
    text-transform: uppercase;
    font-size: 6.2pt;
    color: #111827;
    border-bottom: 0.5px solid #94a3b8;
    margin-bottom: 1px;
}

.ghs-stmt-text {
    color: #111827;
    word-break: break-word;
}

.ghs-ppe-callout {
    background: #f1f5f9;
    border-left: 2.5px solid #111827;
    padding: 1.5px 4px;
    font-size: 5.8pt;
    font-weight: 700;
    margin-top: auto;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.ghs-label-footer {
    background: #f8fafc;
    border-top: 1.5px solid #111827;
    padding: 3px 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 6pt;
    line-height: 1.15;
    color: #111827;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* ============================================================================
   PERMISSION MANAGER & RBAC MATRIX
   ============================================================================ */
.perm-matrix-table th,
.perm-matrix-table td {
    text-align: center;
}

.perm-matrix-table th:first-child,
.perm-matrix-table td:first-child {
    text-align: left;
}

.perm-toggle {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ============================================================================
   MODALS & SDS PDF VIEWER
   ============================================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    overflow-y: auto;
}

.modal-dialog {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 860px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin: auto;
}

.modal-dialog.modal-xl {
    max-width: 1040px;
}

.modal-dialog > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-header {
    padding: 0.9rem 1.35rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 800;
}

.modal-body {
    padding: 1.15rem 1.35rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    max-height: calc(90vh - 125px);
}

.modal-footer {
    padding: 0.85rem 1.35rem;
    border-top: 1px solid var(--border-subtle);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-shrink: 0;
}

.picto-selector-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (max-width: 680px) {
    .picto-selector-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.picto-check-card {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.42rem 0.6rem;
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #ffffff;
    transition: all 0.15s ease;
}

.picto-check-card.selected {
    border-color: var(--ghs-red);
    background: var(--ghs-red-bg);
}

.preset-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    max-height: 95px;
    overflow-y: auto;
    padding: 0.35rem;
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.preset-pill {
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-main);
}

.preset-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast-msg {
    background: #0f172a;
    color: #ffffff;
    padding: 0.75rem 1.15rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    font-weight: 600;
    border-left: 4px solid #10b981;
}

.toast-msg.toast-error {
    border-left-color: #ef4444;
}

/* ============================================================================
   DEDICATED PRINT CONTAINER & @media print RULES FOR AVERY 5164
   ============================================================================ */
#averyPrintRoot {
    display: none;
}

@media print {
    @page {
        size: 8.5in 11in;
        margin: 0mm;
    }

    html, body {
        width: 8.5in !important;
        height: 11in !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        overflow: hidden !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    #loginView,
    #appShell,
    .modal-backdrop,
    .toast-container {
        display: none !important;
    }

    #averyPrintRoot {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 8.5in !important;
        height: 11in !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #averyPrintRoot .avery-5164-sheet {
        box-shadow: none !important;
        margin: 0 !important;
    }

    #averyPrintRoot .avery-5164-slot.slot-empty {
        border: none !important;
        background: transparent !important;
    }

    #averyPrintRoot .slot-empty-placeholder {
        display: none !important;
    }
}
