:root {
  --bg: #f2f6f3;
  --card: #ffffff;
  --border: #dbe5de;
  --text: #16241b;
  --muted: #4a5b50;
  --primary: #166534;
  --primary-dark: #14532d;
  --primary-light: #15803d;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 24px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: #0b2417;
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar .brand span { font-size: 20px; }
.topbar .user-area { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.topbar .user-area .role-badge {
  background: rgba(255,255,255,0.15);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: capitalize;
}
.topbar button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
}
.topbar button:hover { background: rgba(255,255,255,0.1); }

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 { margin-top: 0; font-size: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  background: var(--primary);
  color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f9fafb; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid rgba(22, 101, 52, 0.3);
  border-color: var(--primary);
}
.textarea { min-height: 80px; resize: vertical; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.draft { background: #f0f4f1; color: #4a5b50; }
.badge.pending_review { background: #fef3c7; color: #b45309; }
.badge.in_revision { background: #fef3c7; color: #b45309; }
.badge.approved { background: #ecfdf5; color: #047857; }
.badge.filed { background: #e7f3ec; color: #166534; }
.badge.registered { background: #ecfdf5; color: #065f46; }

.case-list { list-style: none; padding: 0; margin: 0; }
.case-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  background: var(--card);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.case-list li:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.case-list .case-name { font-weight: 600; }
.case-list .case-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.case-list .right { display: flex; align-items: center; gap: 10px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.tabs button {
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.tabs button.active { background: var(--primary); color: #fff; }

.section-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.section-nav button {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.section-nav button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.sub-row { display: flex; gap: 12px; align-items: center; }
.sub-row .grow { flex: 1; }
.sub-row .remove { background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 18px; }

.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.doc-list .doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.comments { max-height: 300px; overflow-y: auto; }
.comment {
  padding: 10px 14px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 14px;
}
.comment .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert.info { background: #eef4ef; color: #14532d; border: 1px solid #cfe3d6; }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #07170f 0%, #14532d 100%);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card .logo { text-align: center; font-size: 28px; margin-bottom: 8px; }
.auth-card h1 { text-align: center; color: #fff; margin: 0 0 20px; font-size: 22px; }
.auth-card .card { padding: 28px; }
.auth-switch { text-align: center; font-size: 13px; color: rgba(255,255,255,0.85); margin-top: 16px; }
.auth-switch a { color: #fff; font-weight: 600; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0b2417;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.status-timeline { display: flex; gap: 4px; margin: 8px 0 16px; }
.status-timeline .step { flex: 1; height: 6px; border-radius: 3px; background: #e5e7eb; }
.status-timeline .step.done { background: var(--success); }
.status-timeline .step.current { background: var(--primary); }

table.review-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.review-table th, table.review-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.review-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }