/* PAPYRUS v3 — NeuroFox-inspired dark UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&family=Playfair+Display:wght@600&display=swap');

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

:root {
  --bg:          #111113;
  --sidebar-bg:  #0A0A0C;
  --surface:     #1A1A1D;
  --surface2:    #222226;
  --surface3:    #2C2C31;
  --border:      #2A2A2F;
  --border-soft: #1E1E23;

  --text:        #F2F2F2;
  --text-muted:  #888892;
  --text-dim:    #44444A;

  --accent:      #FFC200;
  --accent-hover:#FFD54F;
  --accent-dim:  rgba(255, 194, 0, 0.12);
  --accent-glow: rgba(255, 194, 0, 0.06);

  --green:       #30D158;
  --green-dim:   rgba(48, 209, 88, 0.12);
  --blue:        #0A84FF;
  --blue-dim:    rgba(10, 132, 255, 0.12);
  --amber:       #FF9F0A;
  --amber-dim:   rgba(255, 159, 10, 0.12);
  --red:         #FF453A;
  --red-dim:     rgba(255, 69, 58, 0.12);
  --gray-dim:    rgba(142, 142, 147, 0.12);

  --font-sans:   'Inter', system-ui, sans-serif;
  --font-mono:   'IBM Plex Mono', monospace;
  --font-serif:  'Playfair Display', Georgia, serif;

  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;

  --nav-width:   240px;

  --shadow:      0 1px 4px rgba(0,0,0,0.6);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.7);
}

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
}

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

h1, h2, h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p  { color: var(--text-muted); }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── App Shell: sidebar + content (NO topbar row) ── */
.app-shell {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.4rem 1.25rem 1rem;
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 30px;
  height: 30px;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg { width: 18px; height: 18px; color: #111; }

.sidebar-mh-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(72%) sepia(60%) saturate(600%) hue-rotate(5deg) brightness(105%);
}

.sidebar-wordmark {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.03em;
}
.sidebar-wordmark span { color: var(--accent); }

.sidebar-search {
  padding: 0 0.85rem 0.85rem;
  flex-shrink: 0;
}

.sidebar-search-inner {
  position: relative;
}

.sidebar-search-inner svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-dim);
  pointer-events: none;
}

.sidebar-search-inner input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem 0.5rem 2.1rem;
  font-size: 0.8rem;
  color: var(--text);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.12s;
}

.sidebar-search-inner input::placeholder { color: var(--text-dim); }
.sidebar-search-inner input:focus { border-color: var(--surface3); }

.nav-section {
  padding: 0.7rem 1.25rem 0.3rem;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.52rem 0.85rem;
  margin: 0.1rem 0.6rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 400;
  border-radius: var(--radius);
  transition: all 0.12s ease;
  cursor: pointer;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-link.active {
  color: var(--text);
  background: var(--surface2);
  font-weight: 500;
}

.nav-link.active .nav-icon { color: var(--accent); opacity: 1; }

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.45;
  transition: opacity 0.12s;
}
.nav-link:hover .nav-icon { opacity: 0.8; }

.nav-badge {
  margin-left: auto;
  background: var(--surface3);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  font-family: var(--font-sans);
}

.nav-spacer { flex: 1; }

.sidebar-boost {
  margin: 0.75rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  flex-shrink: 0;
}

.sidebar-boost-icon {
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.sidebar-boost-icon svg { width: 18px; height: 18px; }

.sidebar-boost-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.sidebar-boost-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.4;
}

.sidebar-boost .btn-boost {
  width: 100%;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.12s;
  text-align: center;
  display: block;
  text-decoration: none;
}
.sidebar-boost .btn-boost:hover { background: var(--accent-hover); color: #111; }

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
}
.sidebar-profile:hover { background: var(--surface); }

.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-profile-info { flex: 1; min-width: 0; }
.sidebar-profile-name { font-size: 0.8rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-profile-role { font-size: 0.7rem; color: var(--text-muted); }

.sidebar-profile-action { color: var(--text-dim); }
.sidebar-profile-action svg { width: 14px; height: 14px; }

/* ── Main content ── */
.main {
  background: var(--bg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page {
  padding: 2rem 2.5rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.card-sm { padding: 1rem 1.25rem; }
.card-lg { padding: 2rem; }

.card-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  transition: border-color 0.12s;
}
.stat-card:hover { border-color: var(--surface3); }

.stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-delta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  transition: all 0.12s ease;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn-primary { background: var(--accent); color: #111; }
.btn-primary:hover { background: var(--accent-hover); color: #111; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); background: var(--surface3); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255,69,58,0.2);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm  { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg  { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; }
.btn svg  { width: 15px; height: 15px; }

/* ── Forms ── */
.form-group  { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: border-color 0.12s, background 0.12s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface3);
}
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { resize: vertical; min-height: 120px; line-height: 1.6; }
select.form-control { cursor: pointer; }

.form-hint  { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.35rem; }
.form-error { font-size: 0.78rem; color: var(--red); margin-top: 0.35rem; }

/* ── Tables ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

thead th {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  padding: 0.85rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}

tbody tr {
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody td {
  padding: 0.9rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text);
  vertical-align: middle;
}
.td-muted { color: var(--text-muted); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.63rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-draft    { background: var(--gray-dim);  color: var(--text-muted); }
.badge-sent     { background: var(--blue-dim);  color: var(--blue); }
.badge-partial  { background: var(--amber-dim); color: var(--amber); }
.badge-complete { background: var(--green-dim); color: var(--green); }
.badge-voided    { background: var(--red-dim);   color: var(--red); }
.badge-review    { background: var(--amber-dim); color: var(--amber); }
.badge-approved  { background: var(--blue-dim);  color: var(--blue); }
.acct-card .acct-card-value { transition: color 0.2s; }
.badge-overdue  { background: var(--red-dim);   color: var(--red); }

/* ── Modals ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 0.25rem; line-height: 1; font-size: 1.25rem;
}
.modal-close:hover { color: var(--text); }

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Empty states ── */
.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-icon  { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.2; }
.empty-title { font-size: 1.05rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.empty-desc  { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ── Toasts ── */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 260px;
  animation: slideIn 0.2s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Filter/search bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap svg {
  position: absolute;
  left: 0.75rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  width: 14px; height: 14px;
}
.search-wrap .form-control { padding-left: 2.25rem; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab {
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.12s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-sans);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Progress ── */
.progress-bar { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 1rem;
  padding-bottom: 1.25rem;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 6px; top: 20px; bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--surface3);
  border: 2px solid var(--border);
  flex-shrink: 0; margin-top: 4px;
}
.timeline-dot.done   { background: var(--green);  border-color: var(--green); }
.timeline-dot.active { background: var(--accent); border-color: var(--accent); }
.timeline-body  { flex: 1; }
.timeline-label { font-size: 0.875rem; color: var(--text); font-weight: 500; }
.timeline-time  { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Signing page ── */
.signing-page {
  background: #fff; color: #111;
  min-height: 100vh;
  font-family: var(--font-sans);
}
.signing-page .signing-wordmark {
  font-family: var(--font-sans);
  font-size: 1.1rem; font-weight: 700;
  letter-spacing: -0.01em; color: #111;
}
.signing-page .signing-wordmark span { color: #E6A800; }

/* ── Skeleton ── */
.skeleton {
  background: var(--surface2);
  border-radius: var(--radius);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Utils ── */
.flex            { display: flex; }
.flex-1          { flex: 1; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: 0.5rem; }
.gap-2  { gap: 1rem; }
.gap-3  { gap: 1.5rem; }
.mt-1   { margin-top: 0.5rem; }
.mt-2   { margin-top: 1rem; }
.mt-3   { margin-top: 1.5rem; }
.mb-1   { margin-bottom: 0.5rem; }
.mb-2   { margin-bottom: 1rem; }
.mb-3   { margin-bottom: 1.5rem; }
.text-mono   { font-family: var(--font-mono); font-size: 0.8rem; }
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.text-sm     { font-size: 0.8rem; }
.text-xs     { font-size: 0.72rem; }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.w-full      { width: 100%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--sidebar-bg); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface2); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar   { display: none; }
  .page      { padding: 1.25rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Signature block (doc editor + signing page) ────────────────────── */
.sig-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.sig-cell { width: 50%; vertical-align: top; padding: 0 20px 0 0; }
.sig-cell:last-child { padding: 0 0 0 20px; border-left: 1px solid #eee; }
.sig-cell p { font-size: 10pt; margin-bottom: .4rem; line-height: 1.5; }
.sig-line { margin: 12px 0 8px; border-bottom: 2px solid #ddd; min-height: 56px; }
.sig-placeholder { display: inline-block; width: 100%; min-height: 48px; }
