:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-bg: #eff6ff;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand img { width: 32px; height: 32px; border-radius: 6px; }

.sidebar-nav { padding: 1rem 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.85);
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.15);
    color: var(--white);
    border-left-color: var(--white);
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    background: var(--white);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar h1 { font-size: 1.5rem; font-weight: 600; color: var(--gray-800); }

.page-content { padding: 2rem; }

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-50);
}

.card-header h2 { font-size: 1.125rem; font-weight: 600; }

.card-body { padding: 1.5rem; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: var(--primary-bg); color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }

.stat-info h3 { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.stat-info p { color: var(--gray-500); font-size: 0.875rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #059669; color: var(--white); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; color: var(--white); }

.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary-bg); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

textarea.form-control { min-height: 100px; resize: vertical; }

.form-hint { font-size: 0.8125rem; color: var(--gray-500); margin-top: 0.25rem; }

/* Tables */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
}

table tr:hover { background: var(--gray-50); }

.table-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #cffafe; color: #155e75; }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-bg); color: var(--primary-dark); border: 1px solid #bfdbfe; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, #1e40af 100%);
    padding: 2rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: var(--primary-bg);
    padding: 2rem;
    text-align: center;
    border-bottom: 1px solid var(--gray-200);
}

.login-header h1 { font-size: 1.5rem; color: var(--primary-dark); margin-bottom: 0.5rem; }
.login-header p { color: var(--gray-500); font-size: 0.9375rem; }

.login-body { padding: 2rem; }

.login-footer {
    text-align: center;
    padding: 1rem 2rem 2rem;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 1.125rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
    line-height: 1;
}

.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* Task Cards (Agent) */
.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

.task-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.task-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.task-card-link:hover { color: inherit; }

.task-card-preview {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.task-card-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--gray-200);
}

.task-card-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-bg);
    font-size: 1.75rem;
}

.task-card-product {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.task-card-meta {
    font-size: 0.8125rem;
    line-height: 1.4;
    margin-bottom: 0.125rem;
}

/* Task Detail Page */
.task-detail-hero {
    overflow: hidden;
    padding: 0;
}

.task-detail-hero-img img {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    display: block;
}

.task-detail-hero-body {
    padding: 1.25rem 1.5rem;
}

.task-detail-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.task-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.task-detail-product-img {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.detail-list {
    margin: 0;
    padding: 0;
}

.detail-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.detail-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-item dt {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    margin-bottom: 0.35rem;
}

.detail-item dd {
    margin: 0;
    color: var(--gray-800);
    font-size: 0.9375rem;
}

.product-description {
    line-height: 1.7;
    white-space: pre-wrap;
}

.flex-wrap { flex-wrap: wrap; }

.task-card-header {
    padding: 1rem 1.25rem;
    background: var(--primary-bg);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-card-body { padding: 1.25rem; }

.task-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.task-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.875rem;
}

.task-info-row .label { color: var(--gray-500); }
.task-info-row .value { font-weight: 500; color: var(--gray-800); }

.deadline-banner {
    background: linear-gradient(90deg, var(--warning), #f97316);
    color: var(--white);
    padding: 0.75rem 2rem;
    text-align: center;
    font-weight: 500;
    font-size: 0.9375rem;
}

.deadline-banner.urgent { background: linear-gradient(90deg, var(--danger), #dc2626); }

/* QR Code */
.qr-container {
    text-align: center;
    padding: 1.5rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin: 1rem 0;
}

.qr-container canvas, .qr-container img {
    max-width: 220px;
    margin: 0 auto;
    display: block;
}

.upi-details {
    background: var(--primary-bg);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* Wallet */
.wallet-balance {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    margin-bottom: 2rem;
}

.wallet-balance h2 { font-size: 2.5rem; font-weight: 700; margin: 0.5rem 0; }
.wallet-balance p { opacity: 0.85; }

/* Profile Setup */
.profile-setup-banner {
    background: var(--warning);
    color: var(--white);
    padding: 1rem 2rem;
    text-align: center;
}

.profile-setup-banner a { color: var(--white); text-decoration: underline; }

/* Image Preview */
.img-preview {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--gray-200);
    margin-top: 0.5rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--gray-500);
}

.empty-state svg { width: 64px; height: 64px; margin-bottom: 1rem; opacity: 0.5; }

/* Mobile */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-700);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-toggle { display: block; }
    .page-content { padding: 1rem; }
    .topbar { padding: 1rem; }
    .task-grid { grid-template-columns: 1fr; }
    .task-detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-100 { width: 100%; }
