#projectsDialog {
  width: min(1120px, 95vw);
  max-height: min(860px, 92vh);
  overflow: hidden;
  border: 1px solid #d5e0e3;
  border-radius: 16px;
  background: #f3f7f8;
  box-shadow: 0 32px 90px rgba(7,29,38,.36);
}

#projectsDialog .dialog-head {
  height: 82px;
  padding: 0 24px;
  background: #fff;
  border-top: 4px solid #16b8ad;
  border-bottom: 1px solid #d9e3e6;
}

#projectsDialog .dialog-head small { color: #078d83; letter-spacing: .16em; }
#projectsDialog .dialog-head h2 { color: #112c36; font-size: 22px; }

.projects-dialog-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  margin-right: 9px;
}

.projects-dialog-tools button {
  height: 36px;
  padding: 0 13px;
  border: 1px solid #91bbb9;
  border-radius: 8px;
  background: #f3fbfa;
  color: #075f5a;
  font-size: 9px;
  font-weight: 850;
}

.projects-dialog-tools button:hover { border-color: #078d83; background: #e3f5f2; }
.projects-dialog-tools button.primary { border-color: #087b73; background: #087b73; color: #fff; }
.projects-dialog-tools button.primary:hover { border-color: #05655f; background: #05655f; }

.project-storage-location {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 16px 22px 0;
  padding: 13px 15px;
  border: 1px solid #cbe2df;
  border-radius: 14px;
  background: linear-gradient(120deg,#f4fbfa,#edf7f5);
  color: #17333b;
}
.project-storage-location div { display: grid; min-width: 0; gap: 2px; }
.project-storage-location small { color: #087b73; font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.project-storage-location b { font-size: 13px; }
.project-storage-location span { overflow: hidden; color: #527078; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.project-storage-location button { flex: 0 0 auto; min-height: 34px; padding: 0 12px; border: 1px solid #8bb9b3; border-radius: 9px; background: #fff; color: #086b65; font-size: 10px; font-weight: 850; }
.project-storage-location button:disabled { cursor: wait; opacity: .55; }
.project-storage-location[data-state="error"] { border-color: #e9bbb4; background: #fff4f2; }

.projects-list {
  max-height: calc(min(860px,92vh) - 82px);
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(285px,1fr));
  align-items: start;
  gap: 16px;
  padding: 21px;
  overflow-y: auto;
  background: linear-gradient(180deg,#f7fafb,#eef4f5);
}

.projects-library-summary {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid #d3e1e4;
  border-left: 4px solid #12a99d;
  border-radius: 8px;
  background: #fff;
  color: #657982;
  font-size: 9px;
}

.projects-library-summary b { color: #12313c; font-size: 14px; }
.projects-library-summary[data-library-state="dirty"] {
  border-color: #f1c989;
  border-left-color: #e79121;
  background: #fff9ef;
  color: #79551e;
}
.projects-library-summary[data-library-state="recovery"] {
  border-color: #c9d8f3;
  border-left-color: #547bc9;
  background: #f5f8ff;
  color: #3f5682;
}
.projects-dialog-tools #saveCurrentProjectButton[data-library-state="dirty"] {
  border-color: #d97f12;
  background: #d97f12;
}
.projects-dialog-tools #saveCurrentProjectButton[data-library-state="recovery"] {
  border-color: #456dbd;
  background: #456dbd;
}

.projects-search {
  grid-column: 1 / -1;
  height: 42px;
  padding: 0 13px;
  border: 1px solid #cbdadd;
  border-radius: 8px;
  background: #fff;
  color: #18323c;
  font-size: 10px;
  box-shadow: 0 4px 14px rgba(20,48,58,.04);
}

.projects-search:focus {
  border-color: #0a9c91;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(10,156,145,.12);
}

.project-card {
  position: relative !important;
  display: flex !important;
  flex-direction: column;
  gap: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  border: 1px solid #d5e1e4 !important;
  border-radius: 12px !important;
  background: #fff;
  box-shadow: 0 7px 24px rgba(16,45,55,.06);
  transition: transform .16s ease,border-color .16s ease,box-shadow .16s ease;
}

.project-card:hover {
  transform: translateY(-3px);
  border-color: #8fc6c1 !important;
  box-shadow: 0 16px 36px rgba(12,52,62,.13);
}

.project-card .preview {
  position: relative;
  width: 100%;
  height: auto !important;
  aspect-ratio: 16 / 9;
  border: 0 !important;
  border-radius: 0 !important;
  background-color: #dfe9eb !important;
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  box-shadow: inset 0 -1px #d9e3e5;
}

.project-preview-label {
  position: absolute;
  left: 10px;
  bottom: 9px;
  max-width: calc(100% - 20px);
  overflow: hidden;
  padding: 4px 7px;
  border-radius: 5px;
  background: rgba(6,25,34,.78);
  color: #fff;
  font-size: 7px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(5px);
}

.project-card > div:last-child {
  min-height: 225px;
  display: flex;
  flex-direction: column;
  padding: 14px 15px 13px;
}

.project-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.project-card h3 { margin: 0 !important; color: #15303a; font-size: 14px !important; line-height: 1.25; }

.current-project-badge {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 99px;
  background: #def4f0;
  color: #087269;
  font-size: 7px;
  font-weight: 900;
  text-transform: uppercase;
}
.current-project-badge.recovery { background:#fff0d5; color:#9a5a00; }
.current-project-badge.conflict { background:#f1e8ff; color:#6f35a5; }

.project-card p { margin: 6px 0 9px !important; color: #677d85 !important; font-size: 9px !important; }
.project-facts { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.project-facts span { padding: 4px 6px; border: 1px solid #dce6e8; border-radius: 5px; background: #f5f8f9; color: #647880; font-size: 7px; }
.project-facts b { color: #18343e; font-size: 8px; }
.project-sheet-index { margin: 0 0 9px; padding: 8px; border: 1px solid #d8e6e8; border-radius: 8px; background: linear-gradient(145deg,#f9fcfc,#f0f6f7); }
.project-sheet-index header { display:flex; align-items:center; justify-content:space-between; margin-bottom:5px; color:#5b737c; }
.project-sheet-index header small { font-size:7px; font-weight:900; letter-spacing:.09em; }
.project-sheet-index header span { min-width:18px; padding:2px 5px; border-radius:99px; background:#18343e; color:#fff; font-size:7px; font-weight:900; text-align:center; }
.project-sheet-index ol { display:grid; gap:4px; margin:0; padding:0; list-style:none; }
.project-sheet-index li { display:grid; grid-template-columns:24px minmax(0,1fr); align-items:center; gap:7px; min-width:0; }
.project-sheet-index code { width:22px; height:22px; display:grid; place-items:center; border-radius:6px; background:#087d73; color:#fff; font:900 8px/1 inherit; }
.project-sheet-index li[data-sheet-side="back"] code { background:#cc6538; }
.project-sheet-index li[data-sheet-side="panel"] code { background:#236fa4; }
.project-sheet-index li div { min-width:0; display:grid; }
.project-sheet-index li b { overflow:hidden; color:#18343e; font-size:8px; line-height:1.15; text-overflow:ellipsis; white-space:nowrap; }
.project-sheet-index li small { color:#6d8289; font-size:7px; line-height:1.2; }
.project-sheet-index > em { display:block; margin-top:5px; color:#087d73; font-size:7px; font-style:normal; font-weight:850; }
.project-card time { margin-bottom: 8px; color: #809098; font-size: 7px; }

.project-estimate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 9px;
  padding: 7px 8px;
  border-radius: 6px;
  background: #eef7f5;
  color: #5d747c;
  font-size: 8px;
}

.project-estimate b { color: #087269; font-size: 11px; }

.project-integrity {
  display: grid;
  grid-template-columns: 26px minmax(0,1fr);
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  padding: 8px;
  border: 1px solid #bfded8;
  border-radius: 7px;
  background: #eff9f6;
}
.project-integrity > i {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #087d73;
  color: #fff;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}
.project-integrity span { min-width: 0; display: grid; gap: 2px; }
.project-integrity b { color: #15534e; font-size: 8px; }
.project-integrity small { overflow: hidden; color: #53736f; font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
.project-integrity.checking { border-color: #d4dfe2; background: #f5f8f9; }
.project-integrity.checking > i { background: #8a9ca3; }
.project-integrity.issue { border-color: #efc9b3; background: #fff4eb; }
.project-integrity.issue > i { background: #c85f2e; }
.project-integrity.issue b { color: #8b3e1d; }
.project-integrity.issue small { color: #7f5a48; }
.project-integrity.unknown { border-color: #d4c9e7; background: #f7f3fd; }
.project-integrity.unknown > i { background: #7050a7; }
.project-integrity.unknown b { color: #553681; }

.project-card-actions {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 5px;
  margin-top: auto;
}

.project-card-actions .project-open { grid-column: 1 / -1; }
.project-card-actions button {
  min-width: 0;
  height: 36px;
  margin: 0 !important;
  padding: 0 6px !important;
  border: 1px solid #d1dde0 !important;
  border-radius: 6px !important;
  background: #fff !important;
  color: #3c535c;
  font-size: 8px !important;
  font-weight: 750;
  white-space: nowrap;
}

.project-card-actions button:hover { border-color: #8dbbb7 !important; background: #eef8f7 !important; }
.project-card-actions .project-open { border-color: #078d83 !important; background: #078d83 !important; color: #fff !important; }
.project-card-actions .project-open:hover { border-color: #056f68 !important; background: #056f68 !important; }
.project-card-actions .project-repair-artwork { border-color:#d77a42 !important; background:#fff4ea !important; color:#8b3e1d !important; }
.project-card-actions .project-repair-artwork:hover { border-color:#ba5623 !important; background:#ffe7d2 !important; }
.project-card-actions .project-repair-artwork:disabled { opacity:.72; cursor:wait; }
.project-card-actions .project-delete { border-color: #f0d2d5 !important; color: #b42332 !important; }
.project-card-actions .project-delete:hover { background: #fff2f3 !important; }
.project-card-actions .project-delete.confirming { border-color: #bf2737 !important; background: #bf2737 !important; color: #fff !important; }
.project-card-actions [data-restore-project] { border-color:#b9d9d5 !important; color:#087269 !important; }
.project-card-actions [data-restore-project].confirming { border-color:#087269 !important; background:#087269 !important; color:#fff !important; }

.project-history-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  padding: 0;
  border: 1px solid #9bb9bd;
  border-radius: 14px;
  background: #f5f9f8;
  color: #18343d;
  box-shadow: 0 26px 80px rgba(7,30,37,.34);
}
.project-history-dialog::backdrop { background: rgba(4,22,29,.68); backdrop-filter: blur(5px); }
.project-history-dialog > header { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; padding:22px 24px 18px; border-bottom:1px solid #cbd9db; background:#0e2b34; color:#fff; }
.project-history-dialog header small { color:#62ddd0; font-size:8px; font-weight:850; letter-spacing:.16em; }
.project-history-dialog header h2 { margin:5px 0 2px; font-size:21px; }
.project-history-dialog header p { margin:0; color:#b8ced2; font-size:10px; }
.project-history-dialog header button { width:34px; height:34px; border:1px solid rgba(255,255,255,.18); border-radius:8px; background:rgba(255,255,255,.08); color:#fff; font-size:18px; }
.project-history-list { display:grid; gap:10px; max-height:620px; padding:18px; overflow:auto; }
.project-history-list article { display:flex; align-items:center; justify-content:space-between; gap:18px; padding:15px 16px; border:1px solid #d4e0e1; border-left:4px solid #0ba99d; border-radius:9px; background:#fff; }
.project-history-list article > div { min-width:0; }
.project-history-list article small,.project-history-list article b,.project-history-list article span,.project-history-list article time { display:block; }
.project-history-list article small { color:#087269; font-size:7px; font-weight:850; letter-spacing:.11em; }
.project-history-list article b { margin:4px 0; overflow:hidden; color:#16343d; font-size:12px; text-overflow:ellipsis; white-space:nowrap; }
.project-history-list article span,.project-history-list article time { color:#61777f; font-size:9px; }
.project-history-list article time { margin-top:4px; }
.project-history-list article button { flex:0 0 auto; min-width:126px; height:34px; border:1px solid #87bbb5; border-radius:7px; background:#eef9f7; color:#087269; font-size:9px; font-weight:800; }
.project-history-list article button.confirming { border-color:#087269; background:#087269; color:#fff; }
.project-history-empty { padding:46px 22px; border:1px dashed #aac6ca; border-radius:10px; background:#fff; color:#61777f; text-align:center; font-size:11px; }
.project-history-empty b,.project-history-empty span { display:block; }
.project-history-empty b { margin-bottom:5px; color:#15303a; font-size:14px; }
.recovery-drafts-list article { border-left-color:#d8792d; }
.recovery-drafts-list article small { color:#a24f17; }
.recovery-drafts-list article.active-recovery-draft { border-color:#9fc7c3; border-left-color:#0ba99d; background:#eef9f7; }
.recovery-drafts-list article.active-recovery-draft small { color:#087269; }
.recovery-drafts-list article button:disabled { border-color:#b8cdcf; background:#edf2f2; color:#637b80; opacity:1; cursor:default; }
.recovery-drafts-list article button.restoring:disabled { position:relative; border-color:#087269; background:#e6f7f4; color:#075f58; }
.recovery-drafts-list article button.restoring:disabled::before { content:""; width:10px; height:10px; margin-right:7px; display:inline-block; border:2px solid currentColor; border-right-color:transparent; border-radius:50%; vertical-align:-1px; animation:pmp-recovery-spin .7s linear infinite; }
@keyframes pmp-recovery-spin { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion:reduce) { .recovery-drafts-list article button.restoring:disabled::before { animation:none; border-right-color:currentColor; opacity:.55; } }

.projects-empty,
.projects-loading,
.projects-no-results {
  grid-column: 1 / -1;
  padding: 46px;
  border: 1px dashed #aac6ca;
  border-radius: 12px;
  background: #fff;
  color: #61777f;
  text-align: center;
  font-size: 11px;
}

.projects-empty b,
.projects-empty span { display: block; }
.projects-empty b { margin-bottom: 5px; color: #15303a; font-size: 14px; }
.projects-empty.error { border-color: #e6b6bb; background: #fff7f8; }
.projects-no-results { padding: 28px; }
.projects-loading { border-style: solid; }
.projects-no-results[hidden] { display: none; }

@media (max-width: 720px) {
  #projectsDialog { width: 100vw; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  #projectsDialog .dialog-head { height: 70px; padding: 0 10px; }
  .projects-dialog-tools { gap: 4px; margin-right: 4px; }
  .projects-dialog-tools button { padding: 0 7px; font-size: 8px; }
  .project-storage-location { align-items: stretch; margin: 10px 10px 0; padding: 10px 12px; flex-direction: column; gap: 8px; }
  .project-storage-location span { white-space: normal; overflow-wrap: anywhere; }
  .project-storage-location button { width: 100%; }
  .projects-list { grid-template-columns: 1fr; max-height: calc(100dvh - 70px); padding: 14px; }
  .projects-library-summary { align-items: flex-start; flex-direction: column; gap: 3px; }
  .project-card > div:last-child { min-height: 210px; }
  .project-history-dialog { width:100vw; height:100dvh; max-height:none; border:0; border-radius:0; }
  .project-history-list { max-height:calc(100dvh - 92px); padding:12px; }
  .project-history-list article { align-items:stretch; flex-direction:column; gap:10px; }
  .project-history-list article button { width:100%; }
}

@media (prefers-reduced-motion: reduce) {
  .project-card { transition: none; }
}
