:root{
  --bg:#07111d;
  --bg2:#0b1727;
  --panel:#0e1c2f;
  --panel-2:#10233b;
  --line:rgba(255,255,255,.08);
  --text:#eaf2ff;
  --muted:#98a8c6;
  --accent:#77d6ff;
  --accent-2:#6f8cff;
  --danger:#ff6a7a;
  --success:#4dd4a8;
  --warn:#ffcc66;
  --shadow:0 18px 50px rgba(0,0,0,.35);
  --radius:22px;
  --radius-sm:14px;
  --font:Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --row-h:52px;
  --thead-h:56px;
}

*,
*::before,
*::after{
  box-sizing:border-box;
}

html,body{
  height:100%;
}

html{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}

body{
  min-height:100%;
  margin:0;
  background:
    radial-gradient(circle at top left, rgba(119,214,255,.14), transparent 30%),
    radial-gradient(circle at top right, rgba(111,140,255,.12), transparent 32%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  color:var(--text);
  font-family:var(--font);
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

button,
input,
select,
textarea{
  font:inherit;
  color:inherit;
}

button{
  cursor:pointer;
}

img,
svg,
video,
canvas{
  display:block;
  max-width:100%;
}

a{
  color:inherit;
  text-decoration:none;
}

.hidden{
  display:none !important;
}

.shell{
  max-width:1600px;
  margin:0 auto;
  padding:24px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:20px;
  padding:10px 0 20px;
}

.eyebrow{
  text-transform:uppercase;
  letter-spacing:.18em;
  font-size:12px;
  color:var(--accent);
  margin-bottom:8px;
}

h1,h2,h3,h4,p{
  margin:0;
}

h1{
  font-size:clamp(28px,3vw,48px);
  line-height:1.06;
  letter-spacing:-.03em;
}

.subhead{
  margin-top:10px;
  max-width:780px;
  color:var(--muted);
  line-height:1.65;
}

.topbar-meta{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
  margin-top:8px;
}

.badge{
  padding:10px 14px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.04);
  color:var(--text);
  box-shadow:var(--shadow);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
}

.badge.ghost{
  color:var(--muted);
}

.hero-card,
.draft-card,
.table-panel,
.stat-card{
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.03));
  box-shadow:var(--shadow);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
}

.hero-card{
  display:flex;
  justify-content:space-between;
  gap:16px;
  padding:22px;
  border-radius:var(--radius);
  margin:18px 0 22px;
}

.hero-copy h2{
  font-size:22px;
  margin-bottom:8px;
}

.hero-copy p{
  color:var(--muted);
  line-height:1.6;
  max-width:880px;
}

.hero-actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:center;
}

.btn{
  border:none;
  border-radius:14px;
  padding:12px 16px;
  transition:transform .16s ease, opacity .16s ease, background .16s ease, border .16s ease, box-shadow .16s ease;
  min-height:44px;
}

.btn:hover{
  transform:translateY(-1px);
}

.btn:active{
  transform:translateY(0);
}

.btn:focus-visible,
.field-select:focus-visible,
.search-input:focus-visible{
  outline:2px solid rgba(119,214,255,.6);
  outline-offset:2px;
}

.btn.primary{
  color:#06111b;
  background:linear-gradient(135deg, var(--accent), #b4f0ff);
  font-weight:700;
  box-shadow:0 10px 30px rgba(119,214,255,.18);
}

.btn.secondary{
  color:var(--text);
  background:rgba(255,255,255,.07);
  border:1px solid var(--line);
}

.btn.danger{
  color:#fff;
  background:linear-gradient(135deg, #ff7a86, #ff5267);
  font-weight:700;
  box-shadow:0 10px 30px rgba(255,90,110,.18);
}

.stats-grid{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:14px;
  margin-bottom:22px;
}

.stat-card{
  border-radius:18px;
  padding:16px 18px;
}

.stat-card span{
  color:var(--muted);
  display:block;
  margin-bottom:10px;
  font-size:14px;
}

.stat-card strong{
  font-size:28px;
  letter-spacing:-.02em;
}

.tables-layout{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:16px;
  align-items:start;
}

.panel-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:12px;
}

.panel-head h3{
  font-size:20px;
}

.panel-head p{
  color:var(--muted);
  margin-top:6px;
  font-size:13px;
  line-height:1.5;
}

.panel-tools{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.field-select,
.search-input{
  border:1px solid var(--line);
  background:rgba(4,10,18,.55);
  color:var(--text);
  border-radius:12px;
  min-height:42px;
}

.field-select{
  padding:10px 12px;
  max-width:160px;
}

.search-row{
  margin-bottom:12px;
}

.search-input{
  width:100%;
  padding:0 14px;
}

.table-panel{
  border-radius:var(--radius);
  padding:16px;
  overflow:hidden;
  min-height:0;
  display:flex;
  flex-direction:column;
}

.table-wrap{
  overflow:auto;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.05);
  background:rgba(3,8,15,.35);
  min-height:0;
  height:calc(var(--thead-h) + (20 * var(--row-h)));
  max-height:calc(var(--thead-h) + (20 * var(--row-h)));
  scrollbar-gutter:stable;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}

table{
  width:100%;
  border-collapse:collapse;
  table-layout:fixed;
  font-size:13px;
}

thead th{
  position:sticky;
  top:0;
  z-index:2;
  height:var(--thead-h);
  background:rgba(8,16,29,.96);
  color:#dbe7ff;
  text-align:left;
  padding:12px 10px;
  border-bottom:1px solid var(--line);
  white-space:nowrap;
}

tbody td{
  height:var(--row-h);
  border-bottom:1px solid rgba(255,255,255,.06);
  padding:10px 10px;
  vertical-align:middle;
  color:#dce7fb;
}

tbody tr{
  transition:background .15s ease, transform .15s ease;
}

tbody tr:hover{
  background:rgba(255,255,255,.04);
}

tbody tr.selected{
  background:rgba(77,212,168,.16);
}

tbody tr.connected{
  background:rgba(255,106,122,.16);
}

tbody tr.matched{
  outline:1px solid rgba(119,214,255,.2);
  outline-offset:-1px;
}

td,
th{
  max-width:260px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

td:first-child,
th:first-child{
  position:sticky;
  left:0;
  z-index:1;
  background:inherit;
}

thead th:first-child{
  z-index:3;
}

tbody tr.selected td:first-child,
tbody tr.connected td:first-child{
  background:inherit;
}

.draft-card{
  margin-top:18px;
  border-radius:var(--radius);
  padding:18px;
}

.draft-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:14px;
}

.draft-head h2{
  font-size:22px;
  margin-bottom:6px;
}

.draft-head p{
  color:var(--muted);
  line-height:1.6;
}

.draft-sub{
  color:var(--muted);
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  border-radius:999px;
  padding:10px 14px;
  white-space:nowrap;
}

.draft-grid{
  display:grid;
  grid-template-columns:1.2fr 1.2fr 1fr;
  gap:14px;
}

.draft-box{
  border:1px solid rgba(255,255,255,.07);
  background:rgba(255,255,255,.03);
  border-radius:18px;
  padding:14px;
}

.draft-box h4{
  font-size:14px;
  letter-spacing:.03em;
  text-transform:uppercase;
  color:#cfe0ff;
  margin-bottom:10px;
}

.draft-content{
  min-height:120px;
  color:#dbe7ff;
  line-height:1.6;
  overflow:auto;
}

.draft-content.empty{
  color:var(--muted);
}

.draft-chip{
  display:inline-flex;
  gap:6px;
  align-items:center;
  padding:8px 10px;
  margin:0 8px 8px 0;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.05);
}

.draft-chip strong{
  font-weight:700;
}

.action-bar{
  position:sticky;
  bottom:0;
  margin-top:18px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  padding:14px 16px;
  border-radius:18px;
  border:1px solid var(--line);
  background:rgba(8,16,29,.88);
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
  box-shadow:var(--shadow);
}

.action-info{
  color:var(--muted);
  line-height:1.5;
}

.action-buttons{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.62);
  display:grid;
  place-items:center;
  padding:20px;
  z-index:50;
}

.modal{
  width:min(560px, 100%);
  border-radius:24px;
  padding:22px;
  border:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg, rgba(12,22,38,.98), rgba(8,16,29,.98));
  box-shadow:var(--shadow);
}

.modal h3{
  font-size:22px;
  margin-bottom:10px;
}

.modal p{
  color:var(--muted);
  line-height:1.6;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:18px;
}

.cell-lines{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.cell-main{
  font-weight:600;
}

.cell-sub{
  color:var(--muted);
  font-size:12px;
}

@media (max-width: 1280px){
  .tables-layout{
    grid-template-columns:1fr;
  }

  .draft-grid{
    grid-template-columns:1fr;
  }

  .stats-grid{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px){
  .shell{
    padding:14px;
  }

  .topbar,
  .hero-card,
  .draft-head,
  .action-bar{
    flex-direction:column;
    align-items:stretch;
  }

  .topbar-meta,
  .hero-actions,
  .action-buttons{
    justify-content:stretch;
  }

  .stats-grid{
    grid-template-columns:1fr;
  }

  .panel-head{
    flex-direction:column;
  }

  .panel-tools{
    justify-content:stretch;
  }

  .field-select{
    max-width:none;
    width:100%;
  }

  .action-bar{
    position:static;
  }

  .btn{
    width:100%;
  }

  td,
  th{
    max-width:140px;
  }

  .table-wrap{
    height:calc(var(--thead-h) + (20 * 46px));
    max-height:calc(var(--thead-h) + (20 * 46px));
  }

  :root{
    --row-h:40px;
  }
}