/**
 * LIM System - Custom Dark Theme Styles
 * Extends Pico CSS with dark tech-industrial design
 * Following dark mode best practices for accessibility and visual comfort
 */

/* Light theme (default) */
:root,
[data-theme="light"] {
    /* Primary colors - brighter for light theme */
    --color-primary: #0099DB;
    --color-primary-hover: #007BB8;
    --color-secondary: #05DCE1;
    --color-accent: #0099DB;
    
    /* Background hierarchy - light theme */
    --bg-base: #FFFFFF;
    --bg-elevated-1: #F5F5F5;
    --bg-elevated-2: #EEEEEE;
    --bg-elevated-3: #E0E0E0;
    --bg-elevated-4: #D5D5D5;
    
    /* Text colors - dark on light background */
    --text-primary: rgba(0, 0, 0, 0.87);
    --text-secondary: rgba(0, 0, 0, 0.60);
    --text-disabled: rgba(0, 0, 0, 0.38);
    
    /* UI element colors */
    --border-color: #E0E0E0;
    --border-subtle: #F5F5F5;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Form field colors - white background for clarity */
    --input-bg: #FFFFFF;
    --input-border: #E0E0E0;
    --input-border-focus: var(--color-primary);
    
    /* Navigation - blue background for white logo contrast */
    --nav-bg: #0099DB;
    --nav-text: rgba(255, 255, 255, 0.95);
    --nav-text-secondary: rgba(255, 255, 255, 0.80);
    --nav-hover-bg: rgba(255, 255, 255, 0.15);
    
    /* Success/Error states - adjusted for light theme */
    --color-success: #2E7D32;
    --color-success-bg: #E8F5E9;
    --color-error: #C62828;
    --color-error-bg: #FFEBEE;
    --color-warning: #F57C00;
    --color-warning-bg: #FFF3E0;
    --color-info: #0099DB;
    --color-info-bg: #E3F2FD;
    
    /* Typography scale */
    --font-size-base: 17px;
    --line-height-base: 1.7;
    --letter-spacing-base: 0.01em;
}

/* Dark theme */
[data-theme="dark"] {
    /* Primary colors - desaturated for dark theme (WCAG AAA compliant) */
    --color-primary: #5DC1F0;
    --color-primary-hover: #7ED4F5;
    --color-secondary: #6FE8EC;
    --color-accent: #0099DB;
    
    /* Background hierarchy - avoiding pure black, ensuring 15.8:1 contrast for white text */
    --bg-base: #121212;
    --bg-elevated-1: #1E1E1E;
    --bg-elevated-2: #2A2A2A;
    --bg-elevated-3: #363636;
    --bg-elevated-4: #424242;
    
    /* Text colors - WCAG AAA compliant (7:1 contrast ratio minimum) */
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.70);
    --text-disabled: rgba(255, 255, 255, 0.38);
    
    /* UI element colors */
    --border-color: #3A3A3A;
    --border-subtle: #252525;
    --shadow-color: rgba(0, 0, 0, 0.4);
    
    /* Form field colors - elevated background for dark theme */
    --input-bg: var(--bg-elevated-1);
    --input-border: var(--border-color);
    --input-border-focus: var(--color-primary);
    
    /* Navigation - dark theme uses standard elevated background */
    --nav-bg: var(--bg-elevated-1);
    --nav-text: var(--text-primary);
    --nav-text-secondary: var(--text-secondary);
    --nav-hover-bg: var(--bg-elevated-2);
    
    /* Success/Error states - muted for dark theme, high contrast */
    --color-success: #81C784;
    --color-success-bg: #1B3A1D;
    --color-error: #FF6B6B;
    --color-error-bg: #3D1818;
    --color-warning: #FFB74D;
    --color-warning-bg: #3D2E18;
    --color-info: #5DC1F0;
    --color-info-bg: #1A2F3D;
}

/* Development environment banner */
.dev-environment-banner {
    background-color: #8B0000;
    color: #FFFFFF;
    text-align: center;
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 2px solid #FF0000;
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.5);
    width: 100%;
}

/* Base styles */
html {
    height: 100%;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
    background-color: var(--pico-background-color, var(--bg-base));
    color: var(--pico-color, var(--text-primary));
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    letter-spacing: var(--letter-spacing-base);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography hierarchy - optimized for dark theme readability */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0.02em;
    margin-bottom: 1rem;
}

h1 {
    font-family: 'Bebas Neue', sans-serif;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 2.5px;
    font-weight: 400;
    font-size: 2rem;                      /* Reduced from 3rem */
    line-height: 1.1;
}

h2 {
    font-size: 1.5rem;                     /* Reduced from 1.8rem/2rem */
    font-weight: 600;
    letter-spacing: 0.5px;
}

h3 {
    font-size: 1.25rem;                   /* Reduced from 1.4rem */
    font-weight: 700;
}

h4 {
    font-size: 1.1rem;
    font-weight: 600;
}

h5 {
    font-size: 0.9rem;
    font-weight: 600;
}

h6 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

p {
    margin-bottom: 1rem;
    line-height: var(--line-height-base);
}

small {
    font-size: 0.7rem;
    line-height: 1.6;
}

/* Links with proper contrast */
a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease, border-bottom 0.2s ease;
    border-bottom: 1px dotted transparent;
}

a:hover {
    color: var(--color-primary-hover);
    border-bottom-color: var(--color-primary-hover);
}

a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
    border-radius: 2px;
}

/* Buttons with elevation */
button, 
[type="submit"], 
[type="button"], 
[type="reset"],
[role="button"] {
    background-color: var(--color-primary);
    border: 1px solid var(--color-primary);
    color: var(--pico-button-color, var(--pico-color-inverse, #ffffff));
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
    box-shadow: 0 2px 4px var(--shadow-color);
}

button:hover:not(:disabled), 
[type="submit"]:hover:not(:disabled), 
[type="button"]:hover:not(:disabled),
[type="reset"]:hover:not(:disabled),
[role="button"]:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    box-shadow: 0 4px 8px var(--shadow-color);
    transform: translateY(-1px);
}

button:active:not(:disabled), 
[type="submit"]:active:not(:disabled), 
[type="button"]:active:not(:disabled),
[type="reset"]:active:not(:disabled),
[role="button"]:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px var(--shadow-color);
    transition-duration: 0.05s;
}

button:focus-visible,
[type="submit"]:focus-visible,
[type="button"]:focus-visible,
[type="reset"]:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

button:disabled {
    background-color: var(--bg-elevated-2);
    border-color: var(--border-color);
    color: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.5;
}

button.secondary,
[role="button"].secondary {
    background-color: transparent;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

button.secondary:hover,
[role="button"].secondary:hover {
    background-color: var(--bg-elevated-1);
}

/* Cards with elevation hierarchy */
article {
    background-color: var(--bg-elevated-1);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow-color);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    max-width: 100%;
}

/* Subtle article variant - blends with background */
article.article-subtle {
    background-color: transparent;
    box-shadow: none;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

article.article-subtle > header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
}

article.article-subtle > footer {
    background-color: transparent;
    border-top: 1px solid var(--border-color);
}

article > header {
    background-color: var(--bg-elevated-2);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;                /* Reduced from 1rem 1.5rem */
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

/* Header text grouping (Title + Subtitle) */
article > header > div:not(.return-link) {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

article > header > div h1 {
    margin-bottom: 0;
    font-size: 1.5rem;
    line-height: 1.2;
}

article > header > div p {
    margin-bottom: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Header action button */
article > header button {
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    align-self: center;
}

/* Responsive header layout */
@media (max-width: 768px) {
    article > header:has(button) {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    article > header:has(button) > div {
        text-align: center;
    }
    
    article > header button {
        width: 100%;
    }
}

article > footer {
    background-color: var(--bg-elevated-2);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;                /* Reduced from 1rem 1.5rem */
    border-radius: 0 0 8px 8px;
}

/* Table footer - blends with table, no rounded corners or background */
table + footer,
table ~ footer {
    background-color: transparent;
    border-top: 1px solid var(--border-subtle);
    padding: 0.75rem 1rem;
    border-radius: 0;
    margin-top: 0;
    margin-bottom: 0;
    text-align: left;
}

table + footer small,
table ~ footer small {
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.5;
}

/* Navigation - fixed for Pico CSS compatibility */
nav {
    background-color: var(--nav-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
    flex-shrink: 0;
}

nav ul {
    margin: 0;
    padding: 0;
}

nav ul li {
    list-style: none;
    margin: 0;
}

nav a {
    color: var(--nav-text-secondary);
    transition: all 0.3s ease;
    border-bottom: none;
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

nav a:hover {
    color: var(--nav-text);
    background-color: var(--nav-hover-bg);
}

nav strong a {
    color: var(--nav-text);
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 1px;
}

nav strong a:hover {
    color: var(--nav-text);
    background-color: transparent;
}

/* Dropdown menus - Pico CSS compliant (using .dropdown class) */
nav details.dropdown summary {
    color: var(--nav-text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    line-height: 1.5;
    vertical-align: middle;
    height: auto;
}

nav details.dropdown summary:hover {
    color: var(--nav-text);
    background-color: var(--nav-hover-bg);
}

/* Ensure dropdown container matches nav link height */
nav li details.dropdown {
    display: inline-flex;
    align-items: center;
    height: 100%;
}

/* Settings icon dropdown - improve emoji appearance and alignment */
nav ul:last-child li:last-child details.dropdown {
    height: auto;
    align-items: center;
}

nav ul:last-child li:last-child details.dropdown summary {
    font-size: 0.66rem;
    line-height: 1;
    padding: 0.2rem 0.45rem;
    height: auto;
    min-height: auto;
}

/* Pico CSS handles the dropdown positioning automatically with dir="rtl" on the ul */
nav details.dropdown ul {
    min-width: 250px;
    background-color: var(--bg-elevated-3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow-color);
    padding: 0.25rem 0;
    overflow: visible;
    direction: ltr;
    text-align: left;
}

/* Right-align dropdowns in the last nav ul (settings menu) */
nav ul:last-child li details.dropdown ul {
    right: 0;
    left: auto;
}

/* Keep RTL positioning for customer switcher dropdown */
nav details.dropdown ul[dir="rtl"] {
    direction: ltr !important;
}

nav details.dropdown ul li {
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
    list-style: none;
    line-height: 0;
}

nav details.dropdown ul li a {
    display: block;
    width: 100%;
    padding: 0.4rem 1.5rem;
    color: var(--text-secondary);
    text-align: left;
    direction: ltr !important;
    background: none;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
    font-size: 0.8rem;
    font-weight: 400;
    white-space: nowrap;
    border-bottom: none;
    box-sizing: border-box;
    line-height: 1.3;
    margin: 0 !important;
    text-indent: 0;
}

nav details.dropdown ul li a:hover {
    color: var(--text-primary);
    background-color: var(--bg-elevated-4);
}

/* Light theme: dropdown menu needs to work with blue nav bar */
[data-theme="light"] nav details.dropdown ul {
    background-color: #FFFFFF;
    border-color: rgba(0, 153, 219, 0.3);
}

[data-theme="light"] nav details.dropdown ul li a {
    color: var(--text-secondary);
}

[data-theme="light"] nav details.dropdown ul li a:hover {
    color: var(--text-primary);
    background-color: var(--bg-elevated-1);
}

nav details.dropdown ul li:first-child a {
    border-radius: 8px 8px 0 0;
}

nav details.dropdown ul li:last-child a {
    border-radius: 0 0 8px 8px;
}

/* Dropdown divider */
nav details.dropdown ul li.dropdown-divider {
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    margin-bottom: 0;
    padding-top: 0.5rem;
    padding-bottom: 0;
    list-style: none;
    line-height: 0;
    height: auto;
}

/* Table styling - proper elevation and contrast */
table thead {
    background-color: var(--bg-elevated-2);
    border-bottom: 2px solid var(--color-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

table thead th {
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.75rem 1rem;                 /* Reduced from 1rem 1.25rem */
    text-align: left;
    font-size: 0.76rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background-color: var(--bg-elevated-2); /* Ensure opacity for sticky */
    box-shadow: 0 1px 0 var(--border-color); /* Border replacement */
}

table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color 0.2s ease;
}

table tbody tr:hover {
    background-color: var(--bg-elevated-2);
}

table tbody td {
    padding: 0.75rem 1rem;                 /* Reduced from 1rem 1.25rem */
    color: var(--text-secondary);
    font-size: 0.75rem;                    /* Reduced from 0.8rem */
    line-height: 1.5;                      /* Reduced from 1.6 */
}

/* Customer name cell - allow word break */
table tbody td.customer-cell {
    word-break: break-word;
    hyphens: auto;
}

/* Available cell - prevent breaking, keep number on one line */
table tbody td.available-cell {
    white-space: nowrap;
}

table tbody td strong {
    font-size: 0.8rem;                     /* Slightly larger for item names */
}

table tbody td a {
    color: var(--color-primary);
    font-weight: 500;
}

/* Flash messages with proper contrast */
.flash-message {
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 6px;
    border-left: 4px solid;
    font-weight: 500;
}

.flash-success {
    background-color: var(--color-success-bg);
    border-left-color: var(--color-success);
    color: var(--color-success);
}

.flash-error {
    background-color: var(--color-error-bg);
    border-left-color: var(--color-error);
    color: var(--color-error);
}

.flash-warning {
    background-color: var(--color-warning-bg);
    border-left-color: var(--color-warning);
    color: var(--color-warning);
}

.flash-info {
    background-color: var(--color-info-bg);
    border-left-color: var(--color-info);
    color: var(--color-info);
}

[data-theme="dark"] .flash-success {
    color: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .flash-error {
    color: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .flash-warning {
    color: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .flash-info {
    color: rgba(255, 255, 255, 0.92);
}

/* Grid layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Filter form grid - standardized */
.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Transaction filter form - optimized layout with search row separation */
.filter-form-optimized {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Search row - full width on narrow screens, inline on wide screens */
.filter-form .filter-search-row {
    width: 100%;
}

/* Selects row - grid layout for selects */
.filter-form .filter-selects-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* On wider screens, show search inline with selects */
@media (min-width: 768px) {
    .filter-form-optimized {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .filter-form-optimized .filter-search-row {
        flex: 1 1 auto;
        min-width: 200px;
    }
    
    .filter-form-optimized .filter-selects-row {
        flex: 1 1 auto;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* On narrow screens, force search to own row above selects */
@media (max-width: 767px) {
    .filter-form-optimized {
        flex-direction: column;
    }
    
    .filter-form-optimized .filter-search-row {
        width: 100%;
    }
    
    .filter-form-optimized .filter-selects-row {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

/* Forms with proper contrast */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), 
select, 
textarea {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    font-size: 0.875rem;                    /* Reduced from default */
    line-height: 1.5;
    padding: 0.5rem 0.75rem;                /* Reduced padding */
    height: auto;                           /* Allow height to adjust */
    min-height: 2.5rem;                     /* Consistent minimum height */
    box-sizing: border-box;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):focus, 
select:focus, 
textarea:focus {
    background-color: var(--input-bg);
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px rgba(0, 153, 219, 0.15);
    outline: none;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):disabled,
select:disabled,
textarea:disabled {
    background-color: var(--bg-elevated-2);
    opacity: 0.6;
    cursor: not-allowed;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"])::placeholder,
textarea::placeholder {
    color: var(--text-disabled);
    font-size: 0.875rem;
}

/* Date input calendar picker icon - ensure existing Pico CSS icon is clickable */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    pointer-events: auto;
    padding: 1rem;
    margin-left: 1rem;
    width: auto;
    height: auto;
}

input[type="date"]::-moz-calendar-picker-indicator {
    cursor: pointer;
    pointer-events: auto;
    padding: 1rem;
    margin-left: 1rem;
}

label {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: block;
    font-size: 0.875rem;                    /* Reduced label size */
}

/* Native checkbox and radio controls */
label input[type="checkbox"],
label input[type="radio"] {
    margin-right: 0.5rem;
    vertical-align: middle;
}

input[type="checkbox"],
input[type="radio"] {
    width: 1.1rem;
    height: 1.1rem;
    min-height: 0;
    padding: 0;
    accent-color: var(--color-primary);
}

/* Filter form elements - consistent sizing */
.filter-form input,
.filter-form select {
    font-size: 0.85rem;
    padding: 0.45rem 0.65rem;
    height: 2.5rem;                         /* Fixed height for consistency */
    line-height: 1.5;
    box-sizing: border-box;
    vertical-align: middle;
}

/* Filter form button group - buttons side by side */
.filter-form .filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.filter-form button[type="submit"],
.filter-form .btn-clear {
    font-size: 0.85rem;
    padding: 0.45rem 0.85rem;
    height: 2.5rem;                         /* Match other elements */
    line-height: 1.5;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    margin: 0;
}

.filter-form button[type="submit"] {
    flex: 1;
    min-width: 0;
}

.filter-form .btn-clear {
    flex: 0 0 auto;
}

/* Footer - stays at bottom */
footer {
    text-align: center;
    padding: 1.5rem 0;                     /* Reduced from 3rem 0 2rem */
    color: var(--text-disabled);
    font-size: 0.7rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 2rem;                      /* Reduced from 4rem */
    flex-shrink: 0;
    background-color: var(--bg-base);
}

/* Login page footer - minimal styling */
.login-container footer,
body:not(.has-nav) footer {
    background-color: transparent;
    border-top: none;
    padding: 1rem 0;
    margin-top: 1.5rem;
    font-size: 0.65rem;
    color: var(--text-disabled);
}

/* Login page specific styles */
body.login-page {
    background: linear-gradient(135deg, #1F1F1F 0%, #171717 100%);
}

body.login-page main.container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
    padding: 0;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h1 {
    color: var(--color-primary);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.login-header p {
    color: rgba(255, 255, 255, 0.70);
    font-size: 0.95rem;
}

.login-container article {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
}

.login-container .error-message {
    background-color: var(--color-error-bg);
    color: var(--color-error);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 1.5rem;
    border: 1px solid var(--color-error);
}

.login-container footer {
    text-align: center;
    margin-top: 1.5rem;
}

/* Code blocks */
code {
    background-color: var(--bg-elevated-2);
    color: var(--color-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.72em;
}

blockquote {
    border-left: 4px solid var(--color-primary);
    background-color: var(--bg-elevated-1);
    padding: 1rem 1.5rem;
    margin: 1rem 0;
    color: var(--text-secondary);
}

/* Main container - flex grow to push footer down */
main.container {
    padding-top: 2rem;
    padding-bottom: 2rem;
    flex: 1 0 auto;
    max-width: 100%;
    width: 100%;
}

/* Container width adjustments for table-heavy pages */
main.container--wide {
    max-width: 1400px;
}

/* Standard container width - consistent across pages */
main.container:not(.container--wide) {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* Text color utilities */
.text-error {
    color: var(--color-error);
}

.text-success {
    color: var(--color-success);
}

.text-warning {
    color: var(--color-warning);
}

.text-info {
    color: var(--color-info);
}

.text-muted {
    color: var(--text-secondary);
}

/* Button placement - standardized below content */
.create-button-container {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

/* Return link - small link above h1 on form pages */
.return-link {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: color 0.2s ease;
    text-align: left;
    width: 100%;
}

.return-link:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* Ensure header content is left-aligned when return link is present */
article > header:has(.return-link),
header:has(.return-link) {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    text-align: left !important;
    gap: 0.5rem 0;
}

/* Return link always first, full width */
article > header:has(.return-link) > .return-link,
header:has(.return-link) > .return-link {
    width: 100%;
}

article > header:has(.return-link) h1,
header:has(.return-link) h1 {
    text-align: left !important;
    margin-left: 0 !important;
}

/* Empty state styling */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.empty-state a {
    color: var(--color-primary);
    font-weight: 500;
}

/* Clear filter button */
.btn-clear {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    border-radius: 0.25rem;
    text-decoration: none;
    display: inline-block;
    background-color: transparent;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-clear:hover {
    background-color: var(--bg-elevated-1);
    color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

/* Logo styling */
.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    white-space: normal;
}

.logo-container img {
    height: 26px;                          /* Reduced from 32px */
    filter: brightness(1.2);
}

.logo-subheadline {
    font-size: 0.85rem;
    line-height: 1.1;
    color: var(--nav-text);          /* White on blue nav bar */
    font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    :root {
        --font-size-base: 16px;           /* Consistent with design system */
        --line-height-base: 1.7;
    }
    
    body {
        font-size: 16px;
    }
    
    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    nav ul {
        flex-wrap: wrap;
        flex-direction: column;
    }
    
    nav ul li {
        width: 100%;
    }
    
    nav a {
        display: block;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-subtle);
    }
    
    nav strong a {
        border-bottom: 1px solid var(--border-subtle);
    }
    
    nav details.dropdown summary {
        display: block;
        padding: 0.75rem 1rem;
    }
    
    nav details.dropdown ul {
        min-width: auto;
        width: 100%;
        border-radius: 0;
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--border-subtle);
        padding: 0;
        margin: 0;
    }
    
    nav details.dropdown ul li a {
        padding: 0.5rem 2rem;
        border-bottom: 1px solid var(--border-subtle);
    }
    
    h1 {
        font-size: 1.75rem;               /* Reduced */
    }
    
    h2 {
        font-size: 1.25rem;               /* Reduced */
    }
    
    h3 {
        font-size: 1.1rem;                /* Reduced */
    }
    
    table thead th,
    table tbody td {
        padding: 0.625rem 0.875rem;       /* Reduced for density */
        font-size: 0.7rem;                 /* Reduced further on mobile */
    }
    
    table tbody td.available-cell {
        white-space: nowrap;                /* Keep available numbers on one line */
    }
}

/* Large text (18pt+) can use lower contrast (4.5:1) per WCAG AAA */
@media (min-width: 1200px) {
    :root {
        --font-size-base: 18px;
        --line-height-base: 1.75;
    }
    
    h1 {
        font-size: 2.25rem;               /* Reduced from 2.8rem */
    }
    
    h2 {
        font-size: 1.75rem;               /* Reduced from 2rem */
    }
}

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

/* Status badges - consolidated definition */
.status-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

/* Status badge variants */
.status-badge.badge-draft {
    background-color: var(--bg-elevated-2);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.status-badge.badge-deleted {
    background-color: rgba(244, 67, 54, 0.15);
    color: #f44336;
    border-color: #f44336;
    opacity: 0.7;
}

.status-badge.badge-pending,
.status-badge.badge-pending-approval {
    background-color: #3D2850;
    color: #E0B0FF;
    border-color: #7D5AAA;
}

.status-badge.badge-approved {
    background-color: var(--color-info-bg);
    color: var(--color-info);
    border-color: var(--color-info);
}

.status-badge.badge-shipped {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    border-color: var(--color-success);
}

.status-badge.badge-returned {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
    border-color: var(--color-warning);
}

.status-badge.badge-default {
    background-color: var(--bg-elevated-2);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

/* Base badge styles - shared across all badge types */
.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Role badges */
.badge-role-admin,
.badge-role-editor,
.badge-role-customer {
    color: white;
}

.badge-role-admin {
    background-color: var(--color-error);
}

.badge-role-editor {
    background-color: var(--color-warning);
}

.badge-role-customer {
    background-color: var(--color-success);
}

/* Status badges (active/inactive) */
.badge-success,
.badge-inactive {
    border: 1px solid transparent;
}

.badge-success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.badge-inactive {
    background-color: var(--color-error-bg);
    color: var(--color-error);
}

/* Stock status colors (for inventory) */
.status-critical,
.status-warning,
.status-good {
    font-weight: bold;
}

.status-critical {
    color: var(--color-error);
}

.status-warning {
    color: var(--color-warning);
}

.status-good {
    color: var(--color-success);
}

/* Small button variant */
.button-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    display: inline-block;
}

/* Sortable table styles - reusable */
table.sortable tbody tr {
    cursor: pointer;
}

table.sortable thead th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

table.sortable thead th:hover {
    background-color: var(--bg-elevated-2);
}

.sort-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    opacity: 0.5;
}

.sort-indicator::after {
    content: '⇅';
}

table.sortable thead th[data-sorted="asc"] .sort-indicator::after {
    content: '↑';
    opacity: 1;
}

table.sortable thead th[data-sorted="desc"] .sort-indicator::after {
    content: '↓';
    opacity: 1;
}

/* Table cell alignment utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

/* Table overflow handling - wrapper for horizontal scrolling */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
    margin: 0;
    -webkit-overflow-scrolling: touch;
}

/* Table base styles - consolidated */
table {
    width: 100%;
    min-width: 800px; /* Minimum width to prevent cramping */
    border-collapse: separate;
    border-spacing: 0;
    background-color: var(--bg-elevated-1);
    border: 1px solid var(--border-subtle);
}

/* Centered content utility */
.centered {
    text-align: center;
}

.centered-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* Info/section boxes - reusable */
.info-box {
    background-color: var(--bg-elevated-2);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.info-box-success {
    background-color: var(--color-success-bg);
    border-left: 4px solid var(--color-success);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.info-box-error {
    background-color: var(--color-error-bg);
    border-left: 4px solid var(--color-error);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.info-box-warning {
    background-color: var(--color-warning-bg);
    border-left: 4px solid var(--color-warning);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.info-box-info {
    background-color: var(--color-info-bg);
    border-left: 4px solid var(--color-info);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 2rem;
}

.info-box h3 {
    margin-top: 0;
}

.info-box strong {
    color: inherit;
}

.info-box p {
    margin-bottom: 0;
}

.info-box p.mb-0 {
    margin-bottom: 0;
}

/* Stat Card - Modern Dashboard Style */
.stat-card {
    background-color: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 0;
}

.stat-card .stat-value.text-success { color: var(--color-success); }
.stat-card .stat-value.text-warning { color: var(--color-warning); }
.stat-card .stat-value.text-error { color: var(--color-error); }
.stat-card .stat-value.text-info { color: var(--color-info); }

.stat-card .stat-detail {
    margin-top: auto;
    padding-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Grid variants */
.grid-2-col {
    grid-template-columns: 1fr 1fr;
}

/* Spacing utilities */
.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.ml-1 {
    margin-left: 0.5rem;
}

/* Font size utilities */
.text-sm {
    font-size: 0.9rem;
}

.text-xs {
    font-size: 0.75rem;
}

/* Link utilities */
.link-bold {
    font-weight: bold;
    color: inherit;
}

/* ==== Action Button Groups - Using Pico CSS Native Styling ==== */
/* Pico CSS automatically renders all buttons identically */

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.button-group button,
.button-group form {
    flex: 1;
}

.button-group form {
    margin: 0;
}

.button-group a[role="button"] {
    flex: 1;
}

/* Item image icon and tooltip */
.item-image-icon {
    position: relative;
    display: inline-block;
}

.item-image-icon:hover .item-image-tooltip {
    visibility: visible;
    opacity: 1;
}

.item-image-tooltip {
    visibility: hidden;
    width: 500px;
    height: 500px;
    background-color: var(--bg-elevated-3);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 5px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Secondary button for Cancel - transparent style */
.button-group button.secondary {
    background-color: transparent;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Item status indicators for transaction forms */
.item-row.item-available {
    border-left-color: var(--color-success, #4caf50);
}

.item-row.item-limited {
    border-left-color: var(--color-warning, #ff9800);
}

.item-row.item-unavailable {
    border-left-color: var(--color-error, #f44336);
}

.stock-status-indicator {
    font-weight: 500;
}

.item-row.item-available .stock-status-indicator {
    color: var(--color-success, #4caf50);
}

.item-row.item-limited .stock-status-indicator {
    color: var(--color-warning, #ff9800);
}

.item-row.item-unavailable .stock-status-indicator {
    color: var(--color-error, #f44336);
}

/* Availability status container */
.availability-status-container {
    margin-top: 0.5rem;
}

.availability-status {
    font-size: 0.9rem;
    line-height: 1.5;
}

.availability-status strong {
    display: block;
    margin-bottom: 0.25rem;
}

/* Dialog/Modal styling */
dialog {
    padding: 1rem;
    border: none;
    background: transparent;
    max-width: 90vw;
    max-height: 90vh;
    margin: auto;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: visible; /* Allow flatpickr calendar to overflow */
    z-index: 1000; /* Explicit z-index for dialog */
}

dialog[open] {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible; /* Allow flatpickr calendar to overflow */
    z-index: 1000; /* Explicit z-index for open dialog */
    position: fixed !important; /* Ensure fixed positioning for calendar context */
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    z-index: 999; /* Backdrop below dialog */
}

dialog[open] {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible; /* Allow flatpickr calendar to overflow */
    z-index: 1000; /* Explicit z-index for open dialog */
}

dialog article {
    margin: 0;
    max-width: 600px;
    width: 100%;
    max-height: calc(90vh - 2rem);
    overflow-y: auto;
    overflow-x: visible !important; /* Allow flatpickr calendar to overflow horizontally */
    position: relative;
    z-index: 1001; /* Article above dialog */
}

dialog article > *:not(footer) {
    padding-left: 1rem;
    padding-right: 1rem;
}

dialog article > header {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

dialog article footer {
    padding: 1rem 2rem 1rem 1rem !important;
    margin-top: 1rem;
    display: flex !important;
    gap: 0.5rem;
    justify-content: flex-end;
    box-sizing: border-box;
}

#date-range-modal article footer {
    padding-right: 2rem !important;
    padding-left: 1rem !important;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

#date-range-modal article footer button:last-child {
    margin-right: 0 !important;
}

.availability-status ul {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

/* Flatpickr calendar z-index - ensure it appears above modals */
/* Must be higher than dialog (1000) and dialog article (1001) */
.flatpickr-calendar {
    z-index: 10000 !important;
}

.flatpickr-calendar.open {
    z-index: 10000 !important;
}

/* Ensure calendar in modal appears above modal content */
#date-range-modal .flatpickr-calendar {
    z-index: 10000 !important;
}

#date-range-modal .flatpickr-calendar.open {
    z-index: 10000 !important;
}

/* Fix flatpickr header styling to prevent Pico CSS conflicts */
.flatpickr-months {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    position: relative !important;
    height: 34px !important;
    padding: 0 !important;
}

.flatpickr-month {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 34px !important;
    overflow: visible !important;
    flex: 1 !important;
    line-height: 1 !important;
}

.flatpickr-current-month {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 34px !important;
    padding: 0 0.5rem !important;
    font-size: 1rem !important;
    line-height: 1 !important;
    position: static !important;
    width: auto !important;
}

.flatpickr-monthDropdown-months {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background: transparent !important;
    border: none !important;
    padding: 0 0.5rem !important;
    margin: 0 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    color: inherit !important;
    height: auto !important;
    line-height: 1 !important;
    outline: none !important;
    width: auto !important;
    min-width: auto !important;
}

.flatpickr-current-month .numInputWrapper {
    display: inline-block !important;
    width: 4ch !important;
    margin: 0 0 0 0.25rem !important;
    height: auto !important;
}

.flatpickr-current-month .numInputWrapper input,
.flatpickr-current-month input.cur-year {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: inherit !important;
    height: auto !important;
    line-height: 1 !important;
    width: 100% !important;
    min-width: auto !important;
    box-shadow: none !important;
    outline: none !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover,
.flatpickr-current-month input.cur-year:hover {
    background: rgba(0, 0, 0, 0.05) !important;
}

.flatpickr-prev-month,
.flatpickr-next-month {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    cursor: pointer !important;
    position: static !important;
    line-height: 1 !important;
}

.flatpickr-prev-month svg,
.flatpickr-next-month svg {
    width: 14px !important;
    height: 14px !important;
}

/* Prevent Pico CSS from overriding flatpickr input styles */
.flatpickr-input[readonly] {
    cursor: pointer !important;
    background-color: var(--form-element-background-color) !important;
}

.flatpickr-input:focus {
    outline: none !important;
    border-color: var(--form-element-active-border-color) !important;
}

