:root {
    --navy-950: #061c2b;
    --navy-900: #082f49;
    --navy-800: #0c4a6e;
    --blue-700: #0369a1;
    --blue-600: #0284c7;
    --cyan-400: #22d3ee;
    --cyan-100: #cffafe;
    --slate-950: #0f172a;
    --slate-900: #172033;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
    --green-700: #15803d;
    --green-100: #dcfce7;
    --amber-700: #b45309;
    --amber-100: #fef3c7;
    --red-700: #b91c1c;
    --red-100: #fee2e2;
    --white: #fff;
    --radius: 12px;
    --shadow: 0 12px 32px rgba(15, 23, 42, .09);
    --header-height: 86px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; color-scheme: light; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--slate-800);
    background: #edf3f7;
    font: 16px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { color: var(--blue-600); }

.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: var(--header-height);
    padding: 12px clamp(16px, 2.4vw, 36px);
    display: grid;
    grid-template-columns: minmax(190px, .7fr) minmax(440px, 1.7fr) auto;
    gap: clamp(14px, 2vw, 30px);
    align-items: center;
    color: var(--white);
    background: var(--navy-950);
    box-shadow: 0 4px 18px rgba(2, 22, 35, .24);
}

.brand { min-width: max-content; display: flex; align-items: center; gap: 11px; color: var(--white); }
.brand:hover { color: var(--white); }
.brand-mark {
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .32);
    border-radius: 10px;
    color: var(--navy-950);
    background: var(--cyan-400);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: .08em;
    box-shadow: inset 0 -6px 13px rgba(3, 105, 161, .14);
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.1; }
.brand-copy strong { font-size: 16px; letter-spacing: .01em; }
.brand-copy small { margin-top: 5px; color: #7dd3fc; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }

.header-filter { min-width: 0; display: flex; justify-content: center; }
body[data-page="settings"] .header-filter { visibility: hidden; }
.filter-form { width: 100%; display: flex; align-items: end; justify-content: center; gap: 7px; }
.filter-form label, .scanner-fallback label { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.filter-form label > span { color: #bae6fd; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.filter-form input, .filter-form select {
    min-width: 0;
    height: 35px;
    padding: 0 9px;
    border: 1px solid rgba(186, 230, 253, .26);
    border-radius: 7px;
    outline: none;
    color: white;
    background: rgba(255, 255, 255, .08);
    font-size: 13px;
}
.filter-form input:focus, .filter-form select:focus { border-color: var(--cyan-400); box-shadow: 0 0 0 3px rgba(34, 211, 238, .14); }
.filter-form input[type="date"] { width: 132px; }
.filter-form select { max-width: 190px; }
.filter-form select option { color: var(--slate-950); background: white; }
.filter-form .search-label { flex: 1; max-width: 250px; }

.filter-details { position: relative; }
.filter-details summary {
    height: 35px;
    padding: 8px 10px;
    display: block;
    border: 1px solid rgba(186, 230, 253, .26);
    border-radius: 7px;
    color: #bae6fd;
    background: rgba(255, 255, 255, .08);
    font-size: 12px;
    cursor: pointer;
    list-style: none;
}
.filter-details summary::-webkit-details-marker { display: none; }
.filter-details[open] summary { border-color: var(--cyan-400); }
.filter-details .area-filter-grid {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    z-index: 50;
    width: 390px;
    padding: 14px;
    transform: translateX(-50%);
    border: 1px solid var(--slate-300);
    border-radius: 10px;
    background: white;
    box-shadow: var(--shadow);
}
.filter-details .area-filter-grid::before { content: ""; position: absolute; top: -7px; left: 50%; width: 12px; height: 12px; border: solid var(--slate-300); border-width: 1px 0 0 1px; transform: rotate(45deg); background: white; }
.filter-details .area-filter-grid label > span { color: var(--slate-600); }
.filter-details .area-filter-grid input { width: 100%; color: var(--slate-900); background: var(--slate-50); }
.status-filter-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    z-index: 50;
    width: 190px;
    padding: 9px;
    transform: translateX(-50%);
    border: 1px solid var(--slate-300);
    border-radius: 10px;
    color: var(--slate-800);
    background: white;
    box-shadow: var(--shadow);
}
.status-filter-menu::before { content: ""; position: absolute; top: -7px; left: 50%; width: 12px; height: 12px; border: solid var(--slate-300); border-width: 1px 0 0 1px; transform: translateX(-50%) rotate(45deg); background: white; }
.status-filter-menu label { min-height: 34px; padding: 6px 7px; display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 7px; border-radius: 7px; cursor: pointer; }
.status-filter-menu label:hover { background: var(--slate-100); }
.status-filter-menu input { width: 16px; height: 16px; padding: 0; accent-color: var(--blue-700); }
.status-filter-menu label > span { color: var(--slate-700); font-size: 13px; font-weight: 700; letter-spacing: 0; text-transform: none; }

.icon-button {
    width: 35px;
    height: 35px;
    flex: 0 0 35px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    font-size: 18px;
}
.filter-submit { color: var(--navy-950); background: var(--cyan-400); }
.filter-reset { color: #bae6fd; background: rgba(255,255,255,.09); }
.filter-reset:hover { color: white; background: rgba(255,255,255,.16); }

.main-nav { height: 56px; display: flex; align-items: stretch; gap: 3px; }
.nav-item { position: relative; display: flex; align-items: stretch; }
.nav-item > a { padding: 18px 9px 13px; border-bottom: 3px solid transparent; color: #dbeafe; font-size: 14px; font-weight: 650; white-space: nowrap; }
.nav-item > a:hover, .nav-item > a.active { color: white; border-bottom-color: var(--cyan-400); }
.nav-item > button {
    position: absolute;
    top: calc(100% - 2px);
    right: 0;
    z-index: 60;
    width: max-content;
    padding: 10px 13px;
    display: none;
    border: 1px solid var(--slate-300);
    border-radius: 8px;
    color: var(--slate-800);
    background: white;
    box-shadow: var(--shadow);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}
.nav-item:hover > button, .nav-item:focus-within > button { display: block; }
.nav-item > button:hover { color: var(--blue-700); background: var(--slate-50); }
.nav-account { margin-left: 5px; padding-left: 7px; display: flex; align-items: center; gap: 2px; border-left: 1px solid rgba(255,255,255,.16); }
.nav-account > a, .nav-account button { min-height: 36px; padding: 7px 8px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 7px; color: #bae6fd; background: transparent; cursor: pointer; font-size: 13px; font-weight: 700; }
.nav-account > a:hover, .nav-account > a.active, .nav-account button:hover { color: white; background: rgba(255,255,255,.1); }
.nav-account form { margin: 0; }
.account-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-button { display: none; }

.page-shell { width: min(1540px, calc(100% - 42px)); margin: 0 auto; padding: 34px 0 64px; }
.page-heading { min-height: 62px; margin-bottom: 23px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.page-heading h1 { margin: 2px 0 0; color: var(--slate-950); font-size: clamp(28px, 3vw, 39px); line-height: 1; letter-spacing: -.035em; }
.eyebrow { margin: 0; color: var(--blue-700); font-size: 11px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--slate-500); }

.button-row { display: flex; align-items: center; gap: 8px; }
.button {
    min-height: 38px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 750;
    font-size: 14px;
    line-height: 1;
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--blue-700); box-shadow: 0 5px 12px rgba(3,105,161,.18); }
.button.primary:hover { color: white; background: var(--blue-600); }
.button.ghost { color: var(--slate-700); border-color: var(--slate-300); background: white; }
.button.ghost:hover { color: var(--blue-700); border-color: #7dd3fc; }
.button.ghost.light { color: white; border-color: rgba(255,255,255,.34); background: rgba(255,255,255,.08); }
.button.danger { color: var(--red-700); border-color: #fecaca; background: var(--red-100); }
.button.danger:hover { color: white; background: var(--red-700); }
.button.small { min-height: 31px; padding: 6px 10px; font-size: 12px; }
.button[disabled] { opacity: .48; cursor: not-allowed; transform: none; }

.active-filter, .notice {
    margin-bottom: 18px;
    padding: 11px 14px;
    border: 1px solid #bae6fd;
    border-radius: 9px;
    color: var(--navy-800);
    background: #e0f2fe;
}
.active-filter { display: flex; align-items: center; gap: 5px; }
.active-filter a { margin-left: auto; font-weight: 700; }
.notice.warning { border-color: #fde68a; color: #92400e; background: var(--amber-100); }
.notice.danger { border-color: #fecaca; color: var(--red-700); background: var(--red-100); }
.notice.success { border-color: #bbf7d0; color: var(--green-700); background: var(--green-100); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.entity-card {
    position: relative;
    min-height: 220px;
    padding: 21px;
    overflow: hidden;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    background: white;
    box-shadow: 0 3px 12px rgba(15, 23, 42, .04);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.entity-card:hover, .entity-card:focus-visible { transform: translateY(-3px); border-color: #7dd3fc; box-shadow: var(--shadow); outline: none; }
.card-accent { position: absolute; inset: 0 auto 0 0; width: 5px; background: linear-gradient(180deg, var(--cyan-400), var(--blue-700)); }
.card-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.record-id { color: var(--slate-500); font-size: 11px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.count-badge { padding: 4px 8px; border-radius: 999px; color: var(--blue-700); background: #e0f2fe; font-size: 11px; font-weight: 800; }
.entity-card h2 { margin: 19px 0 18px; color: var(--slate-950); font-size: 20px; line-height: 1.22; }
.card-meta, .sample-facts { margin: 0; display: grid; gap: 9px; }
.card-meta div, .sample-facts div { display: grid; grid-template-columns: 86px 1fr; gap: 8px; }
.card-meta dt, .sample-facts dt { color: var(--slate-500); font-size: 12px; }
.card-meta dd, .sample-facts dd { margin: 0; color: var(--slate-700); font-size: 13px; font-weight: 650; }
.card-actions { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.link-hint { color: var(--slate-400); font-size: 12px; }

.person-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.person-card { min-height: 210px; display: grid; grid-template-columns: 53px 1fr; grid-template-rows: auto 1fr auto; gap: 0 14px; }
.person-monogram { width: 53px; height: 53px; grid-row: 1 / 3; display: grid; place-items: center; border-radius: 11px; color: var(--navy-900); background: var(--cyan-100); font-weight: 900; }
.person-content h2 { margin: 0 0 4px; }
.person-content p { margin: 0 0 3px; color: var(--slate-700); font-size: 14px; }
.person-content small { color: var(--slate-500); }
.person-counts { grid-column: 2; margin-top: 13px; display: flex; gap: 14px; color: var(--slate-500); font-size: 12px; }
.person-card .card-actions { grid-column: 1 / 3; }

.vessel-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.vessel-card { min-height: 330px; padding: 0; display: flex; flex-direction: column; }
.vessel-card-photo { width: 100%; height: 190px; flex: 0 0 190px; display: block; object-fit: cover; background: #dbe8ee; }
.vessel-photo-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--slate-500); background: linear-gradient(145deg, #dbe8ee, #edf4f7); }
.vessel-photo-empty > span { color: var(--blue-700); font-size: 38px; }
.vessel-photo-empty small { font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.vessel-card-content { min-height: 140px; padding: 17px 19px 18px; display: flex; flex: 1; flex-direction: column; }
.vessel-card h2 { margin: 13px 0 3px; }
.vessel-card .card-actions { margin-top: auto; padding-top: 16px; }

.table-summary { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; color: var(--slate-500); font-size: 12px; }
.table-wrap { overflow: auto; border: 1px solid var(--slate-200); border-radius: var(--radius); background: white; box-shadow: 0 3px 12px rgba(15,23,42,.04); }
.data-table { width: 100%; min-width: 1640px; border-collapse: collapse; font-size: 13px; }
.data-table th { position: sticky; top: 0; z-index: 2; padding: 12px 11px; text-align: left; color: var(--slate-600); background: var(--slate-100); border-bottom: 1px solid var(--slate-300); font-size: 11px; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 12px 11px; border-bottom: 1px solid var(--slate-200); white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f0f9ff; }
.sample-table-row { cursor: pointer; }
.sample-table-row:focus-visible { outline: 3px solid rgba(2,132,199,.25); outline-offset: -3px; background: #f0f9ff; }
.data-table a { font-weight: 700; }
.status { padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 850; }
.status.collected { color: var(--amber-700); background: var(--amber-100); }
.status.processed { color: var(--green-700); background: var(--green-100); }
.status.failed { color: var(--red-700); background: var(--red-100); }
.sample-inline-control { width: 100%; min-width: 86px; height: 32px; padding: 5px 7px; border: 1px solid transparent; border-radius: 6px; color: var(--slate-800); background: transparent; font: inherit; }
.sample-inline-control:hover { border-color: var(--slate-300); background: white; }
.sample-inline-control:focus { border-color: #38bdf8; outline: none; background: white; box-shadow: 0 0 0 3px rgba(14,165,233,.12); }
.sample-inline-control[type="date"] { min-width: 128px; }
.sample-inline-control[type="time"] { min-width: 92px; }
.sample-inline-control.coordinate { min-width: 112px; }
.sample-inline-control.compact { min-width: 78px; }
.sample-inline-unit { display: flex; align-items: center; gap: 3px; }
.sample-inline-unit .sample-inline-control { min-width: 82px; }
.sample-inline-state { min-width: 54px; display: inline-block; color: var(--slate-400); font-size: 10px; font-weight: 700; vertical-align: middle; }
.sample-inline-state.saving { color: var(--blue-700); }
.sample-inline-state.saved { color: var(--green-700); }
.sample-inline-state.error { color: var(--red-700); }
.sample-table-row.inline-saving { background: #f0f9ff; }
.sample-table-row.inline-error { background: #fff1f2; }

.bottle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 13px; }
.bottle-card-wrap { position: relative; min-width: 0; }
.bottle-card { min-height: 138px; padding: 12px; display: flex; align-items: center; gap: 15px; border: 1px solid var(--slate-200); border-radius: 11px; color: var(--slate-800); background: white; box-shadow: 0 3px 12px rgba(15,23,42,.04); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.bottle-card:hover { transform: translateY(-2px); border-color: #7dd3fc; color: var(--slate-800); box-shadow: var(--shadow); }
.qr-mini { width: 116px; height: 116px; flex: 0 0 116px; image-rendering: pixelated; border-radius: 5px; }
.bottle-card h2 { margin: 0 0 5px; color: var(--slate-950); font: 800 18px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; }
.bottle-card p { margin: 0 0 7px; color: var(--slate-600); font-size: 12px; }
.bottle-card small { color: var(--slate-400); font-size: 11px; }
.bottle-reprint-bar { position: sticky; top: calc(var(--header-height) + 10px); z-index: 7; margin-bottom: 13px; padding: 11px 13px; display: flex; align-items: center; gap: 15px; border: 1px solid #7dd3fc; border-radius: 10px; color: var(--slate-800); background: #f0f9ff; box-shadow: 0 8px 28px rgba(2,132,199,.14); }
.bottle-reprint-bar > span { margin-right: auto; color: var(--slate-500); font-size: 12px; }
.bottle-reprint-choice { position: absolute; top: 10px; right: 10px; z-index: 3; display: none; cursor: pointer; }
.bottle-reprint-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.bottle-reprint-choice span { width: 32px; height: 32px; display: grid; place-items: center; border: 2px solid var(--slate-300); border-radius: 8px; color: transparent; background: white; box-shadow: 0 3px 10px rgba(15,23,42,.12); font-weight: 900; }
.bottle-reprint-choice input:checked + span { border-color: var(--blue-600); color: white; background: var(--blue-600); }
body.bottle-reprint-mode .bottle-reprint-choice { display: block; }
body.bottle-reprint-mode .bottle-card { padding-right: 52px; cursor: pointer; }
body.bottle-reprint-mode .bottle-card-wrap:has(input:checked) .bottle-card { border-color: var(--blue-600); background: #f0f9ff; box-shadow: 0 0 0 2px rgba(2,132,199,.13); }

.bottle-detail-heading { margin-bottom: 22px; padding: 18px 24px; display: flex; align-items: center; gap: 24px; border: 1px solid var(--slate-200); border-radius: var(--radius); background: white; }
.bottle-detail-heading .qr-detail { width: 150px; height: 150px; image-rendering: pixelated; }
.bottle-detail-heading h2 { margin: 5px 0 8px; color: var(--slate-950); font: 900 clamp(26px, 4vw, 44px)/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.bottle-detail-heading p { max-width: 580px; margin: 0; color: var(--slate-500); }
.panel { margin-bottom: 22px; padding: 22px; border: 1px solid var(--slate-200); border-radius: var(--radius); background: white; box-shadow: 0 3px 12px rgba(15,23,42,.04); }
.section-title { margin-bottom: 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.section-title h2 { margin: 3px 0 0; color: var(--slate-950); font-size: 21px; }
.sample-editor-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr); gap: 24px; align-items: start; }
.sample-entry-panel .sample-form { max-width: none; }
.sample-files-panel { min-width: 0; padding-left: 23px; border-left: 1px solid var(--slate-200); }
.sample-files-heading { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sample-files-heading > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sample-files-heading strong { color: var(--slate-900); font-size: 15px; }
.file-dropzone { min-height: 174px; padding: 22px 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed var(--slate-300); border-radius: 11px; outline: none; color: var(--slate-600); background: var(--slate-50); text-align: center; cursor: pointer; transition: border-color .15s ease, background .15s ease, opacity .15s ease; }
.file-dropzone:hover, .file-dropzone:focus-visible, .file-dropzone.dragover { border-color: var(--blue-600); background: #e0f2fe; }
.file-dropzone.uploading { opacity: .55; pointer-events: none; }
.file-dropzone.uploading::after { content: "Загрузка…"; color: var(--blue-700); font-size: 12px; font-weight: 800; }
.file-drop-icon { color: var(--blue-700); font-size: 30px; line-height: 1; }
.file-dropzone > strong { color: var(--slate-800); font-size: 14px; }
.file-dropzone > small { max-width: 280px; color: var(--slate-500); font-size: 11px; }
.file-dropzone label { margin-top: 7px; }
.file-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sample-files-hint { margin: 10px 2px; color: var(--slate-500); font-size: 11px; line-height: 1.4; }
.sample-file-list { max-height: 330px; display: grid; gap: 7px; overflow: auto; }
.sample-file-item { width: 100%; min-width: 0; padding: 9px; display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 9px; border: 1px solid var(--slate-200); border-radius: 8px; color: var(--slate-800); background: white; text-align: left; cursor: pointer; }
.sample-file-item:hover { border-color: #7dd3fc; background: #f0f9ff; }
.sample-file-item.pending { grid-template-columns: 38px minmax(0, 1fr) 28px; cursor: default; background: var(--slate-50); }
.sample-file-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 7px; color: var(--blue-700); background: #e0f2fe; font-size: 10px; font-weight: 900; }
.sample-file-icon.image { color: var(--green-700); background: var(--green-100); font-size: 21px; }
.sample-file-icon.video, .sample-file-icon.audio { color: #7e22ce; background: #f3e8ff; font-size: 17px; }
.sample-file-icon.pdf { color: var(--red-700); background: var(--red-100); }
.sample-file-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sample-file-copy strong { overflow: hidden; color: var(--slate-800); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.sample-file-copy small { overflow: hidden; color: var(--slate-500); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.pending-file-remove { width: 28px; height: 28px; border: 0; border-radius: 50%; color: var(--slate-500); background: var(--slate-200); cursor: pointer; font-size: 18px; }
.pending-file-remove:hover { color: white; background: var(--red-700); }
.sample-history { display: grid; gap: 12px; }
.sample-history > .section-title { margin-bottom: 2px; }
.sample-history-card { padding: 18px; border: 1px solid var(--slate-200); border-radius: 10px; background: white; }
.sample-history-main { margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.sample-history-main h3 { margin: 4px 0 0; color: var(--slate-950); font-size: 18px; }
.status-select { padding: 7px 9px; border: 0; border-radius: 999px; font-size: 12px; font-weight: 850; outline: none; }
.status-select.collected { color: var(--amber-700); background: var(--amber-100); }
.status-select.processed { color: var(--green-700); background: var(--green-100); }
.status-select.failed { color: var(--red-700); background: var(--red-100); }
.sample-facts { grid-template-columns: repeat(3, 1fr); }
.sample-facts div { display: block; }
.sample-card-actions { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.attachment-count { color: var(--slate-500); font-size: 11px; font-weight: 700; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid > label, .big-number-label, .smart-field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.form-grid label > span:first-child, .big-number-label > span:first-child, .smart-field > span:first-child, .scanner-fallback label > span { color: var(--slate-600); font-size: 12px; font-weight: 750; }
.form-grid input, .form-grid select, .form-grid textarea, .big-number-label input, .scanner-fallback input, .picker-list + input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--slate-300);
    border-radius: 8px;
    outline: none;
    background: white;
}
.form-grid textarea { resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .big-number-label input:focus, .scanner-fallback input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(2,132,199,.12); }
.span-2 { grid-column: 1 / -1; }
.compound-input { display: grid; grid-template-columns: 1fr 84px; }
.compound-input input { border-radius: 8px 0 0 8px; }
.compound-input select { border-left: 0; border-radius: 0 8px 8px 0; }
.select-with-pin { display: grid; grid-template-columns: minmax(0, 1fr) 43px; }
.select-with-pin select { border-radius: 8px 0 0 8px; }
.native-pin { border: 1px solid var(--slate-300); border-left: 0; border-radius: 0 8px 8px 0; color: var(--slate-300); background: var(--slate-50); cursor: pointer; font-size: 19px; }
.native-pin:hover, .native-pin.active { color: #eab308; }
.coordinate-fieldset { margin: 2px 0 0; padding: 13px; border: 1px solid var(--slate-300); border-radius: 9px; }
.coordinate-fieldset legend { padding: 0 5px; color: var(--slate-700); font-size: 13px; font-weight: 800; }
.coordinate-fieldset > p { margin: 0 0 10px; color: var(--slate-400); font: 11px/1.35 ui-monospace, monospace; }
.area-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.big-number-label input { min-height: 82px; text-align: center; color: var(--navy-900); font-size: 34px; font-weight: 900; }
.big-number-label small { color: var(--slate-500); }
.field-help { color: var(--slate-500); font-size: 11px; line-height: 1.4; }
.form-divider { padding: 13px 0 2px; display: flex; flex-direction: column; gap: 3px; border-top: 1px solid var(--slate-200); }
.form-divider strong { color: var(--slate-900); }
.form-divider small { color: var(--slate-500); font-size: 11px; }
.vessel-editor-layout { display: grid; grid-template-columns: 1fr 270px; gap: 20px; }
.vessel-photo-preview { min-height: 220px; overflow: hidden; border: 1px solid var(--slate-300); border-radius: 10px; background: var(--slate-100); }
.vessel-photo-preview img, .vessel-photo-preview .vessel-photo-empty { width: 100%; height: 100%; min-height: 220px; object-fit: cover; }

.modal {
    width: min(680px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 14px;
    background: transparent;
    box-shadow: 0 26px 80px rgba(2, 15, 25, .32);
}
.modal.modal-wide { width: min(1100px, calc(100vw - 28px)); }
.modal.modal-small { width: min(480px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(2, 15, 25, .68); backdrop-filter: blur(3px); }
.modal-shell { max-height: calc(100vh - 28px); display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: white; }
.modal-header { min-height: 76px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--slate-200); }
.modal-header h2 { margin: 3px 0 0; color: var(--slate-950); font-size: 22px; }
.modal-close { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--slate-500); background: var(--slate-100); cursor: pointer; font-size: 24px; }
.modal-close:hover { color: var(--slate-950); background: var(--slate-200); }
.modal-body { padding: 20px; overflow: auto; }
.modal-footer { min-height: 66px; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--slate-200); background: var(--slate-50); }
.autosave-state { color: var(--slate-500); font-size: 12px; }
.autosave-state.saving { color: var(--blue-700); }
.autosave-state.saved { color: var(--green-700); }
.autosave-state.error { color: var(--red-700); }
.expedition-layout { display: grid; grid-template-columns: 1.12fr .88fr; gap: 20px; }
.map-panel { min-height: 470px; display: flex; flex-direction: column; gap: 8px; }
.map-panel iframe { width: 100%; min-height: 425px; flex: 1; border: 1px solid var(--slate-300); border-radius: 10px; background: #dce8ee; }
.map-panel > a { font-size: 12px; font-weight: 700; }

.picker-list { max-height: 330px; margin-top: 12px; overflow: auto; border: 1px solid var(--slate-200); border-radius: 9px; }
.picker-option { min-height: 47px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--slate-200); cursor: pointer; }
.picker-option:last-child { border-bottom: 0; }
.picker-option:hover { background: #f0f9ff; }
.picker-option input { accent-color: var(--blue-700); }
.picker-option > span:nth-of-type(1) { font: 750 14px ui-monospace, SFMono-Regular, Consolas, monospace; }
.picker-check { margin-left: auto; color: var(--blue-700); opacity: 0; font-weight: 900; }
.picker-option:has(input:checked) { background: #e0f2fe; }
.picker-option:has(input:checked) .picker-check { opacity: 1; }

.smart-select { position: relative; }
.smart-trigger { width: 100%; min-height: 42px; padding: 9px 36px 9px 11px; overflow: hidden; border: 1px solid var(--slate-300); border-radius: 8px; text-align: left; text-overflow: ellipsis; white-space: nowrap; background: white; cursor: pointer; }
.smart-trigger::after { content: "⌄"; position: absolute; right: 12px; color: var(--slate-500); }
.smart-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 80; width: 100%; min-width: 280px; padding: 8px; border: 1px solid var(--slate-300); border-radius: 9px; background: white; box-shadow: var(--shadow); }
.smart-search { width: 100%; min-height: 38px !important; margin-bottom: 7px; }
.smart-options { max-height: 230px; overflow: auto; }
.smart-option-row { display: grid; grid-template-columns: 1fr 38px; border-radius: 6px; }
.smart-option-row:hover { background: var(--slate-100); }
.smart-option, .pin-option { min-height: 39px; border: 0; background: transparent; cursor: pointer; }
.smart-option { min-width: 0; padding: 8px; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.pin-option { color: var(--slate-300); font-size: 18px; }
.pin-option:hover, .pin-option.active { color: #eab308; }
.smart-option-row.selected { color: var(--blue-700); background: #e0f2fe; font-weight: 750; }

.camera-frame { position: relative; min-height: 330px; overflow: hidden; border-radius: 11px; background: var(--navy-950); }
.camera-frame video { width: 100%; height: 100%; min-height: 330px; display: block; object-fit: cover; }
.scan-guide { position: absolute; top: 50%; left: 50%; width: min(62%, 260px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid var(--cyan-400); border-radius: 15px; box-shadow: 0 0 0 999px rgba(2,15,25,.34); }
.camera-snapshot-note { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 32px; color: white; text-align: center; background: radial-gradient(circle at 50% 42%, rgba(14,116,144,.54), transparent 52%); }
.camera-snapshot-note > span { display: grid; width: 82px; height: 82px; place-items: center; border: 2px solid var(--cyan-400); border-radius: 18px; color: var(--cyan-400); font-size: 46px; line-height: 1; }
.camera-snapshot-note strong { font-size: 19px; }
.camera-snapshot-note small { max-width: 310px; color: var(--slate-200); font-size: 13px; }
.scanner-body > p { text-align: center; }
.scanner-fallback { display: flex; align-items: end; justify-content: center; gap: 10px; }
.scanner-fallback label:not(.file-button) { flex: 1; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.sample-file-modal-body { min-height: 520px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 20px; }
.file-preview { min-width: 0; min-height: 470px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--slate-300); border-radius: 10px; background: #0b1726; }
.file-preview img, .file-preview video { width: 100%; height: 100%; max-height: 68vh; object-fit: contain; }
.file-preview iframe { width: 100%; height: 100%; min-height: 470px; border: 0; background: white; }
.file-preview audio { width: min(440px, calc(100% - 30px)); }
.file-preview-empty { padding: 35px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: white; text-align: center; }
.file-preview-empty span { color: var(--cyan-400); font-size: 54px; }
.file-preview-empty small { max-width: 320px; color: var(--slate-300); }
.file-metadata-editor { min-width: 0; display: flex; flex-direction: column; gap: 15px; }
.file-metadata-editor label { display: flex; flex-direction: column; gap: 6px; }
.file-metadata-editor label > span { color: var(--slate-600); font-size: 12px; font-weight: 750; }
.file-metadata-editor input, .file-metadata-editor textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--slate-300); border-radius: 8px; outline: none; resize: vertical; }
.file-metadata-editor input:focus, .file-metadata-editor textarea:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(2,132,199,.12); }
.file-technical { padding: 11px; display: flex; flex-direction: column; gap: 3px; border-radius: 8px; background: var(--slate-100); }
.file-technical span { overflow-wrap: anywhere; color: var(--slate-800); font-size: 12px; font-weight: 750; }
.file-technical small { color: var(--slate-500); font-size: 10px; }

.settings-panel { max-width: 760px; }
.settings-form { max-width: 680px; }
.settings-submit { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.sync-expedition-fields { padding: 14px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--slate-50); }
.sync-last-run { margin-top: 18px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; border-left: 4px solid var(--blue-600); border-radius: 7px; background: var(--slate-50); }
.sync-last-run.error { border-left-color: #dc2626; }
.sync-last-run span { color: var(--slate-500); font-size: 12px; }
.settings-panel .notice { margin-top: 18px; overflow-wrap: anywhere; }
.settings-panel .notice code { user-select: all; }
.key-create-grid { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.key-create-form { padding: 16px; display: flex; flex-direction: column; align-items: stretch; gap: 12px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--slate-50); }
.key-create-form h3 { margin: 0; color: var(--slate-900); font-size: 15px; }
.key-create-form label { display: flex; flex-direction: column; gap: 5px; }
.key-create-form label > span { color: var(--slate-600); font-size: 11px; font-weight: 750; }
.new-key-box { margin-top: 18px; padding: 15px; border: 1px solid #86efac; border-radius: 10px; background: #f0fdf4; }
.new-key-box > div { margin-top: 9px; display: flex; align-items: center; gap: 9px; }
.new-key-box code { min-width: 0; flex: 1; padding: 10px; overflow-wrap: anywhere; border-radius: 7px; background: white; user-select: all; }
.key-list { margin-top: 18px; display: grid; gap: 9px; }
.key-row { padding: 12px 14px; display: grid; grid-template-columns: minmax(150px, 1.2fr) minmax(120px, .8fr) minmax(130px, .9fr) auto; align-items: center; gap: 12px; border: 1px solid var(--slate-200); border-radius: 9px; }
.key-row > div:first-child { display: flex; flex-direction: column; gap: 3px; }
.key-row small { color: var(--slate-500); }
.key-row code { overflow-wrap: anywhere; font-size: 11px; }
.key-row .button { padding: 7px 9px; font-size: 11px; }
.empty-state.compact { min-height: 100px; margin-top: 18px; padding: 20px; }

.empty-state { min-height: 360px; padding: 42px; display: grid; place-items: center; align-content: center; text-align: center; border: 1px dashed var(--slate-300); border-radius: var(--radius); background: rgba(255,255,255,.55); }
.empty-state h2 { margin: 10px 0 4px; color: var(--slate-900); }
.empty-state p { max-width: 520px; margin: 0 0 18px; color: var(--slate-500); }
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; color: var(--blue-700); background: #e0f2fe; font-size: 28px; }
.empty-inline { padding: 25px; border: 1px dashed var(--slate-300); border-radius: 9px; color: var(--slate-500); text-align: center; background: rgba(255,255,255,.5); }
.hidden { display: none !important; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; width: min(370px, calc(100vw - 36px)); display: grid; gap: 8px; }
.toast { padding: 12px 14px; display: flex; align-items: start; gap: 9px; border-radius: 9px; color: white; background: var(--slate-900); box-shadow: 0 12px 35px rgba(2,15,25,.25); animation: toast-in .2s ease-out; }
.toast.success::before { content: "✓"; color: #86efac; font-weight: 900; }
.toast.error::before { content: "!"; color: #fca5a5; font-weight: 900; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

.install-page { display: grid; place-items: center; padding: 30px 16px; background: radial-gradient(circle at 50% 0, #0c4a6e, var(--navy-950) 55%); }
.install-card { width: min(620px, 100%); padding: 30px; border-radius: 15px; background: white; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.install-card > .brand-mark { margin-bottom: 20px; }
.install-card h1 { margin: 0 0 5px; color: var(--slate-950); }
.install-card > .muted { margin: 0 0 22px; }
.install-card .button-row { margin-top: 18px; }
.auth-card { width: min(460px, 100%); }
.auth-card > .eyebrow { margin-bottom: 5px; }
.auth-card .notice { margin-top: 18px; }
.auth-form { margin-top: 22px; }
.demo-option { padding: 13px; display: grid !important; grid-template-columns: 22px 1fr; gap: 10px !important; border: 1px solid var(--slate-300); border-radius: 9px; background: var(--slate-50); cursor: pointer; }
.demo-option input { width: 18px !important; min-height: 18px !important; margin: 3px 0 0; accent-color: var(--blue-700); }
.demo-option > span { display: flex; flex-direction: column; gap: 3px; color: var(--slate-800) !important; font-size: 14px !important; letter-spacing: 0 !important; text-transform: none !important; }
.demo-option small { color: var(--slate-500); font-size: 11px; font-weight: 500; line-height: 1.45; }

@media (max-width: 1580px) {
    :root { --header-height: 100px; }
    .app-header {
        min-height: var(--header-height);
        padding: 5px clamp(16px, 2.4vw, 36px);
        grid-template-columns: minmax(190px, 1fr) auto;
        grid-template-rows: 43px 43px;
        column-gap: 16px;
        row-gap: 2px;
    }
    .brand { grid-column: 1; grid-row: 1; }
    .brand-mark { width: 40px; height: 40px; flex-basis: 40px; }
    .header-filter {
        height: 43px;
        grid-column: 1 / -1;
        grid-row: 2;
        align-items: end;
        overflow: visible;
        padding: 0;
    }
    .filter-form { width: max-content; max-width: 100%; gap: 6px; }
    .filter-form label { gap: 2px; }
    .filter-form label > span { font-size: 9px; line-height: 1; }
    .filter-form input, .filter-form select { height: 32px; padding-inline: 8px; font-size: 12px; }
    .filter-form input[type="date"] { width: 118px; }
    .filter-form select { max-width: 175px; }
    .filter-form .search-label { width: 220px; }
    .filter-details summary { height: 32px; padding: 7px 9px; font-size: 11px; }
    .icon-button { width: 32px; height: 32px; flex-basis: 32px; }
    .main-nav { height: 43px; grid-column: 2; grid-row: 1; justify-self: end; }
    .nav-item > a { padding: 12px 8px 8px; }
    body[data-page="settings"] .app-header { min-height: 53px; grid-template-rows: 43px; }
    body[data-page="settings"] .header-filter { display: none; }
}

@media (max-width: 820px) {
    :root { --header-height: auto; }
    .app-header { position: relative; padding: 10px 14px 13px; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; gap: 9px; }
    body[data-page="settings"] .app-header { min-height: 0; grid-template-rows: auto auto; }
    .brand-copy small { display: none; }
    .main-nav { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 44px; overflow-x: auto; justify-self: stretch; }
    .nav-item { flex: 1 0 auto; }
    .nav-item > a { width: 100%; padding: 12px 10px 9px; text-align: center; }
    .nav-item > button { display: none !important; }
    .nav-account { flex: 0 0 auto; }
    .account-name { display: none; }
    .header-filter { height: auto; grid-column: 1 / -1; grid-row: 3; overflow-x: auto; justify-content: start; padding: 0 0 2px; }
    body[data-page="settings"] .header-filter { display: none; }
    .filter-form { width: max-content; justify-content: start; }
    .filter-details .area-filter-grid { position: fixed; top: 50%; left: 14px; right: 14px; width: auto; transform: translateY(-50%); }
    .status-filter-menu { position: fixed; top: 50%; left: 14px; right: 14px; width: auto; transform: translateY(-50%); }
    .scan-button { min-height: 42px; padding: 8px 11px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; color: white; background: rgba(255,255,255,.08); font-size: 12px; font-weight: 750; }
    .page-shell { width: min(100% - 24px, 1540px); padding-top: 23px; }
    .page-heading { align-items: center; }
    .page-heading .eyebrow { display: none; }
    .page-heading h1 { font-size: 28px; }
    .page-heading .button { padding-inline: 10px; }
    .card-grid, .person-grid { grid-template-columns: 1fr; }
    .expedition-layout { grid-template-columns: 1fr; }
    .vessel-editor-layout { grid-template-columns: 1fr; }
    .map-panel { min-height: 320px; }
    .map-panel iframe { min-height: 290px; }
    .sample-facts { grid-template-columns: repeat(2, 1fr); }
    .sample-editor-layout { grid-template-columns: 1fr; }
    .sample-files-panel { padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--slate-200); }
    .sample-file-modal-body { grid-template-columns: 1fr; }
    .file-preview { min-height: 360px; }
    .file-preview iframe { min-height: 360px; }
    .modal { max-height: calc(100dvh - 14px); }
    .modal-shell { max-height: calc(100dvh - 14px); }
    .scanner-fallback { flex-wrap: wrap; }
    .scanner-fallback > span { display: none; }
    .scanner-fallback label:not(.file-button) { flex-basis: calc(100% - 100px); }
    .camera-frame, .camera-frame video { min-height: 280px; }
}

@media (max-width: 560px) {
    .brand-mark { width: 39px; height: 39px; flex-basis: 39px; }
    .brand-copy strong { font-size: 14px; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .page-heading > .button, .page-heading > .button-row { align-self: stretch; }
    .page-heading .button-row .button { flex: 1; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: 1; }
    .area-filter-grid { grid-template-columns: 1fr 1fr; }
    .modal-header { padding: 14px 15px; }
    .modal-body { padding: 15px; }
    .modal-footer { padding: 11px 15px; }
    .modal-footer .autosave-state { max-width: 55%; }
    .modal-footer .button { max-width: 48%; }
    .bottle-grid { grid-template-columns: 1fr; }
    .bottle-reprint-bar { position: static; align-items: stretch; flex-direction: column; gap: 8px; }
    .bottle-reprint-bar > span { margin-right: 0; }
    .bottle-reprint-bar .button-row { width: 100%; }
    .bottle-reprint-bar .button { flex: 1; }
    .bottle-detail-heading { padding: 13px; gap: 13px; }
    .bottle-detail-heading .qr-detail { width: 105px; height: 105px; }
    .bottle-detail-heading p { display: none; }
    .panel { padding: 15px; }
    .sample-facts { grid-template-columns: 1fr; }
    .sample-history-main { align-items: start; }
    .sample-card-actions { align-items: stretch; flex-direction: column; }
    .sample-card-actions .button { width: 100%; }
    .sample-file-modal-body { min-height: auto; }
    .file-preview, .file-preview iframe { min-height: 300px; }
    .settings-submit { align-items: stretch; flex-direction: column; }
    .key-create-grid { grid-template-columns: 1fr; }
    .key-row { grid-template-columns: 1fr; }
    .new-key-box > div { align-items: stretch; flex-direction: column; }
    .entity-card { padding: 17px; }
    .person-card { grid-template-columns: 47px 1fr; }
    .person-monogram { width: 47px; height: 47px; }
    .table-summary span:last-child { display: none; }
    .active-filter { align-items: start; flex-wrap: wrap; }
    .active-filter a { width: 100%; margin-left: 0; }
}
