/* ============================================================
   Mattox Law Case Manager — Stylesheet
   Brand palette (matches mattoxlawpc.com):
     Maroon  #751A37  (primary)
     Maroon Dark  #5a1229
     Orange  #D4620A  (accent / secondary action)
     Orange Light  #fdecd9
     Light   #f5f7fa
     White   #ffffff
     Text    #1a1a2e
     Muted   #6b7280
     Border  #e2e8f0
   ============================================================ */

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

:root {
  --navy:    #751A37;
  --navy-dk: #5a1229;
  --gold:    #D4620A;
  --gold-lt: #fdecd9;
  --light:   #f5f7fa;
  --white:   #ffffff;
  --text:    #1a1a2e;
  --muted:   #6b7280;
  --border:  #e2e8f0;
  --ok:      #16a34a;
  --warn:    #d97706;
  --error:   #dc2626;
  --radius:  6px;
  --shadow:  0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
}

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

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

/* ============================================================
   Layout
   ============================================================ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.logo-icon {
  font-size: 22px;
  color: var(--gold);
}

.logo-firm {
  font-size: 14px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .3px;
}

.logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.7);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: var(--white);
  text-decoration: none;
}

.nav-item.active {
  background: rgba(255,255,255,.18);
  color: var(--white);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}

.badge {
  background: var(--error);
  color: white;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  margin-left: auto;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.user-role-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.8);
}

.user-role-badge.admin  { background: rgba(255,255,255,.25); color: var(--white); }
.user-role-badge.attorney { background: rgba(255,255,255,.15); color: white; }

.user-name {
  font-size: 12px;
  color: rgba(255,255,255,.7);
  font-weight: 500;
}

.logout-link {
  font-size: 12px;
  color: rgba(255,255,255,.4);
}
.logout-link:hover { color: rgba(255,255,255,.8); text-decoration: none; }

/* Main content area */
.main {
  flex: 1;
  overflow-y: auto;
}

.main-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 28px 48px;
}

/* ============================================================
   Page header
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.3px;
}

.page-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.page-note {
  color: var(--muted);
  margin-bottom: 20px;
  font-size: 13.5px;
  max-width: 720px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; text-decoration: none; }

.btn-primary  { background: var(--navy); color: white; }
.btn-secondary { background: white; color: var(--navy); border: 1.5px solid var(--border); }
.btn-ghost    { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-warn     { background: #fff3cd; color: #92400e; border: 1.5px solid #f6d860; }
.btn-block    { width: 100%; justify-content: center; }
.btn-lg       { padding: 10px 22px; font-size: 14.5px; }
.btn-sm       { padding: 5px 10px; font-size: 12px; }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.card-link {
  font-size: 12.5px;
  color: var(--gold);
  font-weight: 600;
}

.empty-card {
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.or-text { color: var(--muted); font-size: 13px; }

/* ============================================================
   Stat grid (dashboard)
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.stat-card--warn { border-top: 3px solid var(--warn); }

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
  font-weight: 600;
}

.stat-link { color: var(--muted); }
.stat-link:hover { color: var(--navy); }

/* ============================================================
   Two-column layout
   ============================================================ */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============================================================
   Tables
   ============================================================ */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: var(--light);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: top;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: #f8fafc; }

.clickable-row { cursor: pointer; }

.table-card { padding: 0; }

/* ============================================================
   Filter bar
   ============================================================ */

.filter-bar {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  outline: none;
}
.search-input:focus { border-color: var(--navy); }

.select-input {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  background: white;
  outline: none;
  cursor: pointer;
}
.select-input:focus { border-color: var(--navy); }

.result-count {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  margin-left: auto;
}

/* ============================================================
   Status & source badges
   ============================================================ */

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.status-prospect    { background: #e0f2fe; color: #0369a1; }
.status-consultation { background: #fef9c3; color: #854d0e; }
.status-retained    { background: #dcfce7; color: #166534; }
.status-closed      { background: #f1f5f9; color: #64748b; }

.source-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  text-transform: capitalize;
}

.badge-paid {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
  text-transform: uppercase;
}

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0;
}

.page-btn {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  background: white;
}

.page-info {
  font-size: 13px;
  color: var(--muted);
}

/* ============================================================
   Simple list (sidebar cards)
   ============================================================ */

.simple-list {
  list-style: none;
  padding: 6px 0;
}

.simple-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.simple-list li:last-child { border-bottom: none; }

.list-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-meta {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   Forms
   ============================================================ */

.form-card { padding: 20px; }

.card-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-group.span-2 { grid-column: span 2; }
.field-group.field-group--sm { max-width: 120px; }

.field-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.field-group input,
.field-group select,
.field-group textarea {
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: white;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus { border-color: var(--navy); }

.field-group textarea { resize: vertical; }

.form-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px;
}

.required { color: var(--error); }

/* ============================================================
   Detail view (dl)
   ============================================================ */

.detail-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0;
  padding: 0 18px;
}

.detail-list dt {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 11px 12px 11px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.detail-list dd {
  font-size: 13.5px;
  color: var(--text);
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.detail-list dt:last-of-type,
.detail-list dd:last-of-type { border-bottom: none; }

.notes-body {
  padding: 16px 18px;
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
}

.record-meta {
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
  margin-top: -8px;
  padding: 4px 0 8px;
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warn    { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }

/* ============================================================
   Login page
   ============================================================ */

.login-body {
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: white;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 360px;
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-icon {
  font-size: 36px;
  color: var(--navy);
}

.login-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  margin-top: 4px;
}

.login-header p {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.login-note {
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  margin-top: 12px;
}

/* ============================================================
   Import / upload zone
   ============================================================ */

.upload-form { margin-top: 16px; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 16px;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--navy);
  background: #f0f4ff;
}

.upload-icon {
  font-size: 28px;
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
}

.upload-zone p { color: var(--muted); font-size: 14px; }
.upload-note   { font-size: 12.5px; margin-top: 8px; font-weight: 600; color: var(--navy); }

.file-label {
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

/* ============================================================
   Duplicate review
   ============================================================ */

.dupe-card { padding: 0; }

.dupe-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--light);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.dupe-score {
  font-size: 13px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  flex-shrink: 0;
}

.score-high { background: #fee2e2; color: #991b1b; }
.score-med  { background: #fef9c3; color: #854d0e; }

.dupe-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.reason-tag {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  color: var(--navy);
}

.dupe-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.dupe-cases {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
}

.dupe-case {
  padding: 18px;
}

.dupe-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.dupe-case-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.dupe-case-name a {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}

.dupe-detail {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 0;
}

.dupe-detail dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.dupe-detail dd {
  font-size: 13px;
  color: var(--text);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.dupe-detail dt:last-of-type,
.dupe-detail dd:last-of-type { border-bottom: none; }

/* ============================================================
   Agreement send form
   ============================================================ */

.option-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.toggle-arrow { font-size: 11px; color: var(--muted); }

.option-section-body { padding-top: 4px; }

.option-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.option-row:last-child { border-bottom: none; }
.option-row:hover { background: #f8fafc; margin: 0 -4px; padding-left: 4px; padding-right: 4px; border-radius: 4px; }

.option-check { margin-top: 3px; flex-shrink: 0; width: 15px; height: 15px; accent-color: var(--navy); }

.option-text { display: flex; flex-direction: column; gap: 2px; }
.option-text strong { font-size: 13.5px; font-weight: 600; color: var(--text); }
.option-text span   { font-size: 12px; color: var(--muted); }

.state-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}

.state-check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 3px;
}
.state-check-row:hover { background: var(--light); }
.state-check-row input { accent-color: var(--navy); }

.state-shortcuts { display: flex; gap: 8px; margin-top: 4px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
  margin-top: 10px;
}
.checkbox-row input { accent-color: var(--navy); width: 15px; height: 15px; }

.field-hint { font-size: 11.5px; color: var(--muted); }

.selected-summary {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--light);
  border-radius: var(--radius);
  font-size: 13px;
}

.portal-link-code {
  display: inline-block;
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
  margin: 0 6px;
}

/* Portal status block on case detail */
.portal-status-block {
  padding: 14px 18px;
}

.portal-send-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--navy);
  color: white;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  margin-top: 12px;
}
.portal-send-link:hover { opacity: .88; text-decoration: none; }

.doc-list { list-style: none; padding: 0; }
.doc-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.doc-list li:last-child { border-bottom: none; }

/* ============================================================
   Utilities
   ============================================================ */

.mono       { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12.5px; }
.text-muted { color: var(--muted); }
.text-warn  { color: var(--warn); font-weight: 700; }
.text-ok    { color: var(--ok); font-weight: 700; }
.small      { font-size: 11.5px; }
.empty-state { color: var(--muted); font-size: 14px; padding: 16px 0; }
