:root {
    /* Sophisticated Corporate Palette */
    --midnight: #0f172a;
    --midnight-dark: #020617;
    --primary: #6366f1; /* Indigo Accent */
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --slate: #475569;
    --slate-light: #94a3b8;
    --background: #f8fafc;
    --sidebar-bg: #0f172a;
    --sidebar-text: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-focus: #c7d2fe;
    
    /* Premium Shadows & Radius */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --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);
    --radius: 12px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    letter-spacing: -0.011em;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar: High End Contrast --- */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    padding: 2.5rem 1.5rem;
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
}

.logo i {
    color: var(--primary);
    font-size: 1.6rem;
}

.sidebar-nav {
    padding: 1.5rem 1rem;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    transition: var(--transition);
    opacity: 0.7;
    font-weight: 500;
}

.sidebar-nav a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    opacity: 1;
    transform: translateX(4px);
}

.sidebar-nav a.active {
    background-color: var(--primary);
    opacity: 1;
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.sidebar-footer {
    padding: 2rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.4;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- Main Content Shell --- */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: 80px;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--midnight);
    letter-spacing: -0.02em;
}

.content-body {
    padding: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* --- Cards: Modern Sleekness --- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1.5rem 2rem;
    background-color: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--midnight);
}

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

.stat-card {
    background: var(--card-bg);
    padding: 1.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.blue { background-color: #eff6ff; color: #2563eb; }
.stat-icon.green { background-color: #f0fdf4; color: #16a34a; }
.stat-icon.orange { background-color: #fff7ed; color: #ea580c; }
.stat-icon.red { background-color: #fef2f2; color: #dc2626; }

.stat-info .value {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--midnight);
    margin-bottom: 0.25rem;
}

.stat-info .label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* --- Tables: Bespoke List Design --- */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--slate);
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-main);
    transition: background 0.2s;
}

tr:hover td {
    background-color: #fcfdfe;
}

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

/* --- Badges --- */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-success { background-color: #dcfce7; color: #166534; }
.badge-success::before { background-color: #22c55e; }

.badge-warning { background-color: #fef9c3; color: #854d0e; }
.badge-warning::before { background-color: #eab308; }

.badge-danger { background-color: #fee2e2; color: #991b1b; }
.badge-danger::before { background-color: #ef4444; }

/* --- Buttons: Premium Interaction --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background-color: var(--primary); color: #fff; box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2); }
.btn-primary:hover { background-color: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4); }

.btn-secondary { background-color: #fff; border-color: var(--border); color: var(--midnight); }
.btn-secondary:hover { background-color: var(--background); border-color: var(--slate-light); }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }

/* --- Modern Form Controls --- */
.form-group {
    margin-bottom: 1.75rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    color: var(--midnight);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background-color: #fff;
    font-size: 0.95rem;
    transition: var(--transition);
    color: var(--text-main);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-control[readonly] {
    background-color: #f8fafc;
    border-style: dashed;
    cursor: not-allowed;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 2rem; }

/* --- PO Specific Elements --- */
.totals-section {
    max-width: 350px;
    margin-left: auto;
    background: #f8fafc;
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--slate);
}

.total-row.grand-total {
    border-top: 2px solid var(--border);
    margin-top: 1rem;
    padding-top: 1.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

/* --- Animations --- */
@keyframes pulseIndigo {
    0% { background-color: #fff; }
    30% { background-color: #e0e7ff; }
    100% { background-color: #f8fafc; }
}

.autofill-flash {
    animation: pulseIndigo 1s ease-out;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.fade-in {
    animation: fadeInScale 0.4s ease-out forwards;
}

/* --- Print & Responsive --- */
@media (max-width: 1200px) {
    .sidebar { width: 90px; }
    .sidebar .logo span, .sidebar-nav a span, .sidebar-footer { display: none; }
    .sidebar-header { padding: 2rem 1rem; justify-content: center; }
    .sidebar-nav a { justify-content: center; padding: 1rem; }
    .main-content { margin-left: 90px; }
}

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 1rem; }
}
