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

:root {
  --blue:    #1D6FA4;
  --blue-lt: #e6f1fb;
  --teal:    #0F6E56;
  --teal-lt: #e1f5ee;
  --amber:   #854F0B;
  --amber-lt:#faeeda;
  --green:   #3B6D11;
  --green-lt:#eaf3de;
  --coral:   #993C1D;
  --coral-lt:#faece7;
  --gray:    #5F5E5A;
  --gray-lt: #f1efe8;
  --border:  #d3d1c7;
  --text:    #2c2c2a;
  --text-muted: #888780;
  --bg:      #f9f8f5;
  --white:   #ffffff;
  --radius:  8px;
  --shadow:  0 1px 3px rgba(0,0,0,.08);
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 14px;
       color: var(--text); background: var(--bg); line-height: 1.5; }

a { color: var(--blue); text-decoration: none; }

/* ── Navbar ── */
.navbar { display:flex; align-items:center; justify-content:space-between;
          padding: 0 24px; height: 52px; background: var(--white);
          border-bottom: 1px solid var(--border); position: sticky; top:0; z-index:10; }
.brand  { font-weight: 600; font-size: 15px; color: var(--text); }
.nav-title { font-weight: 500; color: var(--text-muted); }
.nav-actions { display:flex; gap:8px; }

/* ── Buttons ── */
.btn { display:inline-flex; align-items:center; gap:6px; padding: 7px 16px;
       border-radius: var(--radius); font-size: 13px; font-weight: 500;
       cursor: pointer; border: 1px solid transparent; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-outline  { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-sm { padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; border: none; }
.btn-edit { background: var(--blue-lt); color: var(--blue); }
.btn-del  { background: #fcebeb; color: #a32d2d; }

/* ── Container ── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }

/* ── Stats row ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
             gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--border);
             border-radius: var(--radius); padding: 16px 20px;
             cursor: pointer; transition: box-shadow .15s; }
.stat-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.stat-num   { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.status-assigned .stat-num { color: var(--amber); }
.status-reported .stat-num { color: var(--blue); }
.status-billed   .stat-num { color: var(--coral); }
.status-paid     .stat-num { color: var(--green); }
.highlight { border-color: var(--coral); }
.highlight .stat-num { color: var(--coral); font-size: 18px; margin-top: 4px; }

/* ── Filter bar ── */
.filter-bar { display:flex; gap:10px; margin-bottom:16px; }
.search-input { flex:1; padding: 8px 12px; border:1px solid var(--border);
                border-radius: var(--radius); font-size:13px; background: var(--white); }
.search-input:focus { outline: 2px solid var(--blue); outline-offset:1px; }
.select-filter { padding: 8px 12px; border:1px solid var(--border);
                 border-radius: var(--radius); font-size:13px;
                 background: var(--white); cursor:pointer; }

/* ── Table ── */
.table-wrap { overflow-x: auto; background: var(--white);
              border: 1px solid var(--border); border-radius: var(--radius); }
.case-table { width:100%; border-collapse: collapse; font-size:13px; }
.case-table th { padding: 10px 14px; text-align:left; font-weight:600;
                 background: var(--gray-lt); border-bottom: 1px solid var(--border);
                 white-space: nowrap; }
.case-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align:top; }
.case-table tr:last-child td { border-bottom: none; }
.case-table tr:hover td { background: var(--bg); }
.empty-msg { text-align:center; color: var(--text-muted); padding: 40px !important; }
.actions { display:flex; gap:6px; white-space:nowrap; }

/* ── Badges ── */
.badge { display:inline-block; padding:3px 8px; border-radius:20px;
         font-size:11px; font-weight:600; text-transform:uppercase; }
.badge-assigned { background: var(--amber-lt); color: var(--amber); }
.badge-reported  { background: var(--blue-lt);  color: var(--blue); }
.badge-billed    { background: var(--coral-lt); color: var(--coral); }
.badge-paid      { background: var(--green-lt); color: var(--green); }

/* ── Form container ── */
.form-container { max-width: 860px; }
.status-banner { padding: 10px 16px; border-radius: var(--radius); margin-bottom:20px;
                 font-size:13px; }
.status-banner.status-assigned { background: var(--amber-lt); color: var(--amber); }
.status-banner.status-reported  { background: var(--blue-lt);  color: var(--blue); }
.status-banner.status-billed    { background: var(--coral-lt); color: var(--coral); }
.status-banner.status-paid      { background: var(--green-lt); color: var(--green); }

/* ── Phase cards ── */
.phase-card { background: var(--white); border: 1px solid var(--border);
              border-radius: var(--radius); margin-bottom:20px; overflow:hidden; }
.phase-header { display:flex; align-items:center; gap:10px; padding:14px 20px;
                border-bottom:1px solid var(--border); }
.phase-badge { font-size:11px; font-weight:700; padding:3px 8px;
               border-radius:20px; text-transform:uppercase; }
.phase-1 .phase-badge { background: var(--coral-lt); color: var(--coral); }
.phase-2 .phase-badge { background: var(--blue-lt);  color: var(--blue); }
.phase-3 .phase-badge { background: var(--coral-lt); color: var(--coral); }
.phase-4 .phase-badge { background: var(--teal-lt);  color: var(--teal); }
.phase-title { font-weight:600; font-size:14px; }
.phase-note  { font-size:12px; color: var(--text-muted); margin-left:auto; }

/* ── Grid layout ── */
.grid-2 { display:grid; grid-template-columns: 1fr 1fr; gap:0; padding:0; }
.grid-2 label { display:flex; flex-direction:column; gap:4px; font-size:12px;
                font-weight:500; color: var(--text-muted); padding:14px 20px;
                border-bottom:1px solid var(--border); border-right:1px solid var(--border); }
.grid-2 label:nth-child(even) { border-right:none; }
.grid-2 label:nth-last-child(-n+2) { border-bottom:none; }
.full-width { grid-column: 1 / -1 !important; border-right:none !important; }

input[type=text], input[type=date], input[type=number], textarea {
  width:100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size:13px; color: var(--text);
  background: var(--white); transition: outline .1s; }
input:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset:1px; border-color:transparent; }
input[readonly] { background: var(--gray-lt); color: var(--text-muted); cursor:default; }
textarea { resize: vertical; font-family: inherit; }

/* ── Form actions ── */
.form-actions { display:flex; justify-content:flex-end; gap:10px; padding: 16px 0 8px; }

/* ── Toast ── */
.toast { position:fixed; bottom:24px; right:24px; padding:12px 20px;
         border-radius: var(--radius); font-size:13px; font-weight:500;
         box-shadow: 0 4px 12px rgba(0,0,0,.15); z-index:100;
         transition: opacity .3s; }
.toast.success { background: var(--green-lt); color: var(--green); border:1px solid #c0dd97; }
.toast.error   { background: #fcebeb; color: #a32d2d; border:1px solid #f7c1c1; }
.toast.hidden  { opacity:0; pointer-events:none; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 label { border-right:none !important; }
  .grid-2 label:last-child { border-bottom:none; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; }
}

/* ── Insurance dropdown / select ── */
select.form-select {
  width:100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size:13px; color: var(--text);
  background: var(--white); transition: outline .1s; cursor:pointer;
  appearance: auto;
}
select.form-select:focus { outline: 2px solid var(--blue); outline-offset:1px; border-color:transparent; }

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--white); border-radius: 12px;
  width: 100%; max-width: 780px; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  overflow: hidden;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--gray-lt); flex-shrink: 0;
}
.modal-title { font-weight: 700; font-size: 15px; }
.modal-close {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--text-muted); padding: 2px 6px; border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { overflow-y: auto; padding: 0; flex: 1; }

/* ── Detail sections inside modal ── */
.detail-section { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.detail-section:last-child { border-bottom: none; }
.detail-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 12px;
}
.phase-1-title { color: var(--coral); }
.phase-2-title { color: var(--blue); }
.phase-3-title { color: var(--coral); }
.phase-4-title { color: var(--teal); }

.detail-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 16px;
}
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.detail-val { font-size: 13px; color: var(--text); word-break: break-word; }
.full-detail { grid-column: 1 / -1; }

/* ── Report file row ── */
.report-file-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--teal-lt); border: 1px solid #b2ddd1;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
}
.report-file-name { font-size: 13px; font-weight: 500; color: var(--teal); }

/* ── Upload area ── */
.upload-area { display: flex; align-items: center; gap: 8px; }

/* ── Responsive modal ── */
@media (max-width: 600px) {
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .modal-box { max-height: 95vh; }
}
@media (max-width: 400px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* ── Sortable column headers ── */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover { background: var(--border); }
th.sort-active { background: var(--blue-lt); color: var(--blue); }
.sort-icon { font-size: 11px; opacity: .6; margin-left: 3px; }
th.sort-active .sort-icon { opacity: 1; }

/* ── User menu (navbar dropdown) ── */
.user-menu {
  position: relative;
  display: inline-block;
}
.user-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  padding: 6px 10px; border-radius: var(--radius);
  cursor: pointer; border: 1px solid var(--border);
  background: var(--white);
  user-select: none;
}
.user-name:hover { background: var(--gray-lt); }
.user-dropdown {
  display: none;
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.12);
  min-width: 180px; z-index: 50; overflow: hidden;
}
.user-menu:hover .user-dropdown,
.user-menu:focus-within .user-dropdown { display: block; }
.user-dropdown a {
  display: block; padding: 10px 16px; font-size: 13px;
  color: var(--text); text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.user-dropdown a:last-child { border-bottom: none; }
.user-dropdown a:hover { background: var(--bg); }

/* ── Table actions cell — prevent wrapping & align top ── */
.case-table td.actions {
  vertical-align: top;
  padding-top: 10px;
  white-space: nowrap;
}
.actions { display:flex; gap:6px; flex-wrap: nowrap; }
