*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2451c8;
  --blue-dark: #1a3d9e;
  --blue-light: #e8effe;
  --blue-mid: #c5d3f8;
  --white: #ffffff;
  --gray-50: #f8f9fc;
  --gray-100: #eef0f6;
  --gray-200: #dde1ed;
  --gray-400: #9099b5;
  --gray-600: #5a6380;
  --black: #111827;
  --text: #111827;
  --text-mid: #374151;
  --text-muted: #6b7280;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(36,81,200,0.08);
  --shadow-md: 0 4px 24px rgba(36,81,200,0.12);
}

html, body { height: 100%; font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--gray-50); color: var(--text); font-size: 15px; }

/* VIEWS */
.view { min-height: 100vh; }
.hidden { display: none !important; }

/* AUTH */
.auth-card {
  width: 100%; max-width: 400px; margin: 80px auto;
  background: var(--white); border-radius: 16px;
  box-shadow: var(--shadow-md); padding: 40px 36px;
}
.auth-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 32px; gap: 12px; }
.logo-img { width: 64px; height: 64px; object-fit: contain; }
.auth-title { font-size: 22px; font-weight: 700; color: var(--blue); }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-mid); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input { width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: var(--radius); font-size: 15px; color: var(--text); background: var(--white); outline: none; transition: border-color .15s; }
.field input:focus { border-color: var(--blue); }
.otp-hint { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
.otp-emails { list-style: none; margin-bottom: 20px; }
.otp-emails li { font-size: 13px; color: var(--blue); font-weight: 500; padding: 2px 0; }
.error-msg { color: var(--red); font-size: 13px; margin-bottom: 12px; padding: 8px 12px; background: #fef2f2; border-radius: 6px; }

/* BUTTONS */
.btn-primary { background: var(--blue); color: var(--white); border: none; border-radius: var(--radius); padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-full { width: 100%; padding: 12px; font-size: 15px; margin-bottom: 8px; }
.btn-ghost { background: transparent; border: 1.5px solid var(--gray-200); color: var(--text-mid); border-radius: var(--radius); padding: 10px 20px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-ghost:hover { background: var(--gray-100); }
.btn-ghost-sm { background: transparent; border: 1.5px solid var(--gray-200); color: var(--text-mid); border-radius: 8px; padding: 5px 12px; font-size: 13px; font-weight: 500; cursor: pointer; }
.btn-ghost-sm:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-outline { background: transparent; border: 1.5px solid var(--blue); color: var(--blue); border-radius: var(--radius); padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-outline:hover { background: var(--blue-light); }
.btn-icon { background: var(--blue-light); border: none; border-radius: 8px; width: 34px; height: 34px; font-size: 16px; cursor: pointer; color: var(--blue); display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--blue-mid); }
.btn-danger { background: var(--red); color: var(--white); border: none; border-radius: var(--radius); padding: 6px 14px; font-size: 13px; cursor: pointer; }
.btn-danger:hover { background: #b91c1c; }

/* TOP BAR */
.topbar { background: var(--white); border-bottom: 1.5px solid var(--gray-100); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-logo { width: 32px; height: 32px; object-fit: contain; }
.topbar-title { font-size: 17px; font-weight: 700; color: #4a4a4a; user-select: none; font-family: 'Montserrat', sans-serif; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: capitalize; }

/* TABS */
.tabs { background: var(--white); border-bottom: 1.5px solid var(--gray-100); display: flex; padding: 0 24px; gap: 4px; }
.tab { background: none; border: none; border-bottom: 3px solid transparent; padding: 14px 18px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: color .15s, border-color .15s; margin-bottom: -1.5px; }
.tab:hover { color: var(--blue); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* PANELS */
.panel-inner { max-width: 800px; margin: 0 auto; padding: 28px 24px; }
.panel-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 20px; }

/* SPLIT LAYOUT */
.split-layout { display: flex; height: calc(100vh - 110px); overflow-x: auto; }
.split-left { width: 820px; min-width: 600px; border-right: 1.5px solid var(--gray-100); background: var(--white); padding: 20px 20px; overflow-y: auto; flex-shrink: 0; }
.split-right { flex: 1; min-width: 320px; padding: 28px 32px; overflow-y: auto; background: var(--gray-50); }
.split-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* GLOBAL QUICK VIEW */
.global-quickview { width: 780px; min-width: 560px; }
.qv-header { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1.5px solid var(--gray-100); }
.qv-title { font-size: 12px; font-weight: 700; color: var(--text-mid); text-transform: uppercase; letter-spacing: .07em; }
.qv-profit { background: var(--blue-light); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.qv-profit-label { font-size: 10px; font-weight: 700; color: var(--blue-dark); text-transform: uppercase; letter-spacing: .05em; }
.qv-profit-value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.qv-section-title { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin: 14px 0 5px; }
.qv-client-label { font-size: 10px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .04em; padding: 5px 2px 2px 18px; }
.qv-entity { margin-bottom: 1px; }
.qv-entity-header { display: flex; align-items: center; gap: 5px; padding: 6px 6px; border-radius: 7px; cursor: pointer; transition: background .12s; }
.qv-entity-header:hover { background: var(--gray-50); }
.qv-expand { font-size: 9px; color: var(--gray-400); flex-shrink: 0; width: 12px; line-height: 1; }
.qv-name { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qv-sub { font-size: 10px; color: var(--text-muted); flex-shrink: 0; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qv-nav { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 14px; padding: 0 2px; flex-shrink: 0; opacity: 0.6; line-height: 1; }
.qv-nav:hover { opacity: 1; }
.qv-tasks-list { padding: 2px 0 4px 20px; }
.qv-task-row { display: flex; align-items: flex-start; gap: 6px; padding: 2px 0; }
.qv-task-row.qv-done .qv-task-text { text-decoration: line-through; color: var(--text-muted); }
.qv-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); flex-shrink: 0; margin-top: 5px; }
.qv-done .qv-dot { background: var(--gray-400); }
.qv-task-text { font-size: 12px; color: var(--text); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.qv-loading { font-size: 12px; color: var(--text-muted); padding: 4px 0; }
.qv-empty { font-size: 12px; color: var(--text-muted); padding: 3px 0; }
.qv-toggle-done { background: none; border: none; color: var(--blue); font-size: 11px; font-weight: 600; cursor: pointer; padding: 4px 0 2px 20px; display: block; }
.qv-toggle-done:hover { text-decoration: underline; }
.qv-done-list { margin-top: 2px; }

/* ENTITY LIST */
.entity-list { display: flex; flex-direction: column; gap: 4px; }
.entity-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); font-weight: 500; transition: background .12s; }
.entity-item:hover { background: var(--gray-50); }
.entity-item.active { background: var(--blue-light); color: var(--blue); }
.client-group { margin-bottom: 12px; }
.client-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--text-mid); text-transform: uppercase; letter-spacing: .04em; }
.client-projects { padding-left: 8px; }

/* TASK LIST */
.task-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.task-row { display: flex; align-items: flex-start; gap: 10px; background: var(--white); border: 1.5px solid var(--gray-100); border-radius: var(--radius); padding: 12px 14px; transition: border-color .15s; }
.task-row:hover { border-color: var(--blue-mid); }
.task-row.completed .task-text { text-decoration: line-through; color: var(--text-muted); }
.task-check { width: 18px; height: 18px; accent-color: var(--blue); cursor: pointer; flex-shrink: 0; margin-top: 2px; }
.task-body { flex: 1; min-width: 0; }
.task-text-wrap { display: block; }
.task-text { font-size: 14px; color: var(--text); line-height: 1.5; word-break: break-word; white-space: pre-wrap; }
.task-edit-input { width: 100%; padding: 4px 8px; border: 1.5px solid var(--blue); border-radius: 6px; font-size: 14px; color: var(--text); outline: none; background: var(--blue-light); resize: vertical; min-height: 36px; font-family: inherit; line-height: 1.5; }
.task-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.6; }
.task-meta strong { color: var(--text-mid); font-weight: 600; }
.task-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.drag-handle { cursor: grab; color: var(--gray-400); font-size: 18px; line-height: 1; flex-shrink: 0; padding: 0 2px; user-select: none; margin-top: 1px; }
.drag-handle:active { cursor: grabbing; }
.task-row.dragging { opacity: 0.35; background: var(--blue-light); }
.task-row.drag-over { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(36,81,200,0.18); }
.task-row.linked-task { border-left: 3px solid var(--blue-mid); }
.linked-badge { display: inline-block; background: var(--blue-mid); color: var(--blue-dark); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 4px; padding: 1px 5px; vertical-align: middle; margin-right: 2px; }
.tag { background: var(--blue-light); color: var(--blue); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; display: inline-flex; align-items: center; gap: 4px; }
.tag-project { background: #dcfce7; color: #15803d; }
.tag-project .tag-remove { color: #166534; }
.tag-remove { cursor: pointer; font-size: 13px; line-height: 1; color: var(--blue-dark); }
.task-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.btn-assign { background: var(--blue-light); border: none; color: var(--blue); border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-assign:hover { background: var(--blue-mid); }
.btn-assign-project { background: #dcfce7; border: none; color: #15803d; border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-assign-project:hover { background: #bbf7d0; }
.btn-edit-task { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 15px; padding: 2px 4px; border-radius: 4px; }
.btn-edit-task:hover { color: var(--blue); }
.btn-edit-task.saving { color: var(--green); }
.btn-del-task { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 16px; padding: 2px 4px; border-radius: 4px; }
.btn-del-task:hover { color: var(--red); }
.assign-group-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 4px 4px; }
.add-task-row { display: flex; gap: 10px; margin-top: 8px; margin-bottom: 16px; align-items: flex-end; }
.task-input { flex: 1; padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: var(--radius); font-size: 14px; color: var(--text); outline: none; }
.task-input:focus { border-color: var(--blue); }
.task-textarea { resize: vertical; min-height: 42px; font-family: inherit; line-height: 1.5; }
.completed-section { margin-top: 8px; }
.toggle-completed { background: none; border: none; color: var(--blue); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 0; }

/* EMPLOYEE / PROJECT DETAIL */
.detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px; }
.detail-field label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 4px; }
.detail-field input { width: 100%; padding: 8px 12px; border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: 14px; color: var(--text); outline: none; }
.detail-field input:focus { border-color: var(--blue); }
.detail-actions { display: flex; gap: 10px; margin-bottom: 28px; }
.empty-state { color: var(--text-muted); font-size: 15px; padding: 60px 0; text-align: center; }
.detail-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 20px; }
.detail-subtitle { font-size: 14px; font-weight: 700; color: var(--text-mid); margin-bottom: 12px; margin-top: 4px; }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.status-active { background: #dcfce7; color: #15803d; }
.status-completed { background: var(--gray-100); color: var(--text-muted); }

/* FINANCES */
.month-nav { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.month-label { font-size: 20px; font-weight: 700; color: var(--text); min-width: 160px; text-align: center; }
.fin-summary { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.fin-stat { flex: 1; min-width: 160px; background: var(--white); border: 1.5px solid var(--gray-100); border-radius: var(--radius); padding: 16px 20px; }
.fin-stat-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 4px; }
.fin-stat-value { font-size: 22px; font-weight: 700; }
.fin-stat-income .fin-stat-value { color: var(--green); }
.fin-stat-expense .fin-stat-value { color: var(--red); }
.fin-stat-profit .fin-stat-value { color: var(--blue); }
.fin-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 32px; }
.fin-col-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.income-title { color: var(--green); }
.expense-title { color: var(--red); }
.fin-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.fin-entry { background: var(--white); border: 1.5px solid var(--gray-100); border-radius: var(--radius); padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fin-entry-info { flex: 1; min-width: 0; }
.fin-entry-cat { font-size: 13px; font-weight: 700; color: var(--text); }
.fin-entry-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.fin-entry-amount { font-size: 15px; font-weight: 700; white-space: nowrap; }
.fin-entry-income .fin-entry-amount { color: var(--green); }
.fin-entry-expense .fin-entry-amount { color: var(--red); }
.chart-container { background: var(--white); border: 1.5px solid var(--gray-100); border-radius: var(--radius); padding: 24px; }
.chart-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 20px; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(17,24,39,.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: var(--white); border-radius: 16px; padding: 32px; min-width: 340px; max-width: 460px; width: 100%; box-shadow: var(--shadow-md); }
.modal-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 20px; }
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.modal-field input, .modal-field select { width: 100%; padding: 9px 12px; border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: 14px; color: var(--text); outline: none; background: var(--white); }
.modal-field input:focus, .modal-field select:focus { border-color: var(--blue); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.assign-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.assign-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--gray-100); font-size: 14px; cursor: pointer; }
.assign-item:hover { background: var(--gray-50); }
.assign-item.assigned { background: var(--blue-light); border-color: var(--blue-mid); color: var(--blue); font-weight: 600; }
