/* EHSFlow application styles */
:root {
  color-scheme: light;
  --web-ink: #15201e;
  --web-muted: #68736f;
  --web-line: #dfe4e1;
  --web-surface: #ffffff;
  --web-canvas: #f3f5f3;
  --web-accent: #176b5a;
  --web-accent-dark: #0f5547;
  --web-shadow: 0 24px 70px rgb(24 42 37 / 8%);
}

.web-page,
.web-page * {
  box-sizing: border-box;
}

.web-page {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--web-ink);
  background: var(--web-canvas);
  font-family: "Segoe UI", "Microsoft YaHei", "微软雅黑", sans-serif;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

.site-shell {
  width: min(1120px, calc(100% - 48px));
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding-bottom: 72px;
}

.site-footer {
  margin-top: 32px;
  padding: 16px 0 8px;
  color: var(--web-muted);
  font-size: 13px;
  text-align: center;
}

.site-footer a {
  color: var(--web-muted);
}

.site-header {
  width: 100%;
  min-height: 64px;
  color: #fff;
  background: #141918;
  box-shadow: 0 1px 0 rgb(255 255 255 / 6%);
}

.site-navigation {
  display: flex;
  gap: 40px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 0 28px;
}

.site-brand {
  flex: 0 0 auto;
  color: #fff;
  font-size: 19px;
  font-weight: 720;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
}

.site-nav-link {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-weight: 620;
  text-decoration: none;
  transition: border-color 150ms ease, background 150ms ease;
}

.site-nav-link:hover {
  border-color: rgb(255 255 255 / 34%);
  background: rgb(255 255 255 / 6%);
}

@media (min-width: 1401px) {
  .site-navigation {
    display: grid;
    grid-template-columns: 1fr minmax(0, 1120px) 1fr;
    gap: 0;
    padding: 0;
  }

  .site-brand {
    grid-row: 1;
    grid-column: 1;
    align-self: center;
    justify-self: start;
    margin-left: 28px;
  }

  .site-nav {
    grid-row: 1;
    grid-column: 2;
    justify-self: start;
  }
}

.site-main {
  padding-top: 34px;
}

.site-brand:focus-visible,
.site-nav-link:focus-visible,
.error-card a:focus-visible {
  outline: 3px solid rgb(23 107 90 / 25%);
  outline-offset: 3px;
}

.error-card {
  max-width: 680px;
  padding: 54px;
  border: 1px solid var(--web-line);
  border-radius: 22px;
  background: var(--web-surface);
  box-shadow: var(--web-shadow);
}

.error-code {
  margin: 0 0 12px;
  color: var(--web-accent);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

.error-card h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.03em;
}

.error-card > p:not(.error-code) {
  margin: 18px 0 28px;
  color: var(--web-muted);
}

.error-card a {
  display: inline-flex;
  padding: 10px 16px;
  border-radius: 10px;
  color: #fff;
  background: var(--web-accent);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

@media (max-width: 720px) {
  .site-shell {
    width: min(1120px, calc(100vw - 28px));
    padding-bottom: 40px;
  }

  .site-header {
    min-height: 60px;
  }

  .site-navigation {
    gap: 18px;
    width: 100%;
    min-height: 60px;
    padding: 0 14px;
  }

  .site-nav-link {
    padding: 8px 11px;
    font-size: 15px;
  }

  .site-main {
    min-width: 0;
    padding-top: 28px;
  }

}

/* V1 library pages */
.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.flash-message {
  padding: 12px 16px;
  border: 1px solid #b9d5cd;
  border-radius: 12px;
  color: var(--web-accent-dark);
  background: #eaf4f1;
}

.flash-error {
  border-color: #e5c2bd;
  color: #8a3028;
  background: #fff0ee;
}

.login-page .flash-stack {
  position: fixed;
  z-index: 20;
  top: 84px;
  left: 50%;
  width: min(440px, calc(100% - 32px));
  margin: 0;
  transform: translateX(-50%);
}

.page-heading {
  margin: 16px 0 22px;
}

.page-nav + .page-heading {
  margin-top: 16px;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.page-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 9px;
  align-items: center;
}

.page-heading h1 {
  min-width: 0;
  max-width: min(800px, 100%);
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 680;
  letter-spacing: -0.035em;
  line-height: 1.25;
}

.title-row > h1 {
  flex: 1 1 auto;
}

.title-line {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.edit-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid rgb(23 107 90 / 62%);
  border-radius: 10px;
  color: var(--web-accent-dark);
  background: rgb(239 248 245 / 74%);
  box-shadow: 0 3px 12px rgb(23 107 90 / 7%);
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--web-accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
}

.page-description,
.muted-text {
  color: var(--web-muted);
}

.page-description {
  margin: 9px 0 0;
}

.back-link,
.page-nav a,
.breadcrumbs a {
  color: var(--web-accent-dark);
  text-decoration: none;
}

.back-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 650;
}

.back-link:hover,
.page-nav a:hover,
.breadcrumbs a:hover {
  text-decoration: underline;
}

.page-nav,
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  min-width: 0;
  color: var(--web-muted);
  font-size: 13px;
}

.page-nav-trail {
  display: flex;
  flex: 1 1 12rem;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.page-nav .back-link:has(+ .page-nav-trail) {
  padding-right: 16px;
  border-right: 1px solid #d3dbd7;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  list-style: none;
  text-decoration: none;
}

.button-primary {
  color: #fff;
  background: var(--web-accent);
}

.button-primary:hover {
  background: var(--web-accent-dark);
}

.button-secondary,
.button-quiet {
  border-color: #cad4d0;
  color: var(--web-accent-dark);
  background: #fff;
}

.button-danger {
  color: #98362e;
  background: transparent;
}

.button-danger:hover {
  background: #fff0ee;
}

.create-panel,
.inline-editor,
.description-editor,
.operation-menu {
  position: relative;
  display: inline-block;
}

.create-panel > summary::-webkit-details-marker,
.inline-editor > summary::-webkit-details-marker,
.description-editor > summary::-webkit-details-marker,
.operation-menu > summary::-webkit-details-marker {
  display: none;
}

.mode-action-form {
  margin: 0;
}

.operation-menu-placeholder {
  cursor: default;
  user-select: none;
}

.operation-menu-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 9px);
  right: 0;
  width: 190px;
  padding: 7px;
  border: 1px solid var(--web-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 48px rgb(24 42 37 / 14%);
}

.operation-menu-panel form {
  margin: 0;
}

.operation-menu-panel button,
.operation-menu-panel .operation-link {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 8px;
  color: var(--web-ink);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
}

.operation-menu-panel .operation-danger { color: #93312c; }

.operation-menu-panel button:hover,
.operation-menu-panel button:focus-visible,
.operation-menu-panel .operation-link:hover,
.operation-menu-panel .operation-link:focus-visible {
  outline: none;
  color: var(--web-accent-dark);
  background: #edf5f2;
}

/* V2 matter management and work overview */
.overview-heading {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
}

.overview-heading h1 { margin: 0; font-size: clamp(27px, 3vw, 34px); }
.heading-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; color: var(--web-muted); font-size: 12px; }
.manage-card { padding: 0; overflow: hidden; }
.manage-tabs { display: flex; gap: 24px; min-height: 56px; padding: 0 22px; border-bottom: 1px solid var(--web-line); background: #f8faf9; }
.overview-toolbar { display: flex; min-height: 56px; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--web-line); background: #f8faf9; }
.overview-tabs { display: flex; align-self: stretch; gap: 24px; }
.manage-tab,
.overview-tab { position: relative; display: inline-flex; align-items: center; color: var(--web-muted); font-size: 13px; font-weight: 680; text-decoration: none; }
.manage-tab.active,
.overview-tab.active { color: var(--web-ink); }
.manage-tab.active::after,
.overview-tab.active::after { position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: var(--web-accent); content: ""; }
.manage-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--web-line); }
.manage-list { padding: 0 22px 10px; }
.manage-matter-row { display: grid; grid-template-columns: minmax(0, 1fr) 115px auto; gap: 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid #ebefed; }
.manage-matter-row .matter-copy strong { display: block; font-size: 13px; }
.manage-matter-row .matter-copy .badge { margin-top: 6px; }
.matter-manage-page .matter-date { color: #44504c; font-size: 12px; }
.matter-manage-page .matter-date.overdue,
.work-overview-page .overdue { color: #a33933; font-weight: 680; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.row-actions form { margin: 0; }
.row-actions .button { min-height: 32px; padding: 6px 9px; font-size: 11px; }
.button-danger { border-color: #efcbc8; color: #93312c; background: #fff; }
.badge { display: inline-flex; width: fit-content; min-height: 24px; align-items: center; padding: 3px 8px; border-radius: 999px; color: var(--web-accent-dark); background: #e7f1ee; font-size: 11px; font-weight: 680; white-space: nowrap; }
.badge-danger { color: #93312c; background: #fbe9e7; }
.badge-neutral { color: #59635f; background: #edf0ee; }

.matter-manage-page dialog { width: min(560px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; overflow: auto; border: 1px solid var(--web-line); border-radius: 16px; color: var(--web-ink); background: #fff; box-shadow: 0 28px 90px rgb(13 28 24 / 28%); }
.matter-manage-page dialog::backdrop { background: rgb(10 20 17 / 48%); backdrop-filter: blur(2px); }
.matter-manage-page .modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px 16px; border-bottom: 1px solid var(--web-line); }
.matter-manage-page .modal-header h2 { margin: 0; font-size: 19px; }
.matter-manage-page .modal-close { width: 32px; height: 32px; border: 0; border-radius: 8px; color: var(--web-muted); background: transparent; font-size: 20px; cursor: pointer; }
.matter-manage-page .modal-body { display: grid; gap: 15px; padding: 20px 22px; }
.matter-manage-page .form-group { display: grid; gap: 7px; }
.matter-manage-page .form-group label { font-size: 12px; font-weight: 680; }
.matter-manage-page .form-control { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid #cbd4d0; border-radius: 9px; font: inherit; font-size: 13px; }
.matter-manage-page textarea.form-control { min-height: 120px; resize: vertical; }
.matter-manage-page .modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px 20px; border-top: 1px solid var(--web-line); }
.modal-error { margin: 0; padding: 10px 12px; border: 1px solid #efcbc8; border-radius: 9px; color: #8c302b; background: #fdf1f0; font-size: 12px; }

.attachment-manage-card { padding: 0; overflow: hidden; }
.upload-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; margin: 20px 22px; padding: 18px; border: 1px solid #cfe0da; border-radius: 13px; background: #f4f9f7; }
.upload-card strong { font-size: 14px; }
.upload-card p { margin: 3px 0 0; color: var(--web-muted); font-size: 11px; }
.upload-controls { display: flex; gap: 8px; align-items: center; }
.upload-controls input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
.selected-file { max-width: 260px; overflow: hidden; color: var(--web-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.attachment-search { display: flex; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--web-line); border-bottom: 1px solid var(--web-line); }
.attachment-search input { min-width: min(320px, 100%); padding: 8px 10px; border: 1px solid #cbd4d0; border-radius: 8px; }
.manage-file-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: 18px; align-items: center; padding: 14px 0; border-bottom: 1px solid #ebefed; }
.manage-file-row .file-identity { display: flex; gap: 12px; align-items: center; min-width: 0; }
.manage-file-row .file-icon { position: relative; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 10px; background: #e7f1ee; }
.manage-file-row .file-icon::before { position: absolute; top: 8px; left: 12px; width: 12px; height: 17px; border: 2px solid var(--web-accent); border-radius: 2px; content: ""; }
.manage-file-row .file-copy { min-width: 0; }
.manage-file-row .file-copy strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.manage-file-row .file-copy span,
.manage-file-row .file-date { color: var(--web-muted); font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { display: flex; min-height: 92px; flex-direction: column; justify-content: space-between; padding: 16px; border: 1px solid var(--web-line); border-radius: 14px; color: var(--web-ink); background: #fff; box-shadow: 0 12px 34px rgb(24 42 37 / 5%); text-decoration: none; }
.metric-card span { color: var(--web-muted); font-size: 12px; }
.metric-card strong { font-size: 28px; line-height: 1; }
.metric-card.active { border-color: #a9c9c0; box-shadow: 0 0 0 2px rgb(23 107 90 / 8%); }
.overview-card { overflow: hidden; border: 1px solid var(--web-line); border-radius: 18px; background: #fff; box-shadow: var(--web-shadow); }
.advanced-query-trigger { gap: 8px; }
.advanced-query-trigger.active { border-color: #9abfb5; background: #eef6f3; }
.query-count { display: inline-flex; min-width: 20px; height: 20px; align-items: center; justify-content: center; padding: 0 6px; border-radius: 999px; color: #fff; background: var(--web-accent); font-size: 10px; }
.quick-views { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 22px; border-bottom: 1px solid var(--web-line); }
.quick-view { padding: 6px 10px; border: 1px solid var(--web-line); border-radius: 8px; color: var(--web-muted); font-size: 12px; text-decoration: none; }
.quick-view.active { border-color: var(--web-accent); color: #fff; background: var(--web-accent); }
.active-query-summary { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 11px 22px; border-bottom: 1px solid var(--web-line); background: #fbfcfb; }
.active-query-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.active-query-chips a { display: inline-flex; gap: 7px; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 7px; color: #41504b; background: #edf3f1; font-size: 11px; text-decoration: none; }
.active-query-chips a:hover { color: var(--web-accent-dark); background: #e4efeb; }
.active-query-chips a span { font-size: 15px; line-height: 1; }
.clear-query-link { flex: 0 0 auto; color: var(--web-accent-dark); font-size: 11px; font-weight: 650; text-decoration: none; }
.query-drawer { position: fixed; inset: 0 0 0 auto; width: min(460px, 100%); height: 100dvh; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0; border-left: 1px solid var(--web-line); color: var(--web-ink); background: #fff; box-shadow: -24px 0 70px rgb(13 28 24 / 18%); }
.query-drawer[open] { animation: query-drawer-enter 180ms ease-out; }
.query-drawer::backdrop { background: rgb(10 20 17 / 42%); }
.query-drawer-form { display: grid; height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; }
.query-drawer-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 24px 26px 19px; border-bottom: 1px solid var(--web-line); }
.query-drawer-header h2 { margin: 0; font-size: 22px; }
.query-drawer .modal-close { width: 34px; height: 34px; border: 0; border-radius: 8px; color: var(--web-muted); background: transparent; cursor: pointer; font: inherit; font-size: 22px; line-height: 1; }
.query-drawer .modal-close:hover { background: #f0f3f1; }
.query-drawer-body { display: grid; align-content: start; gap: 18px; padding: 24px 26px; overflow-y: auto; }
.query-field { display: grid; gap: 7px; }
.query-field > span { color: #394642; font-size: 12px; font-weight: 650; }
.query-field input,
.query-field select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #c4cfcb; border-radius: 9px; color: var(--web-ink); background: #fff; font: inherit; font-size: 13px; }
.query-date-range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.query-drawer-footer { display: flex; gap: 9px; justify-content: flex-end; padding: 17px 26px 22px; border-top: 1px solid var(--web-line); background: #fbfcfb; }
@keyframes query-drawer-enter { from { transform: translateX(100%); } to { transform: translateX(0); } }
.overview-table { padding: 0 22px; }
.overview-row { display: grid; gap: 14px; align-items: center; min-height: 66px; padding: 11px 0; border-bottom: 1px solid #ebefed; color: var(--web-ink); font-size: 12px; text-decoration: none; }
.matter-overview-table .overview-row { grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) 100px 135px 78px; }
.incomplete-overview-table .overview-row { grid-template-columns: minmax(220px, 1fr) minmax(220px, 1.2fr) 100px minmax(180px, .8fr); }
.overview-row:not(.overview-header):hover { background: #fafcfb; }
.overview-header { min-height: 42px; color: var(--web-ink); font-weight: 700; }
.overview-primary { font-weight: 650; }
.overview-row small { display: block; font-size: 10px; }
.reason-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.overview-pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; color: var(--web-muted); font-size: 12px; }
.overview-pagination > span { display: flex; gap: 6px; }

/* V2 document archive and lifecycle */
.archive-notice,
.archive-folder-notice { margin-bottom: 18px; padding: 12px 15px; border: 1px solid #e1d5b5; border-radius: 10px; color: #66501c; background: #fff9e9; font-size: 13px; }
.archive-folder-notice a { color: var(--web-accent-dark); font-weight: 650; }
.archive-list-card { overflow: hidden; border: 1px solid var(--web-line); border-radius: 18px; background: #fff; box-shadow: var(--web-shadow); }
.archive-row { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1fr) 110px 110px auto; gap: 16px; align-items: center; min-height: 66px; padding: 11px 22px; border-bottom: 1px solid #ebefed; font-size: 12px; }
.archive-header { min-height: 44px; color: var(--web-ink); background: #f8faf9; font-weight: 700; }
.archive-document-link { color: var(--web-ink); font-weight: 650; text-decoration: none; }
.archive-document-link:hover { color: var(--web-accent-dark); text-decoration: underline; }
.delete-confirm-card { max-width: 760px; }
.delete-warning { margin: 0 0 22px; padding: 14px 16px; border: 1px solid #efcbc8; border-radius: 10px; color: #8c302b; background: #fdf1f0; }
.delete-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0 0 24px; border: 1px solid var(--web-line); border-radius: 12px; overflow: hidden; }
.delete-summary div { padding: 12px 14px; border-bottom: 1px solid var(--web-line); }
.delete-summary div:nth-child(odd) { border-right: 1px solid var(--web-line); }
.delete-summary dt { color: var(--web-muted); font-size: 11px; }
.delete-summary dd { margin: 2px 0 0; font-weight: 650; }

@media (max-width: 940px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .matter-overview-table .overview-row { grid-template-columns: minmax(200px, 1fr) 150px 110px 75px; }
  .matter-overview-table .overview-row > span:nth-child(3) { display: none; }
  .incomplete-overview-table .overview-row { grid-template-columns: minmax(200px, 1fr) minmax(180px, 1fr) minmax(180px, .8fr); }
  .incomplete-overview-table .overview-row > span:nth-child(3) { display: none; }
  .archive-row { grid-template-columns: minmax(200px, 1fr) minmax(180px, 1fr) 110px auto; }
  .archive-row > span:nth-child(3) { display: none; }
}

@media (max-width: 620px) {
  .manage-tabs,
  .overview-tabs { gap: 16px; overflow-x: auto; }
  .manage-matter-row,
  .manage-file-row,
  .overview-row { grid-template-columns: 1fr !important; gap: 5px; }
  .overview-header { display: none; }
  .row-actions { justify-content: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-toolbar { gap: 12px; padding: 0 16px; }
  .overview-tabs { gap: 14px; }
  .advanced-query-trigger { flex: 0 0 auto; padding: 7px 10px; }
  .active-query-summary { align-items: flex-start; flex-direction: column; }
  .query-date-range { grid-template-columns: 1fr; }
  .upload-card { grid-template-columns: 1fr; }
  .upload-controls { align-items: stretch; flex-direction: column; }
  .selected-file { max-width: 100%; }
  .attachment-search { flex-wrap: wrap; }
  .archive-row { grid-template-columns: 1fr; gap: 5px; padding: 14px 18px; }
  .archive-header { display: none; }
  .delete-summary { grid-template-columns: 1fr; }
  .delete-summary div:nth-child(odd) { border-right: 0; }
}

.compact-form,
.popover-form {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--web-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 48px rgb(24 42 37 / 14%);
}

.compact-form {
  position: absolute;
  z-index: 20;
  top: calc(100% + 9px);
  right: 0;
  width: min(420px, calc(100vw - 28px));
}

.popover-form {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: min(330px, calc(100vw - 28px));
}

.compact-form label,
.popover-form label,
.description-editor label {
  color: #394642;
  font-size: 13px;
  font-weight: 650;
}

.compact-form fieldset {
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 0;
  border: 0;
}

.compact-form legend {
  margin-bottom: 5px;
  color: #394642;
  font-size: 13px;
  font-weight: 650;
}

.compact-form fieldset label {
  font-weight: 500;
}

.form-line {
  display: flex;
  gap: 8px;
}

input[type="text"],
input:not([type]),
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #bdc9c5;
  border-radius: 9px;
  color: var(--web-ink);
  background: #fff;
  font: inherit;
}

input:focus,
textarea:focus {
  outline: 3px solid rgb(23 107 90 / 16%);
  border-color: var(--web-accent);
}

.node-list {
  overflow: visible;
  border: 1px solid rgb(91 110 104 / 18%);
  border-radius: 18px;
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--web-shadow);
}

.node-row {
  position: relative;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  padding: 15px 20px;
}

.node-row + .node-row {
  border-top: 1px solid #e8ecea;
}

.node-row:hover {
  background: #fafcfb;
}

.node-main {
  display: flex;
  flex: 1;
  gap: 15px;
  align-items: center;
  min-width: 0;
  color: var(--web-ink);
  text-decoration: none;
}

.node-icon {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #e7f1ee;
}

.node-icon-folder::before {
  position: absolute;
  top: 13px;
  left: 10px;
  width: 22px;
  height: 16px;
  border-radius: 3px;
  background: var(--web-accent);
  content: "";
}

.node-icon-folder::after {
  position: absolute;
  top: 10px;
  left: 11px;
  width: 10px;
  height: 5px;
  border-radius: 2px 2px 0 0;
  background: var(--web-accent);
  content: "";
}

.node-icon-document::before {
  position: absolute;
  top: 9px;
  left: 13px;
  width: 17px;
  height: 23px;
  border: 2px solid var(--web-accent);
  border-radius: 2px;
  content: "";
}

.node-text {
  display: grid;
  min-width: 0;
}

.node-text strong {
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 620;
}

.node-text small {
  margin-top: 2px;
  color: var(--web-muted);
  font-size: 12px;
}

.node-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 3px;
  align-items: center;
}

.node-actions > form {
  margin: 0;
}

.empty-state {
  padding: 50px 24px;
  color: var(--web-muted);
  text-align: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.content-card {
  padding: 26px;
  border: 1px solid rgb(91 110 104 / 18%);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--web-shadow);
}

.card-heading h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.card-heading {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
}

.description-text {
  margin: 22px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.description-editor {
  margin-top: 22px;
}

.description-editor form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.description-editor .button {
  justify-self: start;
}

.upload-form {
  margin: 0;
}

.upload-form input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.attachment-list {
  margin-top: 20px;
  border-top: 1px solid var(--web-line);
}

.attachment-row {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 0;
}

.attachment-row + .attachment-row {
  border-top: 1px solid #e8ecea;
}

.attachment-identity {
  display: flex;
  gap: 13px;
  align-items: center;
  min-width: 0;
}

.attachment-identity > div {
  display: grid;
  min-width: 0;
}

.attachment-identity strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 620;
}

.attachment-identity small {
  margin-top: 2px;
  color: var(--web-muted);
  font-size: 12px;
}

.attachment-icon {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e7f1ee;
}

.attachment-icon::before {
  position: absolute;
  top: 8px;
  left: 11px;
  width: 13px;
  height: 18px;
  border: 2px solid var(--web-accent);
  border-radius: 2px;
  content: "";
}

.attachment-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  align-items: center;
}

.attachment-actions form {
  margin: 0;
}

.attachment-empty {
  margin: 0;
  padding: 24px 0 4px;
}

@media (max-width: 760px) {
  .node-row {
    align-items: stretch;
  }

  .title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 12px;
  }

  .node-row,
  .form-line {
    flex-direction: column;
  }

  .page-actions {
    display: flex;
    justify-content: flex-end;
    min-height: 38px;
  }

  .page-actions .operation-menu,
  .page-actions .create-panel {
    position: relative;
    display: block;
  }

  .page-actions .operation-menu > summary,
  .page-actions .create-panel > summary,
  .page-actions > .button {
    margin-left: auto;
  }

  .page-nav .back-link:has(+ .page-nav-trail) {
    padding-right: 0;
    border-right: 0;
  }

  .create-panel > summary {
    width: 100%;
  }

  .compact-form {
    position: relative;
    top: 8px;
    width: 100%;
  }

  .node-actions {
    justify-content: flex-end;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .card-heading,
  .attachment-row {
    align-items: stretch;
  }

  .attachment-row {
    flex-direction: column;
  }

  .attachment-actions {
    justify-content: flex-end;
  }
}

/* V2 document detail */
.document-detail .page-actions {
  position: relative;
}

.document-detail .content-stack {
  display: grid;
  gap: 18px;
}

.document-detail .card-heading {
  margin-bottom: 18px;
}

.document-detail .card-heading h2 {
  font-size: 20px;
}

.document-detail .count-badge {
  display: inline-grid;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--web-accent-dark);
  background: #e7f1ee;
  font-size: 11px;
  font-weight: 700;
  place-items: center;
}

.document-detail .info-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
}

.document-detail .description-pane {
  padding-right: 28px;
}

.document-detail .description-copy {
  color: #34403d;
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.document-detail .owner-pane {
  display: flex;
  flex-direction: column;
  min-height: 96px;
  padding: 2px 0 0 28px;
  border-left: 1px solid var(--web-line);
}

.document-detail .owner-label {
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 720;
}

.document-detail .owner-name {
  font-size: 16px;
  font-weight: 720;
}

.document-detail .owner-position {
  margin-top: 2px;
  color: var(--web-muted);
  font-size: 12px;
}

.document-detail .owner-pane.unassigned .owner-name {
  color: #79500f;
}

.document-detail .matter-list,
.document-detail .file-list,
.document-detail .log-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.document-detail .matter-header,
.document-detail .matter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 90px;
  gap: 18px;
}

.document-detail .matter-header,
.document-detail .log-header {
  padding: 9px 0;
  border-bottom: 1px solid var(--web-line);
  color: var(--web-ink);
  font-size: 12px;
  font-weight: 700;
}

.document-detail .matter-row {
  align-items: center;
  min-height: 67px;
  padding: 12px 0;
  border-top: 1px solid #ebefed;
}

.document-detail .matter-row:first-child,
.document-detail .file-row:first-child,
.document-detail .log-row:first-child {
  border-top: 0;
}

.document-detail .matter-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 630;
}

.document-detail .matter-date {
  color: #44504c;
  font-size: 12px;
  white-space: nowrap;
}

.document-detail .matter-date.overdue {
  color: #a33933;
  font-weight: 680;
}

.document-detail .badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--web-accent-dark);
  background: #e7f1ee;
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.document-detail .badge-danger {
  color: #93312c;
  background: #fbe9e7;
}

.document-detail .badge-neutral {
  color: #59635f;
  background: #edf0ee;
}

.document-detail .file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 70px;
  padding: 12px 0;
  border-top: 1px solid #ebefed;
}

.document-detail .file-identity {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.document-detail .file-icon {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: #e7f1ee;
}

.document-detail .file-icon::before {
  position: absolute;
  top: 8px;
  left: 12px;
  width: 12px;
  height: 17px;
  border: 2px solid var(--web-accent);
  border-radius: 2px;
  content: "";
}

.document-detail .file-copy {
  min-width: 0;
}

.document-detail .file-copy strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 630;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-detail .file-copy span {
  color: var(--web-muted);
  font-size: 11px;
}

.document-detail .file-links {
  display: flex;
  gap: 7px;
}

.document-detail .file-links a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  border: 1px solid #cbd4d0;
  border-radius: 8px;
  color: var(--web-accent-dark);
  background: #fff;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.document-detail .log-header,
.document-detail .log-row {
  display: grid;
  grid-template-columns: 140px 90px 75px minmax(0, 1fr);
  gap: 14px;
}

.document-detail .log-row {
  align-items: start;
  padding: 15px 0;
  border-top: 1px solid #ebefed;
  font-size: 13px;
  line-height: 1.65;
}

.document-detail .log-time,
.document-detail .log-operator {
  color: #394642;
  font-weight: 600;
}

.document-detail .card-footer {
  display: flex;
  justify-content: center;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--web-line);
}

.document-detail .button-text {
  min-height: 30px;
  padding: 4px 5px;
  color: var(--web-accent-dark);
  background: transparent;
}

.document-detail .inline-pagination {
  display: none;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--web-line);
  color: var(--web-muted);
  font-size: 11px;
}

.document-detail .inline-pagination.visible,
.document-detail .mini-pages {
  display: flex;
}

.document-detail .mini-pages {
  gap: 6px;
}

.document-detail .mini-page {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid var(--web-line);
  border-radius: 7px;
  color: var(--web-accent-dark);
  background: #fff;
  text-decoration: none;
}

.document-detail .card-empty {
  margin: 0;
  padding: 8px 0;
}

.document-operation-panel {
  width: 220px;
}

.document-detail dialog {
  width: min(560px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--web-line);
  border-radius: 16px;
  color: var(--web-ink);
  background: #fff;
  box-shadow: 0 28px 90px rgb(13 28 24 / 28%);
}

.document-detail dialog::backdrop {
  background: rgb(10 20 17 / 48%);
  backdrop-filter: blur(2px);
}

.document-detail .modal-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--web-line);
}

.document-detail .modal-header h2 {
  margin: 0;
  font-size: 19px;
}

.document-detail .modal-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  color: var(--web-muted);
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

.document-detail .modal-body {
  padding: 20px 22px;
}

.document-detail .modal-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #efcbc8;
  border-radius: 9px;
  color: #8c302b;
  background: #fdf1f0;
  font-size: 12px;
}

.document-detail .form-group {
  display: grid;
  gap: 7px;
}

.document-detail .form-group label {
  font-size: 12px;
  font-weight: 680;
}

.document-detail .form-control {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #cbd4d0;
  border-radius: 9px;
  color: var(--web-ink);
  background: #fff;
  font: inherit;
  font-size: 13px;
}

.document-detail textarea.form-control {
  min-height: 180px;
  resize: vertical;
  line-height: 1.65;
}

.document-detail .modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--web-line);
}

@media (max-width: 820px) {
  .document-detail .info-layout { grid-template-columns: 1fr; }
  .document-detail .description-pane { padding-right: 0; }
  .document-detail .owner-pane { min-height: 0; margin-top: 22px; padding: 18px 0 0; border-top: 1px solid var(--web-line); border-left: 0; }
  .document-detail .log-header,
  .document-detail .log-row { grid-template-columns: 125px 80px minmax(0, 1fr); }
  .document-detail .log-header span:nth-child(3),
  .document-detail .log-row .badge { display: none; }
}

@media (max-width: 620px) {
  .document-detail .page-actions .operation-menu > summary { width: 100%; }
  .document-detail .matter-header,
  .document-detail .log-header { display: none; }
  .document-detail .matter-row,
  .document-detail .file-row,
  .document-detail .log-row { grid-template-columns: 1fr; gap: 5px; }
  .document-detail .file-links { padding-left: 50px; }
}

/* V2 authentication and user management */
.account-menu { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.account-identity { display: grid; margin-right: 6px; line-height: 1.25; text-align: right; }
.account-identity strong { font-size: 13px; }
.account-identity span { color: rgb(255 255 255 / 66%); font-size: 11px; }
.account-menu form { margin: 0; }
.account-link { padding: 6px 8px; border: 0; color: #fff; background: transparent; cursor: pointer; font: inherit; font-size: 13px; text-decoration: none; }

input[type="password"], select { width: 100%; padding: 10px 12px; border: 1px solid #bdc9c5; border-radius: 9px; color: var(--web-ink); background: #fff; font: inherit; }
.auth-layout { display: grid; min-height: calc(100vh - 166px); place-items: center; }
.auth-layout-login { transform: translateY(-72px); }
.auth-card { width: min(440px, 100%); padding: 34px; border: 1px solid var(--web-line); border-radius: 20px; background: #fff; box-shadow: var(--web-shadow); }
.auth-card h1, .content-card h2 { margin: 0; }
.stacked-form { display: grid; gap: 10px; margin-top: 24px; }
.stacked-form label { color: #394642; font-size: 13px; font-weight: 650; }
.stacked-form .button { justify-self: start; margin-top: 8px; }
.form-help { margin: -3px 0 0; color: var(--web-muted); font-size: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 20px; }
.data-card { overflow-x: auto; border: 1px solid var(--web-line); border-radius: 18px; background: #fff; box-shadow: var(--web-shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 15px 18px; border-bottom: 1px solid #e8ecea; text-align: left; vertical-align: middle; }
.data-table th { color: #394642; font-size: 12px; }
.data-table td small { display: block; color: var(--web-muted); }
.table-actions { display: flex; gap: 6px; align-items: center; }
.table-actions form { margin: 0; }
.status-badge { display: inline-flex; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.status-active { color: var(--web-accent-dark); background: #e7f1ee; }
.status-inactive { color: #6f625f; background: #eeeae8; }
.content-card .section-heading { margin-top: 28px; }

@media (min-width: 1401px) {
  .account-menu { grid-row: 1; grid-column: 3; justify-self: end; margin-right: 28px; }
}

@media (max-width: 760px) {
  .account-identity { display: none; }
  .account-link { padding: 5px; font-size: 12px; }
  .auth-card { padding: 26px 22px; }
}
