/* Independent contact workspace: layout, filters and navigation. */
body:has([data-app-view="contacts"].active) .app-layout { grid-template-columns: minmax(0, 1fr); }
#contactBookMount, #contactBookMount .panel { min-width: 0; }
#contactBookMount .page-heading { flex-wrap: wrap; }
#contactBookMount .page-heading > div { min-width: 0; }
.contact-workspace-active .month-badge, .contact-workspace-active #workspaceTools { display: none !important; }
.workspace-menu-body > a.workspace-independent-link {
  border-top: 1px solid #dce5e3 !important;
  margin-top: 5px !important;
  border-radius: 0 0 8px 8px !important;
  color: #0f766e;
}
.contact-file-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.contact-file-actions .workspace-menu > summary { background: #edf2f2; }
.contact-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.contact-tabs button { border: 1px solid var(--line, #dce4e3); background: #fff; border-radius: 10px; padding: 12px 18px; }
.contact-tabs button[aria-selected=true] { background: #0f766e; color: #fff; border-color: #0f766e; }
.contact-tabs span { margin-left: 8px; font-size: .85em; opacity: .8; }
.contact-panel { padding: 24px; }
.contact-tools, .contact-selection { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.contact-tools label { display: grid; gap: 6px; }
.contact-tools label:first-child { flex: 1; min-width: 190px; }
.contact-filter-state { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; margin-top: 14px; }
.contact-filter-state p { font-size: 12px; color: #526b70; margin: 0; }
.contact-filter-state button { font-size: 12px; padding: 8px 10px; }
.contact-filter-state button[hidden] { display: none; }
.contact-selection { border-block: 1px solid #e5ebea; margin: 14px 0; padding: 14px 0; align-items: center; }
.contact-selection label { display: flex; gap: 7px; align-items: center; }
.contact-selection button { margin-left: auto; }
.contact-sheet input, .contact-selection input, .contact-table input { width: auto; }

/* Overview totals deliberately remain independent of active filters. */
.contact-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.contact-overview[hidden] { display: none; }
.contact-overview button { display: flex; flex-direction: column; gap: 5px; align-items: start; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: 12px; text-align: left; color: #20313d; }
.contact-overview button:hover { border-color: #0f766e; background: #f4faf8; }
.contact-overview span { font-size: 12px; color: #526b70; }
.contact-overview strong { font-size: 28px; letter-spacing: -.04em; }
.contact-overview small { font-size: 11px; font-weight: 400; color: #6b7d79; }
.contact-overview button:last-child strong { color: #0f766e; }

/* Only the table scrolls horizontally. Actions stay at the right edge. */
#contactBookMount .table-wrap { max-width: 100%; }
.contact-table { min-width: 1280px; table-layout: fixed; width: 100%; }
.contact-col-select { width: 40px; }
.contact-col-queue { width: 116px; }
.contact-col-name { width: 122px; }
.contact-col-birth { width: 112px; }
.contact-col-disability, .contact-col-service { width: 100px; }
.contact-col-phone, .contact-col-recent { width: 136px; }
.contact-col-actions { width: 200px; }
.contact-table th { white-space: normal; line-height: 1.6; overflow-wrap: anywhere; }
.contact-table td { font-size: 12px; vertical-align: top; overflow-wrap: anywhere; white-space: normal; }
.contact-table td small { display: block; margin-top: 5px; color: #6b7d79; font-size: 11px; }
.contact-table .contact-note, .contact-table .contact-disability { white-space: normal; overflow-wrap: anywhere; }
.contact-table .contact-birth-age { white-space: nowrap; }
.contact-table .contact-birth-age small { font-size: 12px; color: #365b58; }
.contact-table th:last-child, .contact-table td:last-child { position: sticky; right: 0; background: #fff; z-index: 1; box-shadow: -6px 0 10px -9px #415d64; }
.contact-table .empty { padding: 40px 20px; text-align: center; vertical-align: middle; }
.contact-table .empty button { margin-left: 10px; }
.contact-tag { display: inline-block; font-size: 10px; line-height: 1.5; padding: 3px 7px; border-radius: 6px; background: #eef3f3; color: #48636b; margin-top: 4px; white-space: nowrap; }
.contact-tag.long, .contact-tag[data-contact-state=hold] { background: #fff3de; color: #8d5b10; }
.contact-tag.due, .contact-tag[data-contact-state=started] { background: #e5f4ee; color: #12624c; }
.contact-tag[data-contact-state=offered] { background: #e8f0fa; color: #365f8a; }
.contact-row-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 6px; width: 100%; }
.contact-row-actions button { display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 100%; min-width: 0; height: 34px; min-height: 34px; margin: 0; padding: 0 6px; font-size: 11px; line-height: 1.2; white-space: nowrap; }
.contact-row-actions .contact-start-button { grid-column: 1 / -1; color: #0f625b; background: #e7f3ef; border: 1px solid #c7e2d8; box-shadow: none; }
.contact-row-actions .contact-start-button:hover { background: #d8ece3; border-color: #91c6b1; }
.contact-row-actions .contact-remove-button { color: #a34334; }
.contact-requeued-note { grid-column: 1 / -1; font-size: 10px; color: #667e80; }

/* Shared contact form patterns. */
.contact-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.contact-edit-grid > label { min-width: 0; }
#contactEditDialog { width: min(760px, 94vw); }
#contactLogDialog { width: min(720px, 94vw); }
#contactStartDialog { width: min(480px, 94vw); }
#contactWaitDialog { width: min(520px, 94vw); }
#contactEditForm > label, #contactLogForm > label, #contactStartForm > label, #contactWaitForm > label { display: grid; gap: 6px; }
#contactEditForm > label, #contactWaitForm > label { margin-top: 14px; }
#contactStartForm > .hint, #contactWaitForm > .hint { line-height: 1.7; }
#contactEditForm .dialog-actions, #contactLogForm .dialog-actions { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line, #dce4e3); padding: 14px 0; margin-bottom: 0; z-index: 2; }
#contactAge[readonly], #contactWaitDate[readonly] { background: #f0f5f4; color: #365b58; cursor: default; }
#contactAgeHint { font-size: 11px; line-height: 1.5; }
.contact-start-person { font-weight: 650; color: #264b50; }
.contact-start-error { color: #a83434; font-size: 12px; min-height: 18px; }
.contact-start-error:empty { min-height: 0; margin: 0; }
.contact-edit-extra { margin: 16px 0; padding: 12px 0; border-block: 1px solid #e5ebea; }
.contact-edit-extra summary { font-size: 12px; cursor: pointer; margin-bottom: 8px; }
.contact-edit-extra:not([open]) summary { margin: 0; }
.contact-log-history { margin-top: 20px; border-top: 1px solid #e5ebea; padding-top: 16px; max-height: 290px; overflow: auto; }
.contact-log-history h3 { font-size: 14px; }
.contact-log-history article { padding: 12px 0; border-top: 1px solid #edf1f0; }
.contact-log-history strong { font-size: 12px; }
.contact-log-history p { font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.contact-log-history small { font-size: 11px; color: #58736a; }
.contact-history { padding: 20px; margin-top: 18px; }
.contact-history summary { cursor: pointer; font-weight: 650; }
.contact-history p { font-size: 13px; line-height: 1.7; }
.contact-sheet { display: flex !important; align-items: center; gap: 8px; padding: 12px; background: #f5f8f7; border-radius: 8px; margin-bottom: 8px; }
.contact-long-setting { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.contact-long-setting input { width: 90px; margin: 0; }
#contactBookMount #contactStatusFilterLabel[hidden] { display: none; }

@media (max-width: 800px) {
  .contact-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-overview button { padding: 15px; }
  .contact-tools { gap: 10px; }
  .contact-tools label:first-child { flex-basis: 100%; }
  .contact-file-actions { width: 100%; }
  .contact-tabs button { padding: 10px 12px; }
}
@media (max-width: 700px) {
  .contact-panel { padding: 16px; }
  .contact-edit-grid { grid-template-columns: 1fr; }
  .contact-selection button { margin-left: 0; width: 100%; }
}
@media (max-width: 520px) {
  .contact-overview { gap: 8px; }
  .contact-overview strong { font-size: 24px; }
  .contact-overview small { font-size: 10px; }
  .contact-tools > label { min-width: 120px; flex: 1; }
  .contact-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .contact-tabs button:last-child { grid-column: 1 / -1; }
  .contact-tabs button { font-size: 12px; }
  .contact-file-actions > .primary { flex: 1; }
}
