/* Eclipse dark theme: near-black backgrounds, blue accents, light text. */
:root {
  --bg: #0d1117;
  --bg-panel: #151b23;
  --bg-hover: #1c2530;
  --bg-sidebar: #0b1a33;
  --border: #2a3441;
  --accent: #7fbdf5;
  --accent-strong: #2b7de9;
  --text: #e6edf3;
  --text-muted: #8b949e;
}

* { box-sizing: border-box; }

/* Global link color: every anchor uses the accent unless a component overrides it.
   Root-cause fix for stray browser-default blue/purple links (Jeff, 2026-09-01). */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--accent); }

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

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

.sidebar {
  width: 220px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}

.brand {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 3px;
  padding: 0 20px 16px;
  font-size: 18px;
}
.brand-link { display: block; padding: 0 16px 16px; }
.brand-logo { width: 100%; max-width: 170px; display: block; }
.login-logo { width: 240px; max-width: 100%; display: block; margin: 0 auto 6px; }

.nav-item {
  display: block;
  padding: 10px 20px;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { border-left-color: var(--accent); background: var(--bg-hover); }
.nav-item.disabled { color: var(--text-muted); pointer-events: none; }
.nav-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.nav-user { display: block; padding: 6px 20px; color: var(--text-muted); font-size: 13px; }

.content { flex: 1; padding: 28px 32px; }
.content-full { display: flex; justify-content: center; align-items: center; min-height: 100vh; }

h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 6px; }
.muted { color: var(--text-muted); }

.cards { display: flex; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  min-width: 200px;
}

.login-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 40px;
  width: 340px;
  text-align: center;
}
.login-sub { color: var(--text-muted); margin: 4px 0 24px; }
.login-box form { display: flex; flex-direction: column; text-align: left; gap: 6px; }
.login-box label { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.login-box input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box button {
  margin-top: 20px;
  background: var(--accent-strong);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-box button:hover { background: var(--accent); }

.flash {
  background: #3d1d1d;
  border: 1px solid #6e2c2c;
  color: #ffb4b4;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* Mockup screens: matters, matter detail, contacts */
.page-head, .matter-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { cursor: default; opacity: 0.75; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-small-primary { background: var(--accent-strong); border: none; color: #fff; border-radius: 6px; padding: 6px 12px; font-size: 13px; margin-top: 8px; }
.pill {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.tabs-row { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs-row .tab { padding: 8px 2px; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tabs-row .tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs-row .tab.disabled { opacity: 0.6; }
.matter-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.matter-main { display: flex; flex-direction: column; gap: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel-label { font-weight: 700; margin-bottom: 10px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { border-right: 1px solid var(--border); padding-right: 12px; }
.stat:last-child { border-right: none; }
.stat-name { font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.stat-sub { font-size: 12px; margin-bottom: 10px; line-height: 1.4; }
/* Breathing room for action buttons inside stat panels (Jeff, 2026-09-01):
   Quick bill / View bills / Client ledger were crammed against the caption. */
.stat .btn, .stat .btn-small-primary { margin-top: 4px; }
.time-strip { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; flex-wrap: wrap; align-items: center; }
.accent { color: var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--text-muted); font-size: 13px; }
.kv dd { margin: 0; font-size: 14px; word-break: break-word; }
.timeline .tl-day { color: var(--text-muted); font-size: 12px; font-weight: 700; margin: 10px 0 4px; }
.timeline .tl-item { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.row-links tr { cursor: pointer; }
.row-links tr:hover td { background: var(--bg-hover); }
.data-table a { color: var(--accent); text-decoration: none; }
.badge { border-radius: 4px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.badge-unpaid, .badge-awaiting_payment { background: #4a3510; color: #f0b429; }
.badge-paid { background: #143a24; color: #4ade80; }
.badge-draft { background: #2d2a4a; color: #b4a7f5; }
.badge-void, .badge-deleted { background: #3d1d1d; color: #f47067; }
.badge-other { background: var(--bg-hover); color: var(--text-muted); }
.overdue { color: #f47067; font-weight: 600; }
.sort-link { color: var(--text-muted) !important; cursor: pointer; }
.sort-link:hover { color: var(--accent) !important; }
.sort-arrow { font-size: 10px; color: var(--accent); }
@media (max-width: 1000px) {
  .matter-grid, .two-col { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .stat { border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
}

/* Contact form sections (per Jeff's reference screenshot) */
.form-section { margin-bottom: 16px; }
.field-label { color: var(--text); font-size: 14px; font-weight: 600; margin: 4px 0 8px; }
.type-toggle { display: flex; gap: 10px; margin-bottom: 16px; }
.toggle-btn {
  background: var(--bg-panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 22px; font-size: 14px; cursor: pointer;
}
.toggle-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 700; background: var(--bg-hover); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.form-row label { flex: 1; min-width: 140px; }
.form-row .w-xs { flex: 0 0 90px; min-width: 90px; }
.req { color: #f47067; }
.contact-row { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; }
.contact-row label { flex: 1; min-width: 150px; }
.contact-row .w-sm { flex: 0 0 140px; min-width: 120px; }
.contact-row .w-xs { flex: 0 0 90px; min-width: 80px; }
.contact-row .radio-line { flex: 0 0 auto; min-width: 0; flex-direction: row; align-items: center; gap: 6px; padding-bottom: 10px; color: var(--text); }
.remove-link, .add-link { color: var(--accent); cursor: pointer; font-size: 14px; padding-bottom: 10px; }
.add-link { display: inline-block; margin-top: 4px; padding-bottom: 0; }
.remove-link:hover, .add-link:hover { text-decoration: underline; }
@media (max-width: 700px) { .contact-row { align-items: stretch; } .contact-row .radio-line { padding-bottom: 0; } }

/* Entity forms */
.entity-form { max-width: 1100px; }
.entity-form h2 { margin: 18px 0 8px; font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; }
.entity-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted); }
.entity-form label.check { flex-direction: row; align-items: center; gap: 8px; }
.entity-form input, .entity-form select, .entity-form textarea {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  width: 100%;
}
.entity-form input:focus, .entity-form select:focus, .entity-form textarea:focus { outline: none; border-color: var(--accent); }
.row-line { display: flex; gap: 8px; margin-bottom: 8px; }
.row-line input:first-child { max-width: 140px; }
.row-line.addr input { min-width: 0; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } .row-line { flex-wrap: wrap; } }

/* Description autofill suggestions */
.ac-box {
  display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 120;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px;
  max-height: 220px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.ac-item { padding: 8px 12px; font-size: 13px; font-weight: 400; cursor: pointer; color: var(--text); }
.ac-item:hover, .ac-item.sel { background: var(--bg-hover); color: var(--accent); }

/* Modal dialogs (Add time, per Clio reference) */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6); align-items: flex-start; justify-content: center;
  padding: 6vh 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  width: 100%; max-width: 860px; max-height: 88vh; overflow-y: auto;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { font-size: 24px; color: var(--text-muted); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); text-decoration: none; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px 20px; }
.m-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.m-label input, .m-label textarea {
  display: block; width: 100%; margin-top: 5px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 9px 12px; font-size: 14px;
}
.m-label input:focus, .m-label textarea:focus { outline: none; border-color: var(--accent); }
.m-static { font-weight: 400; color: var(--text-muted); margin-top: 5px; font-size: 14px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}
.cell-input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 5px;
  color: var(--text); padding: 6px 8px; font-size: 13px; width: 100%; min-width: 90px;
}
.cell-input:focus { outline: none; border-color: var(--accent); }
.w-dur { min-width: 70px; max-width: 90px; }
@media (max-width: 700px) { .modal-grid { grid-template-columns: 1fr; } }

/* Inline add-time / add-expense forms */
.inline-form summary { list-style: none; display: inline-block; }
.inline-form summary::-webkit-details-marker { display: none; }
.inline-form[open] summary { border-color: var(--accent); color: var(--accent); }
.inline-form form { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }

/* MFA */
.mfa-steps { text-align: left; color: var(--text-muted); font-size: 14px; padding-left: 20px; }
.mfa-qr { width: 180px; height: 180px; border-radius: 8px; margin: 10px auto; display: block; background: #fff; padding: 8px; }
.login-box code { color: var(--accent); font-size: 12px; word-break: break-all; }

/* Admin tables and forms */
.data-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 13px; }
.data-table .actions { display: flex; gap: 8px; }
.btn-small {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
}
.btn-small:hover { border-color: var(--accent); }
.create-user-form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.create-user-form input, .create-user-form select {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
}
.create-user-form button {
  background: var(--accent-strong);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-weight: 600;
  cursor: pointer;
}

/* Dashboard */
.sample-banner {
  background: #1b2634;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 8px 14px;
  margin-bottom: 18px;
  font-size: 13px;
}
.dash-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-row .panel { flex: 1; min-width: 380px; }
.panel {
  background: transparent;
  margin-bottom: 18px;
}
.panel-title { font-size: 16px; font-weight: 700; margin: 0 0 10px; }
.panel-title.center { text-align: center; }
.panel-body {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}
.center { text-align: center; }
.hours-panel h3 { margin-top: 0; }
.range-tabs { display: flex; justify-content: center; gap: 16px; margin: 8px 0 14px; }
.range-tabs .tab { color: var(--text-muted); cursor: pointer; font-size: 13px; }
.range-tabs .tab.active { color: var(--accent); font-weight: 600; }
.ring-wrap { position: relative; width: 180px; margin: 0 auto; }
.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.ring-actual { color: var(--accent); font-size: 20px; font-weight: 700; }
.ring-target { color: var(--text); font-size: 16px; }

.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.tile h3 { margin: 0 0 6px; font-size: 14px; }
.tile-value { font-size: 20px; font-weight: 700; }
.tile-value.accent { color: var(--accent); }
.tile-value.danger { color: #f47067; }

.chart-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.chart-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.chart-box h3 { margin: 0 0 8px; font-size: 14px; }
.annual-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  height: 340px;
}

@media (max-width: 1100px) {
  .chart-row { grid-template-columns: 1fr 1fr; }
}

/* Matter detail 3-column full-width layout */
.matter-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; align-items: start; }
.mg-financial { grid-column: 1 / 3; }
.mg-side { grid-column: 3; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 16px; }
.mg-col { display: flex; flex-direction: column; gap: 16px; }

/* Contacts screens */
.filter-tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.filter-tabs a { padding: 8px 16px; color: var(--text-muted); font-size: 14px; cursor: pointer; }
.filter-tabs a.active { background: var(--bg-hover); color: var(--text); font-weight: 600; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.search-input { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 9px 12px; min-width: 240px; }
.search-input:focus { outline: none; border-color: var(--accent); }
.avatar { display: inline-flex; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-hover); border: 1px solid var(--border); align-items: center; justify-content: center; font-weight: 700; color: var(--accent); }

/* Mobile: original Eclipse design (deliberately not Clio's app) */
.mobile-nav { display: none; }
@media (max-width: 700px) {
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .content { padding: 14px 14px 78px; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--bg-sidebar); border-top: 1px solid var(--border);
    justify-content: space-around; padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .mobile-nav a { color: var(--text-muted); text-decoration: none; font-size: 13px; text-align: center; padding: 6px 10px; border-radius: 8px; }
  .mobile-nav a.active { color: var(--accent); background: var(--bg-hover); font-weight: 700; }
  .matter-grid3 { grid-template-columns: 1fr; }
  .mg-financial, .mg-side { grid-column: auto; grid-row: auto; }
  .stat-row { grid-template-columns: 1fr; }
  .stat { border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
  .data-table { display: block; overflow-x: auto; }
  .page-head h1, .matter-head h1 { font-size: 19px; }
}
