@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --ink: #1a2528;
  --muted: #647276;
  --faint: #97a2a5;
  --paper: #f2f0ea;
  --panel: #faf9f5;
  --line: #d8d8d2;
  --navy: #163f47;
  --navy-light: #dce7e7;
  --coral: #df654f;
  --shadow: 0 18px 45px rgba(26, 37, 40, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; overflow-x: clip; color: var(--ink); background: var(--paper); font-family: Manrope, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-header {
  min-height: 72px;
  padding: 0 clamp(24px, 4vw, 64px);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 12px; width: max-content; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 700; letter-spacing: -.03em; }
.brand-title::after { content: ":"; }
.brand-context { margin-left: -5px; color: var(--coral); font-family: "DM Mono", monospace; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .11em; }
.brand-symbol { display: flex; align-items: center; gap: 2px; width: 28px; height: 24px; }
.brand-symbol i { display: block; width: 3px; height: 12px; border-radius: 2px; background: var(--navy); }
.brand-symbol i:nth-child(2) { height: 22px; background: var(--coral); }
.brand-symbol i:nth-child(3) { height: 16px; }
.header-context { text-align: left; font-size: 12px; }
.header-context label { display: block; }
.context-label { margin-bottom: 2px; color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: .14em; }
.header-context select { width: auto; max-width: 260px; padding: 2px 22px 2px 0; border: 0; color: var(--ink); background-color: transparent; font-size: 12px; font-weight: 700; text-align: left; cursor: pointer; }
.collection-bar { min-height: 46px; position: relative; padding: 7px clamp(24px, 4vw, 64px) 8px; display: flex; align-items: flex-start; justify-content: center; background: var(--panel); border-bottom: 1px solid var(--line); }
.collection-picker, .collection-search { min-height: 34px; display: flex; align-items: center; gap: 12px; }
.collection-picker > div, .collection-search-field { display: flex; flex-direction: column; }
.collection-toggle { padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; font-size: 9px; font-weight: 700; }
.collection-search-toggle { width: 27px; height: 27px; padding: 0; display: inline-grid; place-items: center; font-size: 18px; line-height: 1; }
.collection-search-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.collection-search-toggle:hover, .collection-search-toggle:focus { color: var(--navy); background: var(--navy-light); outline: 0; }
.collection-search { margin: 0; padding: 0; }
.collection-search-field { position: relative; width: min(280px, 62vw); }
.collection-search input { width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; outline: 0; color: var(--ink); background: var(--panel); font-size: 12px; font-weight: 600; }
.collection-search input:focus { border-color: var(--navy); }
.collection-search-field:has(.collection-search-result) input { border-radius: 4px 4px 0 0; }
.collection-search-results { position: absolute; z-index: 20; left: 0; top: 100%; width: 100%; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 4px 4px; background: var(--panel); box-shadow: 0 12px 28px rgba(26, 37, 40, .12); }
.collection-search-results:empty { display: none; }
.collection-search-result { width: 100%; padding: 9px 12px; display: block; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; cursor: pointer; font-size: 11px; font-weight: 600; text-align: left; }
.collection-search-result:last-child { border-bottom: 0; }
.collection-search-result:hover, .collection-search-result:focus, .collection-search-result.active { background: var(--navy-light); outline: 0; }
.account-actions { justify-self: end; display: flex; gap: 8px; }
.account-actions .button { flex: 0 0 auto; white-space: nowrap; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.button { padding: 10px 16px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 700; }
.button.primary { color: white; background: var(--navy); }
.button.primary:hover { background: #0e3036; }
.button.secondary { border-color: var(--line); background: transparent; }

.workspace { padding: 26px clamp(24px, 5vw, 78px) 80px; }
.data-workspace { min-height: calc(100vh - 122px); padding: 52px clamp(24px, 5vw, 78px) 80px; }
.account-workspace { min-height: calc(100vh - 122px); padding: 52px clamp(24px, 5vw, 78px) 80px; }
.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 48px; max-width: 1500px; margin: 0 auto 34px; }
.eyebrow { margin: 0 0 9px; color: var(--coral); font-family: "DM Mono", monospace; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .13em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(34px, 4vw, 52px); line-height: 1.05; letter-spacing: -.045em; }
.intro { max-width: 660px; margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.legend { display: flex; gap: 24px; padding-bottom: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 3px #f4d7d1; }
.legend-bar { width: 24px; height: 7px; border-radius: 2px; background: var(--navy); }

.chart-panel { max-width: 1500px; margin: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.chart-toolbar { min-height: 68px; padding: 12px 18px 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.range-copy span { display: block; margin-bottom: 2px; color: var(--faint); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; }
.range-copy strong { font-family: "DM Mono", monospace; font-size: 14px; font-weight: 500; }
.toolbar-actions { display: flex; gap: 10px; }
.range-button { height: 34px; padding: 0 12px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; }
.range-button:hover { background: #ebeae5; }
.range-button-icon { color: var(--coral); font-size: 15px; }
.control-group { display: flex; height: 34px; align-items: center; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.control-group button { min-width: 34px; height: 100%; border: 0; border-right: 1px solid var(--line); background: transparent; cursor: pointer; }
.control-group button:last-child { border: 0; }
.control-group button:hover { background: #ebeae5; }
.control-group span { padding: 0 11px; color: var(--muted); font-size: 10px; border-right: 1px solid var(--line); }

.timeline-frame { overflow: auto; }
.timeline-chart { min-width: 1080px; position: relative; }
.time-axis { height: 68px; display: grid; grid-template-columns: 220px 1fr; border-bottom: 1px solid var(--line); background: #f0efea; }
.axis-title { padding: 27px 24px; color: var(--faint); font-family: "DM Mono", monospace; font-size: 9px; text-transform: uppercase; letter-spacing: .12em; border-right: 1px solid var(--line); }
.tick-space { position: relative; margin-right: 32px; }
.tick-label { position: absolute; left: var(--position); top: 26px; transform: translateX(-50%); color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.chart-body { display: grid; grid-template-columns: 220px 1fr; }
.lane-labels { border-right: 1px solid var(--line); }
.lane-label { height: 66px; padding: 14px 18px 10px 24px; border-bottom: 1px solid #e5e4df; overflow: hidden; }
.lane-label strong, .lane-label span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-label strong { margin-bottom: 3px; font-size: 11px; }
.lane-label span { color: var(--faint); font-family: "DM Mono", monospace; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.plot { position: relative; margin-right: 32px; }
.grid-line { position: absolute; z-index: 0; left: var(--position); top: 0; bottom: 0; width: 1px; background: #e2e2dc; }
.timeline-event { display: block; position: relative; z-index: 1; width: 100%; height: 66px; padding: 0; border: 0; border-bottom: 1px solid #e5e4df; background: transparent; cursor: pointer; text-align: left; }
.event-shape { position: absolute; left: var(--left); top: 27px; width: var(--width); height: 12px; min-width: 12px; }
.timeline-event.duration .event-shape { border-radius: 3px; background: var(--navy); box-shadow: 0 3px 8px rgba(22,63,71,.18); transition: filter .2s, transform .2s; transform-origin: left center; }
.timeline-event.duration .event-shape::before, .timeline-event.duration .event-shape::after { content: ""; position: absolute; top: 3px; width: 1px; height: 6px; background: rgba(255,255,255,.55); }
.timeline-event.duration .event-shape::before { left: 5px; }
.timeline-event.duration .event-shape::after { right: 5px; }
.timeline-event.point .event-shape { width: 11px; height: 11px; border: 3px solid #f8eeea; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 1px var(--coral); transform: translateX(-50%); }
.timeline-event:hover .event-shape { filter: brightness(1.18); }
.timeline-event:focus-visible { outline: 2px solid var(--coral); outline-offset: -3px; }
.event-mobile-copy { display: none; }
.chart-hint { margin: 0; padding: 12px 24px; color: var(--faint); font-size: 9px; border-top: 1px solid var(--line); }
.loading, .empty { padding: 60px; color: var(--muted); text-align: center; font-size: 13px; }

.detail-panel { position: fixed; z-index: 10; top: 0; right: 0; bottom: 0; width: min(420px, 90vw); padding: 90px 48px; background: var(--navy); color: white; box-shadow: -20px 0 60px rgba(20,35,38,.2); transform: translateX(105%); transition: transform .3s ease; }
.detail-panel.open { transform: translateX(0); }
.detail-close { position: absolute; top: 28px; right: 30px; color: white; border: 0; background: transparent; font-size: 28px; cursor: pointer; }
.detail-panel .eyebrow { color: #f39a88; }
.detail-panel h2 { margin-bottom: 14px; font-size: 34px; line-height: 1.15; letter-spacing: -.035em; }
.detail-date { color: #b8cccc; font-family: "DM Mono", monospace; font-size: 11px; line-height: 1.6; }
.detail-description { margin-top: 36px; color: #dbe5e4; font-size: 14px; line-height: 1.8; }
.detail-edit { margin-top: 24px; color: var(--navy); background: white; }

.data-heading { max-width: 1500px; margin: 0 auto 34px; display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.data-heading h1 { margin-bottom: 9px; }
.data-heading-actions { display: flex; gap: 9px; flex-shrink: 0; }
.data-panel { max-width: 1500px; margin: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.data-summary { display: grid; grid-template-columns: 2fr 1fr 1fr; border-bottom: 1px solid var(--line); }
.data-summary > div { min-height: 74px; padding: 17px 22px; border-right: 1px solid var(--line); }
.data-summary > div:last-child { border-right: 0; }
.data-summary span, .data-summary strong { display: block; }
.data-summary span { margin-bottom: 5px; color: var(--faint); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.data-summary strong { font-size: 13px; }
.data-table-wrap { overflow-x: auto; }
.table-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; }
.data-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.data-table th, .data-table td { padding: 15px 20px; border-bottom: 1px solid #e5e4df; text-align: left; }
.data-table th { color: var(--faint); background: #f0efea; font-family: "DM Mono", monospace; font-size: 9px; font-weight: 500; text-transform: uppercase; letter-spacing: .09em; }
.data-table td { color: var(--muted); font-size: 11px; }
.data-table td:first-child { width: 38%; color: var(--ink); font-weight: 700; }
.reused-label { display: block; margin-top: 3px; color: var(--coral); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f4f3ee; }
.table-type { display: inline-block; padding: 4px 7px; border-radius: 3px; color: var(--navy); background: var(--navy-light); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.table-edit { float: right; border: 1px solid var(--line); border-radius: 3px; padding: 6px 10px; color: var(--ink); background: transparent; cursor: pointer; font-size: 9px; font-weight: 700; }
.table-edit:hover { border-color: var(--navy); }
.collection-danger { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: #f6f1ed; }
.collection-danger strong, .collection-danger span { display: block; }
.collection-danger strong { margin-bottom: 2px; font-size: 10px; }
.collection-danger span { color: var(--muted); font-size: 9px; }
.danger-button { color: #9b3728; border-color: #d8b5ad; background: transparent; }
.danger-button:hover { color: white; background: #9b3728; }
.danger-button:disabled { opacity: .4; cursor: not-allowed; color: var(--muted); background: transparent; }
.collection-range-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.boundary-field legend { padding: 0 5px; color: var(--ink); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.reuse-dialog { width: min(700px, calc(100vw - 30px)); }
.reuse-dialog-content { padding: 34px; }
.reuse-list { min-height: 82px; max-height: 440px; margin-top: 20px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; }
.reuse-item { padding: 15px 16px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); }
.reuse-item:last-child { border-bottom: 0; }
.reuse-item strong, .reuse-item span { display: block; }
.reuse-item strong { margin-bottom: 3px; font-size: 11px; }
.reuse-item span { color: var(--muted); font-size: 9px; }
.reuse-empty { padding: 35px; color: var(--muted); text-align: center; font-size: 11px; }
.account-heading { max-width: 1100px; margin: 0 auto 34px; display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.account-grid { max-width: 1100px; margin: auto; display: grid; grid-template-columns: .8fr 1.2fr; gap: 20px; }
.account-panel { padding: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow); }
.account-panel h2 { margin-bottom: 24px; font-size: 25px; letter-spacing: -.03em; }
.profile-details { margin: 0; }
.profile-details div { padding: 15px 0; border-bottom: 1px solid var(--line); }
.profile-details div:last-child { border-bottom: 0; }
.profile-details dt { margin-bottom: 4px; color: var(--faint); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.profile-details dd { margin: 0; font-size: 13px; font-weight: 700; }
.password-form { padding: 0; box-shadow: none; }
.form-success { min-height: 17px; margin: -7px 0; color: #397157; font-size: 11px; }
.status-banner { margin: 0 0 22px; padding: 15px 18px; border: 1px solid #d69473; border-radius: 4px; color: #713c29; background: #fff2e9; font-size: 12px; font-weight: 700; line-height: 1.55; }
.status-banner:empty { display: none; }
.system-notices { margin: 14px clamp(24px, 4vw, 64px) 0; }

dialog { width: min(560px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 6px; color: var(--ink); background: var(--panel); box-shadow: 0 28px 80px rgba(18,35,39,.25); }
dialog::backdrop { background: rgba(18,35,39,.62); backdrop-filter: blur(3px); }
form { padding: 34px; display: grid; gap: 20px; }
.verification-content { padding: 34px; display: grid; gap: 20px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; }
.dialog-heading h2 { margin-bottom: 0; font-size: 32px; letter-spacing: -.035em; }
.close-button { border: 0; color: var(--muted); background: none; font-size: 26px; cursor: pointer; }
label { display: grid; gap: 7px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
input, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); background: white; text-transform: none; letter-spacing: normal; }
select { width: 100%; padding: 11px 30px 11px 12px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); background: white; }
textarea { resize: vertical; }
small { color: var(--faint); font-size: 8px; font-weight: 500; text-transform: none; letter-spacing: normal; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.user-actions { display: flex; justify-content: flex-end; gap: 10px; }
.date-fieldset { margin: 0; padding: 15px; border: 1px solid var(--line); border-radius: 4px; }
.date-fieldset legend { padding: 0 5px; color: var(--ink); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.historical-date { display: grid; grid-template-columns: minmax(95px, 1fr) 80px 88px 70px; gap: 9px; transition: opacity .2s; }
.historical-date.disabled { opacity: .38; }
.end-date-toggle { margin-bottom: 15px; }
.end-date-toggle span { display: grid; gap: 2px; }
.approximate-toggle { margin-top: 12px; display: flex; grid-template-columns: none; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.approximate-toggle input { width: 14px; height: 14px; margin: 0; accent-color: var(--navy); }
.timeline-event.approximate.duration .event-shape { background: repeating-linear-gradient(135deg, var(--navy), var(--navy) 6px, #53757b 6px, #53757b 10px); }
.timeline-event.approximate.point .event-shape { box-shadow: 0 0 0 1px var(--coral), 0 0 0 5px rgba(223,101,79,.14); }
.dialog-actions { display: flex; justify-content: end; gap: 9px; }
.form-intro { margin: -6px 0 2px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.boundary-field { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 4px; }
.boundary-toggle { display: flex; grid-template-columns: none; align-items: center; gap: 9px; margin-bottom: 15px; font-size: 11px; cursor: pointer; }
.boundary-toggle input { width: 15px; height: 15px; margin: 0; accent-color: var(--navy); }
.year-entry { display: grid; grid-template-columns: 1fr 100px; gap: 12px; }
.form-error { min-height: 17px; margin: -7px 0; color: #a13e2d; font-size: 11px; }
.split-actions { justify-content: space-between; align-items: center; }
.split-actions > div { display: flex; gap: 9px; }
.text-button { padding-left: 0; color: var(--muted); background: transparent; }

@media (orientation: portrait), (max-width: 850px) {
  .app-header { display: flex; }
  .workspace { padding: 24px 18px 60px; }
  .data-workspace { padding: 36px 18px 60px; }
  .account-workspace { padding: 36px 18px 60px; }
  .workspace-heading { align-items: start; flex-direction: column; gap: 24px; }
  .data-heading { align-items: start; flex-direction: column; }
  .data-summary { grid-template-columns: 1fr; }
  .data-summary > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .account-heading { align-items: start; flex-direction: column; }
  .account-grid { grid-template-columns: 1fr; }
  .collection-range-fields { grid-template-columns: 1fr; }
  .legend { padding: 0; }
  .chart-toolbar { align-items: start; flex-direction: column; }
  .timeline-chart { min-width: 0; }
  .time-axis { display: none; }
  .chart-body { display: block; }
  .lane-labels { display: none; }
  .plot { min-height: 760px; margin: 0; padding: 28px 20px 28px 86px; }
  .grid-line { display: none; }
  .plot::before { content: ""; position: absolute; left: 52px; top: 36px; bottom: 36px; width: 2px; background: var(--line); }
  .timeline-event { position: absolute; left: 0; top: var(--left); width: 100%; height: var(--width); min-height: 54px; padding: 0 20px 0 86px; border: 0; overflow: visible; }
  .event-shape { left: 46px; top: 9px; width: 14px !important; height: max(var(--width), 14px); min-height: 14px; transform: none !important; }
  .timeline-event.duration .event-shape { width: 12px !important; }
  .timeline-event.point .event-shape { width: 13px !important; height: 13px; left: 46px; }
  .event-mobile-copy { display: block; }
  .event-mobile-copy strong, .event-mobile-copy small { display: block; }
  .event-mobile-copy strong { margin-bottom: 3px; font-size: 11px; }
  .event-mobile-copy small { font-family: "DM Mono", monospace; font-size: 8px; line-height: 1.5; }
  .chart-hint { display: none; }
}

@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .app-header { align-items: stretch; flex-direction: column; gap: 10px; padding: 14px 18px; }
  .collection-bar { padding-left: 18px; padding-right: 18px; }
  .brand { font-size: 16px; }
  .brand-context { font-size: 9px; }
  .account-actions { justify-self: stretch; flex-wrap: wrap; }
  .account-actions .button { flex: 1 1 auto; padding: 8px 10px; }
  .field-row { grid-template-columns: 1fr; }
  .historical-date { grid-template-columns: 1fr 80px; }
  .toolbar-actions { width: 100%; justify-content: space-between; }
  .legend { gap: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
