:root {
  --navy: #18334a;
  --navy-2: #244b65;
  --orange: #ed5a28;
  --ink: #1d2732;
  --muted: #687586;
  --line: #d1d7df;
  --canvas: #f3f5f8;
  --panel: #ffffff;
  --blue: #1976bd;
  --blue-soft: #eaf4fc;
  --green: #177a52;
  --green-soft: #e8f7f0;
  --amber: #996100;
  --amber-soft: #fff4d6;
  --gray-soft: #eef1f4;
  --shadow: 0 8px 24px rgba(26, 50, 72, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1080px;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", Arial, sans-serif;
}

button, input, select { font: inherit; }

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  color: #fff;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}

.brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 800; letter-spacing: .04em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid #fff; border-radius: 7px; font-size: 11px; }
.top-state { display: flex; align-items: center; gap: 9px; }
.pill { padding: 6px 10px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(255,255,255,.1); font-size: 12px; font-weight: 700; }
.pill::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #aeb9c4; }
.pill.online::before { background: #48d496; }
.pill.offline::before { background: #ffbf4a; }

main { width: calc(100% - 34px); max-width: 1780px; margin: 16px auto 32px; }

.connection-panel {
  display: grid;
  grid-template-columns: minmax(250px, .8fr) minmax(360px, 1.35fr) minmax(190px, .65fr) auto;
  gap: 14px;
  align-items: end;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

label { display: block; }
.caption { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.field, .search, select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #b9c2ce;
  border-radius: 6px;
  background: #fff;
  outline: none;
}
.field:focus, .search:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(25,118,189,.12); }

.button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 750;
}
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { color: #fff; background: var(--orange); }
.button-secondary { color: #526172; border-color: var(--line); background: #fff; }
.button-danger { color: #a23828; border-color: #e5b5ad; background: #fff7f5; }

.notice { display: none; margin-top: 12px; padding: 10px 14px; border: 1px solid #e6c773; border-radius: 7px; color: var(--amber); background: var(--amber-soft); }
.notice.show { display: block; }

.panel { margin-top: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.title-row { display: flex; align-items: baseline; gap: 10px; min-width: 280px; }
.title-row h1 { margin: 0; font-size: 18px; }
.record-count { color: var(--muted); font-size: 12px; }
.toolbar { display: grid; grid-template-columns: minmax(220px, 330px) 130px 130px 100px; gap: 8px; align-items: center; }

.library-meta { display: flex; gap: 22px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; color: var(--muted); font-size: 12px; }
.library-meta strong { color: var(--ink); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; min-height: 610px; }
.table-wrap { overflow: auto; border-right: 1px solid var(--line); }
table { width: 100%; min-width: 1390px; border-spacing: 0; border-collapse: separate; font-size: 13px; }
th, td { padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 4; height: 42px; color: #3e4c5b; background: #edf1f5; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #f7fbfe; }
tbody tr.active td { background: var(--blue-soft); }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 3; min-width: 92px; font-weight: 800; }
th:first-child { z-index: 6; }
.mark { color: var(--blue); }
.sketch-box { width: 170px; height: 76px; display: grid; place-items: center; overflow: hidden; border: 1px solid #e0e5ea; border-radius: 5px; background: #fff; }
.sketch-box img { display: block; max-width: 160px; max-height: 68px; object-fit: contain; }
tbody tr.active td.sketch-cell, tbody tr:hover td.sketch-cell { background: #fff; }

.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-active { color: var(--green); background: var(--green-soft); }
.status-inactive { color: #697482; background: var(--gray-soft); }
.status-archived { color: var(--amber); background: var(--amber-soft); }

.reference-panel { padding: 15px; background: #fafbfd; }
.reference-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.reference-header h2 { margin: 0; font-size: 15px; }
.shape-badge { min-width: 48px; padding: 5px 8px; border-radius: 6px; color: #fff; background: var(--navy); text-align: center; font-weight: 800; }
.reference-image { width: 298px; height: 220px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.reference-image img { display: block; max-width: 286px; max-height: 208px; object-fit: contain; }
.record-detail { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.record-detail h3 { margin: 0 0 10px; font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: 105px 1fr; gap: 8px 10px; font-size: 12px; }
.detail-grid span:nth-child(odd) { color: var(--muted); }
.detail-grid span:nth-child(even) { font-weight: 700; word-break: break-word; }
.reference-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }

.empty { display: none; padding: 55px; color: var(--muted); text-align: center; }
.empty.show { display: block; }
.start-state { padding: 80px 20px; color: var(--muted); text-align: center; }
.start-state strong { display: block; margin-bottom: 8px; color: var(--ink); font-size: 17px; }
.footer-note { padding: 9px 14px; border-top: 1px solid var(--line); color: var(--muted); background: #fafbfd; font-size: 11px; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 440px; padding: 12px 15px; border-radius: 8px; color: #fff; background: var(--navy); box-shadow: 0 8px 28px rgba(0,0,0,.24); opacity: 0; transform: translateY(10px); transition: .2s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1250px) {
  .connection-panel { grid-template-columns: 1fr 1.25fr 1fr auto; }
  .content-grid { grid-template-columns: minmax(0, 1fr) 310px; }
  .reference-image { width: 278px; }
}
