/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

/* ─── Navigation ─── */
.nav {
    background: #1a56db;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
}
.nav-logo { font-size: 1.2rem; font-weight: 700; }
.nav-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
}
.nav-links {
    display: none;
    flex-direction: column;
    padding: 0 16px 12px;
}
.nav-links.open { display: flex; }
.nav-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}
.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}
.nav-link.active { font-weight: 600; }
.nav-icon { font-size: 1.1rem; }

/* ─── Main ─── */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}
.page-header {
    margin-bottom: 20px;
}
.page-header h1 { font-size: 1.5rem; color: #1a1a2e; }
.subtitle { color: #666; font-size: 0.9rem; margin-top: 2px; }

/* ─── Cards ─── */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
}
.card-header h3 { font-size: 1rem; color: #333; }
.card-body { padding: 16px; }
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* ─── Stats ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 4px solid #1a56db;
}
.stat-card.blue { border-color: #1a56db; }
.stat-card.green { border-color: #10b981; }
.stat-card.orange { border-color: #f59e0b; }
.stat-card.purple { border-color: #8b5cf6; }
.stat-number { font-size: 1.8rem; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 0.8rem; color: #666; margin-top: 2px; }

/* ─── Buttons ─── */
.btn {
    background: #1a56db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
    display: inline-block;
    text-align: center;
}
.btn:hover { background: #1e40af; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm {
    background: #1a56db;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-weight: 500;
}
.btn-sm:hover { background: #1e40af; }
.btn-sm.danger { background: #ef4444; }
.btn-sm.danger:hover { background: #dc2626; }

/* ─── Forms ─── */
.form { display: flex; flex-direction: column; gap: 12px; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.form-inline {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.form-inline .input { flex: 1; }
label { font-size: 0.85rem; font-weight: 600; color: #444; display: block; margin-bottom: 4px; }
.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fafafa;
    transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: #1a56db; background: white; box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
textarea.input { resize: vertical; min-height: 60px; font-family: inherit; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: #f9fafb;
    color: #666;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
}
tbody td {
    padding: 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f4f6;
}
tbody tr:hover { background: #f9fafb; }
.desc { color: #555; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: #999; padding: 20px; text-align: center; }

/* ─── Badges ─── */
.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge.draft { background: #fef3c7; color: #92400e; }
.badge.sent { background: #dbeafe; color: #1e40af; }
.badge.paid { background: #d1fae5; color: #065f46; }
.badge.active { background: #d1fae5; color: #065f46; }
.badge.inrepair { background: #fef3c7; color: #92400e; }
.badge.stored { background: #e5e7eb; color: #374151; }
.badge.retired { background: #fee2e2; color: #991b1b; }

/* ─── Drop Zone ─── */
.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    color: #666;
    transition: all 0.15s;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: #1a56db;
    background: #f0f4ff;
}

/* ─── Chat ─── */
.chat-box {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 8px;
}
.chat-msg {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.4;
}
.chat-msg.bot {
    background: white;
    border: 1px solid #e5e7eb;
    border-left: 3px solid #1a56db;
}
.chat-msg.user {
    background: #1a56db;
    color: white;
    margin-left: 20%;
}
.chat-msg strong { display: block; margin-bottom: 4px; font-size: 0.8rem; }
.chat-msg.user strong { opacity: 0.9; }

/* ─── Invoice Preview ─── */
.invoice-preview {
    background: #f0f4ff;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    padding: 16px;
}
.invoice-preview h4 { color: #1a56db; margin-bottom: 10px; font-size: 0.95rem; }
.preview-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.9rem;
}
.preview-row.grand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a56db;
    border-top: 2px solid #dbeafe;
    margin-top: 8px;
    padding-top: 8px;
}

/* ─── Quick Actions ─── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.action-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 14px;
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.15s;
}
.action-btn:hover {
    background: #1a56db;
    color: white;
    border-color: #1a56db;
}

/* ─── Checkbox Groups ─── */
.checkbox-group { max-height: 250px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px; }
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}
.checkbox-label:hover { background: #f9fafb; }
.checkbox-label input { margin-top: 2px; }

/* ─── Filter Bar ─── */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Progress ─── */
.progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: #1a56db;
    width: 0%;
    transition: width 0.3s;
}
.hidden { display: none; }

/* ─── Responsive ─── */
@media (min-width: 768px) {
    .nav-header { padding: 0; }
    .nav {
        display: flex;
        align-items: center;
        padding: 0 24px;
        gap: 24px;
    }
    .nav-logo { padding: 14px 0; }
    .nav-toggle { display: none; }
    .nav-links {
        display: flex !important;
        flex-direction: row;
        padding: 0;
        gap: 4px;
        flex: 1;
    }
    .nav-link { padding: 14px 12px; border-radius: 0; font-size: 0.85rem; }
    .main { padding: 24px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .card-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .quick-actions { grid-template-columns: repeat(4, 1fr); }
    .page-header h1 { font-size: 1.8rem; }
}
@media (min-width: 1024px) {
    .card-grid.full { grid-template-columns: 1fr; }
}
