:root {
  --ldd-teal: #1a8bb5;
  --ldd-teal-dark: #146e90;
  --ldd-teal-light: #e8f4f9;
  --ldd-sidebar-bg: #f8fafc;
  --ldd-border: #e2e8f0;
  --ldd-text: #1e293b;
  --ldd-muted: #64748b;
  --ldd-header-h: 52px;
  --ldd-left-icon-w: 64px;
  --ldd-left-nav-w: 240px;
  --ldd-right-panel-w: 56px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #f1f5f9; color: var(--ldd-text); font-size: 13px; }

/* ── Layout ─────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.app-header {
  height: var(--ldd-header-h);
  background: var(--ldd-teal);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px;
  flex-shrink: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.app-header .logo { display: flex; align-items: center; gap: 8px; color: white; font-weight: 700; font-size: 11px; text-decoration: none; }
.app-header .logo-icon { background: white; color: var(--ldd-teal); border-radius: 4px; padding: 2px 5px; font-weight: 900; font-size: 14px; letter-spacing: -1px; }
.app-header h1 { color: white; font-size: 17px; font-weight: 600; margin: 0 auto 0 16px; }
.app-header .ab-badge { background: rgba(255,255,255,0.2); color: white; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-left: 4px; }
.header-icon-btn { background: none; border: none; color: rgba(255,255,255,0.85); cursor: pointer; padding: 6px; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.header-icon-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.header-notif { position: relative; }
.notif-dot { position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; background: #f59e0b; border-radius: 50%; border: 2px solid var(--ldd-teal); }
.header-avatar { width: 30px; height: 30px; background: rgba(255,255,255,0.25); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 12px; cursor: pointer; border: 1px solid rgba(255,255,255,0.4); }

.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Left icon rail ─────────────────────────── */
.icon-rail { width: var(--ldd-left-icon-w); background: #fff; border-right: 1px solid var(--ldd-border); display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 4px; flex-shrink: 0; z-index: 10; }
.icon-rail-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border-radius: 8px; cursor: pointer; width: 52px; border: none; background: none; color: var(--ldd-muted); transition: all 0.15s; }
.icon-rail-btn span { font-size: 10px; }
.icon-rail-btn svg { width: 20px; height: 20px; }
.icon-rail-btn:hover { background: var(--ldd-teal-light); color: var(--ldd-teal); }
.icon-rail-btn.active { background: var(--ldd-teal-light); color: var(--ldd-teal); font-weight: 600; }
.icon-rail-divider { width: 36px; height: 1px; background: var(--ldd-border); margin: 4px 0; }

/* ── Left detail nav ────────────────────────── */
.left-nav { width: var(--ldd-left-nav-w); background: #fff; border-right: 1px solid var(--ldd-border); overflow-y: auto; flex-shrink: 0; }
.left-nav-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; border-left: 3px solid transparent; transition: all 0.1s; color: var(--ldd-text); font-size: 13px; }
.left-nav-item:hover { background: var(--ldd-teal-light); }
.left-nav-item.active { background: var(--ldd-teal-light); border-left-color: var(--ldd-teal); color: var(--ldd-teal); font-weight: 600; }
.left-nav-item.sub { padding-left: 28px; font-size: 12px; color: var(--ldd-muted); }
.left-nav-item.sub.active { color: var(--ldd-teal); font-weight: 600; }
.left-nav-badge { background: #e2e8f0; border-radius: 10px; padding: 1px 6px; font-size: 11px; margin-left: auto; }
.left-nav-badge.warn { background: #fef3c7; color: #92400e; }

/* ── Right panel ────────────────────────────── */
.right-panel { width: var(--ldd-right-panel-w); background: #fff; border-left: 1px solid var(--ldd-border); display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 4px; flex-shrink: 0; }
.right-panel-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border-radius: 8px; cursor: pointer; width: 48px; border: none; background: none; color: var(--ldd-muted); transition: all 0.15s; }
.right-panel-btn span { font-size: 10px; }
.right-panel-btn svg { width: 18px; height: 18px; }
.right-panel-btn:hover { background: var(--ldd-teal-light); color: var(--ldd-teal); }
.right-panel-btn.active { background: var(--ldd-teal-light); color: var(--ldd-teal); }

/* ── Right expanded panel ───────────────────── */
.right-expanded { width: 320px; background: #fff; border-left: 1px solid var(--ldd-border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.right-expanded-header { padding: 12px 16px; border-bottom: 1px solid var(--ldd-border); display: flex; align-items: center; justify-content: space-between; }
.right-expanded-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.right-expanded-body { flex: 1; overflow-y: auto; padding: 12px; }

/* ── Main content ───────────────────────────── */
.main-content { flex: 1; overflow-y: auto; padding: 0; display: flex; flex-direction: column; }

/* ── File List ──────────────────────────────── */
.files-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: white; border-bottom: 1px solid var(--ldd-border); }
.files-toolbar h2 { font-size: 15px; font-weight: 700; margin: 0 12px 0 0; }
.search-box { flex: 1; position: relative; }
.search-box input { width: 100%; padding: 7px 12px 7px 34px; border: 1px solid var(--ldd-border); border-radius: 6px; font-size: 13px; outline: none; background: #f8fafc; }
.search-box input:focus { border-color: var(--ldd-teal); background: white; box-shadow: 0 0 0 2px rgba(26,139,181,0.15); }
.search-box .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ldd-muted); }
.btn-primary { background: var(--ldd-teal); color: white; border: none; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; transition: background 0.15s; white-space: nowrap; }
.btn-primary:hover { background: var(--ldd-teal-dark); }
.btn-secondary { background: white; color: var(--ldd-text); border: 1px solid var(--ldd-border); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 6px; transition: all 0.15s; }
.btn-secondary:hover { border-color: var(--ldd-teal); color: var(--ldd-teal); background: var(--ldd-teal-light); }
.btn-danger { background: #ef4444; color: white; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-ghost { background: none; border: none; color: var(--ldd-muted); cursor: pointer; padding: 4px 8px; border-radius: 4px; font-size: 12px; }
.btn-ghost:hover { color: var(--ldd-text); background: #f1f5f9; }

.files-table-wrap { overflow-x: auto; }
.files-table { width: 100%; border-collapse: collapse; }
.files-table th { background: #f8fafc; padding: 8px 12px; text-align: left; font-weight: 600; font-size: 12px; color: var(--ldd-muted); border-bottom: 2px solid var(--ldd-border); cursor: pointer; user-select: none; white-space: nowrap; }
.files-table th:hover { color: var(--ldd-teal); }
.files-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.files-table tr:hover td { background: var(--ldd-teal-light); cursor: pointer; }
.files-table .file-no { font-weight: 700; color: var(--ldd-teal); font-size: 13px; }
.recent-tag { background: #f59e0b; color: white; font-size: 10px; padding: 1px 5px; border-radius: 3px; margin-left: 6px; font-weight: 600; vertical-align: middle; }

/* ── Badges ─────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-sale { background: #d1fae5; color: #065f46; }
.badge-purchase { background: #dbeafe; color: #1e40af; }
.badge-mortgage { background: #e0e7ff; color: #3730a3; }
.badge-refinance { background: #fce7f3; color: #9d174d; }
.badge-transfer { background: #fef3c7; color: #92400e; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-closed { background: #e2e8f0; color: #475569; }
.badge-inactive { background: #fef3c7; color: #92400e; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-waived { background: #d1fae5; color: #065f46; }
.badge-satisfied { background: #dbeafe; color: #1e40af; }
.badge-collapsed { background: #fee2e2; color: #991b1b; }

/* ── Bottom panels (key dates + task mgr) ───── */
.bottom-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 2px solid var(--ldd-border); }
.bottom-panel { background: white; padding: 12px 16px; }
.bottom-panel:first-child { border-right: 1px solid var(--ldd-border); }
.bottom-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.bottom-panel-header h3 { font-size: 13px; font-weight: 700; margin: 0; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; color: var(--ldd-muted); gap: 6px; }
.empty-state svg { width: 36px; height: 36px; opacity: 0.4; }
.empty-state p { margin: 0; font-size: 12px; text-align: center; }

/* ── File detail header ─────────────────────── */
.file-detail-header { background: white; border-bottom: 1px solid var(--ldd-border); padding: 10px 16px; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.file-detail-header-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-detail-header-top .file-no-large { font-size: 18px; font-weight: 800; color: var(--ldd-teal); }
.closing-date-badge { background: #f0f9ff; border: 1px solid #bae6fd; color: #0369a1; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.file-detail-header-meta { color: var(--ldd-muted); font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.header-lawyer { display: flex; align-items: center; gap: 5px; }
.header-lawyer svg { color: var(--ldd-teal); }
.progress-bars { display: flex; gap: 12px; flex-wrap: wrap; }
.progress-item { display: flex; flex-direction: column; gap: 3px; min-width: 100px; }
.progress-label { font-size: 11px; color: var(--ldd-muted); }
.progress-bar-track { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--ldd-teal); border-radius: 3px; transition: width 0.3s; }
.progress-bar-fill.warn { background: #f59e0b; }
.progress-bar-fill.danger { background: #ef4444; }

/* ── Cards ──────────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 16px; }
.card { background: white; border: 1px solid var(--ldd-border); border-radius: 8px; overflow: hidden; }
.card-header { padding: 10px 14px; border-bottom: 1px solid var(--ldd-border); display: flex; align-items: center; justify-content: space-between; background: #fafbfc; }
.card-header h4 { margin: 0; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 12px 14px; }
.field-row { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.field-row:last-child { margin-bottom: 0; }
.field-label { font-size: 11px; color: var(--ldd-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.field-value { font-size: 13px; color: var(--ldd-text); font-weight: 500; }
.field-value.currency { font-size: 15px; font-weight: 700; color: var(--ldd-teal-dark); }
.field-value.muted { color: var(--ldd-muted); }

.person-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.person-row:last-child { border-bottom: none; }
.person-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ldd-teal-light); color: var(--ldd-teal); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.person-name { flex: 1; font-weight: 600; }
.person-actions { display: flex; gap: 4px; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--ldd-muted); padding: 3px; border-radius: 4px; display: flex; }
.icon-btn:hover { color: var(--ldd-teal); background: var(--ldd-teal-light); }

/* ── Documents ──────────────────────────────── */
.docs-layout { display: flex; flex: 1; overflow: hidden; }
.docs-left { width: 220px; border-right: 1px solid var(--ldd-border); background: white; overflow-y: auto; flex-shrink: 0; padding: 8px 0; }
.docs-left-item { padding: 7px 14px; cursor: pointer; font-size: 13px; color: var(--ldd-muted); transition: all 0.1s; border-left: 3px solid transparent; }
.docs-left-item:hover { background: var(--ldd-teal-light); color: var(--ldd-text); }
.docs-left-item.active { background: var(--ldd-teal-light); color: var(--ldd-teal); border-left-color: var(--ldd-teal); font-weight: 600; }
.docs-right { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.docs-toolbar { display: flex; align-items: center; gap: 8px; }
.doc-category-section { background: white; border: 1px solid var(--ldd-border); border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
.doc-category-header { padding: 10px 14px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--ldd-border); background: #fafbfc; }
.doc-category-header:hover { background: var(--ldd-teal-light); }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid #f8fafc; }
.doc-item:last-child { border-bottom: none; }
.doc-icon { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; background: #fee2e2; color: #dc2626; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.doc-icon.pdf { background: #fee2e2; color: #dc2626; }
.doc-icon.word { background: #dbeafe; color: #1d4ed8; }
.doc-icon.img { background: #d1fae5; color: #059669; }
.doc-info { flex: 1; }
.doc-name { font-weight: 600; font-size: 13px; }
.doc-meta { font-size: 11px; color: var(--ldd-muted); }
.doc-actions { display: flex; gap: 4px; }
.upload-drop-zone { border: 2px dashed var(--ldd-border); border-radius: 8px; padding: 24px; text-align: center; color: var(--ldd-muted); cursor: pointer; transition: all 0.15s; }
.upload-drop-zone:hover { border-color: var(--ldd-teal); background: var(--ldd-teal-light); color: var(--ldd-teal); }

/* ── Details form ───────────────────────────── */
.details-form { padding: 16px; max-width: 700px; }
.form-section { background: white; border: 1px solid var(--ldd-border); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.form-section-header { padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--ldd-border); font-weight: 700; font-size: 13px; }
.form-section-body { padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-section-body.single { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--ldd-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.form-group input, .form-group select, .form-group textarea { padding: 6px 10px; border: 1px solid var(--ldd-border); border-radius: 6px; font-size: 13px; outline: none; background: #fafbfc; width: 100%; transition: all 0.15s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--ldd-teal); background: white; box-shadow: 0 0 0 2px rgba(26,139,181,0.15); }
.form-group textarea { min-height: 80px; resize: vertical; }
.radio-group { display: flex; gap: 16px; padding-top: 4px; }
.radio-group label { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ldd-text); font-weight: normal; text-transform: none; letter-spacing: 0; cursor: pointer; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding-top: 4px; color: var(--ldd-text); }

/* ── Conditions ─────────────────────────────── */
.conditions-list { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.condition-row { background: white; border: 1px solid var(--ldd-border); border-radius: 8px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 12px; }
.condition-row.overdue { border-left: 3px solid #ef4444; }
.condition-row.pending { border-left: 3px solid #f59e0b; }
.condition-row.waived { border-left: 3px solid #10b981; }

/* ── Tasks list ─────────────────────────────── */
.task-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px; border-radius: 6px; transition: background 0.1s; }
.task-item:hover { background: var(--ldd-teal-light); }
.task-item input[type=checkbox] { margin-top: 2px; cursor: pointer; accent-color: var(--ldd-teal); width: 14px; height: 14px; }
.task-text { flex: 1; font-size: 13px; }
.task-text.done { text-decoration: line-through; color: var(--ldd-muted); }
.task-due { font-size: 11px; color: var(--ldd-muted); }
.task-due.overdue { color: #ef4444; font-weight: 600; }

/* ── Notes ──────────────────────────────────── */
.note-item { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.note-meta { font-size: 11px; color: var(--ldd-muted); margin-bottom: 4px; }
.note-content { font-size: 13px; }

/* ── Communications ─────────────────────────── */
.comm-item { background: white; border: 1px solid var(--ldd-border); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.comm-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.comm-type-icon { padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; background: var(--ldd-teal-light); color: var(--ldd-teal); }
.comm-subject { font-weight: 600; font-size: 13px; }
.comm-meta { font-size: 11px; color: var(--ldd-muted); margin-bottom: 4px; }
.comm-content { font-size: 12px; color: var(--ldd-muted); }

/* ── Modal ──────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal { background: white; border-radius: 12px; max-width: 680px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--ldd-border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: white; z-index: 1; }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--ldd-border); display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: white; }

/* ── Tabs (top) ─────────────────────────────── */
.top-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--ldd-border); background: white; padding: 0 16px; flex-shrink: 0; }
.top-tab { padding: 10px 16px; cursor: pointer; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 500; color: var(--ldd-muted); transition: all 0.15s; white-space: nowrap; }
.top-tab:hover { color: var(--ldd-teal); }
.top-tab.active { color: var(--ldd-teal); border-bottom-color: var(--ldd-teal); font-weight: 600; }

/* ── Reports ────────────────────────────────── */
.report-card { background: white; border: 1px solid var(--ldd-border); border-radius: 8px; padding: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 16px; }
.stat-card { background: white; border: 1px solid var(--ldd-border); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--ldd-teal); }
.stat-label { font-size: 11px; color: var(--ldd-muted); font-weight: 600; }

/* ── Misc ───────────────────────────────────── */
.section-body { flex: 1; display: flex; overflow: hidden; }
.add-btn { display: flex; align-items: center; gap: 4px; color: var(--ldd-teal); background: none; border: none; cursor: pointer; font-size: 12px; font-weight: 600; padding: 2px 6px; border-radius: 4px; }
.add-btn:hover { background: var(--ldd-teal-light); }
.back-btn { display: flex; align-items: center; gap: 4px; color: var(--ldd-teal); background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 600; }
.back-btn:hover { text-decoration: underline; }
.tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; background: #e2e8f0; color: #475569; margin: 2px; }
.divider { height: 1px; background: var(--ldd-border); margin: 8px 0; }
.text-muted { color: var(--ldd-muted); }
.text-teal { color: var(--ldd-teal); }
.text-error { color: #ef4444; }
.text-warning { color: #f59e0b; }
.font-bold { font-weight: 700; }
input[type=file] { display: none; }
.filter-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-chip { padding: 4px 10px; border-radius: 20px; border: 1px solid var(--ldd-border); cursor: pointer; font-size: 12px; background: white; transition: all 0.1s; }
.filter-chip:hover, .filter-chip.active { background: var(--ldd-teal); color: white; border-color: var(--ldd-teal); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
