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

:root {
  --bg: #f4f6f9;
  --sidebar-bg: #1a2332;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #3b82f6;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--card); border-radius: 12px; padding: 40px; width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.login-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 28px; color: var(--text); }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--sidebar-bg); padding: 20px 0; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-logo { color: #fff; font-size: 16px; font-weight: 700; padding: 0 20px 20px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 8px; }
.sidebar-logo span { font-size: 20px; }
.sidebar-nav { flex: 1; padding-top: 12px; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--sidebar-text); text-decoration: none; font-size: 14px; transition: all .15s; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(59,130,246,.15); color: #fff; border-right: 3px solid var(--sidebar-active); }
.sidebar-nav a .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-user { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); color: var(--sidebar-text); font-size: 13px; }
.sidebar-user a { color: #ef4444; text-decoration: none; font-size: 12px; }
.content { flex: 1; padding: 28px 32px; overflow-y: auto; }

/* ── Cards ── */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--text); }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }

/* ── Stats ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.td-link { color: var(--primary); text-decoration: none; font-weight: 500; cursor: pointer; }
.td-link:hover { text-decoration: underline; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-consultation { background: #e0f2fe; color: #0369a1; }
.badge-contract { background: #fef9c3; color: #854d0e; }
.badge-preparation { background: #fde68a; color: #92400e; }
.badge-filing { background: #dbeafe; color: #1d4ed8; }
.badge-trial { background: #ede9fe; color: #6d28d9; }
.badge-decision { background: #d1fae5; color: #065f46; }
.badge-appeal { background: #fee2e2; color: #991b1b; }
.badge-enforcement { background: #f0abfc; color: #701a75; }
.badge-closed { background: #f1f5f9; color: #475569; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-partial { background: #fef9c3; color: #854d0e; }
.badge-pending { background: #fee2e2; color: #991b1b; }

/* ── Forms ── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); background: #fff; outline: none; transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 11px; }

/* ── Search ── */
.search-bar { display: flex; gap: 12px; margin-bottom: 20px; }
.search-bar input { flex: 1; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: #fff; border-radius: 12px; padding: 28px; width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.hidden { display: none !important; }

/* ── Client detail ── */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.detail-name { font-size: 24px; font-weight: 700; }
.detail-meta { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.info-item label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; }
.info-item p { font-size: 14px; margin-top: 3px; font-weight: 500; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 18px; border: none; background: none; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Misc ── */
.error-msg { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.amount-positive { color: var(--success); font-weight: 600; }

/* ── Stage stepper ── */
.stage-stepper { display: flex; align-items: flex-start; gap: 0; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.stage-step { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 64px; cursor: pointer; position: relative; }
.stage-step:not(:last-child)::after { content: ''; position: absolute; top: 11px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.stage-step.done:not(:last-child)::after { background: var(--primary); }
.stage-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); background: white; z-index: 1; transition: all .2s; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: white; }
.stage-step.done .stage-dot { background: var(--primary); border-color: var(--primary); }
.stage-step.current .stage-dot { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.25); }
.stage-step.closed-step .stage-dot { background: #475569; border-color: #475569; }
.stage-step.closed-step:not(:last-child)::after { background: #475569; }
.stage-label { font-size: 10px; color: var(--text-muted); margin-top: 5px; text-align: center; line-height: 1.3; max-width: 64px; }
.stage-step.current .stage-label { color: var(--primary); font-weight: 600; }
.stage-step.closed-step .stage-label { color: #475569; font-weight: 600; }
.stage-step:hover .stage-dot { border-color: var(--primary); }
.stage-step:hover .stage-label { color: var(--primary); }

/* ── Arrow pipeline (stage switcher at top of client page) ── */
.pipeline-card { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px 10px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.pipeline-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; min-height: 28px; }
.pipeline-case-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipeline-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.pipeline-select { flex: 1; font-size: 13px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: #f8fafc; color: var(--text); min-width: 0; }
.pipeline { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 4px; }
.pipeline-step { display: flex; align-items: center; justify-content: center; padding: 8px 20px 8px 26px; font-size: 12px; font-weight: 500; cursor: pointer; background: #f1f5f9; color: #64748b; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); transition: background .15s, color .15s; white-space: nowrap; flex-shrink: 0; user-select: none; }
.pipeline-step:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); padding-left: 14px; }
.pipeline-step:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%); padding-right: 14px; }
.pipeline-step.done { background: #dbeafe; color: #1d4ed8; }
.pipeline-step.current { background: var(--primary); color: white; font-weight: 600; }
.pipeline-step.pipeline-closed { background: #e2e8f0; color: #475569; }
.pipeline-step.current.pipeline-closed { background: #475569; color: white; }
.pipeline-step:hover:not(.current) { background: #e0e7ff; color: #4338ca; }
.pipeline-step.done:hover { background: #bfdbfe; color: #1d4ed8; }
.case-card { transition: box-shadow .15s; }
.case-card-active { border-color: var(--primary) !important; box-shadow: 0 0 0 2px rgba(99,102,241,.15) !important; }
