:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --accent: #0ea5e9;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --font-display: "IBM Plex Serif", Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 40%);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

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

.brand {
  display: flex;
  gap: 0.85rem;
}

.logo {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-size: 1.1rem;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
  font-weight: 500;
}

.subtitle,
.hint,
.auth-lead {
  color: var(--muted);
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

.auth-tagline {
  color: var(--muted);
  margin: 0.15rem 0 0.5rem;
  font-size: 0.85rem;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.reminder-days-input {
  width: 4rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.processed-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 6px;
  background: #dcfce7;
  color: #166534;
  vertical-align: middle;
}

.intake-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
  vertical-align: middle;
}

button.intake-pill,
button.processed-pill {
  border: none;
  cursor: pointer;
  font: inherit;
}

button.intake-pill:hover,
button.processed-pill:hover {
  filter: brightness(0.95);
}

.panel-subhead {
  margin: 1.25rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.team-directory-seat-btn {
  display: block;
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.team-directory-seat-btn:hover,
.team-directory-seat-btn:focus-visible {
  text-decoration: underline;
}

.panel-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.panel-head input[type="search"] {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.admin-subheading {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.admin-subheading:first-of-type {
  margin-top: 0;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}

.primary-docs-banner {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.85rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--ink);
}

.primary-docs-banner strong {
  font-weight: 600;
}

.onboarding-banner {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #1e3a8a;
}

#client-intake-attention-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 1rem 0.75rem;
}

#client-intake-attention-banner .btn-sm {
  margin-left: auto;
}

tr.intake-queue-row-focus {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  background: #eff6ff;
}

#client-retention-due-banner.retention-due-banner-clickable {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.summary-metric-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: #1d4ed8;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.summary-metric-link:hover {
  color: #1e3a8a;
}

.client-folder-name-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
}

.client-folder-name-link:hover {
  text-decoration: underline;
}

.practice-code-line {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
}

.practice-code {
  font-family: ui-monospace, monospace;
  font-size: 1.05rem;
  padding: 0.15rem 0.4rem;
  background: #f1f5f9;
  border-radius: 4px;
}

.btn-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
}

.invite-snippet-block {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.invite-snippet-text {
  width: 100%;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

.type-pill-client {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.folder-access-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  max-width: 24rem;
}

.folder-access-checklist {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.folder-access-checklist li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.folder-access-row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.platform-panel {
  border-color: #c4b5fd;
  background: linear-gradient(180deg, #faf5ff 0%, #fff 2rem);
}

.platform-panel .panel-head h2 {
  color: #5b21b6;
}

  margin: 0.5rem 0;
  font-size: 0.95rem;
}

.billing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-top: 0.5rem;
}

.billing-actions label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

.billing-actions input[type="number"] {
  width: 5rem;
  padding: 0.35rem 0.5rem;
}

.folder-row-client .folder-icon {
  filter: none;
}

.upload-inline {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.upload-inline h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.upload-meta-row {
  margin-bottom: 0.75rem;
}

.upload-meta-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  max-width: 16rem;
}

.upload-meta-row select {
  padding: 0.35rem 0.5rem;
}

.upload-metadata-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.upload-metadata-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
}

.upload-metadata-fields input {
  padding: 0.3rem 0.45rem;
  font-size: 0.9rem;
}

.kind-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  vertical-align: middle;
}

.kind-pill-bank {
  background: #e0e7ff;
  color: #3730a3;
}

button.kind-pill {
  border: none;
  cursor: pointer;
  font: inherit;
}

button.kind-pill:hover {
  filter: brightness(0.95);
}

.storage-totals {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
}

.folder-loc-btn {
  text-align: left;
  white-space: normal;
  max-width: 14rem;
  font-size: 0.85rem;
}

.create-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.create-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-right: 0.25rem;
}

.workspace-modal-body .workspace-save-label {
  display: block;
  margin-top: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.workspace-modal-body input[type="file"] {
  display: block;
  margin-top: 0.5rem;
  font: inherit;
}

.workspace-footer {
  margin-top: 1rem;
  padding: 0;
  justify-content: flex-end;
}

.workspace-versions {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.workspace-versions h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.version-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.version-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

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

.archive-provider-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.archive-provider-label select {
  display: block;
  margin-top: 0.35rem;
  font: inherit;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  min-width: 220px;
}

.archive-actions {
  margin-bottom: 1rem;
}

.archived-pill {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #e0e7ff;
  color: #3730a3;
}

button.archived-pill {
  border: none;
  cursor: pointer;
  font: inherit;
}

button.archived-pill:hover {
  filter: brightness(0.95);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumbs .sep {
  color: #94a3b8;
}

.breadcrumb-segment {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.breadcrumbs .breadcrumb-folder {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--primary);
  cursor: pointer;
}

.breadcrumbs .breadcrumb-folder:hover {
  text-decoration: underline;
}

.breadcrumbs .breadcrumb-browse {
  border: none;
  background: none;
  padding: 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.breadcrumbs .breadcrumb-browse:hover {
  color: var(--primary);
}

.folder-row td:first-child {
  font-weight: 500;
}

.folder-icon {
  margin-right: 0.35rem;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #f8fafc;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.dropzone input {
  display: none;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #eff6ff;
  color: var(--primary);
}

.upload-queue {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
}

.chip-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.doc-table th,
.doc-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.doc-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.type-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e2e8f0;
}

.type-excel {
  background: #dcfce7;
  color: #166534;
}
.type-word {
  background: #dbeafe;
  color: #1e40af;
}
.type-pdf {
  background: #fee2e2;
  color: #991b1b;
}
.type-image {
  background: #fef9c3;
  color: #854d0e;
}

button.type-pill {
  border: none;
  cursor: pointer;
  font: inherit;
}

button.type-pill:hover {
  filter: brightness(0.95);
}

.search-load-more-wrap {
  margin: 0.75rem 0 0;
  text-align: center;
}

.search-meta-hint {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--ink);
}

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

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.microsoft-login {
  margin-top: 0.75rem;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.auth-card h1 {
  margin-bottom: 0.35rem;
}

.auth-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.85rem;
}

.auth-card input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.register-block {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.success {
  color: #15803d;
  font-size: 0.85rem;
  margin: 1rem 0 0;
  padding: 0.65rem 0.75rem;
  background: #f0fdf4;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(900px, calc(100% - 2rem));
  max-height: 90vh;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1rem 0;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}

.modal-body {
  padding: 1rem;
  overflow: auto;
  max-height: calc(90vh - 4rem);
}

.modal-body iframe,
.modal-body img {
  width: 100%;
  min-height: 60vh;
  border: none;
  border-radius: 8px;
}

.modal-body img {
  object-fit: contain;
  min-height: auto;
  max-height: 70vh;
}

.duplicate-group-block {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.duplicate-group-block .duplicate-group-list {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.duplicate-group-doc {
  margin-bottom: 0.35rem;
}

.duplicate-group-doc-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: 0.25rem;
}

.duplicate-group-doc .btn {
  margin-left: 0.35rem;
  vertical-align: baseline;
}

.new-client-templates {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.new-client-templates legend {
  font-weight: 600;
  padding: 0 0.25rem;
}

.new-client-template-option {
  display: block;
  margin: 0.5rem 0;
  cursor: pointer;
}

.new-client-template-option input {
  margin-right: 0.5rem;
}

.new-client-template-option .template-subfolders {
  display: block;
  margin-left: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

#new-client-form label {
  display: block;
  margin: 0.75rem 0;
}

#new-client-form input[type="text"],
#new-client-form select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
}

.checkbox-label {
  display: flex !important;
  align-items: flex-start;
  gap: 0.5rem;
}

.checkbox-label input {
  margin-top: 0.2rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
}

@media (max-width: 640px) {
  .row-actions {
    flex-direction: column;
  }
}
