:root {
  color-scheme: dark;
  --bg: #061118;
  --sidebar: #07151d;
  --panel: #091922;
  --panel-2: #0d202a;
  --line: #183440;
  --line-bright: #1f5159;
  --text: #eef7f8;
  --muted: #a3b8c2;
  --teal: #31d5c6;
  --accent: var(--teal);
  --teal-dark: #0c6e68;
  --warning: #f6c453;
  --danger: #ff7373;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 11px; min-height: 88px; padding: 0 18px; color: var(--text); text-decoration: none; border-bottom: 1px solid rgba(24, 52, 64, .5); }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--teal-dark); border-radius: 8px; color: var(--teal); background: #0b292e; font-size: 12px; font-weight: 850; }
.brand b, .brand small { display: block; }
.brand b { font-size: 14px; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.side-nav { display: grid; gap: 4px; padding: 20px 8px; }
.side-nav a { min-height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 7px; color: #8aa0aa; text-decoration: none; font-size: 12px; font-weight: 650; }
.side-nav a > span { width: 18px; text-align: center; color: #7d98a3; font-size: 15px; }
.side-nav a > small { margin-left: auto; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.side-nav a.active { border-color: #164650; color: #dffcf8; background: #0a282d; }
.side-nav a.active > span { color: var(--teal); }
.privacy-note { margin: auto 12px 12px; padding: 14px; display: flex; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: #0a1c25; }
.privacy-note > span { color: var(--teal); }
.privacy-note b, .privacy-note small, .user-card b, .user-card small { display: block; }
.privacy-note b, .user-card b { font-size: 12px; }
.privacy-note small, .user-card small { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.user-card { min-height: 62px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); }
.user-card > span { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 6px; color: #bff9f3; background: #11323a; font-size: 12px; font-weight: 800; }

.workspace { min-width: 0; }
.page-header { min-height: 130px; max-width: 1180px; margin: 0 auto; padding: 32px 30px 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
h1 { margin: 7px 0 0; font-size: 30px; letter-spacing: -.035em; }
h2 { margin: 5px 0 0; font-size: 18px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.project-picker select { width: 245px; }
input, select { min-height: 44px; padding: 0 12px; border: 1px solid #365460; border-radius: 7px; color: var(--text); background: #0a1a23; }
input:focus, select:focus { border-color: var(--teal-dark); box-shadow: 0 0 0 3px rgba(49, 213, 198, .08); }
.button { min-height: 42px; padding: 9px 16px; border: 1px solid #365460; border-radius: 7px; color: var(--text); background: #0a1a23; font-size: 14px; font-weight: 650; }
.button:hover { border-color: #35606a; }
.button.primary { border-color: #39d5c7; color: #03201e; background: var(--teal); }
.button.primary:hover { background: #5de2d6; }
.button.ghost { background: transparent; }
.button.danger { border-color: #62333a; color: #ffb0b0; background: #26171c; }
.button:disabled { cursor: not-allowed; opacity: .45; }

.page-content { max-width: 1180px; margin: 0 auto; padding: 0 30px 48px; }
.action-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; }
.action-card { min-height: 106px; padding: 18px; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 14px; text-align: left; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); background: var(--panel); }
.action-card:hover, .action-card.featured { border-color: var(--line-bright); background: #0a2028; }
.action-card b, .action-card small { display: block; }
.action-card b { font-size: 16px; }
.action-card small { margin-top: 7px; color: var(--muted); font-size: 12px; }
.action-card i { color: var(--muted); font-style: normal; }
.action-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 8px; color: var(--teal); background: #0a3436; font-size: 18px; }
.action-icon.neutral { color: #bacbd0; background: #142630; }
.metric-grid { margin: 12px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric-grid article { min-height: 100px; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.metric-grid small, .metric-grid strong, .metric-grid span { display: block; }
.metric-grid small { color: #87a2ad; font-size: 12px; font-weight: 700; }
.metric-grid strong { margin: 11px 0 5px; font-size: 20px; }
.metric-grid span { color: var(--muted); font-size: 12px; }
.panel { margin-top: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.panel-heading { min-height: 66px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(24, 52, 64, .72); }
.subtle { color: var(--muted); font-size: 12px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 16px; text-align: left; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 13px 16px; border-top: 1px solid rgba(24, 52, 64, .72); color: #a8bdc5; }
td b { color: var(--text); font-size: 12px; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.status { display: inline-flex; padding: 4px 8px; border: 1px solid #3c5f49; border-radius: 999px; color: #a6ebbc; background: #14291d; font-size: 12px; text-transform: capitalize; }
.status.withdrawn { border-color: #526271; color: #cad4dc; background: #18232d; }
.status.uploading, .status.draft { border-color: #5a5231; color: #f5d675; background: #292315; }
.status-actions { display: flex; align-items: center; gap: 8px; }
.status-actions .button { min-height: 36px; padding: 6px 10px; white-space: nowrap; }
.empty { padding: 24px 16px; color: var(--muted); font-size: 12px; text-align: center; }
.link-list { display: grid; }
.link-row { min-height: 64px; padding: 12px 16px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; border-top: 1px solid rgba(24, 52, 64, .72); }
.link-row:first-child { border-top: 0; }
.link-row > span { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 6px; color: var(--teal); background: #0b2d32; }
.link-row b, .link-row small { display: block; }
.link-row b { font-size: 12px; }
.link-row small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.link-actions { display: flex; align-items: center; gap: 8px; }
.link-actions button { min-height: 30px; padding: 0 10px; }
.view-panel { margin-top: 0; }
.project-directory { padding: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.project-card { min-height: 132px; padding: 16px; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); border-radius: 9px; text-align: left; color: var(--text); background: #081820; }
.project-card:hover, .project-card.selected { border-color: var(--line-bright); background: #0a252d; }
.project-card b { margin-top: 13px; color: var(--teal); font-size: 12px; }
.project-card strong { margin-top: 5px; font-size: 14px; }
.project-card small { margin-top: auto; padding-top: 16px; color: var(--muted); font-size: 12px; text-transform: capitalize; }
.empty-state { min-height: 330px; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-state h2 { margin-top: 16px; font-size: 20px; }
.empty-state p { margin: 10px 0 2px; color: #9aafb7; font-size: 12px; }
.empty-state .button { margin-top: 22px; display: inline-flex; align-items: center; text-decoration: none; }

.toast { position: fixed; z-index: 100; top: 18px; left: 50%; transform: translateX(-50%); max-width: min(520px, calc(100vw - 32px)); padding: 11px 16px; border: 1px solid #23515a; border-radius: 8px; color: #d6fbf7; background: #0b2c32; box-shadow: 0 15px 45px rgba(0,0,0,.35); font-size: 12px; }
.toast[data-tone="error"] { border-color: #75414a; color: #ffd0d0; background: #321b21; }
dialog { width: min(600px, calc(100vw - 28px)); padding: 0; border: 1px solid #23424e; border-radius: 12px; color: var(--text); background: var(--panel); box-shadow: 0 30px 80px rgba(0,0,0,.55); }
dialog.wide-dialog { width: min(860px, calc(100vw - 28px)); }
#detailsDialog { width:min(860px,calc(100vw - 28px)); }
#detailsDialog #detailDescription { min-height:150px;resize:vertical;line-height:1.5; }
dialog#createJobDialog { width:min(820px,calc(100vw - 28px));max-width:820px; }
:is(#detailName,#newJobName,#projectName){min-height:60px;field-sizing:content;resize:vertical;line-height:1.5;overflow-wrap:anywhere;}
:is(#detailDescription,#jobDescription,#projectDescription){field-sizing:content;min-height:140px;resize:vertical;line-height:1.5;}
dialog::backdrop { background: rgba(1, 9, 13, .76); backdrop-filter: blur(3px); }
.dialog-card { padding: 20px; }
.dialog-heading { margin-bottom: 20px; display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { font-size: 20px; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 6px; color: #77919b; background: #10232c; font-size: 20px; }
.field { display: grid; gap: 7px; margin-top: 13px; }
#projectForm [hidden] { display: none; }
.organization-choice { margin: 0; padding: 0; border: 0; min-width: 0; }
.organization-choice legend { color: #8ea6af; font-size: 12px; font-weight: 700; }
.organization-options { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 10px; }
.organization-options label { display: flex; align-items: center; gap: 7px; min-height: 32px; white-space: nowrap; font-size: 12px; cursor: pointer; }
#projectForm .organization-options input { flex: 0 0 16px; min-height: 0; width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--teal); }
.organization-options label:has(input:disabled) { opacity: .5; cursor: default; }
.field > span { color: #8ea6af; font-size: 12px; font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.dialog-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 8px; }
.dialog-copy { color: var(--muted); font-size: 12px; line-height: 1.6; }
.copy-field { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.copy-field input { width: 100%; }
.submission-file-list { display: grid; gap: 10px; }
.submission-file { padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #081820; }
.submission-file-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.submission-file-heading b, .submission-file-heading small { display: block; }
.submission-file-heading b { overflow-wrap: anywhere; font-size: 12px; }
.submission-file-heading small { margin-top: 5px; color: var(--muted); font-size: 12px; text-transform: capitalize; }
.layout-editor { margin-top: 13px; padding-top: 13px; border-top: 1px solid rgba(24, 52, 64, .72); }
.layout-grid { display: grid; grid-template-columns: 1.25fr 1fr 110px; gap: 9px; }
.layout-grid .field { margin-top: 0; }
.layout-actions { margin-top: 11px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.layout-actions small { color: var(--muted); font-size: 12px; }
.coordinate-panel { margin: 14px 0 10px; padding: 14px; border: 1px solid #28515b; border-radius: 9px; background: #0a2029; }
.coordinate-heading, .coordinate-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.coordinate-heading h3 { margin-top: 4px; font-size: 13px; }
.coordinate-heading p, .coordinate-summary small { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.coordinate-summary { margin-top: 12px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 7px; background: #081820; }
.coordinate-summary b, .coordinate-summary small { display: block; }
.coordinate-status { flex: 0 0 auto; padding: 4px 8px; border: 1px solid #554d2d; border-radius: 999px; color: #d5bd68; background: #252113; font-size: 12px; white-space: nowrap; }
.coordinate-status.ready { border-color: #355e48; color: #a6ebbc; background: #14291d; }
.coordinate-editor { margin-top: 11px; }
.coordinate-editor > summary, .source-coordinate > summary, .advanced-reference > summary { cursor: pointer; color: #9db3bb; font-size: 12px; }
.spatial-grid { margin-top: 11px; display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 9px; }
.spatial-grid .field { margin-top: 0; }
.advanced-reference { margin-top: 10px; }
.advanced-reference .field { margin-top: 9px; }
.advanced-reference textarea { min-height: 70px; resize: vertical; }
.source-coordinate { margin-top: 13px; padding-top: 13px; border-top: 1px solid rgba(24, 52, 64, .72); }
.source-coordinate-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.source-coordinate-body { margin-top: 10px; }
.source-coordinate-body > .field { margin-top: 0; }
.source-mode-copy { margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.tabular-preview { margin-top: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #06151c; }
.preview-heading { padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.preview-heading b { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.preview-heading small, .preview-message { color: var(--muted); font-size: 12px; }
.preview-scroll { max-height: 250px; overflow: auto; }
.preview-table { min-width: 100%; width: max-content; }
.preview-table th, .preview-table td { min-width: 105px; max-width: 240px; padding: 7px 9px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid rgba(24, 52, 64, .65); white-space: nowrap; font-size: 12px; }
.preview-table tr.preview-header td { color: #9b8c57; background: #201d13; }
.preview-warning { padding: 8px 10px; border-top: 1px solid #554d2d; color: #d5bd68; background: #252113; font-size: 12px; }
.preview-message { padding: 15px 10px; }

.upload-body { min-height: 100vh; background: radial-gradient(circle at 50% -20%, #10303b 0, var(--bg) 45%); }
.upload-header { height: 74px; padding: 0 max(24px, calc((100vw - 920px) / 2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(6,17,24,.88); backdrop-filter: blur(12px); }
.upload-header .brand { min-height: 0; padding: 0; border: 0; }
.secure-note { color: #6f8b96; font-size: 12px; }
.secure-note span { color: var(--teal); }
.upload-main { width: min(920px, calc(100% - 32px)); margin: 42px auto 70px; }
.upload-intro { text-align: center; }
.upload-intro h1 { font-size: 32px; }
.upload-intro p { margin: 10px auto 0; color: #78939d; font-size: 12px; }
.upload-card { margin-top: 26px; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: rgba(9,25,34,.94); box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.identity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drop-zone { min-height: 190px; margin-top: 20px; padding: 28px; display: grid; place-items: center; text-align: center; border: 1px dashed #2a5661; border-radius: 12px; background: #081820; transition: .15s; }
.drop-zone.dragging { border-color: var(--teal); background: #0a252b; }
.drop-zone-icon { display: grid; width: 48px; height: 48px; margin: 0 auto 13px; place-items: center; border-radius: 12px; color: var(--teal); background: #0c3034; font-size: 23px; }
.drop-zone h2 { font-size: 15px; }
.drop-zone p { margin: 7px 0 16px; color: var(--muted); font-size: 12px; }
.picker-actions { display: flex; justify-content: center; gap: 8px; }
.file-summary { margin-top: 14px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 8px; background: #081820; font-size: 12px; }
.file-summary b { font-size: 12px; }
.file-list { max-height: 260px; margin-top: 10px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.file-row { min-height: 48px; padding: 8px 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; border-top: 1px solid rgba(24, 52, 64, .7); }
.file-row:first-child { border-top: 0; }
.file-row b, .file-row small { display: block; }
.file-row b { overflow: hidden; text-overflow: ellipsis; color: #cfe0e4; font-size: 12px; white-space: nowrap; }
.file-row small { margin-top: 4px; color: #5f7a84; font-size: 12px; }
.upload-actions { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.upload-actions > div { display: flex; gap: 8px; }
.progress-shell { margin-top: 20px; }
.progress-meta { margin-bottom: 7px; display: flex; justify-content: space-between; color: #78949e; font-size: 12px; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #12262e; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #15a89d, var(--teal)); transition: width .18s ease; }
.resume-note { margin-top: 16px; padding: 11px 13px; border: 1px solid #554d2d; border-radius: 8px; color: #d5bd68; background: #252113; font-size: 12px; line-height: 1.5; }
.success-card { padding: 40px 24px; text-align: center; }
.success-icon { display: grid; width: 58px; height: 58px; margin: 0 auto 16px; place-items: center; border-radius: 50%; color: #06201c; background: var(--teal); font-size: 25px; }
.success-icon.invalid { background: #68404a; color: #ffd5d5; }
.success-card p { color: #78949e; font-size: 12px; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .side-nav, .privacy-note, .user-card { display: none; }
  .brand { min-height: 66px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .project-picker { flex: 1 1 100%; }
  .project-picker select { width: 100%; }
  .action-grid, .metric-grid { grid-template-columns: 1fr; }
  .project-directory { grid-template-columns: 1fr; }
  .page-content, .page-header { padding-left: 16px; padding-right: 16px; }
  .identity-grid, .field-row, .field-row.three { grid-template-columns: 1fr; }
  .layout-grid, .spatial-grid { grid-template-columns: 1fr; }
  .upload-header { padding: 0 16px; }
  .secure-note { display: none; }
}

.reference-validation { margin: 12px 0; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--text); overflow-wrap: anywhere; }
.reference-validation:empty { display: none; }
.project-integration-actions { display:flex; justify-content:flex-end; gap:10px; padding:12px 32px 0; flex-wrap:wrap; }
.job-card { border:1px solid var(--line); border-radius:12px; padding:20px; margin:16px 0; overflow-wrap:anywhere; }
.job-heading { display:flex; justify-content:space-between; gap:16px; align-items:center; }
.job-card progress { width:100%; accent-color:var(--accent); }
.job-card pre { white-space:pre-wrap; max-height:280px; overflow:auto; font-size:12px; }
.job-error, #jobError, #detailError { color:#ffb7ad; white-space:pre-wrap; }
.processing-input { border-bottom:1px solid var(--line); padding:10px 0; }
.crs-search { margin:12px 0; }
[data-crs-results] { max-height:230px; overflow:auto; font-size:12px; }
.crs-option { display:block; width:100%; text-align:left; margin-top:5px; padding:9px; color:var(--text); background:var(--panel); border:1px solid var(--line); border-radius:6px; cursor:pointer; }
.crs-option:hover { border-color:var(--accent); }
.reference-validation p { margin: 6px 0; line-height: 1.5; }
.draft-status { color: var(--warning); font-size: 12px; margin: 8px 0; }
.draft-status:empty { display: none; }
/* Keep wide tables scrollable inside the review card on ordinary and small screens. */
.submission-file, .field, .layout-editor, .source-coordinate-body { min-width: 0; }
.dialog-card input, .dialog-card select, .dialog-card textarea { width: 100%; min-width: 0; }
.coordinate-summary { overflow-wrap: anywhere; }
.reference-validation details { margin-top: 8px; }
.reference-validation summary { cursor: pointer; color: var(--muted); }
.layout-editor > small { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
@media (max-width: 820px) {
  .coordinate-heading, .submission-file-heading, .layout-actions, .preview-heading { flex-wrap: wrap; }
  .dialog-card { padding: 14px; }
}
