@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* --- COLOR PALETTE (Modern Slate & Indigo) --- */
    --primary: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --primary-light: #eef2ff;
    /* Indigo 50 */

    --secondary: #64748b;
    /* Slate 500 */
    --success: #10b981;
    /* Emerald 500 */
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    /* Red 500 */
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    /* Amber 500 */

    --bg-body: #f1f5f9;
    /* Slate 100 */
    --bg-card: #ffffff;
    --bg-input: #ffffff;

    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-color: #e2e8f0;
    /* Slate 200 */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 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);

    --radius: 8px;
    --nav-height: 64px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- TYPOGRAPHY --- */
h1,
h2,
h3,
h4,
h5 {
    margin: 0;
    font-weight: 700;
    color: var(--text-main);
}

h1 {
    font-size: 1.8rem;
    letter-spacing: -0.025em;
}

h3 {
    font-size: 1.25rem;
    letter-spacing: -0.025em;
}

p {
    color: var(--text-muted);
}

/* --- LAYOUT --- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    padding-top: 1.5rem;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- NAVIGATION --- */
.navbar {
    background: #0f172a;
    /* Slate 900 */
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(8px);
}

.brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.brand span {
    color: #818cf8;
    /* Indigo 400 */
}

.nav-links {
    display: flex;
    gap: 4px;
    height: 100%;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0 0.85rem;
    color: #94a3b8;
    /* Slate 400 */
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    border-radius: 4px 4px 0 0;
}

.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: white;
    border-bottom-color: #818cf8;
    background: rgba(255, 255, 255, 0.05);
}

.nav-icon {
    margin-right: 8px;
    font-size: 1.1rem;
}

/* --- SHORTCUT BAR --- */
.shortcut-bar {
    background: #1e293b;
    border-top: 1px solid #334155;
    display: flex;
    justify-content: center;
    gap: 1px;
    padding: 0;
    overflow-x: auto;
    position: sticky;
    top: var(--nav-height);
    z-index: 99;
}

.sc-item {
    padding: 5px 15px;
    background: #0f172a;
    color: #94a3b8;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    border-right: 1px solid #334155;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.2s;
}

.sc-item strong {
    color: #facc15;
}

/* Tally Yellowish for Key */
.sc-item:hover {
    background: #334155;
    color: white;
    cursor: pointer;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #cbd5e1;
    font-size: 0.85rem;
    padding-left: 20px;
    border-left: 1px solid #334155;
    height: 50%;
}

.btn-logout {
    color: #f87171;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 6px 14px;
    border-radius: 50px;
    background: rgba(239, 68, 68, 0.1);
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* --- CARDS & PANELS --- */
.card,
.panel,
.invoice-header,
.invoice-footer,
.grid-container,
.top-bar-legacy {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

/* Dashboard Card Override */
.card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.card-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    /* Soft gradients for icons */
    background: linear-gradient(135deg, var(--primary-light), white);
    color: var(--primary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* --- FORMS (Smooth Inputs) --- */
.invoice-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

input,
select,
textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    /* Primary Ring */
}

input::placeholder {
    color: #cbd5e1;
}

/* In-Table Inputs (Seamless) */
td input,
td select {
    border: 1px solid transparent;
    background: transparent;
    padding: 8px;
    border-radius: 4px;
    width: 100%;
    font-size: 0.9rem;
    box-shadow: none;
}

td input:focus,
td select:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

td input[readonly] {
    color: var(--text-muted);
    background: transparent;
    cursor: default;
}

td input[readonly]:focus {
    box-shadow: none;
    border-color: transparent;
}

/* Auto-Suggestion Cleanup */
input::-webkit-calendar-picker-indicator {
    opacity: 0.6;
    cursor: pointer;
}

/* --- DATA TABLES --- */
.grid-container {
    overflow: hidden;
    /* Rounded corners clip */
    border: 1px solid var(--border-color);
    padding: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

td {
    border-bottom: 1px solid var(--border-color);
    padding: 4px;
    /* Minimal padding for input fit */
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

/* --- TOTALS & ACTIONS --- */
.invoice-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem;
    gap: 2rem;
    background: #fdfdfd;
    /* Slight distinction */
}

.notes-area {
    flex: 1;
    max-width: 400px;
}

.totals-area {
    width: 320px;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.total-row.grand {
    margin-top: 10px;
    border-top: 2px dashed var(--border-color);
    padding-top: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.total-row.grand span:last-child {
    color: var(--primary);
    font-size: 1.4rem;
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: none;
    /* Modern buttons don't shout */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-dark {
    background: #334155;
    color: white;
}

.btn-dark:hover {
    background: #1e293b;
}

.btn-outline {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-saver {
    background: linear-gradient(135deg, #4f46e5, #ec4899);
    color: white;
    border: none;
}

/* --- UTILITIES --- */
.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {

    .invoice-header,
    .invoice-footer {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .totals-area {
        width: 100%;
    }

    .navbar {
        padding: 0 1rem;
    }

    .nav-links {
        display: none;
    }

    /* Needs mobile menu, but for now fallback */
    .container {
        padding: 1rem;
    }
}

/* --- INVENTORY & RESPONSIVE FORMS --- */
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    align-items: end;
    /* Align buttons/inputs */
}

/* Span classes for grid */
.col-span-2 {
    grid-column: span 2;
}

.col-span-full {
    grid-column: 1 / -1;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

/* --- TRANSACTION TABLE ENHANCEMENTS --- */
.transaction-table th {
    background: #f1f5f9;
    padding: 10px 10px;
    /* Reduced from 12px 16px */
    font-size: 0.75rem;
    /* Slightly smaller font for headers */
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    /* Prevent headers breaking */
}

.transaction-table td {
    padding: 4px 4px;
    /* Reduced from 6px 8px */
    /* Breathing room */
    border-bottom: 1px solid #f1f5f9;
}

.transaction-table input,
.transaction-table select {
    padding: 6px 8px;
    /* Compact inputs */
    font-size: 0.85rem;
    border: 1px solid transparent;
    /* cleaner look */
    border-radius: 4px;
    background: transparent;
    transition: all 0.2s;
    width: 100%;
    /* Ensure full width usage */
    box-sizing: border-box;
    /* Prevent padding overflow */
}

.transaction-table input:hover,
.transaction-table select:hover {
    background: #f8fafc;
    /* subtle hover */
}

.transaction-table input:focus,
.transaction-table select:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Specific Column Tweaks */
.transaction-table .input-number {
    font-family: 'Inter', monospace;
    /* better alignment for numbers */
    font-weight: 500;
}

/* Modal Improvements */
.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 600px) {
    .grid-form {
        grid-template-columns: 1fr;
    }

    .col-span-2 {
        grid-column: auto;
    }
}


/* --- POLISHED FORM ELEMENTS --- */
.input-group-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius);
    position: relative;
    /* subtle pattern or gradient? keep simple */
}

.input-group-label {
    position: absolute;
    top: -10px;
    left: 12px;
    background: white;
    padding: 0 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
}

.tax-inputs {
    display: flex;
    gap: 1rem;
}

.tax-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tax-input-wrapper small {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
}

.tax-inputs input {
    text-align: center;
    font-weight: 600;
    color: var(--primary);
}

/* Make Product Name stand out */
.input-hero {
    font-size: 1.1rem;
    padding: 0.75rem;
}