/* ShadowCore shared public UI system */

:root {
  color-scheme: dark;
  --sc-bg: #03060a;
  --sc-surface: rgba(10, 19, 30, 0.9);
  --sc-surface-strong: rgba(14, 27, 42, 0.96);
  --sc-surface-soft: rgba(4, 9, 16, 0.68);
  --sc-line: rgba(97, 255, 235, 0.15);
  --sc-line-strong: rgba(97, 255, 235, 0.34);
  --sc-text: #f3f8ff;
  --sc-muted: #9ab0c0;
  --sc-muted-2: #6f8796;
  --sc-accent: #18f5df;
  --sc-blue: #38bdf8;
  --sc-green: #22c55e;
  --sc-amber: #f59e0b;
  --sc-red: #fb7185;
  --sc-violet: #a78bfa;
  --sc-radius-sm: 12px;
  --sc-radius: 16px;
  --sc-radius-lg: 20px;
  --sc-shadow: 0 18px 54px rgba(0, 0, 0, 0.3);
  --sc-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; overflow-x: hidden; background: var(--sc-bg); }
body {
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: clip;
  background-color: var(--sc-bg) !important;
  color: var(--sc-text) !important;
  font-family: var(--sc-font) !important;
  text-rendering: optimizeLegibility;
}
body::selection { background: rgba(24, 245, 223, .28); color: #fff; }

.wrap, main, .container {
  width: min(1640px, 100%) !important;
  max-width: min(1640px, 100%) !important;
  margin-inline: auto;
}
.wrap { padding: clamp(16px, 2vw, 28px) !important; }

.grid, .cards, .targets, .summary, .toolgrid, .settings, .kpis, .row, .toolbar, .actions, .fields, .status-grid {
  min-width: 0;
  max-width: 100%;
}
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span4 { grid-column: span 4; }
.span6 { grid-column: span 6; }
.span8 { grid-column: span 8; }
.span12 { grid-column: 1 / -1; }

#app > .top, .top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px !important;
  padding: 14px 0 18px;
  border-bottom: 1px solid rgba(97, 255, 235, .12);
}
.brand { color: #fff !important; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
.brand span, .accent { color: var(--sc-accent) !important; }
.muted, .small, .note, .empty { color: var(--sc-muted) !important; }
.small { font-size: 13px; line-height: 1.45; }
.label {
  color: var(--sc-muted-2) !important;
  font: 950 .68rem/1 ui-monospace, SFMono-Regular, Menlo, monospace !important;
  letter-spacing: .14em !important;
  text-transform: uppercase !important;
}
.value { color: #fff; font-weight: 950; letter-spacing: -.055em; }
h1, h2, h3, .card h1, .card h2, .card h3, .panel h1, .panel h2, .panel h3 { color: #f8fbff !important; letter-spacing: -.045em; }
h1, .card h1, .panel h1 { font-size: clamp(1.8rem, 3vw, 3.6rem); line-height: .96; }
h2, .card h2, .panel h2 { font-size: clamp(1.25rem, 2vw, 2rem); }

.card, .panel, .tile, .box, article, section, .kpi, .tool, .metric { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.card, .panel, .tile, .box {
  border: 1px solid var(--sc-line) !important;
  border-radius: var(--sc-radius-lg) !important;
  background: linear-gradient(180deg, var(--sc-surface), var(--sc-surface-strong)) !important;
  box-shadow: var(--sc-shadow) !important;
}
.card, .panel { padding: clamp(14px, 1.5vw, 18px); }
.card:hover, .panel:hover, .tile:hover, .box:hover { border-color: rgba(24, 245, 223, .3) !important; }

button, .btn, a.btn, .button-link, input, select, textarea {
  max-width: 100%;
  border-radius: var(--sc-radius-sm) !important;
  border-color: rgba(97, 255, 235, .17) !important;
  background: rgba(3, 8, 14, .78) !important;
  color: var(--sc-text) !important;
  font: inherit;
}
button, .btn, a.btn, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 10px 12px;
  font-weight: 900 !important;
  line-height: 1.1;
  text-decoration: none !important;
  cursor: pointer;
  box-shadow: none !important;
  transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
button:hover, .btn:hover, a.btn:hover, .button-link:hover { border-color: rgba(24, 245, 223, .5) !important; background: rgba(24, 245, 223, .08) !important; transform: translateY(-1px); }
button:disabled, .btn[aria-disabled="true"], input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .56; }
.btn.primary, button.primary, a.primary, .primary { border-color: transparent !important; background: linear-gradient(135deg, var(--sc-accent), var(--sc-blue)) !important; color: #03110f !important; box-shadow: 0 16px 42px rgba(24, 245, 223, .17) !important; }
.btn.danger, button.danger, .danger, .btn.bad, button.bad { border-color: rgba(251, 113, 133, .42) !important; background: rgba(251, 113, 133, .08) !important; color: #fecdd3 !important; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid rgba(24, 245, 223, .78); outline-offset: 2px; }
input, select, textarea { min-height: 40px; padding: 10px 12px !important; }
input:focus, select:focus, textarea:focus { border-color: rgba(24, 245, 223, .62) !important; box-shadow: 0 0 0 4px rgba(24, 245, 223, .1) !important; outline: none !important; }
textarea { resize: vertical; }
label { color: var(--sc-muted); font-size: .82rem; font-weight: 800; }

.toolbar, .actions, .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar input { min-width: min(280px, 100%); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }

.note, .empty, .error, .alert, .notice { border-radius: var(--sc-radius) !important; }
.note { border-left: 3px solid var(--sc-accent); padding: 10px 12px; background: rgba(24, 245, 223, .06); }
.empty, .empty-state { border: 1px dashed rgba(97, 255, 235, .22) !important; background: rgba(3, 8, 14, .35) !important; color: var(--sc-muted) !important; }
.note[data-sc-state="error"], .error, [data-sc-state="error"] { border-color: rgba(251, 113, 133, .45) !important; background: rgba(251, 113, 133, .08) !important; color: #fecdd3 !important; }
.note[data-sc-state="warning"], [data-sc-state="warning"] { border-color: rgba(245, 158, 11, .45) !important; background: rgba(245, 158, 11, .08) !important; color: #fde68a !important; }
.note[data-sc-state="ok"], [data-sc-state="ok"] { border-color: rgba(34, 197, 94, .42) !important; background: rgba(34, 197, 94, .08) !important; color: #dcfce7 !important; }
.pill, .tag, .badge, kbd { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(97, 255, 235, .18) !important; border-radius: 999px !important; background: rgba(24, 245, 223, .07) !important; color: #c9fffb !important; }
.pill.hot, .pill.attackable, .pill.online, .pill.good, .tag.good, .ok, .green { border-color: rgba(34, 197, 94, .36) !important; color: #bbf7d0 !important; }
.pill.warn, .tag.warn, .warn, .amber, .warnText { border-color: rgba(245, 158, 11, .38) !important; color: #fde68a !important; }
.pill.bad, .pill.hospital, .tag.bad, .badText { border-color: rgba(251, 113, 133, .4) !important; color: #fecdd3 !important; }
.pill.off { border-color: rgba(251, 113, 133, .4) !important; color: #fecdd3 !important; }
.blue { color: #bae6fd !important; }
.purple { color: #ddd6fe !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.status { border: 1px solid var(--sc-line); border-radius: var(--sc-radius); background: rgba(3, 8, 14, .44); padding: 12px; }
.status span { display: block; color: var(--sc-muted-2); font-size: .68rem; text-transform: uppercase; font-weight: 950; letter-spacing: .1em; }
.status b { display: block; margin-top: 3px; color: #fff; font-size: clamp(1.25rem, 2vw, 1.75rem); }

.table-wrap, .table-scroll, .sc-table-wrap, .scroll, .tableWrap { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid rgba(97, 255, 235, .14) !important; border-radius: var(--sc-radius) !important; background: rgba(3, 8, 14, .38) !important; }
table { width: 100%; max-width: 100%; border-collapse: separate !important; border-spacing: 0 !important; }
th, td { padding: 9px 10px; border-bottom: 1px solid rgba(97, 255, 235, .09) !important; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; white-space: nowrap; background: rgba(7, 14, 24, .96) !important; color: #b7fbf6 !important; text-align: left; }
td { color: #dbeafe !important; overflow-wrap: anywhere; }
tbody tr:hover, tbody tr:hover td { background: rgba(24, 245, 223, .045) !important; }
.num-cell, .money-cell { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.toolgrid, .targets { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.tool, .target { display: block; border: 1px solid rgba(97, 255, 235, .14) !important; border-radius: var(--sc-radius-lg) !important; background: linear-gradient(180deg, rgba(11, 22, 35, .84), rgba(5, 10, 17, .84)) !important; box-shadow: 0 14px 42px rgba(0, 0, 0, .28) !important; }
.tool { min-height: 118px; padding: 15px; color: var(--sc-text); text-decoration: none; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.tool:hover { border-color: rgba(24, 245, 223, .5) !important; background: rgba(24, 245, 223, .07) !important; transform: translateY(-1px); }
.tool b { display: block; margin-bottom: 6px; font-size: 16px; }
.tool span { display: block; color: var(--sc-muted); font-size: 13px; line-height: 1.4; }
.target.hot, .target.attackable { border-color: rgba(34, 197, 94, .42) !important; }
.target.hospital { border-color: rgba(251, 113, 133, .34) !important; }
.target.travel { border-color: rgba(245, 158, 11, .34) !important; }
.tab { border: 1px solid rgba(97, 255, 235, .16) !important; border-radius: 999px !important; background: rgba(3, 8, 14, .78) !important; color: var(--sc-text) !important; }
.tab.active, [aria-selected="true"].tab { border-color: transparent !important; background: linear-gradient(135deg, var(--sc-accent), var(--sc-blue)) !important; color: #03110f !important; }

.embedded-report, iframe { width: 100%; min-height: 760px; border: 1px solid rgba(97, 255, 235, .14); border-radius: var(--sc-radius-lg); background: #03060a; }
#toast { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100010; }
.toast { max-width: min(420px, calc(100vw - 28px)); border: 1px solid rgba(24, 245, 223, .35); border-radius: 14px; background: #08111f; color: #dffefa; padding: 11px 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); }
.toast.bad { border-color: rgba(251, 113, 133, .5); color: #fecdd3; }

.sc-loading { position: relative; overflow: hidden !important; }
.sc-loading::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); animation: sc-shimmer 1.6s infinite; }
@keyframes sc-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
#shadowcoreRolePreview, #scDataQuality { right: 12px !important; z-index: 9990 !important; max-width: min(340px, calc(100vw - 24px)) !important; }
#shadowcoreRolePreview { bottom: 12px !important; }
#scDataQuality { bottom: 70px !important; z-index: 9989 !important; }
.sc-floating-min { transform: scale(.88); transform-origin: bottom right; opacity: .82; }
.sc-floating-min:hover, .sc-floating-min:focus-within { transform: none; opacity: 1; }

@media (max-width: 1050px) {
  .span2, .span3, .span4, .span6, .span8, .span12 { grid-column: 1 / -1 !important; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid, .settings, #chainKpis, .kpis { display: grid !important; grid-template-columns: 1fr !important; }
  .top { flex-direction: column !important; align-items: stretch !important; }
  .top .row { justify-content: flex-start; }
  .card, .panel { padding: 14px !important; }
  .table, .table-wrap table, .sc-table-wrap table { min-width: 720px; }
  .toolbar input { min-width: 100%; }
}
@media (max-width: 760px) {
  .sc-data-quality, #scDataQuality { display: none !important; }
  #shadowcoreRolePreview { right: 8px !important; bottom: 8px !important; max-width: calc(100vw - 16px) !important; }
  .wrap { padding: 12px !important; }
  .targets, .toolgrid, .fields, .status-grid { grid-template-columns: 1fr !important; }
  .toolbar, .actions, .row { align-items: stretch; }
  .toolbar > *, .actions > * { flex: 1 1 160px; }
  .embedded-report, iframe { min-height: 900px; }
}
@media (max-width: 520px) {
  button, .btn, a.btn, .button-link { width: auto; min-height: 42px; }
  .row { gap: 6px !important; }
  .table, .table-wrap table, .sc-table-wrap table { min-width: 650px; }
  .value { font-size: 24px !important; }
  .brand { font-size: 13px !important; }
}
