:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif !important;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

input,
select,
textarea,
button {
    font-size: 16px !important;
}

.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    font-size: 16px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.nav {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.header-update-time {
    width: 100%;
    text-align: right;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* Filter Height Standardization */
.filter-form input,
.filter-form select,
.filter-form .btn {
    height: 42px !important;
    display: inline-flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
}

.filter-form input,
.filter-form select {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    line-height: normal !important;
    /* Let height + align-items center do the work */
}

/* Ensure buttons don't have conflicting padding-based heights */
.filter-form .btn {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    line-height: 42px !important;
}

.table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.pending {
    background: #e0f2fe;
    color: #0369a1;
}

.status-badge.in_progress {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.completed {
    background: #dcfce7;
    color: #166534;
}

.status-badge.on_hold {
    background: #f3f4f6;
    color: #374151;
}

/* Navigation Structure */
.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary);
}

.nav-link i,
.nav-link [data-lucide] {
    width: 18px;
    height: 18px;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: white !important;
    background: var(--primary);
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.btn-logout:hover {
    opacity: 0.9;
}

.btn-logout i,
.btn-logout [data-lucide] {
    width: 18px;
    height: 18px;
}

/* Dropdown Menu Alignment */
.dropdown-menu a,
.dropdown-menu button {
    display: flex !important;
    align-items: center !important;
    gap: 6px;
}

/* Tablet & Mobile Optimization */
@media (max-width: 1024px) {
    .btn-logout .btn-text {
        display: none;
    }

    .btn-logout {
        padding: 0.5rem !important;
    }

    body,
    input,
    select,
    textarea,
    button {
        font-size: 14px !important;
    }
}

@media (max-width: 768px) {

    /* Bottom Navigation Mobile */
    .nav {
        position: fixed;
        bottom: 0;
        top: auto !important;
        left: 0;
        right: 0;
        z-index: 1000;
        background: #fff;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
        padding: 0;
        height: 65px;
    }

    .nav-container {
        flex-direction: row !important;
        padding: 0 1rem !important;
        height: 100%;
        max-width: 100%;
    }

    .nav-brand {
        display: none !important;
    }

    .nav-links {
        width: 100%;
        justify-content: space-around !important;
        gap: 0 !important;
        align-items: center;
    }

    .nav-link {
        flex: 1;
        flex-direction: column !important;
        gap: 4px !important;
        font-size: 12px !important;
        /* Increased to 12px */
        padding: 8px 0 !important;
        color: var(--text-muted) !important;
        font-weight: 500;
        text-align: center;
    }

    .nav-link i,
    .nav-link [data-lucide] {
        width: 22px !important;
        height: 22px !important;
    }

    .nav-link.active {
        color: var(--primary) !important;
    }

    .btn-logout {
        flex: 1;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        color: var(--danger) !important;
        padding: 8px 0 !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 4px !important;
        font-size: 12px !important;
        /* Increased to 12px */
        font-weight: 500 !important;
        justify-content: center;
    }

    .btn-logout i,
    .btn-logout [data-lucide] {
        width: 22px !important;
        height: 22px !important;
    }

    .btn-logout .btn-text {
        display: block !important;
        font-size: 12px !important;
        /* Increased to 12px */
        font-weight: 500;
        margin-top: 4px;
    }

    .page-header {
        flex-direction: column !important;
        text-align: center;
        gap: 1.5rem;
    }

    .header-actions {
        text-align: center !important;
        width: 100%;
    }

    .header-update-time {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        order: -1;
        margin-bottom: 1rem !important;
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    .header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Stats Grid Mobile optimization */
    .stats-grid {
        display: flex !important;
        overflow-x: auto !important;
        gap: 1rem !important;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .stats-grid>* {
        min-width: 250px !important;
        flex: 0 0 auto !important;
        margin-bottom: 0 !important;
        scroll-snap-align: start;
    }

    .stats-grid>*:first-child {
        grid-column: auto !important;
    }

    .stat-card {
        padding: 1.25rem !important;
    }

    /* Items Filter Mobile */
    .filter-form {
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }

    .search-box {
        width: 100% !important;
        flex: none !important;
    }

    .filter-row {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.75rem !important;
    }

    .filter-selects {
        width: 100% !important;
        flex: none !important;
        min-width: unset !important;
        display: flex !important;
        gap: 0.5rem !important;
    }

    .filter-selects>div {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .filter-selects select {
        width: 100% !important;
        padding: 0.6rem 0.4rem !important;
    }

    .filter-actions {
        width: 100% !important;
        display: flex !important;
        gap: 0.5rem !important;
    }

    .filter-actions .btn {
        flex: 1 !important;
        min-width: 0 !important;
        padding: 0.75rem 0.5rem !important;
        justify-content: center !important;
        text-align: center !important;
    }

    .container {
        margin: 1.5rem auto 5.5rem !important;
        /* Fixed bottom nav space */
    }

    .stat-card {
        padding: 1.25rem !important;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        width: 100%;
        overflow: hidden;
    }

    .dashboard-grid>* {
        max-width: 100%;
        width: 100%;
        overflow: hidden;
    }

    .table {
        min-width: 0 !important;
    }

    .btn {
        font-size: 0.875rem !important;
        /* 14px for Tablet/Mobile */
    }

    .activity-table td {
        white-space: normal !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .activity-table .activity-cell div[style*="flex: 1"] p {
        word-break: break-all;
    }
}

/* Global Responsive Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #fff;
    display: block;
}

.table-responsive .table {
    min-width: 700px;
}

.dashboard-grid .table-responsive .table {
    min-width: 0 !important;
}

/* Items Create Global Styles */
.items-create-form {
    padding: 1.5rem;
}

.items-create-table-wrapper {
    width: 100%;
    overflow-x: auto !important;
    display: block !important;
}

/* Mobile Overrides placed at the end for specificity */
@media (max-width: 768px) {
    .btn {
        font-size: 14px !important;
    }

    .items-create-form {
        padding: 0.5rem !important;
    }

    .item-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        width: 100%;
    }

    .item-actions a,
    .item-actions button,
    .item-actions label {
        width: 100% !important;
        margin: 0 !important;
        padding: 0.6rem !important;
        font-size: 14px !important;
    }

    .item-actions .btn-add,
    .header-update-time {
        grid-column: span 2;
    }
}