/* ============================================================
   Demo — Title Block Extractor
   Project BPS-04 drawing register inside the Asite CDE chrome.
   Drop a drawing → a real agent reads its title block → a clean
   row is filed into the register. All selectors prefixed `tbx-`.
   Builds on tokens in main.css.
   ============================================================ */

.tbx-app {
  position: relative;
  min-height: 520px;
  --tbx: #0E8F8A;
  --tbx-d: #0A6E6A;
  --tbx-l: #E6F4F3;
}

/* ---- CDE shell ---- */
.tbx-cde {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: var(--sh-1);
  overflow: hidden;
  font-size: 12.5px;
}

/* ---- dark top bar ---- */
.tbx-top {
  display: flex; align-items: center; gap: 14px;
  height: 46px; padding: 0 14px; color: #fff;
  background: linear-gradient(90deg, #2a6db5, #15375f);
}
.tbx-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.tbx-logo {
  width: 26px; height: 26px; border-radius: 6px; background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.tbx-brandtx { letter-spacing: .04em; font-size: 14px; }
.tbx-topsearch {
  display: flex; align-items: center; gap: 8px;
  width: 220px; height: 28px; padding: 0 11px; border-radius: 6px;
  background: rgba(255,255,255,.92); color: var(--text-3); font-size: 12.5px;
}
.tbx-proj { display: flex; align-items: center; gap: 6px; opacity: .96; }
.tbx-proj strong { font-weight: 700; }
.tbx-tools { margin-left: auto; display: flex; align-items: center; gap: 11px; }
.tbx-ic { opacity: .9; display: inline-flex; }
.tbx-ava {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%; font-size: 9.5px; font-weight: 800;
  color: #fff; background: #2f9c8f;
}

/* ---- nav tabs ---- */
.tbx-tabs {
  display: flex; align-items: center; gap: 2px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: #fff; overflow-x: auto;
}
.tbx-tab {
  padding: 11px 12px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--text-2); border-bottom: 2px solid transparent;
}
.tbx-tab.active { color: var(--asite-blue-text); border-bottom-color: var(--asite-blue); font-weight: 700; }

/* ---- body ---- */
.tbx-body { padding: 16px; background: #fafbfc; }

/* ============================================================
   REGISTER
   ============================================================ */
.tbx-reg {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.tbx-reg-head {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--bg-sunken);
}
.tbx-reg-title { display: flex; align-items: baseline; gap: 10px; }
.tbx-reg-title h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.tbx-reg-count {
  font-size: 11.5px; font-weight: 600; color: var(--text-3);
  padding: 2px 8px; border-radius: 999px; background: #eef2f7;
}
.tbx-extract-btn {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px; border: none; border-radius: 7px;
  background: linear-gradient(120deg, var(--tbx), var(--tbx-d));
  color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 14px -6px rgba(14,143,138,.6);
  transition: filter .14s ease, transform .12s ease;
}
.tbx-extract-btn:hover { filter: brightness(1.06); }
.tbx-extract-btn:active { transform: translateY(1px); }
.tbx-extract-sp { display: inline-flex; }

.tbx-tablewrap { overflow-x: auto; }
.tbx-table { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.tbx-table th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 700;
  color: var(--text-3); background: #f5f7fa; padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.tbx-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); color: var(--text); vertical-align: middle; }
.tbx-table tbody tr:last-child td { border-bottom: none; }
.tbx-table tbody tr:hover td { background: #f7fafc; }
.tbx-c-ic { width: 34px; color: var(--tbx); }
.tbx-c-ic .ico { display: inline-flex; }
.tbx-c-num { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.tbx-c-rev { font-variant-numeric: tabular-nums; font-weight: 600; }
.tbx-c-dim { color: var(--text-3); }

.tbx-new-pill,
.tbx-new-pill { margin-left: 8px; }
.tbx-new-pill {
  display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; padding: 1px 6px; border-radius: 4px;
  background: var(--tbx-l); color: var(--tbx-d);
}

/* just-filed row highlight */
.tbx-row-new td { background: var(--tbx-l) !important; animation: tbx-flash 2.4s ease; }
@keyframes tbx-flash {
  0% { background: #C9EBE8; }
  100% { background: var(--tbx-l); }
}

/* status badge */
.tbx-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.tbx-badge.ok   { background: var(--ok-bg); color: var(--ok); }
.tbx-badge.warn { background: var(--warn-bg); color: var(--warn); }
.tbx-badge.bad  { background: #FBEAEE; color: var(--err); }
.tbx-badge.info { background: #eef2f7; color: var(--text-2); }

/* ============================================================
   EXTRACTION PANEL (docks above the register)
   ============================================================ */
.tbx-panel {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: var(--sh-2);
  overflow: hidden;
  margin-bottom: 16px;
}
.tbx-pn-head {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 13px; color: #fff;
  background: linear-gradient(100deg, var(--tbx) 0%, var(--tbx-d) 70%, #11507a 100%);
}
.tbx-pn-orb {
  width: 32px; height: 32px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; background: rgba(255,255,255,.18);
}
.tbx-pn-id { flex: 1; min-width: 0; }
.tbx-pn-name { font-size: 14px; font-weight: 700; }
.tbx-pn-sub { font-size: 11.5px; opacity: .88; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbx-pn-tag {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.18);
}
.tbx-pn-tag.live { background: rgba(255,255,255,.26); }
.tbx-pn-x {
  width: 30px; height: 30px; flex: none; display: flex; align-items: center; justify-content: center;
  border: none; background: rgba(255,255,255,.14); border-radius: 6px; color: #fff; cursor: pointer;
  transition: background .12s;
}
.tbx-pn-x:hover { background: rgba(255,255,255,.28); }
.tbx-pn-body { padding: 16px; background: #F6FAFA; }

/* spinner */
.tbx-spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(14,143,138,.3); border-top-color: var(--tbx);
  display: inline-block; animation: tbx-spin .65s linear infinite;
}
.tbx-spin.sm { width: 13px; height: 13px; }
@keyframes tbx-spin { to { transform: rotate(360deg); } }

/* reading checklist */
.tbx-reading-t { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 14px; }
.tbx-cklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.tbx-ck { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-3); }
.tbx-ck.active { color: var(--text); font-weight: 600; }
.tbx-ck.done { color: var(--text-2); }
.tbx-ck-mark { display: inline-flex; }
.tbx-ck-mark.ok { color: var(--ok); }
.tbx-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-strong); display: inline-block; }

/* review fields */
.tbx-review-head {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--tbx-d);
  background: var(--tbx-l); padding: 4px 10px; border-radius: 999px; margin-bottom: 12px;
}
.tbx-review-head .ico { color: var(--tbx-d); }
.tbx-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line-soft); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.tbx-fld {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; min-width: 0;
}
.tbx-fld-l { font-size: 11px; font-weight: 600; color: var(--text-3); width: 96px; flex: none; }
.tbx-fld-v { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.tbx-fld-v em { font-style: normal; font-weight: 500; color: var(--warn); }
.tbx-fld-ic { flex: none; display: inline-flex; color: var(--ok); }
.tbx-fld.miss { background: #FFFBF2; }
.tbx-fld.miss .tbx-fld-ic { color: var(--warn); }
.tbx-review-note { font-size: 12px; line-height: 1.5; color: var(--text-2); margin: 12px 0 0; }

/* fail state */
.tbx-fail { text-align: center; padding: 14px 8px 6px; }
.tbx-fail-ic {
  width: 50px; height: 50px; margin: 0 auto 12px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; color: var(--warn); background: var(--warn-bg);
}
.tbx-fail-t { font-size: 15px; font-weight: 700; color: var(--text); }
.tbx-fail p { font-size: 12.5px; line-height: 1.55; color: var(--text-2); margin: 8px auto 16px; max-width: 42ch; }

/* manual entry */
.tbx-mfields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 4px; }
.tbx-mf { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tbx-mf-l { font-size: 11px; font-weight: 600; color: var(--text-3); }
.tbx-mf-l em { font-style: normal; color: var(--tbx-d); font-weight: 700; }
.tbx-mf-i {
  height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text); background: #fff; min-width: 0;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.tbx-mf-i:focus { outline: none; border-color: var(--tbx); box-shadow: 0 0 0 3px var(--tbx-l); }

/* panel actions */
.tbx-pn-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.tbx-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: filter .14s ease, background .14s ease, transform .12s ease;
}
.tbx-btn.ghost { background: #fff; border-color: var(--line-strong); color: var(--text-2); }
.tbx-btn.ghost:hover { border-color: var(--tbx); color: var(--tbx-d); }
.tbx-btn.primary {
  background: linear-gradient(120deg, var(--tbx), var(--tbx-d)); color: #fff;
  box-shadow: 0 6px 14px -6px rgba(14,143,138,.6);
}
.tbx-btn.primary:hover { filter: brightness(1.06); }
.tbx-btn.primary:active { transform: translateY(1px); }
.tbx-btn:disabled { opacity: .5; cursor: default; filter: none; box-shadow: none; }

/* ============================================================
   UPLOAD MODAL
   ============================================================ */
.tbx-drop {
  border: 2px dashed var(--line-strong); border-radius: 12px;
  padding: 28px 20px 24px; text-align: center; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.tbx-drop:hover, .tbx-drop:focus-visible { background: var(--tbx-l); border-color: var(--tbx); outline: none; }
.tbx-drop.drag { background: var(--tbx-l); border-color: var(--tbx); }
.tbx-file-input { display: none; }
.tbx-drop-cloud { color: var(--tbx); margin-bottom: 10px; line-height: 0; }
.tbx-drop-cloud svg { display: inline-block; }
.tbx-drop-t { font-size: 17px; font-weight: 700; color: var(--text); }
.tbx-drop-s { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.tbx-drop-link { color: var(--tbx-d); font-weight: 600; text-decoration: underline; }
.tbx-drop-types { font-size: 11.5px; color: var(--text-3); margin-top: 10px; letter-spacing: .02em; }

.tbx-or {
  display: flex; align-items: center; gap: 12px; margin: 16px 0;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
}
.tbx-or::before, .tbx-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.tbx-sample-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; cursor: pointer;
  transition: border-color .14s ease, background .14s ease;
}
.tbx-sample-btn:hover { border-color: var(--tbx); background: var(--tbx-l); }
.tbx-sample-ic {
  width: 36px; height: 36px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--tbx-l); color: var(--tbx-d);
}
.tbx-sample-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tbx-sample-tx b { font-size: 13px; font-weight: 700; color: var(--text); }
.tbx-sample-tx span { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.tbx-sample-go { flex: none; color: var(--text-3); display: inline-flex; }
.tbx-sample-btn:hover .tbx-sample-go { color: var(--tbx-d); }

.tbx-drop-hint {
  display: flex; align-items: flex-start; gap: 7px; margin: 16px 0 0;
  font-size: 11.5px; line-height: 1.5; color: var(--text-3);
}
.tbx-drop-hint .ico { color: var(--tbx); flex: none; margin-top: 1px; }
.tbx-drop-hint b { color: var(--text-2); }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .tbx-topsearch { display: none; }
  .tbx-fields { grid-template-columns: 1fr; }
  .tbx-reg-head { flex-wrap: wrap; }
  .tbx-extract-btn { margin-left: 0; }
}
