:root {
    --bg: #f6f7f9;
    --fg: #17202a;
    --muted: #5c6670;
    --line: #d8dee5;
    --panel: #ffffff;
    --accent: #176b87;
    --accent-dark: #114f63;
    --danger: #a83232;
}

.home-upload-dropzone {
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.home-upload-dropzone.is-dragover {
    border-color: var(--accent);
    background-color: rgba(23, 107, 135, 0.08);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.upload-toast-root {
    position: fixed;
    right: 44px;
    bottom: 44px;
    z-index: 80;
    width: min(420px, calc(100vw - 88px));
    pointer-events: none;
}

.upload-toast-root[hidden] {
    display: none !important;
}

.upload-toast {
    position: relative;
    box-sizing: border-box;
    pointer-events: auto;
    min-height: 88px;
    padding: 18px 48px 18px 20px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: #fff;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.upload-toast-root[data-state="loading"] .upload-toast {
    background: #edf6fa;
    border-color: #176b8c;
}

.upload-toast-root[data-state="success"] .upload-toast {
    background: #ecf8f0;
    border-color: #73bf8c;
}

.upload-toast-root[data-state="error"] .upload-toast {
    background: #fdf0f0;
    border-color: #db7d7d;
}

.upload-toast__close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent !important;
    background-color: transparent !important;
    color: #526173;
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.15s ease;
}

.upload-toast__close:hover,
.upload-toast__close:focus,
.upload-toast__close:focus-visible,
.upload-toast__close:active {
    background: transparent !important;
    background-color: transparent !important;
    border-color: transparent;
    color: #526173;
    opacity: 0.55;
    outline: none;
    box-shadow: none;
}

.upload-toast__filename {
    margin: 0 0 10px;
    color: #1f2630;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    word-break: break-word;
}

.upload-toast__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 16px;
}

.upload-toast__status {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
}

.upload-toast-root[data-state="loading"] .upload-toast__status {
    color: #176b8c;
}

.upload-toast-root[data-state="success"] .upload-toast__status {
    color: #1a7338;
}

.upload-toast-root[data-state="error"] .upload-toast__status {
    color: #b81f1f;
}

.upload-toast__progress {
    flex: 0 0 132px;
    width: 132px;
}

.upload-toast__progress[hidden] {
    display: none !important;
}

.upload-toast__progress-track {
    height: 6px;
    overflow: hidden;
    border-radius: 3px;
    background: #c7dbe5;
}

.upload-toast__progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #176b8c;
    transition: width 0.2s linear;
}

.upload-toast__open {
    display: inline-block;
    margin-top: 10px;
    color: #176b8c;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: underline;
    text-underline-position: from-font;
}

.upload-toast__open[hidden] {
    display: none !important;
}

.upload-toast__open:hover {
    color: #114f63;
}

.clear-selected-file {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    background-color: transparent;
    color: #9aa3ad;
    cursor: pointer;
    transition: color 0.15s ease;
}

.clear-selected-file:hover,
.clear-selected-file:focus,
.clear-selected-file:focus-visible,
.clear-selected-file:active {
    background: transparent;
    background-color: transparent;
    border-color: transparent;
    color: #4b5563;
    outline: none;
    box-shadow: none;
}

.create-project-dialog {
    padding: 1rem;
    background: transparent;
    border: 0;
}

.create-project-dialog::backdrop {
    background: rgba(0, 0, 0, 0.3);
}

.create-project-dialog__panel {
    border-radius: 20px;
    border: 1px solid var(--line);
    padding: 2rem 1.75rem;
    overflow: hidden;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--accent);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand {
    color: var(--fg);
    font-weight: 700;
    text-decoration: none;
}

.site-header nav,
.actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.container {
    width: min(1180px, calc(100% - 2rem));
    margin: 1.5rem auto;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

h1 {
    margin: 0 0 0.5rem;
    font-size: 1.8rem;
}

.muted,
.empty {
    color: var(--muted);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.25rem;
}

.narrow {
    max-width: 520px;
}

form label {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

input,
select,
button,
.button {
    min-height: 2.35rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    padding: 0.45rem 0.7rem;
    font: inherit;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--accent-dark);
}

.sortable-header,
.sortable-header:hover {
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    color: inherit;
}

.secondary {
    background: #fff;
    color: var(--accent);
}

.danger {
    color: var(--danger);
}

button.danger,
.button.danger {
    border-color: var(--danger);
}

.inline-form {
    margin: 0;
}

.link-button {
    min-height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
}

.messages {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.message {
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.message.success {
    border-color: #6aa36f;
}

.message.error {
    border-color: var(--danger);
}

.filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 0.85rem;
    align-items: end;
    margin-bottom: 1rem;
}

.filters fieldset {
    grid-column: 1 / -1;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.8rem;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.4rem 0.8rem;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}

.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    background: #eef2f4;
}

.sheet-table-wrap {
    max-height: calc(100vh - 190px);
}

.sheet-table {
    width: max-content;
    min-width: 100%;
    table-layout: fixed;
    font-size: 0.88rem;
}

.sheet-table th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.sheet-table td,
.sheet-table th {
    min-width: 3.5rem;
    max-width: 24rem;
    height: 1.85rem;
    padding: 0.32rem 0.45rem;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.sheet-table td {
    background: #fff;
    user-select: text;
}

.sheet-table td.merged {
    background: #f7fafb;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
}

.sheet-table td.empty-cell {
    background: #fbfcfd;
}

.sheet-table td.formula-cell {
    color: var(--muted);
}

.sheet-table td.editable-cell {
    background: #fffdf4;
}

.sheet-table input {
    width: 100%;
    min-width: 4rem;
    height: 1.8rem;
    min-height: 1.8rem;
    padding: 0.2rem 0.35rem;
}

.row-action-col-template,
.row-number-col-template {
    width: 3rem;
}

.row-action-col,
.row-number-col {
    min-width: 2.25rem !important;
    max-width: 2.75rem !important;
    text-align: center;
    white-space: nowrap !important;
}

.row-action-col {
    position: sticky;
    right: 0;
    z-index: 3;
    background: var(--panel);
}

.row-number-col {
    position: sticky;
    left: 0;
    z-index: 3;
}

.has-actions .row-number-col {
    left: 3rem;
}

td.row-action-col {
    background: var(--panel);
}

.sheet-table tbody .row-number-col {
    background: #eef2f4;
    color: var(--muted);
    font-weight: 600;
}

.editing-row td,
.editing-row th {
    background: #fff8df;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    min-width: 1.35rem;
    height: 1.35rem;
    min-height: 1.35rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    line-height: 1;
    font-size: 0.8rem;
}

.secondary-icon {
    background: var(--accent);
    color: #fff;
}

.icon-button:hover,
.secondary-icon:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.semantic-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.field-pair {
    display: grid;
    gap: 0.2rem;
    padding: 0.75rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.field-pair span {
    color: var(--muted);
    font-size: 0.85rem;
}

.field-pair strong {
    font-weight: 600;
}

.field-edit-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
}

.field-edit-form[data-autosave-card] {
    grid-template-columns: minmax(0, 1fr);
}

.field-edit-form input,
.field-edit-form select {
    width: 100%;
    min-width: 0;
}

.compact-button {
    min-height: 2.2rem;
    padding: 0.4rem 0.65rem;
    font-size: 0.88rem;
}

.semantic-section {
    margin-top: 1.25rem;
}

.proforma-block {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem 1rem;
    margin: 1rem 0 1.5rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.proforma-block > h2 {
    flex: 0 0 100%;
    margin: 0 0 0.85rem;
    font-size: 1.2rem;
}

.proforma-block > .semantic-section {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: min(100%, 420px);
    margin: 0;
}

.hydrobiology-block > .semantic-section {
    flex-basis: 100%;
}

.proforma-block > .eco-position-table-section {
    flex: 0 0 100%;
}

.eco-position-table-section .semantic-table-wrap {
    overflow-x: auto;
}

.proforma-block > .eco-sediment-eh-table-section,
.proforma-block > .eco-sediment-ph-table-section,
.proforma-block > .eco-replication-table-section,
.proforma-block > .eco-column-height-table-section {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: min(100%, 360px);
}

.eco-position-table th:nth-child(1),
.eco-position-table td:nth-child(1) {
    width: 8%;
}

.eco-position-table th:nth-child(2),
.eco-position-table td:nth-child(2) {
    width: 9%;
}

.eco-position-table th:nth-child(3),
.eco-position-table td:nth-child(3),
.eco-position-table th:nth-child(4),
.eco-position-table td:nth-child(4) {
    width: 32%;
    min-width: 20rem;
}

.eco-position-table th:nth-child(5),
.eco-position-table td:nth-child(5) {
    width: 19%;
}

.eco-position-table {
    min-width: 78rem;
}

.eco-position-table .coordinate-inputs {
    gap: 0.18rem;
    width: max-content;
    min-width: max-content;
}

.eco-position-table .coordinate-inputs input {
    box-sizing: border-box;
    text-align: center;
}

.eco-position-table .coordinate-inputs input[data-coordinate-part="degrees"] {
    width: 5.25rem !important;
    min-width: 5.25rem;
}

.eco-position-table .coordinate-inputs input[data-coordinate-part="minutes"] {
    width: 4.75rem !important;
    min-width: 4.75rem;
}

.eco-position-table .coordinate-inputs input[data-coordinate-part="seconds"] {
    width: 7rem !important;
    min-width: 7rem;
}

.eco-position-table .coordinate-inputs input::-webkit-outer-spin-button,
.eco-position-table .coordinate-inputs input::-webkit-inner-spin-button {
    margin: 0;
    appearance: none;
}

.eco-position-table .coordinate-inputs input[type="number"] {
    appearance: textfield;
}

.compact-fields {
    flex: 0 0 100%;
    margin-bottom: 0;
}

.semantic-section h2 {
    margin: 0 0 0.65rem;
    font-size: 1.15rem;
}

.semantic-section h3 {
    margin: 0 0 0.55rem;
    font-size: 1rem;
}

.table-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
}

.table-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 0.45rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7faf8;
}

.table-stat span {
    color: var(--muted);
    font-size: 0.9rem;
}

.table-stat strong {
    font-size: 1rem;
}

.semantic-table-wrap {
    margin-bottom: 1rem;
    overflow-x: visible;
}

.semantic-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.semantic-table th,
.semantic-table td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.semantic-table td.cell-with-action {
    position: relative;
    padding-right: 2.7rem;
}

.row-action-buttons {
    position: absolute;
    top: 50%;
    right: 0.45rem;
    transform: translateY(-50%);
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.row-action-buttons form {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.semantic-table input,
.semantic-table select {
    width: 100%;
    min-width: 0;
}

.structured-input {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: nowrap;
    width: 100%;
}

.structured-input input {
    min-width: 0;
}

.structured-input span {
    color: var(--muted);
    font-size: 0.85rem;
}

.date-inputs,
.time-inputs {
    width: max-content;
    min-width: max-content;
}

.date-inputs input[data-date-part="day"],
.date-inputs input[data-date-part="month"],
.time-inputs input[data-time-part="hour"],
.time-inputs input[data-time-part="minute"] {
    flex: 0 0 calc(2ch + 1.2rem);
    width: calc(2ch + 1.2rem) !important;
    inline-size: calc(2ch + 1.2rem);
    min-inline-size: calc(2ch + 1.2rem);
    max-inline-size: calc(2ch + 1.2rem);
    box-sizing: content-box;
    padding-inline: 0.25rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.date-inputs input[data-date-part="year"] {
    flex: 0 0 calc(4ch + 1.2rem);
    width: calc(4ch + 1.2rem) !important;
    inline-size: calc(4ch + 1.2rem);
    min-inline-size: calc(4ch + 1.2rem);
    max-inline-size: calc(4ch + 1.2rem);
    box-sizing: content-box;
    padding-inline: 0.25rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.meteo-observation-table {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.meteo-observation-table th,
.meteo-observation-table td {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
}

.meteo-observation-table .meteo-date-col {
    width: 12.5%;
}

.meteo-observation-table .meteo-time-col {
    width: 8%;
}

.meteo-observation-table .meteo-station-col {
    width: 9%;
}

.meteo-observation-table .meteo-speed-col,
.meteo-observation-table .meteo-temperature-col,
.meteo-observation-table .meteo-direction-col,
.meteo-observation-table .meteo-wave-height-col,
.meteo-observation-table .meteo-wave-direction-col,
.meteo-observation-table .meteo-cloud-col,
.meteo-observation-table .meteo-pressure-col,
.meteo-observation-table .meteo-humidity-col {
    width: 8.8%;
}

.meteo-observation-table .date-cell {
    padding-right: 0.65rem;
}

.meteo-observation-table .time-cell {
    padding-left: 0.65rem;
}

.meteo-observation-table .date-inputs,
.meteo-observation-table .time-inputs {
    gap: 0.12rem;
    width: auto;
    min-width: 0;
}

.meteo-observation-table .date-inputs input[data-date-part="day"],
.meteo-observation-table .date-inputs input[data-date-part="month"],
.meteo-observation-table .time-inputs input[data-time-part="hour"],
.meteo-observation-table .time-inputs input[data-time-part="minute"] {
    flex: 0 0 2.2rem;
    width: 2.2rem !important;
    min-width: 2.2rem;
    max-width: 2.2rem;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
    box-sizing: border-box;
}

.meteo-observation-table .date-inputs input[data-date-part="year"] {
    flex: 0 0 3.55rem;
    width: 3.55rem !important;
    min-width: 3.55rem;
    max-width: 3.55rem;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
    box-sizing: border-box;
}

.coordinate-inputs input[data-coordinate-part="degrees"],
.coordinate-inputs input[data-coordinate-part="minutes"] {
    width: 3.75rem;
}

.coordinate-inputs input[data-coordinate-part="seconds"] {
    width: 5rem;
}

.semantic-table .summary-row td {
    background: #fffbd1;
    font-weight: 700;
}

.semantic-table .summary-row .row-action-col {
    background: #fffbd1;
}

.semantic-table td.invalid-reference-cell {
    background: #ffe8e8;
    color: var(--danger);
    font-weight: 700;
}

.semantic-table td.invalid-reference-cell input,
.semantic-table td.invalid-reference-cell select {
    border-color: var(--danger);
    color: var(--danger);
}

.report-table-section {
    margin-top: 1rem;
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.report-table-title {
    margin: 0 0 0.6rem;
    font-size: 1.45rem;
    font-weight: 800;
}

.report-source-note {
    margin: 0 0 0.5rem;
}

.report-table-wrap {
    overflow: auto;
    max-height: calc(100vh - 220px);
    background: #fff;
    border: 1px solid #111;
}

.report-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: Arial, sans-serif;
    font-size: 0.86rem;
    line-height: 1.05;
}

.report-table th,
.report-table td {
    min-width: 2.15rem;
    height: 1.25rem;
    padding: 0.1rem 0.25rem;
    border: 1px solid #111;
    color: #000;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.report-table th {
    background: #d9d9d9;
    font-weight: 700;
}

.report-table .station-col {
    min-width: 9.5rem;
    text-align: left;
}

.report-table .date-col {
    min-width: 6.5rem;
}

.report-table .coordinate-col {
    min-width: 10.5rem;
}

.report-table .description-col {
    min-width: 18rem;
    max-width: 36rem;
    white-space: normal;
    text-align: left;
}

.report-table th.station-col {
    text-align: center;
}

.report-table .vessel-row {
    background: #d9d9d9;
    text-align: center;
    font-weight: 700;
}

.report-table .empty-table-row {
    height: 3rem;
    color: var(--muted);
    text-align: center;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.matrix-table-wrap {
    overflow: auto;
    max-height: calc(100vh - 280px);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: #fff;
}

.matrix-table {
    width: max-content;
    min-width: 100%;
}

.matrix-table th,
.matrix-table td {
    min-width: 7rem;
    text-align: center;
    white-space: nowrap;
}

.matrix-table .matrix-station-col {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 12rem;
    background: #fff;
    text-align: left;
}

.matrix-table th.matrix-station-col {
    z-index: 3;
    background: #f3f4f6;
    text-align: center;
}

.matrix-value-input {
    min-width: 5.5rem;
    width: 100%;
    padding: 0.35rem 0.45rem;
    text-align: center;
}

.matrix-station-input {
    min-width: 11rem;
}

@media (max-width: 760px) {
    .page-title,
    .filters {
        display: grid;
        grid-template-columns: 1fr;
    }

    .proforma-block > .semantic-section {
        flex-basis: 100%;
    }
}
