/* Building screen: header, tabs, timeline, detail panel and supporting tabs. */

.building-header { padding: 28px 32px 0; border-bottom: 1px solid var(--border); }
.building-id { display: flex; align-items: center; gap: 24px; }
.building-cover { width: 144px; height: 96px; border-radius: var(--radius); }
.building-name { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.building-meta { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 15px; color: var(--ink-muted); }
.building-meta svg { width: 14px; height: 14px; color: var(--ink-subtle); }
.building-meta .address { display: inline-flex; align-items: center; gap: 6px; }
.tabs { margin-top: 24px; margin-bottom: -1px; display: flex; gap: 28px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 4px 0 12px; border-bottom: 2px solid transparent; font-size: 15px; color: var(--ink-muted); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { border-color: var(--primary); color: var(--ink); font-weight: 500; }
@media (max-width: 575.98px) {
  .building-header { padding: 24px 16px 0; }
  .building-id { gap: 16px; }
  .building-cover { width: 64px; height: 64px; }
  .building-name { font-size: 20px; }
  .building-meta { font-size: 14px; }
  .building-meta .dot { display: none; }
  .building-meta .address { flex-basis: 100%; }
  .tabs { gap: 24px; }
}

.tab-page { max-width: 1024px; margin: 0 auto; padding: 32px; display: flex; flex-direction: column; gap: 40px; }
@media (max-width: 575.98px) { .tab-page { padding: 24px 16px; } }

/* ---------------------------------------------------------------------------------------------- */
/* Timeline                                                                                         */
/* ---------------------------------------------------------------------------------------------- */

.timeline-layout { display: flex; align-items: flex-start; gap: 32px; padding: 24px 32px; }
.timeline-main { flex: 1; min-width: 0; }
@media (max-width: 575.98px) { .timeline-layout { padding: 24px 16px; } }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; padding: 4px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); font-size: 14px; color: var(--ink-muted); transition: border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--ink); }
.chip .count { font-size: 12px; color: var(--ink-subtle); }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-card); }
.chip.active .count { color: rgb(255 255 255 / 0.7); }
.chip.empty { opacity: 0.6; }
.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.sort-link { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 13px; color: var(--ink-muted); }
.sort-link:hover { border-color: var(--border-strong); color: var(--ink); }
.sort-link svg { width: 14px; height: 14px; }
@media (max-width: 575.98px) {
  .chips { flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
}

.timeline { margin-top: 28px; display: flex; flex-direction: column; gap: 32px; }
.month-title { margin-bottom: 12px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.tl-list { position: relative; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tl-list::before { content: ""; position: absolute; top: 12px; bottom: 12px; left: 5px; width: 1px; background: rgb(216 215 208 / 0.7); }
.tl-item { position: relative; display: grid; grid-template-columns: 12px 92px 44px minmax(0, 1fr); align-items: center; gap: 0 16px; scroll-margin: 96px 0; }
.tl-dot { position: relative; z-index: 1; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--canvas); background: var(--border-strong); }
.tl-item.selected .tl-dot { background: var(--primary); box-shadow: 0 0 0 4px rgb(47 93 84 / 0.15); }
.tl-date { font-size: 13px; line-height: 1.35; color: var(--ink-muted); }
.tl-date .time { color: var(--ink-subtle); }
.tl-card {
  display: flex; align-items: center; gap: 16px; min-width: 0; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tl-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-panel); }
.tl-item.selected .tl-card { border-color: rgb(47 93 84 / 0.35); box-shadow: 0 0 0 3px rgb(47 93 84 / 0.08); }
.tl-body { flex: 1; min-width: 0; }
.tl-mobile-date { display: none; margin-bottom: 2px; font-size: 12px; color: var(--ink-subtle); }
.tl-head { display: flex; align-items: flex-start; gap: 12px; }
.tl-title { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-badges { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tl-desc { margin: 4px 0 0; font-size: 14px; line-height: 1.6; color: var(--ink-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tl-case { margin: 6px 0 0; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-subtle); }
.tl-case svg { width: 14px; height: 14px; }
.tl-thumb { width: 80px; height: 56px; flex-shrink: 0; border-radius: var(--radius-sm); object-fit: cover; box-shadow: 0 0 0 1px var(--border); }
.tl-more { margin-top: 32px; display: flex; justify-content: center; }
@media (max-width: 767.98px) { .tl-badges .type-badge { display: none; } }
@media (max-width: 575.98px) {
  .tl-list::before, .tl-dot, .tl-date { display: none; }
  .tl-item { grid-template-columns: 36px minmax(0, 1fr); gap: 0 12px; }
  .tl-item .event-icon { width: 36px; height: 36px; }
  .tl-item .event-icon svg { width: 16px; height: 16px; }
  .tl-mobile-date { display: block; }
  .tl-thumb { display: none; }
}

/* ---------------------------------------------------------------------------------------------- */
/* Event detail panel: beside the timeline on wide screens, sliding over it below 1200px           */
/* ---------------------------------------------------------------------------------------------- */

.panel-slot:empty { display: none; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: 100%; max-width: 440px;
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-overlay); animation: panel-in 0.18s ease-out; overscroll-behavior: contain;
}
.panel-backdrop { position: fixed; inset: 0; z-index: 45; background: rgb(28 35 32 / 0.15); }
@media (min-width: 1200px) {
  .panel-slot { position: sticky; top: 24px; flex-shrink: 0; }
  .panel { position: static; width: 400px; max-width: none; height: calc(100vh - 48px); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel); }
  .panel-backdrop { display: none; }
}
@media (min-width: 1536px) { .panel { width: 440px; } }
@keyframes panel-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

.panel-actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; padding: 12px 16px 0; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 32px; }
.panel-head { padding: 0 24px 24px; }
.panel-date { font-size: 14px; color: var(--ink-muted); }
.panel-title-row { margin-top: 8px; display: flex; align-items: flex-start; gap: 12px; }
.panel-title { font-size: 20px; line-height: 1.35; font-weight: 600; letter-spacing: -0.01em; }
.panel-badges { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.panel-desc { margin: 20px 0 0; font-size: 15px; line-height: 1.65; color: var(--ink-muted); white-space: pre-wrap; }
.panel-section { padding: 20px 24px; border-top: 1px solid var(--border); }
.panel-section-title { margin-bottom: 12px; font-size: 14px; font-weight: 500; color: var(--ink-muted); }
.panel-dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 24px; margin: 0; font-size: 14px; }
.panel-dl dt { font-weight: 400; color: var(--ink-subtle); }
.panel-dl dd { margin: 0; }
.contact-list, .file-list, .case-list { list-style: none; margin: 0; padding: 0; }
.contact-list { display: flex; flex-direction: column; gap: 12px; }
.contact-item { display: flex; align-items: center; gap: 12px; }
.contact-avatar { width: 36px; height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface-muted); color: var(--ink-subtle); box-shadow: 0 0 0 1px var(--border); }
.contact-avatar svg { width: 16px; height: 16px; }
.contact-name { display: block; font-size: 14px; font-weight: 500; }
.contact-meta { display: block; font-size: 13px; color: var(--ink-subtle); }
.contact-phone { font-size: 13px; color: var(--ink-muted); white-space: nowrap; }
.contact-phone:hover { color: var(--primary); }
.file-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.file-list li + li { border-top: 1px solid var(--border); }
.file-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; transition: background-color 0.15s; }
.file-link:hover { background: var(--surface-muted); }
.file-icon { width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--tint-rose); color: var(--ink-rose); }
.file-icon svg { width: 16px; height: 16px; }
.file-thumb { width: 32px; height: 32px; flex-shrink: 0; border-radius: 6px; object-fit: cover; box-shadow: 0 0 0 1px var(--border); }
.file-name { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 13px; color: var(--ink-subtle); }
.case-name { margin: -4px 0 12px; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
.case-name svg { width: 16px; height: 16px; color: var(--ink-subtle); }
.case-list { position: relative; }
.case-list::before { content: ""; position: absolute; top: 8px; bottom: 8px; left: 13px; width: 1px; background: var(--border); }
.case-link { position: relative; display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 0; border-radius: var(--radius-sm); }
.case-link:hover { background: var(--surface-muted); }
.case-link .event-icon { box-shadow: 0 0 0 4px var(--surface); }
.case-link.current { font-weight: 500; }
.case-link.current .event-icon { box-shadow: 0 0 0 4px rgb(47 93 84 / 0.2); }
.case-title { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-date { flex-shrink: 0; font-size: 12px; color: var(--ink-subtle); }
.panel-footer { margin: 24px 24px 0; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; line-height: 1.6; color: var(--ink-subtle); }

/* ---------------------------------------------------------------------------------------------- */
/* Supporting tabs                                                                                  */
/* ---------------------------------------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--border); }
@media (min-width: 576px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 992px) { .stats { grid-template-columns: repeat(6, 1fr); } }
.stat { padding: 16px 20px; background: var(--surface); transition: background-color 0.15s; }
.stat:hover { background: var(--surface-muted); }
.stat-label { font-size: 13px; color: var(--ink-subtle); }
.stat-value { margin-top: 4px; font-size: 24px; font-weight: 600; }

.table-t { width: 100%; font-size: 14px; }
.table-t th { padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 500; color: var(--ink-subtle); }
.table-t td { padding: 12px 20px; border-top: 1px solid var(--border); vertical-align: middle; }
.table-t tbody tr:first-child td { border-top: 0; }
.table-t tbody tr:hover { background: rgb(246 246 243 / 0.6); }
.doc-link { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.doc-link:hover { color: var(--primary); }
.doc-link svg { width: 16px; height: 16px; }
.doc-context { display: block; color: var(--ink-muted); }
.doc-context:hover { color: var(--primary); }

.contact-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 768px) { .contact-cards { grid-template-columns: 1fr 1fr; } }
.contact-card { display: flex; gap: 16px; padding: 16px; }
.contact-lines { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-muted); }
.contact-lines a { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.contact-lines a:hover { color: var(--primary); }
.contact-lines svg { width: 14px; height: 14px; }

.topic-grid { display: grid; gap: 16px; }
@media (min-width: 768px) { .topic-grid { grid-template-columns: 1fr 1fr; } }
.topic-card { padding: 20px; }
.topic-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.topic-name { font-size: 15px; font-weight: 600; }
.topic-stats { font-size: 13px; color: var(--ink-subtle); white-space: nowrap; }
.topic-desc { margin: 4px 0 0; font-size: 14px; color: var(--ink-muted); }
.asset-list { list-style: none; margin: 16px 0 0; padding: 16px 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.asset { display: flex; gap: 12px; }
.asset svg { width: 16px; height: 16px; margin-top: 2px; color: var(--ink-subtle); }
.asset-name { font-size: 14px; font-weight: 500; }
.asset-meta { font-size: 13px; color: var(--ink-subtle); }

.details-list { margin: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.details-row { display: grid; gap: 4px; padding: 14px 20px; font-size: 14px; }
.details-row + .details-row { border-top: 1px solid var(--border); }
.details-row dt { font-weight: 400; color: var(--ink-subtle); }
.details-row dd { margin: 0; }
@media (min-width: 576px) { .details-row { grid-template-columns: 200px 1fr; } }

.building-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
@media (min-width: 576px) { .building-cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .building-cards { grid-template-columns: repeat(3, 1fr); } }
.building-card { display: flex; flex-direction: column; height: 100%; overflow: hidden; transition: box-shadow 0.15s; }
.building-card:hover { box-shadow: var(--shadow-panel); }
.building-card .thumb { width: 100%; height: 144px; border-radius: 0; }
.building-card-body { flex: 1; display: flex; flex-direction: column; padding: 20px; }
.building-card-name { font-weight: 600; }
.building-card-meta { margin-top: 2px; font-size: 14px; color: var(--ink-muted); }
.building-card-stats { margin-top: auto; padding-top: 16px; font-size: 13px; color: var(--ink-subtle); }

/* Event form: type picker */
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 576px) { .type-grid { grid-template-columns: repeat(4, 1fr); } }
.type-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); font-size: 12px; color: var(--ink-muted); transition: border-color 0.15s, background-color 0.15s;
}
.type-option:hover { border-color: var(--border-strong); color: var(--ink); }
.type-option[aria-pressed="true"] { border-color: rgb(47 93 84 / 0.4); background: rgb(229 238 234 / 0.6); color: var(--ink); font-weight: 500; }
.type-option span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details-box { display: grid; gap: 16px; padding: 16px; border-radius: var(--radius-lg); background: var(--surface-muted); }
@media (min-width: 576px) { .details-box { grid-template-columns: 1fr 1fr; } .details-box .span-2 { grid-column: span 2; } }
.form-grid-date { display: grid; gap: 16px; }
@media (min-width: 576px) { .form-grid-date { grid-template-columns: 1fr 2fr; } }
.form-grid-address { display: grid; grid-template-columns: 1fr 2fr 72px; gap: 12px; }

/* ---------------------------------------------------------------------------------------------- */
/* Building photo and profile                                                                       */
/* ---------------------------------------------------------------------------------------------- */

.cover-wrap { position: relative; flex-shrink: 0; border-radius: var(--radius); overflow: hidden; }
.cover-wrap .building-cover { display: flex; }
.cover-edit {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: rgb(28 35 32 / 0.55); color: #fff; font-size: 12px; font-weight: 500;
  opacity: 0; transition: opacity 0.15s;
}
.cover-edit svg { width: 18px; height: 18px; }
.cover-wrap:hover .cover-edit, .cover-edit:focus-visible, .cover-edit.is-busy { opacity: 1; }
.cover-edit.is-busy { cursor: progress; }
.cover-edit.is-busy svg { animation: pulse 1s ease-in-out infinite; }
@media (hover: none) {
  /* Touch screens have no hover: keep a small camera badge visible. */
  .cover-edit { inset: auto 6px 6px auto; width: 28px; height: 28px; border-radius: 50%; opacity: 1; }
  .cover-edit span { display: none; }
  .cover-edit svg { width: 14px; height: 14px; }
}
@keyframes pulse { 50% { opacity: 0.4; } }
.building-meta .built { white-space: nowrap; }

.photo-block { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.photo-large { display: block; width: 100%; max-width: 480px; aspect-ratio: 3 / 2; height: auto; object-fit: cover; border-radius: var(--radius-lg); box-shadow: 0 0 0 1px var(--border); }
.thumb-placeholder.photo-large svg { width: 48px; height: 48px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-t.is-busy { opacity: 0.6; cursor: progress; }

.form-subtitle { margin: 8px 0 -4px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-subtle); }
.form-grid-2 { display: grid; gap: 16px; }
@media (min-width: 576px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } }
.facts-editor { display: flex; flex-direction: column; gap: 8px; }
.fact-row { display: grid; grid-template-columns: 2fr 3fr 36px; gap: 8px; align-items: center; }
.input-file { height: auto; padding: 8px 12px; }
