/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap');

:root {
    /* "Corporate Navy" Palette */
    --primary-color: #1e3a8a;
    /* Deep Navy Blue */
    --secondary-color: #64748b;
    /* Slate Grey */
    --success-color: #059669;
    /* Darker Emerald */
    --danger-color: #dc2626;
    /* Deep Red */
    --warning-color: #d97706;
    /* Amber */
    --background-color: #f8fafc;
    /* Very light slate bg */
    --card-bg: #ffffff;
    --text-main: #1e293b;
    /* Slate 800 */
    --text-muted: #475569;
    /* Slate 600 */
    --border-color: #e2e8f0;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Layout */
header {
    background: var(--primary-color);
    border-bottom: none;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    color: white;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin: 0;
    letter-spacing: -0.5px;
}

nav ul {
    display: flex;
    gap: 20px;
    align-items: center;
}

nav a {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s;
}

nav a:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

nav a.btn-logout {
    background-color: rgba(220, 38, 38, 0.9);
    color: white;
    padding: 0.5rem 1rem;
}

nav a.btn-logout:hover {
    background-color: #ef4444;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Cards & Containers */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.auth-container {
    max-width: 400px;
    margin: 4rem auto;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    text-align: center;
    transition: background-color 0.2s;
}

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

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: white;
    border: 1px solid #d1d5db;
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #f9fafb;
}

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

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem;
    background-color: #f9fafb;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

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

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

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary-color);
}

.stat-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.stat-card.green {
    border-left-color: var(--success-color);
}

.stat-card.red {
    border-left-color: var(--danger-color);
}

.stat-card.blue {
    border-left-color: var(--primary-color);
}

.stat-card.teal {
    border-left-color: #14b8a6;
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-paid {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-sent {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-draft {
    background-color: #f3f4f6;
    color: #374151;
}

footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    background: white;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    nav ul {
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }

    nav a {
        display: block;
        padding: 5px;
        font-size: 1rem;
    }

    main {
        padding: 0 1rem;
        margin: 1.5rem auto;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Scrollable Tables wrapper */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    table {
        font-size: 0.9rem;
        min-width: 600px;
        /* Force scroll if needed */
    }

    .card {
        padding: 1rem;
    }
}