/* LOCK SCREEN & UTILITIES */
.hidden {
  display: none !important;
}
#lock-screen {
  position: fixed;
  inset: 0;
  background: #0c1c3a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: inherit;
}
#lock-box {
  background: #fff;
  border-radius: 10px;
  padding: 36px 32px;
  width: 320px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.lock-title {
  font-weight: 700;
  font-size: 18px;
  color: #0c1c3a;
  margin-bottom: 4px;
}
.lock-sub {
  font-size: 12.5px;
  color: #6b7280;
  margin-bottom: 20px;
}
#lock-screen input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 10px;
  box-sizing: border-box;
}
#lock-error {
  color: #b91c1c;
  font-size: 12px;
  min-height: 16px;
  margin-bottom: 8px;
}
#lock-submit {
  width: 100%;
  padding: 10px;
  background: #0c1c3a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
#logout-btn {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

:root {
  --navy: #1b2a41;
  --navy-light: #28405f;
  --slate: #44546a;
  --gold: #9c7a3c;
  --gold-light: #c7a869;
  --bg: #f6f5f1;
  --card: #ffffff;
  --line: #e1ded4;
  --ink: #1a1a1a;
  --muted: #6b6b65;
  --red: #a33b2d;
  --red-bg: #fbeae7;
  --green: #3b6d11;
  --green-bg: #eaf3de;
  --yellow: #8a5a15;
  --yellow-bg: #fbf0da;
  --blue: #1d4e7a;
  --blue-bg: #e6eef7;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.app {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* SIDEBAR */
.sidebar {
  width: 222px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, #141d2e 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(155deg, var(--gold-light), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.brand-mark span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  color: var(--navy);
  letter-spacing: 0.5px;
}
.brand-text h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17.5px;
  font-weight: normal;
  color: #fff;
  line-height: 1.2;
}
.brand-text .sub {
  margin-top: 1px;
  font-size: 9.5px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--gold-light);
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #5c6784;
  padding: 12px 12px 4px;
}
.nav-group-label:first-child {
  padding-top: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  border: none;
  color: #b9c0cc;
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(199, 168, 105, 0.15);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gold);
}
.nav-item.active svg {
  opacity: 1;
  color: var(--gold-light);
}
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  padding: 1px 6px;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--slate);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user .who {
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}
.sidebar-user .who .n {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
}
.sidebar-user .who .r {
  font-size: 10px;
  color: #8891a0;
  margin-top: 3px;
}
#staff-picker {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 5px;
  padding: 4px 6px;
}
#staff-picker option {
  color: #1a1a1a;
}

/* MAIN / TOPBAR & MOBILE COMPONENTS */
.mobile-menu-btn {
  display: none;
  cursor: pointer;
  color: var(--navy);
  padding-right: 8px;
}
.mobile-menu-btn svg {
  width: 26px;
  height: 26px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 26px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-weight: normal;
  font-size: 18px;
  color: var(--navy);
  white-space: nowrap;
}
.search-global {
  flex: 1;
  max-width: 360px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
}
.search-global:focus {
  outline: none;
  border-color: var(--gold-light);
  background: #fff;
}
.topbar .spacer {
  flex: 1;
}
.bell {
  position: relative;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.bell:hover {
  border-color: var(--navy);
}
.bell svg {
  width: 16px;
  height: 16px;
  color: var(--slate);
}
.bell .dot {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  border-radius: 8px;
  min-width: 15px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.wrap {
  max-width: 1200px;
  padding: 22px 26px 60px;
}
.panel {
  display: none;
}
.panel.active {
  display: block;
}

/* DASHBOARD */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  cursor: pointer;
  transition:
    box-shadow 0.15s,
    border-color 0.15s;
}
.kpi-card:hover {
  border-color: var(--gold-light);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}
.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kpi-icon svg {
  width: 16px;
  height: 16px;
}
.kpi-navy .kpi-icon {
  background: var(--blue-bg);
  color: var(--blue);
}
.kpi-blue .kpi-icon {
  background: var(--blue-bg);
  color: var(--blue);
}
.kpi-red .kpi-icon {
  background: var(--red-bg);
  color: var(--red);
}
.kpi-gold .kpi-icon {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.kpi-num {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.kpi-lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

.dash-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.dash-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.cal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.cal-header h3 {
  margin: 0;
  font-size: 16px;
  min-width: 170px;
  text-align: center;
}
.cal-nav-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  color: var(--slate);
}
.cal-nav-btn:hover {
  background: var(--bg);
}
.cal-today-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--slate);
}
.cal-legend {
  display: flex;
  gap: 16px;
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
.cal-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}
.cal-legend .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.cal-dow {
  background: var(--navy);
  color: #fff;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 7px 0;
}
.cal-cell {
  background: #fff;
  min-height: 92px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-cell:hover {
  background: var(--bg);
}
.cal-cell.other-month {
  background: #fafaf8;
  color: var(--muted);
}
.cal-cell.today .cal-daynum {
  background: var(--gold);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cal-cell.selected {
  box-shadow: inset 0 0 0 2px var(--navy);
}
.cal-daynum {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate);
}
.cal-chip {
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.cal-chip.deadline {
  background: var(--red-bg);
  color: var(--red);
}
.cal-chip.task {
  background: var(--blue-bg);
  color: var(--blue);
}
.cal-chip.payment {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.cal-chip-more {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}
.cal-agenda {
  margin-top: 18px;
}
.cal-agenda-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  background: #fff;
}
.cal-agenda-item:hover {
  background: var(--bg);
}
.cal-agenda-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 10px;
}
.cal-agenda-tag.deadline {
  background: var(--red-bg);
  color: var(--red);
}
.cal-agenda-tag.task {
  background: var(--blue-bg);
  color: var(--blue);
}
.cal-agenda-tag.payment {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.dash-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--slate);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.dash-panel-head a {
  text-transform: none;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--blue);
  cursor: pointer;
  letter-spacing: 0;
}
.dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.dash-row:last-child {
  border-bottom: none;
}
.dash-row .t {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-row .s {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.dash-row .s.overdue {
  color: var(--red);
  font-weight: 700;
}
.dash-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 6px 0;
}

/* CONFLICT WARNING */
#conflict-warning {
  display: none;
  background: var(--yellow-bg);
  border: 1px solid #e8d6a8;
  color: var(--yellow);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 12px;
}

/* UNSYNCED DATA BANNER */
#unsynced-banner {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--red-bg);
  color: var(--red);
  border-bottom: 1px solid #e7c6bf;
  padding: 9px 26px;
  font-size: 12.5px;
  font-weight: 600;
}
#unsynced-banner .ub-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
}
#unsynced-banner .ub-text {
  flex: 1;
  font-weight: 400;
}
#unsynced-banner .ub-text b {
  font-weight: 700;
}
#unsynced-banner button {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
#unsynced-banner button:hover {
  background: var(--red);
  color: #fff;
}

/* MATTER DETAIL MODAL (wider) */
.modal.modal-wide {
  max-width: 760px;
}
.matter-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.matter-head h2 {
  margin: 0 0 4px;
}
.matter-meta {
  font-size: 12.5px;
  color: var(--muted);
}
.matter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.matter-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.matter-tab {
  background: none;
  border: none;
  padding: 8px 12px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.matter-tab.active {
  color: var(--navy);
  font-weight: 700;
  border-bottom: 2px solid var(--gold);
}
.matter-section {
  display: none;
}
.matter-section.active {
  display: block;
}
.timeline-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.timeline-item:last-child {
  border-bottom: none;
}
.timeline-item .td {
  color: var(--muted);
  white-space: nowrap;
  min-width: 64px;
}
.time-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.time-row:last-child {
  border-bottom: none;
}
.time-row .tn {
  flex: 1;
}
.time-add-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.time-add-row input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12.5px;
  font-family: inherit;
}
.time-add-row input#te-date {
  flex: 0.9;
  min-width: 130px;
}
.time-add-row input#te-hours {
  flex: 0.5;
  min-width: 70px;
}
.time-add-row input#te-rate {
  flex: 0.5;
  min-width: 80px;
}
.time-add-row input#te-note {
  flex: 1.6;
  min-width: 160px;
}
.totals-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--line);
}

/* PRINT INVOICE */
#invoice-print {
  display: none;
}
@media print {
  body.printing > *:not(#invoice-print) {
    display: none !important;
  }
  #invoice-print {
    display: block !important;
    padding: 30px;
    font-family: Georgia, serif;
    color: #111;
  }
}
.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  border-bottom: 2px solid #1b2a41;
  padding-bottom: 14px;
}
.inv-head h1 {
  font-size: 20px;
  margin: 0;
}
.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}
.inv-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px solid #999;
  padding: 6px 8px;
}
.inv-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #ddd;
  font-size: 12.5px;
}
.inv-total {
  text-align: right;
  font-size: 15px;
  font-weight: 700;
  margin-top: 14px;
}

/* REPORTS / CHARTS */
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.chart-card h3 {
  margin: 0 0 12px;
  font-family: Georgia, serif;
  font-weight: normal;
  font-size: 14.5px;
  color: var(--navy);
}
.hbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}
.hbar-label {
  width: 120px;
  flex-shrink: 0;
  color: var(--slate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbar-track {
  flex: 1;
  background: #efede5;
  border-radius: 5px;
  height: 14px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy), var(--blue));
  border-radius: 5px;
}
.hbar-val {
  width: 28px;
  text-align: right;
  font-weight: 700;
  color: var(--navy);
  flex-shrink: 0;
}
.vbar-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 140px;
  padding-top: 10px;
}
.vbar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.vbar {
  width: 100%;
  max-width: 34px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border-radius: 4px 4px 0 0;
}
.vbar-num {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 3px;
}
.vbar-lbl {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 6px;
}
.workload-table {
  width: 100%;
  border-collapse: collapse;
}
.workload-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--slate);
  border-bottom: 2px solid var(--gold);
  padding: 6px 8px;
}
.workload-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.export-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* UNDO TOAST */
#undo-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s,
    transform 0.15s;
  z-index: 200;
  max-width: 420px;
}
#undo-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
#undo-toast button {
  background: var(--gold);
  color: var(--navy);
  border: none;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  flex-shrink: 0;
}
#undo-toast button:hover {
  background: var(--gold-light);
}

/* DRAG AND DROP — pipeline board */
.card[draggable="true"] {
  cursor: grab;
}
.card.dragging {
  opacity: 0.4;
}
.cards.drop-target {
  background: var(--yellow-bg);
  border-radius: 8px;
  outline: 2px dashed var(--gold-light);
  outline-offset: 2px;
}

/* RECEIVABLES inline edit & RESPONSIVE TABLES */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
}
.table-responsive table {
  min-width: 760px; /* Forces wide tables to swipe instead of squish */
}
.ics-row-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 0 0 0 4px;
  opacity: 0.7;
}
.ics-row-btn:hover {
  opacity: 1;
}
input.inline-amount {
  width: 82px;
  text-align: right;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  border-radius: 4px;
  padding: 3px 5px;
}
input.inline-amount:hover {
  border-color: var(--line);
}
input.inline-amount:focus {
  outline: none;
  border-color: var(--gold-light);
  background: #fff;
}

/* BACKUP */
.backup-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.backup-card h3 {
  margin: 0 0 6px;
  font-family: Georgia, serif;
  font-weight: normal;
  font-size: 14.5px;
  color: var(--navy);
}
.backup-card p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
}
.backup-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
#restore-input {
  display: none;
}
#backup-status {
  font-size: 11.5px;
  color: var(--muted);
  margin-left: 4px;
}

/* ACTIVITY LOG */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.activity-item:last-child {
  border-bottom: none;
}
.activity-item .ts {
  color: var(--muted);
  white-space: nowrap;
  min-width: 110px;
  font-size: 11.5px;
}

/* MESSAGE TEMPLATE MODAL */
#msg-modal textarea {
  width: 100%;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}
.toolbar input[type="text"],
.toolbar select {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
}
.spacer {
  flex: 1;
}
button {
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 8px 14px;
}
button:hover {
  border-color: var(--navy);
}
.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-primary:hover {
  background: var(--navy-light);
}
.btn-danger {
  color: var(--red);
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
}
.col {
  min-width: 180px;
}
.col-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--slate);
  padding: 0 4px 10px;
  border-bottom: 2px solid var(--gold);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.col-count {
  background: var(--line);
  color: var(--slate);
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 7px;
}
.cards {
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.card:hover {
  border-color: var(--gold-light);
}
.card .name {
  font-weight: 600;
  font-size: 13.5px;
  margin: 0 0 3px;
}
.card .meta {
  font-size: 11.5px;
  color: var(--muted);
  margin: 0 0 5px;
}
.card .tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.tag {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #efede5;
  color: var(--slate);
  font-weight: 600;
}
.tag.area-pi {
  background: var(--blue-bg);
  color: var(--blue);
}
.tag.area-im {
  background: var(--green-bg);
  color: var(--green);
}
.tag.area-tx {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.tag.stale {
  background: var(--red-bg);
  color: var(--red);
}
.tag.venue-court {
  background: var(--yellow-bg);
  color: var(--yellow);
  font-weight: 700;
}
.tag.venue-uscis {
  background: var(--blue-bg);
  color: var(--blue);
}
.tag.state-fl {
  background: var(--blue-bg);
  color: var(--blue);
}
.tag.state-tx {
  background: var(--red-bg);
  color: var(--red);
}
.tag.litigation-tag {
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}
.empty-col {
  font-size: 11.5px;
  color: #b4b2a9;
  padding: 8px 4px;
  font-style: italic;
}

/* left-edge area stripe, used across tabs */
.stripe-pi {
  border-left: 4px solid var(--blue);
}
.stripe-im {
  border-left: 4px solid var(--green);
}
.stripe-tx {
  border-left: 4px solid var(--yellow);
}
.stripe-other {
  border-left: 4px solid #b4b2a9;
}

#alert-bar {
  background: var(--red-bg);
  border: 1px solid #e8c4bc;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--red);
}
#alert-bar b {
  font-weight: 700;
}
#alert-bar .items {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#alert-bar .item-btn {
  background: #fff;
  border: 1px solid #e8c4bc;
  color: var(--red);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
#alert-bar .item-btn:hover {
  background: var(--red-bg);
}

.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.42);
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal-bg.open {
  display: flex;
}
.modal {
  background: var(--card);
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  padding: 22px 24px 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal h2 {
  margin: 0 0 16px;
  font-family: Georgia, serif;
  font-size: 18px;
  color: var(--navy);
  font-weight: normal;
}
.field {
  margin-bottom: 12px;
}
.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--slate);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
.field textarea {
  resize: vertical;
  min-height: 56px;
}
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.billing-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px 4px;
  margin-bottom: 14px;
  background: var(--yellow-bg);
}
.billing-box .row3 {
  margin-bottom: 2px;
}
.billing-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 8px;
}
.billing-owed {
  font-size: 13px;
  color: var(--navy);
  padding: 8px 0 4px;
  border-top: 1px solid #e8d6a8;
  margin-top: 6px;
}
.billing-owed b {
  font-size: 15px;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}
.modal-actions .right {
  display: flex;
  gap: 8px;
}
.hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 14px;
}

/* Tasks */
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.task-row.done {
  opacity: 0.5;
}
.task-row.done .task-text {
  text-decoration: line-through;
}
.task-row.overdue {
  border-color: #e8c4bc;
}
.task-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  accent-color: var(--navy);
}
.task-text {
  flex: 1;
  font-size: 13.5px;
}
.task-due {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.task-due.overdue {
  color: var(--red);
  font-weight: 700;
}
.task-due.duesoon,
.s.duesoon {
  color: #d97706;
  font-weight: 700;
}
.task-assignee {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-bg);
  border-radius: 5px;
  padding: 2px 8px;
  white-space: nowrap;
}
.task-del {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 16px;
  padding: 2px 6px;
  cursor: pointer;
}
.task-del:hover {
  color: var(--red);
}
.add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.add-row input,
.add-row select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
}
.add-row input[type="text"] {
  flex: 1.6;
  min-width: 200px;
}
.add-row input[type="date"] {
  flex: 0.9;
  min-width: 140px;
}
.add-row select {
  flex: 0.8;
  min-width: 130px;
}

/* Receivables */
table.receivables {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
}
table.receivables th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--slate);
  border-bottom: 2px solid var(--gold);
  padding: 8px 12px;
  background: #fbfaf7;
}
table.receivables td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
table.receivables tr:last-child td {
  border-bottom: none;
}
.status-pill {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 10px;
  font-weight: 700;
}
.status-pill.pending {
  background: var(--red-bg);
  color: var(--red);
}
.status-pill.partial {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.status-pill.paid {
  background: var(--green-bg);
  color: var(--green);
}
.rec-amt {
  font-weight: 600;
  text-align: right;
}
.rec-due {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.rec-due.overdue {
  color: var(--red);
  font-weight: 700;
}

/* PRIORITY / HEALTH / WAITING-ON / FOLLOW-UP additions */
.pri-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 15px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 5px;
}
.pri-btn:hover {
  background: var(--bg);
}
.health-dot {
  display: inline-block;
  font-size: 11px;
  margin-right: 2px;
}
.referral-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.waiting-select {
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 5px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  max-width: 120px;
}
.age-cell {
  font-size: 12px;
  line-height: 1.5;
}
.age-cell .stale-flag {
  color: var(--red);
  font-weight: 700;
}
.contact-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.contact-cell label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  margin-right: 4px;
}
.contact-cell .cc-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.contact-cell input[type="date"] {
  font-size: 11.5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 3px;
  font-family: inherit;
  width: 118px;
}
.contact-cell input.followup-overdue {
  border-color: var(--red);
  background: var(--red-bg);
  color: var(--red);
  font-weight: 700;
}
input.followup-overdue {
  border-color: var(--red);
  background: var(--red-bg);
  color: var(--red);
  font-weight: 700;
}
.quick-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-right: 5px;
  text-decoration: none;
  font-size: 13px;
  background: #fff;
}
.quick-actions a:hover {
  border-color: var(--navy);
  background: var(--bg);
}
.sort-select {
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}
.payment-progress {
  margin: 8px 0 14px;
}
.payment-progress .pp-top {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 5px;
}
.payment-progress .pp-bar {
  height: 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
}
.payment-progress .pp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}
.payment-progress .pp-bottom {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 5px;
}
.qnote {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 7px;
  font-size: 13px;
}
.qnote .qn-meta {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 3px;
}
.mini-add-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.mini-add-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
}
.matter-task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.matter-task-row.done {
  opacity: 0.55;
  text-decoration: line-through;
}
.matter-task-row .mt-del {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}
.attn-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.attn-head {
  font-family: Georgia, serif;
  font-size: 15px;
  color: var(--navy);
  margin-bottom: 10px;
  font-weight: normal;
}
.attn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.attn-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
}
.attn-item:hover {
  border-color: var(--gold-light);
}
.attn-item .n {
  font-weight: 700;
}
.attn-empty {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}
.retainer-badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}
.retainer-badge.ns {
  background: var(--red-bg);
  color: var(--red);
}
.retainer-badge.sent {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.retainer-badge.signed {
  background: var(--blue-bg);
  color: var(--blue);
}
.retainer-badge.paid {
  background: var(--green-bg);
  color: var(--green);
}
.rec-del {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.rec-del:hover {
  color: var(--red);
}

/* Documents */
.docs-toggle {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--slate);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.docs-toggle:hover {
  border-color: var(--navy);
}
.docs-row td {
  background: #fbfaf7;
  padding: 14px 16px;
}
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.doc-item:last-child {
  border-bottom: none;
}
.doc-item a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}
.doc-item a:hover {
  text-decoration: underline;
}
.doc-item .doc-del {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.doc-item .doc-del:hover {
  color: var(--red);
}
.doc-add-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.doc-add-row input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-family: inherit;
}
.doc-add-row input#doc-name-input {
  flex: 1;
}
.doc-add-row input#doc-link-input {
  flex: 1.6;
}
.no-docs {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
}
.totals-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 18px;
  min-width: 130px;
}
.metric.m-red {
  border-top: 3px solid var(--red);
}
.metric.m-yellow {
  border-top: 3px solid var(--yellow);
}
.metric.m-green {
  border-top: 3px solid var(--green);
}
.metric .num {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}
.metric .lbl {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.dot.red {
  background: var(--red);
}
.dot.yellow {
  background: var(--yellow);
}
.dot.green {
  background: var(--green);
}
.dot.blue {
  background: var(--blue);
}

.cal-note {
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--slate);
  margin-bottom: 18px;
}
.cal-note b {
  color: var(--navy);
}

body.role-limited .money-only {
  display: none !important;
}

/* ========================================= */
/* RESPONSIVE DESIGN (MOBILE ADAPTATIONS)    */
/* ========================================= */

@media (max-width: 1050px) {
  .dash-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-cols {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 900px) {
  .board {
    grid-template-columns: repeat(5, 220px);
  }
}

/* Main Mobile Breakpoint */
@media (max-width: 860px) {
  /* Slide-in Hamburger Menu Logic */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  #mobile-menu-toggle:checked ~ .sidebar {
    transform: translateX(0);
  }
  #mobile-menu-toggle:checked ~ .sidebar-overlay {
    display: block;
  }

  /* Reset Sidebar internal layout for vertical slide-in menu */
  .sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-right: none;
  }
  .sidebar-nav {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
  }
  .nav-group-label {
    display: block;
  }
  .nav-item {
    white-space: normal;
    width: 100%;
  }
  .sidebar-user {
    display: flex;
  }

  /* Topbar Layout */
  .topbar {
    padding: 12px 16px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .topbar h2 {
    font-size: 16px;
  }
  .search-global {
    order: 10; /* Pushes the search bar to its own row at the bottom of the topbar */
    max-width: 100%;
    margin-top: 4px;
  }

  /* Modals Layout */
  .modal {
    padding: 18px 16px;
  }
  .row2,
  .row3 {
    grid-template-columns: 1fr;
    gap: 0; /* Removing grid gap since inputs stack vertically on mobile; margins handle spacing */
  }
  .matter-head {
    flex-direction: column;
    align-items: stretch;
  }
  .matter-actions {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }
  .matter-actions button {
    width: 100%;
  }
  .matter-tabs {
    flex-wrap: wrap;
  }
  .matter-tab {
    flex: 1 1 40%;
    text-align: center;
  }

  /* Forms and Toolbars Stacking */
  .toolbar,
  .add-row,
  .time-add-row,
  .doc-add-row,
  .mini-add-row,
  .export-row,
  .backup-row {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar input,
  .toolbar select,
  .toolbar button,
  .add-row input,
  .add-row select,
  .add-row button,
  .time-add-row input,
  .time-add-row button,
  .doc-add-row input,
  .doc-add-row button {
    max-width: 100%;
    width: 100%;
    margin-bottom: 8px;
  }

  /* Calendar */
  .cal-header {
    flex-wrap: wrap;
    justify-content: center;
  }
  .cal-legend {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
  }
  .cal-grid {
    font-size: 10px;
  }
  .cal-cell {
    min-height: 70px;
    padding: 2px;
  }

  /* General Spacing */
  .wrap {
    padding: 16px;
  }
  .dash-panel-head {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* Small Screens */
@media (max-width: 600px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .report-grid {
    grid-template-columns: 1fr;
  }
  .attn-grid {
    grid-template-columns: 1fr;
  }
  .totals-bar {
    flex-direction: column;
    gap: 10px;
  }
  .metric {
    width: 100%;
  }
  #undo-toast {
    width: 90vw;
    flex-direction: column;
    text-align: center;
  }
  #undo-toast button {
    width: 100%;
  }
}
