:root {
  --v3-ink: #203548;
  --v3-paper: #fffaf0;
  --v3-pink: #ff65a3;
  --v3-yellow: #ffd83d;
  --v3-blue: #20cbd4;
  --v3-purple: #a997ff;
  --v3-green: #91dc4d;
  --v3-orange: #ff8b61;
}

.v3-backend-ribbon {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: center;
  margin-block: 24px;
  padding: 14px 18px;
  border: 3px solid var(--v3-ink);
  border-radius: 999px;
  background: #e9fbf7;
  box-shadow: 5px 6px 0 var(--v3-ink);
}

.v3-backend-ribbon.is-offline { background: #ffe1d5; }
.v3-backend-ribbon.is-live { background: #e5ffd0; }
.v3-backend-ribbon small { color: #566574; }
.v3-pulse { width: 13px; height: 13px; border-radius: 50%; background: var(--v3-orange); box-shadow: 0 0 0 5px rgb(255 139 97 / 22%); }
.v3-backend-ribbon.is-live .v3-pulse { background: #31b66d; animation: v3-pulse 1.8s infinite; }

@keyframes v3-pulse { 50% { box-shadow: 0 0 0 10px rgb(49 182 109 / 0%); } }

.v3-tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  margin-block: 34px;
}

.v3-panel,
.route-library,
.coast-switcher {
  position: relative;
  overflow: hidden;
  border: 3px solid var(--v3-ink);
  border-radius: 30px;
  background: var(--v3-paper);
  box-shadow: 8px 9px 0 var(--v3-ink);
}

.v3-panel { padding: clamp(20px, 3vw, 32px); }
.relay-panel { background: linear-gradient(145deg, #fff6fb 0 58%, #ffe1ef 100%); }
.task-panel { background: linear-gradient(145deg, #fffbea 0 58%, #fff0a8 100%); }
.ocr-panel { background: linear-gradient(145deg, #e9fbf7, #d8f8ff); }
.shield-panel { background: linear-gradient(145deg, #f5f0ff, #e7deff); }

.v3-panel::after,
.route-library::after,
.coast-switcher::after {
  content: "✦";
  position: absolute;
  right: 20px;
  top: 14px;
  color: rgb(32 53 72 / 13%);
  font-size: 64px;
  transform: rotate(11deg);
  pointer-events: none;
}

.v3-panel-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 12px; }
.v3-panel-heading > span { display: grid; place-items: center; width: 52px; height: 52px; border: 2px solid var(--v3-ink); border-radius: 18px; background: #fff; font-size: 27px; transform: rotate(-4deg); }
.v3-panel-heading p { margin: 0; font-size: 11px; font-weight: 900; letter-spacing: .14em; color: #685b76; }
.v3-panel-heading h2 { margin: 2px 0 0; font-size: clamp(24px, 3vw, 34px); }

.relay-pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding: 0; margin: 20px 0; list-style: none; counter-reset: relay; }
.relay-pipeline li { position: relative; min-height: 76px; padding: 34px 10px 10px; border: 2px solid var(--v3-ink); border-radius: 15px; background: #fff; font-size: 12px; font-weight: 850; text-align: center; }
.relay-pipeline li::before { counter-increment: relay; content: counter(relay); position: absolute; top: 7px; left: 50%; translate: -50% 0; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--v3-pink); color: #fff; }
.relay-pipeline li:nth-child(2)::before { background: var(--v3-orange); }
.relay-pipeline li:nth-child(3)::before { background: var(--v3-purple); }
.relay-pipeline li:nth-child(4)::before { background: #31b66d; }

.relay-trust { display: flex; align-items: baseline; gap: 10px; padding: 13px 15px; border-radius: 17px; background: var(--v3-ink); color: #fff; }
.relay-trust strong { font-size: 27px; color: var(--v3-yellow); }
.relay-list,
.task-list,
#adminQueue { display: grid; gap: 10px; margin-top: 15px; max-height: 440px; overflow: auto; padding-right: 4px; }
.relay-item,
.task-item,
.admin-item { padding: 13px; border: 2px solid var(--v3-ink); border-radius: 17px; background: rgb(255 255 255 / 86%); }
.relay-item-top,
.task-item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.relay-item small,
.task-item small,
.admin-item small { display: block; margin-top: 4px; color: #61707c; }
.relay-history { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.relay-history span,
.status-pill { display: inline-flex; padding: 4px 8px; border: 1.5px solid var(--v3-ink); border-radius: 999px; background: #fff1b6; font-size: 11px; font-weight: 800; }
.relay-item > button { margin-top: 10px; padding: 7px 9px; border: 1.5px solid var(--v3-ink); border-radius: 10px; background: var(--v3-yellow); font-weight: 850; cursor: pointer; }
.status-pill.is-confirmed,
.status-pill.is-field_reconfirmed { background: #dfffc7; }
.status-pill.is-rejected { background: #ececec; }
.status-pill.is-needs_evidence { background: #ffe0cd; }

.admin-review { margin-top: 18px; padding: 12px; border: 2px dashed var(--v3-ink); border-radius: 16px; }
.admin-review summary { cursor: pointer; font-weight: 900; }
.admin-review label { display: grid; gap: 5px; margin-block: 10px; }
.admin-review input,
.task-toolbar select,
.route-library-toolbar select,
.coast-toolbar input { min-height: 42px; padding: 7px 10px; border: 2px solid var(--v3-ink); border-radius: 11px; background: #fff; color: var(--v3-ink); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.admin-actions button { min-height: 34px; padding: 5px 9px; border: 1.5px solid var(--v3-ink); border-radius: 10px; background: #fff; font-weight: 800; cursor: pointer; }

.task-toolbar,
.route-library-toolbar,
.coast-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-block: 15px; }
.task-toolbar label,
.route-library-toolbar label,
.coast-toolbar label { display: grid; gap: 5px; font-size: 12px; font-weight: 850; }
.task-stats { display: flex; flex-wrap: wrap; gap: 7px; }
.task-stats span { padding: 6px 9px; border-radius: 999px; background: var(--v3-ink); color: #fff; font-size: 11px; font-weight: 800; }
.task-item p { margin: 9px 0; }
.task-item button,
.route-recipe button,
.coast-card button { border: 2px solid var(--v3-ink); border-radius: 11px; padding: 8px 10px; background: var(--v3-yellow); color: var(--v3-ink); font-weight: 900; cursor: pointer; }
.task-item button:disabled { opacity: .48; cursor: not-allowed; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.task-actions .ghost-button { background: #fff; }

.passport-live { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.passport-pick { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 9px; border: 2px solid var(--v3-ink); border-radius: 14px; background: #fff; text-align: left; cursor: pointer; }
.passport-pick > span { font-size: 23px; }
.passport-pick small { display: block; color: #68727b; }
.passport-pick b { color: #7453e8; font-size: 11px; }

.route-library,
.coast-switcher { padding: clamp(22px, 4vw, 42px); margin-block: 46px; }
.route-library { background: linear-gradient(145deg, #f4f0ff, #fff7df); }
.route-library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.route-recipe { display: flex; flex-direction: column; gap: 9px; min-height: 220px; padding: 17px; border: 2.5px solid var(--v3-ink); border-radius: 20px; background: #fff; box-shadow: 4px 5px 0 var(--v3-ink); }
.route-recipe:nth-child(6n + 2) { background: #fff2f8; }
.route-recipe:nth-child(6n + 3) { background: #e9fbf7; }
.route-recipe:nth-child(6n + 4) { background: #fff8ce; }
.route-recipe:nth-child(6n + 5) { background: #f0ebff; }
.route-recipe:nth-child(6n + 6) { background: #edffd8; }
.route-recipe h3 { margin: 0; font-size: 18px; line-height: 1.25; }
.route-recipe p { margin: 0; color: #566574; }
.route-recipe-meta { display: flex; flex-wrap: wrap; gap: 5px; }
.route-recipe-meta span { padding: 4px 7px; border-radius: 999px; background: var(--v3-ink); color: #fff; font-size: 10px; font-weight: 800; }
.route-recipe button { margin-top: auto; }

.coast-switcher { background: linear-gradient(145deg, #e5fbff, #eefdd9); }
.coast-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.coast-card { padding: 16px; border: 2.5px solid var(--v3-ink); border-radius: 20px; background: #fff; }
.coast-card.is-high,
.coast-card.is-unknown { background: #ffe1d5; }
.coast-card.is-medium { background: #fff3bd; }
.coast-card.is-low { background: #e5ffd0; }
.coast-card h3 { margin: 6px 0; }
.coast-card p { margin: 7px 0; font-size: 13px; }
.coast-risk { display: inline-flex; padding: 4px 8px; border: 1.5px solid var(--v3-ink); border-radius: 999px; font-size: 11px; font-weight: 900; background: #fff; }
.coast-license { font-size: 12px; color: #5f6d78; }

.route-fuse-slot { margin-top: 12px; padding: 12px; border: 2px dashed var(--v3-ink); border-radius: 15px; background: rgb(255 255 255 / 70%); }
.fuse-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.fuse-grid div { padding: 8px; border: 1.5px solid var(--v3-ink); border-radius: 11px; background: #fff; }
.fuse-grid small { display: block; color: #68727b; }
.fuse-status { margin: 9px 0 0; font-size: 12px; }
.fuse-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.fuse-actions a,
.fuse-actions button { padding: 7px 9px; border: 1.5px solid var(--v3-ink); border-radius: 10px; background: #fff; color: var(--v3-ink); font-weight: 850; text-decoration: none; }

.file-drop { display: grid; place-items: center; min-height: 90px; padding: 16px; border: 3px dashed var(--v3-ink); border-radius: 18px; background: rgb(255 255 255 / 72%); font-weight: 900; cursor: pointer; }
.file-drop input { max-width: 100%; margin-top: 8px; }
.ocr-canvas-wrap { position: relative; max-height: 420px; overflow: auto; margin-block: 12px; border: 2px solid var(--v3-ink); border-radius: 16px; background: #ccecf4; }
.ocr-canvas-wrap canvas { display: block; width: 100%; max-width: 100%; height: auto; }
.ocr-canvas-wrap .ocr-overlay { position: absolute; inset: 0 auto auto 0; z-index: 2; cursor: crosshair; }
.ocr-candidates { display: grid; gap: 7px; margin-top: 12px; }
.ocr-candidate { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px; border-radius: 11px; background: #fff; }
.ocr-candidate > input[type="text"],
.ocr-candidate input[type="number"] { min-height: 37px; padding: 6px 8px; border: 1.5px solid var(--v3-ink); border-radius: 9px; background: #fff; }
.ocr-candidate input[type="number"] { width: 92px; }
.ocr-redaction-controls { margin-top: 10px; padding: 10px; border: 2px dashed var(--v3-ink); border-radius: 13px; }
.ocr-redaction-controls button { margin: 3px; padding: 5px 7px; border: 1.5px solid var(--v3-ink); border-radius: 999px; background: #ffd8e7; font-size: 11px; cursor: pointer; }
.ocr-panel button:disabled { opacity: .45; cursor: not-allowed; }
.privacy-boundary { padding: 10px; border-radius: 13px; background: #fff0d4; font-size: 12px; }
.shield-rules { display: flex; flex-wrap: wrap; gap: 7px; margin-block: 16px; }
.shield-rules span { padding: 7px 10px; border: 2px solid var(--v3-ink); border-radius: 999px; background: #fff; font-size: 12px; font-weight: 850; }
.shield-alternatives { display: grid; gap: 9px; }
.shield-alt { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; padding: 10px; border: 2px solid var(--v3-ink); border-radius: 14px; background: #fff; }
.quiet-demo { margin-top: 18px; padding: 13px; border-radius: 16px; background: var(--v3-ink); color: #fff; }
.quiet-demo h3 { margin: 0 0 5px; color: var(--v3-yellow); }

.v3-detail-block { margin-top: 14px; padding: 14px; border: 2px solid var(--v3-ink); border-radius: 17px; background: #f7f2ff; }
.evidence-box.is-critical { background: #ffe0d6; border-color: #8d2d24; box-shadow: 5px 5px 0 #8d2d24; }
.confirmed-price-lines { margin-top: 12px; padding: 10px 12px; border: 2px dashed #6a52d2; border-radius: 13px; background: #fff; }
.confirmed-price-lines ul { margin: 7px 0; padding-left: 20px; }
.route-card.is-invalid-live { outline: 5px solid #c83d32; background: #fff0eb; }
.fuse-status.is-blown { color: #7f1d18; background: #ffd9cf; border: 2px solid #c83d32; border-radius: 12px; padding: 9px; }
.route-recipe.is-blocked { opacity: .72; background: #eee; }
.passport-pick em { display: block; margin-top: 3px; color: #586370; font-size: 10px; font-style: normal; line-height: 1.3; }
.review-evidence { display: grid; gap: 7px; margin: 9px 0; }
.review-evidence > div { padding: 8px; border: 1px dashed #7564c8; border-radius: 10px; background: #fff; }
.review-evidence p, .review-evidence ul { margin: 4px 0; }
.review-evidence small, .relay-history span small { display: block; margin-top: 3px; color: #66717a; }
.evidence-empty { padding: 7px; border-radius: 9px; background: #fff1bf; font-size: 11px; }
.v3-detail-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.v3-detail-actions button { padding: 8px 10px; border: 2px solid var(--v3-ink); border-radius: 10px; background: var(--v3-yellow); font-weight: 850; cursor: pointer; }
.quiet-calendar { display: grid; grid-template-columns: auto repeat(5, 1fr); gap: 4px; margin-top: 10px; font-size: 10px; overflow-x: auto; }
.quiet-calendar span { min-height: 31px; display: grid; place-items: center; gap: 2px; padding: 5px 3px; border-radius: 7px; background: #fff; text-align: center; }
.quiet-calendar span strong { font-size: 10px; }
.quiet-calendar span small { font-size: 8px; line-height: 1.2; }
.quiet-calendar .is-quiet { background: #dfffc7; }
.quiet-calendar .is-normal { background: #fff3bd; }
.quiet-calendar .is-busy { background: #ffd8e7; }
.quiet-calendar .is-mixed { background: #e8e0ff; }
.quiet-calendar .is-empty { color: #88949e; background: #f1f1f1; }

@media (max-width: 980px) {
  .v3-tool-grid { grid-template-columns: 1fr; }
  .route-library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coast-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .v3-backend-ribbon { grid-template-columns: auto 1fr; border-radius: 24px; }
  .v3-backend-ribbon small { grid-column: 1 / -1; }
  .relay-pipeline { grid-template-columns: repeat(2, 1fr); }
  .route-library-grid,
  .coast-grid,
  .passport-live { grid-template-columns: 1fr; }
  .fuse-grid { grid-template-columns: 1fr; }
  .quiet-calendar { grid-template-columns: 48px repeat(5, minmax(58px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .v3-pulse { animation: none; }
}
