/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f8fafc; color: #1e293b; line-height: 1.6; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }

/* === Login === */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f8fafc; }
.login-card { background: #fff; padding: 48px 40px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); text-align: center; width: 100%; max-width: 400px; }
.login-card h1 { font-size: 24px; font-weight: 700; color: #1e293b; margin-bottom: 4px; }
.login-subtitle { color: #64748b; margin-bottom: 32px; font-size: 14px; }
.login-card input { width: 100%; padding: 12px 16px; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 16px; font-size: 14px; outline: none; transition: border-color 0.2s; }
.login-card input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.login-card button { width: 100%; padding: 12px; background: #6366f1; color: #fff; border-radius: 8px; font-weight: 600; font-size: 14px; transition: background 0.2s; }
.login-card button:hover { background: #4f46e5; }
.error-text { color: #ef4444; font-size: 13px; margin-top: 8px; }

/* === App Layout === */
.app { display: flex; min-height: 100vh; }

/* === Sidebar === */
.sidebar { width: 260px; background: #fff; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transition: transform 0.3s; }
.sidebar-header { padding: 24px 20px 20px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; }
.sidebar-header h2 { font-size: 16px; font-weight: 700; color: #1e293b; }
.sidebar-header .sidebar-toggle { display: none; font-size: 24px; color: #64748b; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; color: #64748b; transition: all 0.2s; }
.nav-item:hover { background: #f1f5f9; color: #1e293b; }
.nav-item.active { background: #eef2ff; color: #6366f1; }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid #e2e8f0; }
.logout-btn:hover { color: #ef4444 !important; background: #fef2f2 !important; }

/* === Main Content === */
.main-content { margin-left: 260px; flex: 1; min-height: 100vh; }
.topbar { padding: 20px 32px; border-bottom: 1px solid #e2e8f0; background: #fff; display: flex; align-items: center; gap: 16px; }
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .sidebar-toggle { display: none; color: #64748b; }
.content { padding: 32px; }

/* === Stat Cards === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card { background: #fff; padding: 24px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.stat-card .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #1e293b; }
.stat-card .value.text-indigo { color: #6366f1; }
.stat-card .value.text-green { color: #22c55e; }
.stat-card .value.text-yellow { color: #eab308; }
.stat-card .value.text-red { color: #ef4444; }

/* === Tables === */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow: hidden; }
.card-header { padding: 20px 24px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 24px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
td { padding: 14px 24px; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* === Badges === */
.badge { display: inline-block; padding: 3px 10px; border-radius: 9999px; font-size: 12px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-yellow { background: #fef9c3; color: #ca8a04; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-indigo { background: #eef2ff; color: #6366f1; }

/* === Buttons === */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; transition: all 0.2s; }
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* === Forms / Inputs === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 6px; }
.form-input { width: 100%; padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 14px; outline: none; transition: border-color 0.2s; }
.form-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-input { resize: vertical; min-height: 80px; }
.search-input { max-width: 250px; }

/* === Modal === */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { font-size: 24px; color: #94a3b8; line-height: 1; }
.modal-close:hover { color: #475569; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 8px; }

/* === Notes === */
.notes-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.note-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); cursor: pointer; transition: box-shadow 0.2s; }
.note-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.note-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.note-card p { font-size: 13px; color: #64748b; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-card .note-date { font-size: 11px; color: #94a3b8; margin-top: 12px; }

.note-editor { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.note-editor-header { padding: 20px 24px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.note-title-input { border: none; font-size: 20px; font-weight: 700; outline: none; flex: 1; }
.note-toolbar { padding: 8px 24px; border-bottom: 1px solid #f1f5f9; display: flex; gap: 4px; }
.note-toolbar button { padding: 6px 10px; border-radius: 4px; color: #64748b; font-size: 13px; }
.note-toolbar button:hover { background: #f1f5f9; color: #1e293b; }
.note-content-input { border: none; outline: none; width: 100%; min-height: 400px; padding: 24px; font-size: 14px; line-height: 1.8; resize: none; }

/* === Empty State === */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state svg { margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

/* === Client Detail === */
.client-detail-header { margin-bottom: 32px; }
.client-detail-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.client-detail-header p { color: #64748b; font-size: 14px; }
.client-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.client-info-item { background: #fff; padding: 16px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.client-info-item .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; font-weight: 600; }
.client-info-item .value { font-size: 14px; font-weight: 500; margin-top: 4px; }
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-header .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }
    .topbar .sidebar-toggle { display: block; }
    .content { padding: 20px 16px; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .modal { margin: 16px; max-width: calc(100% - 32px); }
}
