/* App chrome: header, breadcrumbs, action bar, flash, main, footer.
   Tokens live here so pages can share them instead of inline styles. */
:root {
  --rd-surface-muted: #f8f9fa;
  --rd-border: #dee2e6;
  --rd-border-input: #ced4da;
  --rd-text: #212529;
  --rd-text-muted: #6c757d;
  --rd-text-faint: #adb5bd;
  --rd-chip: #e9ecef;
  --rd-success-bg: #d4edda;
  --rd-success-text: #155724;
  --rd-danger-bg: #f8d7da;
  --rd-danger-text: #721c24;
  --rd-active: #198754;
  --rd-link: #0d6efd;
  --rd-page-max: 1600px;
  --rd-gutter: 2rem;
  --rd-radius: 4px;
}

.rd-container {
  max-width: var(--rd-page-max);
  margin: 0 auto;
  padding: 0 var(--rd-gutter);
}

/* Header */
.rd-header {
  background: var(--rd-surface-muted);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rd-border);
}
.rd-header .rd-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rd-brand {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rd-brand img { height: 16px; width: 16px; }
.rd-brand span { font-size: 1rem; font-weight: 500; }
.rd-header-left { display: flex; align-items: center; gap: 1.75rem; }
.rd-header-nav { display: flex; gap: 1rem; align-items: center; }
.rd-main-nav { display: flex; gap: 1.25rem; align-items: stretch; }
.rd-main-nav a {
  color: var(--rd-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.925rem;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}
.rd-main-nav a:hover { color: var(--rd-link); }
.rd-main-nav a.active { color: var(--rd-link); border-bottom-color: var(--rd-link); }
.rd-header-nav form { margin: 0; }
.rd-search { width: 300px; }
.rd-search input {
  border-radius: var(--rd-radius) 0 0 var(--rd-radius);
  border-color: var(--rd-border-input);
}
.rd-search button {
  border-radius: 0 var(--rd-radius) var(--rd-radius) 0;
  border: 1px solid var(--rd-border-input);
  border-left: none;
  background: white;
  color: var(--rd-text-muted);
  padding: 0.25rem 0.75rem;
}
.rd-avatar-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--rd-text-muted);
}
.rd-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--rd-radius);
  border: 2px solid var(--rd-border);
}
.rd-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: var(--rd-radius);
  background: var(--rd-text-muted);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
.rd-org-chip {
  color: var(--rd-text-muted);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  background: var(--rd-chip);
  border-radius: var(--rd-radius);
}
.rd-org-dropdown { position: relative; display: inline-block; }
.rd-org-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  list-style: none;
  padding: 0.25rem 0;
  margin: 0.25rem 0 0 0;
  min-width: 160px;
  z-index: 1000;
}
.rd-org-menu .rd-org-current {
  display: block;
  padding: 0.25rem 1rem;
  color: var(--rd-active);
  font-weight: 500;
}
.rd-org-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.25rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--rd-text);
}
.rd-org-menu button:hover,
.rd-org-menu a:hover { background: var(--rd-surface-muted); }
.rd-org-menu a {
  display: block;
  padding: 0.25rem 1rem;
  color: var(--rd-text);
  text-decoration: none;
  white-space: nowrap;
}
.rd-org-menu-divider { border-top: 1px solid var(--rd-border); margin: 0.25rem 0; }
.rd-org-menu-label { padding: 0.25rem 1rem; font-size: 0.75rem; color: var(--rd-text-muted); }
@media (max-width: 992px) {
  .rd-header .rd-container { flex-wrap: wrap; gap: 0.5rem; }
  .rd-header-left { flex-wrap: wrap; gap: 1rem; }
  .rd-search { width: 200px; }
}

/* Breadcrumbs */
.rd-breadcrumbs {
  background: var(--rd-surface-muted);
  border-bottom: 1px solid var(--rd-border);
  font-size: 0.875rem;
}
.rd-breadcrumbs .rd-container { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.rd-breadcrumbs .breadcrumb { margin: 0; padding: 0; background: transparent; font-size: 0.875rem; }
.rd-breadcrumbs a { text-decoration: none; }
.rd-breadcrumbs .breadcrumb-item.active,
.rd-breadcrumbs .rd-crumb-plain { color: var(--rd-text-muted); }

/* Action bar */
.action-bar {
  background: var(--rd-surface-muted);
  border-bottom: 1px solid var(--rd-border);
  padding: 0.75rem 0;
}
.action-bar-container { max-width: var(--rd-page-max); margin: 0 auto; padding: 0 var(--rd-gutter); }
.action-bar .btn { margin: 0 0.25rem; font-size: 0.875rem; }
.action-bar form.d-inline { display: inline-block !important; margin: 0; }
.action-bar-left,
.action-bar-right { display: flex; align-items: center; gap: 0.25rem; }
.action-bar-center { display: flex; align-items: center; gap: 0.25rem; flex: 1; justify-content: center; }

/* Flash */
.rd-flash { text-align: center; padding: 0.75rem; margin: 0; }
.rd-flash-notice { background: var(--rd-success-bg); color: var(--rd-success-text); }
.rd-flash-alert { background: var(--rd-danger-bg); color: var(--rd-danger-text); }

/* Main and footer */
.rd-main { max-width: var(--rd-page-max); margin: 0 auto; padding: var(--rd-gutter); }
.rd-footer { text-align: center; padding: 1rem; color: var(--rd-text-faint); font-size: 0.75rem; }
.rd-footer a { color: var(--rd-text-faint); text-decoration: none; margin-right: 1rem; }

@media (max-width: 768px) {
  .action-bar-container { padding: 0 1rem; }
  .action-bar .d-flex { gap: 0.5rem; }
  .action-bar .btn { font-size: 0.8rem; padding: 0.375rem 0.75rem; }
}

/* Checklist rows (shared by companies and clients) */
.rd-check { font-size: 1.2rem; }
.rd-check-complete { color: var(--rd-active); }
.rd-check-progress { color: #ffc107; }
.rd-check-pending { color: var(--rd-border); }
.rd-check-name { font-weight: 500; color: var(--rd-text); }
.rd-check-name-pending { color: var(--rd-text-muted); }
.rd-tag { font-size: 0.65rem; }

/* Object page header (company, client, matter) */
.rd-object-header { border-bottom: 1px solid var(--rd-border); margin-bottom: 1.5rem; }
.rd-object-title { font-size: 1.75rem; margin: 0; }
.rd-object-facts { color: var(--rd-text-muted); margin-top: 0.35rem; }
.rd-object-tabs { display: flex; gap: 1.5rem; margin-top: 1rem; }
.rd-object-tabs a {
  color: var(--rd-text);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.rd-object-tabs a:hover { color: var(--rd-link); }
.rd-object-tabs a.active { color: var(--rd-link); border-bottom-color: var(--rd-link); }
.rd-tab-count {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--rd-chip);
  color: var(--rd-text-muted);
  font-size: 0.75rem;
}
.rd-more { position: relative; }
.rd-more > summary { list-style: none; }
.rd-more > summary::-webkit-details-marker { display: none; }
.rd-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  min-width: 200px;
  background: white;
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  list-style: none;
  padding: 0.25rem 0;
  margin: 0;
  z-index: 1000;
}
.rd-more-menu a,
.rd-more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 1rem;
  color: var(--rd-text);
  text-decoration: none;
  border: none;
  background: none;
}
.rd-more-menu a:hover,
.rd-more-menu button:hover { background: var(--rd-surface-muted); }
.rd-more-menu form { margin: 0; }
.rd-more-menu .rd-danger { color: #b02a37; }

/* "Filed under" context on create forms */
.rd-filed-under { border: 1px solid var(--rd-border); border-radius: var(--rd-radius); padding: 0.75rem; background: var(--rd-surface-muted); }
.rd-filed-under-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--rd-text-muted); margin-bottom: 0.35rem; }
.rd-chip { display: inline-flex; gap: 0.35rem; align-items: center; background: white; border: 1px solid var(--rd-border); border-radius: 999px; padding: 0.15rem 0.65rem; font-size: 0.875rem; }

/* Super-user timing readout in the footer */
.rd-timing { margin-left: 1rem; font-family: var(--bs-font-monospace); }

/* Matter timeline */
.rd-timeline-kind { min-width: 5.5rem; }
.min-w-0 { min-width: 0; }
