:root {
    --bg: #f5f6f7;
    --card: #ffffff;
    --text: #171717;
    --muted: #555555;
    --border: #c8ccd0;
    --header: #202020;
    --select: #eaf2ff;
    --deleted: #fff2cc;
    --deleted-border: #d6a700;
    --own: #fce4d6;
    --own-border: #c65911;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}
main {
    width: min(98vw, 1900px);
    margin: 0 auto;
    padding: 16px 18px 20px;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}
h1 { margin: 0; font-size: 40px; line-height: 1.05; }
.subtitle { margin: 5px 0 0; color: var(--muted); font-size: 17px; }
.version { color: var(--muted); font-weight: 700; font-size: 15px; padding-top: 8px; }
.search-panel { display: flex; gap: 10px; align-items: stretch; }
#searchInput {
    min-width: 0;
    flex: 1;
    font-size: 30px;
    padding: 14px 16px;
    border: 2px solid #8f959b;
    border-radius: 10px;
    background: #fff;
    outline: none;
}
#searchInput:focus { border-color: #3d6fa7; box-shadow: 0 0 0 3px rgba(61,111,167,.12); }
button {
    min-width: 105px;
    border: 1px solid #aeb4ba;
    background: #fff;
    color: var(--text);
    padding: 10px 16px;
    border-radius: 9px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
}
button:hover { background: #eceff2; }
.status-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 16px;
    margin: 8px 1px 7px;
    min-height: 24px;
}
.master-count { white-space: nowrap; }
.notice {
    padding: 10px 13px;
    background: #fff7df;
    border: 1px solid #e0c56b;
    border-radius: 9px;
    margin-bottom: 9px;
    font-size: 15px;
    font-weight: 700;
}
.hidden { display: none !important; }
.best-card {
    display: grid;
    grid-template-columns: 230px 1fr;
    gap: 8px 24px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 11px;
    padding: 12px 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.best-card.deleted { background: var(--deleted); border-color: var(--deleted-border); }
.best-card.own { background: var(--own); border-color: var(--own-border); }
.best-card.empty { color: var(--muted); }
.best-label {
    grid-column: 1 / -1;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .05em;
    color: var(--muted);
}
.location-block { display: flex; align-items: center; }
.best-bin { font-size: 48px; font-weight: 850; line-height: 1; white-space: nowrap; }
.best-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(170px, 1fr));
    gap: 7px 22px;
    align-items: start;
}
.field { display: flex; flex-direction: column; min-width: 0; font-size: 19px; font-weight: 700; }
.field.wide { grid-column: span 2; }
.field-label { color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 1px; }
.best-status {
    grid-column: 1 / -1;
    font-size: 17px;
    font-weight: 800;
    padding-top: 4px;
}
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 8px; }
.legend-title { font-size: 13px; font-weight: 800; }
.legend-chip {
    border: 1px solid #b9bec3;
    border-radius: 5px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 800;
}
.legend-chip.normal { background: #fff; }
.legend-chip.deleted { background: var(--deleted); }
.legend-chip.own { background: var(--own); }
.table-wrap {
    overflow: auto;
    background: #fff;
    border: 1px solid #d3d6d9;
    border-radius: 9px;
    height: calc(100vh - 365px);
    min-height: 300px;
}
table { border-collapse: collapse; width: 100%; min-width: 1450px; table-layout: fixed; }
col.col-area { width: 85px; }
col.col-bin { width: 105px; }
col.col-pn { width: 210px; }
col.col-alt { width: 170px; }
col.col-nsn { width: 190px; }
col.col-nom { width: 500px; }
col.col-status { width: 390px; }
th, td {
    padding: 9px 11px;
    border-bottom: 1px solid #e5e7e9;
    text-align: left;
    vertical-align: middle;
    font-size: 17px;
}
th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--header);
    color: #fff;
    font-size: 15px;
    white-space: nowrap;
}
td:nth-child(1), td:nth-child(2), td:nth-child(3), td:nth-child(4), td:nth-child(5) { white-space: nowrap; }
td:nth-child(3), td:nth-child(4), td:nth-child(5) {
    overflow: hidden;
    text-overflow: ellipsis;
}
td:nth-child(2) { font-size: 19px; font-weight: 850; }
td:nth-child(6), td:nth-child(7) { white-space: normal; }
td:nth-child(6) { min-width: 500px; }
td:nth-child(7) { min-width: 390px; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { outline: 2px solid rgba(61,111,167,.2); outline-offset: -2px; }
tbody tr.normal:hover, tbody tr.normal.selected { background: var(--select); }
tbody tr.deleted { background: var(--deleted); }
tbody tr.own { background: var(--own); }
.table-wrap::-webkit-scrollbar { height: 17px; width: 15px; }
.table-wrap::-webkit-scrollbar-track { background: #e5e5e5; }
.table-wrap::-webkit-scrollbar-thumb { background: #666; border-radius: 999px; border: 3px solid #e5e5e5; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #333; }
@media (max-width: 1000px) {
    main { padding: 12px; }
    h1 { font-size: 34px; }
    #searchInput { font-size: 24px; }
    .best-card { grid-template-columns: 1fr; }
    .best-label, .best-status { grid-column: 1; }
    .best-details { grid-template-columns: repeat(2, minmax(150px,1fr)); }
    .best-bin { font-size: 42px; }
    .table-wrap { height: calc(100vh - 430px); }
}
@media (max-width: 650px) {
    .search-panel { flex-wrap: wrap; }
    #searchInput { flex-basis: 100%; }
    button { flex: 1; }
    .status-line { flex-direction: column; gap: 2px; }
    .best-details { grid-template-columns: 1fr; }
    .field.wide { grid-column: span 1; }
    .table-wrap { height: 55vh; }
}
