/* =============================================================================
   UTILITY ASSET INSPECTION AI — STYLES
   Visual language inherited from sixthwave-cockpit / policy-copilot,
   tuned with utility-flavor rose accent for CV.
   ============================================================================ */

:root {
  --bg:       #0a0d15;
  --bg2:      #0c1019;
  --panel:    #10141f;
  --panel2:   #141a28;
  --line:     #1e2638;
  --line2:    #2a3550;
  --text:     #e8edf6;
  --dim:      #8a97b0;
  --faint:    #5c6883;
  --teal:     #2dd4bf;
  --gold:     #e0b94d;
  --rose:     #fb7185;
  --red:      #ef4444;
  --amber:    #f59e0b;
  --emerald:  #34d399;

  --mono:    'JetBrains Mono', ui-monospace, monospace;
  --display: 'Fraunces', Georgia, serif;
  --body:    'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  letter-spacing: -0.01em;
  min-height: 100vh;
}

button { font-family: inherit; color: inherit; cursor: pointer; background: none; border: none; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

/* ────────────────────────────────────────────────────────── TOPBAR */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--rose), #9f1239);
  display: grid; place-items: center;
  box-shadow: 0 4px 18px rgba(251, 113, 133, 0.32);
}
.brand-mark span { font-family: var(--mono); font-weight: 600; font-size: 14px; color: #2c0511; }
.brand-name { font-family: var(--display); font-size: 19px; font-weight: 600; line-height: 1.1; }
.brand-tag  { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.22em; color: var(--gold); margin-top: 5px; }

.link-back {
  color: var(--dim); text-decoration: none;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line2);
  transition: all 0.15s;
}
.link-back:hover { color: var(--rose); border-color: var(--rose); }

/* ────────────────────────────────────────────────────────── MAIN */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 36px 32px 64px;
  animation: rise 0.4s ease both;
}

.label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 12px;
}

h1 {
  font-family: var(--display);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}
h1 .accent { color: var(--rose); }

h2 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}

.lede {
  color: var(--dim);
  font-size: 15.5px;
  max-width: 760px;
  line-height: 1.6;
  margin-bottom: 28px;
}

/* ────────────────────────────────────────────────────────── STATS */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--accent, var(--rose)), transparent);
}
.stat-card .n {
  font-family: var(--display); font-size: 28px; font-weight: 600; line-height: 1;
}
.stat-card .l {
  color: var(--dim); font-size: 11.5px; margin-top: 5px;
  font-family: var(--mono); letter-spacing: 0.06em;
}

/* ────────────────────────────────────────────────────────── FLEET */
.fleet-block { margin-bottom: 40px; }

.block-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; margin-bottom: 14px;
}
.block-head .label { margin: 0; }

.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 5px 11px; border-radius: 18px;
  background: var(--panel); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  color: var(--dim);
  transition: all 0.1s;
}
.pill:hover { color: var(--text); border-color: var(--line2); }
.pill.active { background: var(--rose); border-color: var(--rose); color: #2c0511; font-weight: 600; }

.fleet-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.pole-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px 14px;
  cursor: pointer;
  position: relative; overflow: hidden;
  transition: border-color 0.12s, transform 0.08s;
}
.pole-card:hover { border-color: var(--rose); transform: translateY(-1px); }
.pole-card .head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.pole-card .id {
  font-family: var(--mono); font-size: 11.5px; color: var(--text); font-weight: 600;
}
.pole-card .score {
  font-family: var(--display); font-size: 20px; font-weight: 600;
  color: var(--score-color, var(--text));
}
.pole-card .circuit {
  font-family: var(--mono); font-size: 9.5px; color: var(--faint);
  letter-spacing: 0.08em; margin-bottom: 8px;
}
.pole-card .priority-tag {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  background: var(--pcolor); color: #fff; margin-bottom: 8px;
}
.pole-card .defect-row {
  display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px;
}
.pole-card .defect-chip {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 11px;
  background: var(--chip-bg); color: var(--chip-fg);
  border: 1px solid var(--chip-fg);
}
.pole-card .empty { color: var(--faint); font-size: 11px; font-style: italic; }

/* ────────────────────────────────────────────────────────── INSPECT */
.inspect-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 26px;
}

.input-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab {
  padding: 7px 14px; border-radius: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  color: var(--dim); transition: all 0.12s;
  border: 1px solid var(--line);
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg); color: var(--rose); border-color: var(--rose); }

.tab-panel { margin-bottom: 14px; }

.samples-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.sample-card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.1s;
  display: flex; flex-direction: column; gap: 8px;
}
.sample-card:hover { border-color: var(--rose); }
.sample-card img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px;
  background: var(--line);
}
.sample-card .name { font-size: 12px; font-weight: 500; line-height: 1.3; }
.sample-card .hint { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }

.input-form {
  display: flex; gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 10px; padding: 6px;
}
.input-form:focus-within { border-color: var(--rose); }
.input-form input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--body); font-size: 14px; color: var(--text);
  padding: 10px 12px;
}
.input-form input::placeholder { color: var(--faint); }

.primary-btn {
  padding: 10px 22px; border-radius: 7px;
  background: var(--rose); color: #2c0511;
  font-weight: 600; font-size: 13px; letter-spacing: 0.02em;
  transition: background 0.12s, transform 0.08s;
}
.primary-btn:hover { background: #fda4af; }
.primary-btn:active { transform: scale(0.97); }
.primary-btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.hint {
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  margin-top: 6px; letter-spacing: 0.04em;
}

.upload-zone {
  display: block; cursor: pointer;
  background: var(--bg2);
  border: 2px dashed var(--line2);
  border-radius: 11px;
  padding: 40px 20px;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}
.upload-zone:hover, .upload-zone.drag {
  border-color: var(--rose); background: var(--bg);
}
.upload-text strong { display: block; font-family: var(--display); font-size: 17px; margin-bottom: 6px; }
.upload-text span { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }

/* ────────────────────────────────────────────────────────── RESULT */
#result-block { margin-top: 22px; }
.result-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.model-tag {
  font-family: var(--mono); font-size: 10px; color: var(--teal);
  letter-spacing: 0.14em; text-transform: uppercase;
}

.result-grid {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 18px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.result-image img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 8px; background: var(--line);
}
.result-imgmeta {
  font-family: var(--mono); font-size: 9.5px; color: var(--faint);
  margin-top: 6px; word-break: break-all;
}

.result-body { display: flex; flex-direction: column; gap: 14px; }

.result-topline {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line); padding-bottom: 14px;
}
.score-block { display: flex; align-items: baseline; gap: 10px; }
.score-num {
  font-family: var(--display); font-size: 44px; font-weight: 600; line-height: 1;
  color: var(--score-color, var(--text));
}
.score-cap {
  font-family: var(--mono); font-size: 9.5px; color: var(--faint);
  letter-spacing: 0.1em; text-transform: uppercase;
}

.priority-pill {
  padding: 7px 14px; border-radius: 7px;
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.16em;
  background: var(--pcolor); color: #fff;
}

.result-summary { font-size: 14px; line-height: 1.6; color: var(--text); }
.result-action {
  font-family: var(--mono); font-size: 11.5px; color: var(--gold);
  background: rgba(224, 185, 77, 0.07);
  border: 1px solid rgba(224, 185, 77, 0.3);
  padding: 9px 12px; border-radius: 7px;
  letter-spacing: 0.02em;
}

.defects-list { display: flex; flex-direction: column; gap: 7px; }
.defect-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.defect-row .swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.defect-row .label-d {
  font-size: 12.5px; color: var(--text); font-weight: 500; flex: 1;
}
.defect-row .sev {
  font-family: var(--mono); font-size: 9px; padding: 2px 7px; border-radius: 4px;
  letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700;
}
.defect-row .sev.low    { background: rgba(52, 211, 153, 0.16); color: var(--emerald); }
.defect-row .sev.medium { background: rgba(245, 158, 11, 0.16); color: var(--amber); }
.defect-row .sev.high   { background: rgba(239, 68, 68, 0.16); color: var(--red); }
.defect-row .conf {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
}
.defect-row .evidence {
  flex-basis: 100%; padding-left: 20px; padding-top: 4px;
  font-size: 11.5px; color: var(--dim); line-height: 1.5; font-style: italic;
}

/* ────────────────────────────────────────────────────────── LOADING / ERROR */
#loading-block { margin-top: 22px; text-align: center; padding: 30px; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--rose);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 12px;
}
.loading-text { color: var(--dim); font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; animation: pulse 1.6s ease-in-out infinite; }

#error-block { margin-top: 18px; padding: 16px 18px; background: rgba(251, 113, 133, 0.06); border: 1px solid rgba(251, 113, 133, 0.3); border-radius: 11px; }
.error-text { font-family: var(--mono); font-size: 12px; color: #fda4af; line-height: 1.55; white-space: pre-wrap; }

/* ────────────────────────────────────────────────────────── DRILLDOWN */
#drilldown { position: fixed; inset: 0; z-index: 50; }
.dd-backdrop { position: absolute; inset: 0; background: rgba(4, 8, 16, 0.65); }
.dd-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 14px;
  padding: 26px 28px;
}
.dd-close { position: absolute; top: 12px; right: 14px; font-size: 26px; line-height: 1; color: var(--dim); padding: 4px 9px; border-radius: 6px; }
.dd-close:hover { background: var(--panel); color: var(--text); }
#dd-body h3 { font-family: var(--display); font-size: 22px; font-weight: 600; margin-bottom: 12px; }
#dd-body .meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin-bottom: 18px; }
#dd-body .kv-l { font-family: var(--mono); font-size: 9.5px; color: var(--faint); letter-spacing: 0.1em; }
#dd-body .kv-v { font-size: 13px; }

/* ────────────────────────────────────────────────────────── FOOTER */
footer {
  border-top: 1px solid var(--line);
  padding: 18px 32px;
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  max-width: 1180px; margin: 0 auto;
}

/* ────────────────────────────────────────────────────────── 375px MOBILE */
@media (max-width: 760px) {
  .topbar { padding: 14px 16px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-mark span { font-size: 12px; }
  .brand-name { font-size: 15px; }
  .brand-tag { font-size: 8.5px; }

  main { padding: 22px 16px 40px; }
  h1 { font-size: 24px; }
  h2 { font-size: 19px; }
  .lede { font-size: 13.5px; }

  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .fleet-grid { grid-template-columns: 1fr; }
  .samples-grid { grid-template-columns: repeat(2, 1fr); }
  .result-grid { grid-template-columns: 1fr; padding: 14px; }

  .inspect-block { padding: 18px 16px; }
  .input-form { flex-direction: column; padding: 6px; }
  .primary-btn { width: 100%; }
  footer { padding: 14px 16px; }
}
